./PaxHeaders.7244/glusterfs-3.7.60000644000076200007630000000012712617742654014623 xustar000000000000000029 mtime=1447019948.29523403 29 atime=1447019949.33221843 29 ctime=1447019948.29523403 glusterfs-3.7.6/0000755000076200007630000000000012617742654014754 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/PaxHeaders.7244/Makefile.am0000644000076200007630000000013212617742532016566 xustar000000000000000030 mtime=1447019866.007471991 30 atime=1447019866.357466725 30 ctime=1447019929.761512849 glusterfs-3.7.6/Makefile.am0000644000076200007630000000371712617742532017013 0ustar00jenkinsjenkins00000000000000EXTRA_DIST = autogen.sh \ COPYING-GPLV2 COPYING-LGPLV3 \ INSTALL README.md AUTHORS THANKS NEWS \ glusterfs.spec glusterfs-api.pc.in libgfchangelog.pc.in libgfdb.pc.in \ run-tests.sh \ build-aux/pkg-version \ build-aux/xdrgen \ contrib/argp-standalone \ contrib/umountd \ contrib/uuid \ $(shell find $(top_srcdir)/tests -type f -print) SUBDIRS = $(ARGP_STANDALONE_DIR) libglusterfs rpc api xlators glusterfsd \ $(FUSERMOUNT_SUBDIR) doc extras cli heal @SYNCDAEMON_SUBDIR@ \ @UMOUNTD_SUBDIR@ tools pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc if USE_GFDB pkgconfig_DATA += libgfdb.pc endif CLEANFILES = CONFIG_CLEAN_FILES = $(CONTRIB_BUILDDIR)/uuid/uuid_types.h gitclean: distclean find . -name Makefile.in -exec rm -f {} \; find . -name Makefile -exec rm -f {} \; find . -name mount.glusterfs -exec rm -f {} \; rm -fr autom4te.cache rm -f missing aclocal.m4 config.h.in config.guess config.sub ltmain.sh install-sh configure depcomp -rm -fr $(CONTRIBDIR)/argp-standalone/autom4te.cache -rm -f $(CONTRIBDIR)/argp-standalone/aclocal.m4 -rm -f $(CONTRIBDIR)/argp-standalone/config.h.in -rm -f $(CONTRIBDIR)/argp-standalone/configure -rm -f $(CONTRIBDIR)/argp-standalone/config.status -rm -f $(CONTRIBDIR)/argp-standalone/config.log -rm -f $(CONTRIBDIR)/argp-standalone/depcomp -rm -fr $(CONTRIBDIR)/argp-standalone/.deps -rm -f $(CONTRIBDIR)/argp-standalone/install-sh -rm -f $(CONTRIBDIR)/argp-standalone/missing dist-hook: gen-VERSION gen-ChangeLog -rm -fr $(distdir)/contrib/argp-standalone/autom4te.cache -rm -fr $(distdir)/contrib/argp-standalone/.deps -rm -fr $(distdir)/contrib/umountd/.deps .PHONY: gen-VERSION gen-ChangeLog gen-ChangeLog: (cd $(srcdir) && git diff && echo ===== git log ==== && git log) > $(distdir)/ChangeLog gen-VERSION: if test -d .git; then \ $(top_srcdir)/build-aux/pkg-version --full \ > $(distdir)/VERSION; \ fi glusterfs-3.7.6/PaxHeaders.7244/COPYING-LGPLV30000644000076200007630000000013112617742532016531 xustar000000000000000030 mtime=1447019866.007471991 30 atime=1447019866.357466725 29 ctime=1447019929.85251148 glusterfs-3.7.6/COPYING-LGPLV30000644000076200007630000001674312617742532016762 0ustar00jenkinsjenkins00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. 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 that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. glusterfs-3.7.6/PaxHeaders.7244/build-aux0000644000076200007630000000013112617742631016346 xustar000000000000000030 mtime=1447019929.869511224 29 atime=1447019949.33221843 30 ctime=1447019929.869511224 glusterfs-3.7.6/build-aux/0000755000076200007630000000000012617742631016641 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/build-aux/PaxHeaders.7244/xdrgen0000644000076200007630000000013212617742532017636 xustar000000000000000030 mtime=1447019866.012471916 30 atime=1447019866.359466695 30 ctime=1447019929.869511224 glusterfs-3.7.6/build-aux/xdrgen0000755000076200007630000000435312617742532020063 0ustar00jenkinsjenkins00000000000000#!/bin/sh append_licence_header () { local src_file=$1; local dst_file=$2; cat >$dst_file < This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include "compat.h" #include "xdr-common.h" #include "xdr-nfs3.h" #if defined(__GNUC__) #if __GNUC__ >= 4 #if !defined(__clang__) #if !defined(__NetBSD__) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wunused-variable" #endif #else #pragma clang diagnostic ignored "-Wunused-variable" #pragma clang diagnostic ignored "-Wunused-value" #endif #endif #endif EOF cat $src_file >> $dst_file; } gen_sources () { local xfile="$1"; local cfile="${1%.x}.c"; local hfile="${1%.x}.h"; local tmp_cfile="$1.c.tmp"; local tmp_hfile="$1.h.tmp"; rm -f $cfile; rpcgen -c -o $cfile $xfile; append_licence_header $cfile $tmp_cfile; mv $tmp_cfile $cfile; # remove unwanted temporary files (if any) rm -f $tmp_cfile; echo "Generated $cfile" return } gen_headers () { local xfile="$1"; local cfile="${1%.x}.c"; local hfile="${1%.x}.h"; local tmp_cfile="$1.c.tmp"; local tmp_hfile="$1.h.tmp"; # no need for a temporary file here as there are no changes from glusterfs rm -f $hfile; rpcgen -h -o $hfile $xfile; # the '#ifdef' part of file should be fixed sed -e 's/-/_/g' $hfile > ${hfile}.new && mv ${hfile}.new $hfile; # Gen header to temp file and append generated file append_licence_header $hfile $tmp_hfile; # now move the destination file to actual original file mv $tmp_hfile $hfile; rm -f $tmp_hfile; echo "Generated $hfile"; return } main () { if [ $# -ne 2 ]; then echo "wrong number of arguments given" echo " $0 [header|source] .x" exit 1; fi if [ $1 = "header" ]; then gen_headers $2 fi if [ $1 = "source" ]; then gen_sources $2 fi } main "$@"; glusterfs-3.7.6/build-aux/PaxHeaders.7244/pkg-version0000644000076200007630000000013212617742532020613 xustar000000000000000030 mtime=1447019866.012471916 30 atime=1447019866.359466695 30 ctime=1447019929.865511284 glusterfs-3.7.6/build-aux/pkg-version0000755000076200007630000000264512617742532021042 0ustar00jenkinsjenkins00000000000000#!/bin/sh # To override version/release from git, # create VERSION file containing text with version/release # eg. v3.4.0-1 PKG_VERSION=`cat VERSION 2> /dev/null || git describe --tags --match "v[0-9]*"` get_version() { # tags and output versions: # - v3.4.0 => 3.4.0 (upstream clean) # - v3.4.0-1 => 3.4.0 (downstream clean) # - v3.4.0-2-g34e62f => 3.4.0 (upstream dirty) # - v3.4.0-1-2-g34e62f => 3.4.0 (downstream dirty) AWK_VERSION=' BEGIN { FS="-" } /^v[0-9]/ { sub(/^v/,"") ; print $1 }' echo $PKG_VERSION | awk "$AWK_VERSION" | tr -cd '[:alnum:].' } get_release() { # tags and output releases: # - v3.4.0 => 0 (upstream clean) # - v3.4.0-1 => 1 (downstream clean) # - v3.4.0-2-g34e62f1 => 2.git34e62f1 (upstream dirty) # - v3.4.0-1-2-g34e62f1 => 1.2.git34e62f1 (downstream dirty) AWK_RELEASE=' BEGIN { FS="-"; OFS="." } /^v[0-9]/ { if (NF == 1) print 0 else if (NF == 2) print $2 else if (NF == 3) print $2, "git" substr($3, 2) else if (NF == 4) print $2, $3, "git" substr($4, 2) }' echo $PKG_VERSION | awk "$AWK_RELEASE" | tr -cd '[:alnum:].' } if test "x$1" = "x--full"; then echo -n "v$(get_version)-$(get_release)" elif test "x$1" = "x--version"; then get_version elif test "x$1" = "x--release"; then get_release else echo "usage: $0 [--full|--version|--release]" exit 1 fi glusterfs-3.7.6/PaxHeaders.7244/NEWS0000644000076200007630000000013212617742532015231 xustar000000000000000030 mtime=1447019866.007471991 30 atime=1447019866.357466725 30 ctime=1447019929.817512006 glusterfs-3.7.6/NEWS0000644000076200007630000000003112617742532015440 0ustar00jenkinsjenkins00000000000000Gluster moves to Gerrit. glusterfs-3.7.6/PaxHeaders.7244/configure.ac0000644000076200007630000000013212617742532017020 xustar000000000000000030 mtime=1447019866.550463822 30 atime=1447019867.481449815 30 ctime=1447019929.754512954 glusterfs-3.7.6/configure.ac0000644000076200007630000013327712617742532017252 0ustar00jenkinsjenkins00000000000000dnl Copyright (c) 2006-2012 Red Hat, Inc. dnl This file is part of GlusterFS. dnl dnl This file is licensed to you under your choice of the GNU Lesser dnl General Public License, version 3 or any later version (LGPLv3 or dnl later), or the GNU General Public License, version 2 (GPLv2), in all dnl cases as published by the Free Software Foundation. AC_INIT([glusterfs], [m4_esyscmd([build-aux/pkg-version --version])], [gluster-users@gluster.org],,[https://github.com/gluster/glusterfs.git]) AC_SUBST([PACKAGE_RELEASE], [m4_esyscmd([build-aux/pkg-version --release])]) AM_INIT_AUTOMAKE(tar-pax) # Removes warnings when using automake 1.14 around (...but option 'subdir-objects' is disabled ) #but libglusterfs fails to build with contrib (Then are not set up that way?) #AM_INIT_AUTOMAKE([subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) if make --help 2>&1 | grep -q no-print-directory; then AM_MAKEFLAGS="$AM_MAKEFLAGS --no-print-directory"; fi if make --help 2>&1 | grep -q quiet; then AM_MAKEFLAGS="$AM_MAKEFLAGS --quiet" fi if libtool --help 2>&1 | grep -q quiet; then AM_LIBTOOLFLAGS="--quiet"; fi AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile libglusterfs/Makefile libglusterfs/src/Makefile libglusterfs/src/gfdb/Makefile geo-replication/src/peer_gsec_create geo-replication/src/peer_mountbroker extras/peer_add_secret_pub geo-replication/syncdaemon/configinterface.py glusterfsd/Makefile glusterfsd/src/Makefile rpc/Makefile rpc/rpc-lib/Makefile rpc/rpc-lib/src/Makefile rpc/rpc-transport/Makefile rpc/rpc-transport/socket/Makefile rpc/rpc-transport/socket/src/Makefile rpc/rpc-transport/rdma/Makefile rpc/rpc-transport/rdma/src/Makefile rpc/xdr/Makefile rpc/xdr/src/Makefile xlators/Makefile xlators/meta/Makefile xlators/meta/src/Makefile xlators/mount/Makefile xlators/mount/fuse/Makefile xlators/mount/fuse/src/Makefile xlators/mount/fuse/utils/mount.glusterfs xlators/mount/fuse/utils/mount_glusterfs xlators/mount/fuse/utils/Makefile xlators/storage/Makefile xlators/storage/posix/Makefile xlators/storage/posix/src/Makefile xlators/storage/bd/Makefile xlators/storage/bd/src/Makefile xlators/cluster/Makefile xlators/cluster/afr/Makefile xlators/cluster/afr/src/Makefile xlators/cluster/stripe/Makefile xlators/cluster/stripe/src/Makefile xlators/cluster/dht/Makefile xlators/cluster/dht/src/Makefile xlators/cluster/ec/Makefile xlators/cluster/ec/src/Makefile xlators/performance/Makefile xlators/performance/write-behind/Makefile xlators/performance/write-behind/src/Makefile xlators/performance/read-ahead/Makefile xlators/performance/read-ahead/src/Makefile xlators/performance/readdir-ahead/Makefile xlators/performance/readdir-ahead/src/Makefile xlators/performance/io-threads/Makefile xlators/performance/io-threads/src/Makefile xlators/performance/io-cache/Makefile xlators/performance/io-cache/src/Makefile xlators/performance/symlink-cache/Makefile xlators/performance/symlink-cache/src/Makefile xlators/performance/quick-read/Makefile xlators/performance/quick-read/src/Makefile xlators/performance/open-behind/Makefile xlators/performance/open-behind/src/Makefile xlators/performance/md-cache/Makefile xlators/performance/md-cache/src/Makefile xlators/debug/Makefile xlators/debug/trace/Makefile xlators/debug/trace/src/Makefile xlators/debug/error-gen/Makefile xlators/debug/error-gen/src/Makefile xlators/debug/io-stats/Makefile xlators/debug/io-stats/src/Makefile xlators/protocol/Makefile xlators/protocol/auth/Makefile xlators/protocol/auth/addr/Makefile xlators/protocol/auth/addr/src/Makefile xlators/protocol/auth/login/Makefile xlators/protocol/auth/login/src/Makefile xlators/protocol/client/Makefile xlators/protocol/client/src/Makefile xlators/protocol/server/Makefile xlators/protocol/server/src/Makefile xlators/features/Makefile xlators/features/arbiter/Makefile xlators/features/arbiter/src/Makefile xlators/features/changelog/Makefile xlators/features/changelog/src/Makefile xlators/features/changelog/lib/Makefile xlators/features/changelog/lib/src/Makefile xlators/features/changetimerecorder/Makefile xlators/features/changetimerecorder/src/Makefile xlators/features/glupy/Makefile xlators/features/glupy/examples/Makefile xlators/features/glupy/src/Makefile xlators/features/glupy/src/setup.py xlators/features/glupy/src/__init__.py xlators/features/glupy/src/glupy/Makefile xlators/features/locks/Makefile xlators/features/locks/src/Makefile xlators/features/quota/Makefile xlators/features/quota/src/Makefile xlators/features/marker/Makefile xlators/features/marker/src/Makefile xlators/features/read-only/Makefile xlators/features/read-only/src/Makefile xlators/features/compress/Makefile xlators/features/compress/src/Makefile xlators/features/mac-compat/Makefile xlators/features/mac-compat/src/Makefile xlators/features/quiesce/Makefile xlators/features/quiesce/src/Makefile xlators/features/barrier/Makefile xlators/features/barrier/src/Makefile xlators/features/ganesha/Makefile xlators/features/ganesha/src/Makefile xlators/features/index/Makefile xlators/features/index/src/Makefile xlators/features/protect/Makefile xlators/features/protect/src/Makefile xlators/features/gfid-access/Makefile xlators/features/gfid-access/src/Makefile xlators/features/trash/Makefile xlators/features/trash/src/Makefile xlators/features/snapview-server/Makefile xlators/features/snapview-server/src/Makefile xlators/features/snapview-client/Makefile xlators/features/snapview-client/src/Makefile xlators/features/upcall/Makefile xlators/features/upcall/src/Makefile xlators/features/shard/Makefile xlators/features/shard/src/Makefile xlators/features/bit-rot/Makefile xlators/features/bit-rot/src/Makefile xlators/features/bit-rot/src/stub/Makefile xlators/features/bit-rot/src/bitd/Makefile xlators/playground/Makefile xlators/playground/template/Makefile xlators/playground/template/src/Makefile xlators/encryption/Makefile xlators/encryption/rot-13/Makefile xlators/encryption/rot-13/src/Makefile xlators/encryption/crypt/Makefile xlators/encryption/crypt/src/Makefile xlators/features/qemu-block/Makefile xlators/features/qemu-block/src/Makefile xlators/system/Makefile xlators/system/posix-acl/Makefile xlators/system/posix-acl/src/Makefile xlators/nfs/Makefile xlators/nfs/server/Makefile xlators/nfs/server/src/Makefile xlators/mgmt/Makefile xlators/mgmt/glusterd/Makefile xlators/mgmt/glusterd/src/Makefile cli/Makefile cli/src/Makefile doc/Makefile extras/Makefile extras/glusterd.vol extras/init.d/Makefile extras/init.d/glusterd.plist extras/init.d/glusterd-Debian extras/init.d/glusterd-Redhat extras/init.d/glusterd-FreeBSD extras/init.d/glusterd-SuSE extras/ganesha/Makefile extras/ganesha/config/Makefile extras/ganesha/scripts/Makefile extras/ganesha/ocf/Makefile extras/systemd/Makefile extras/systemd/glusterd.service extras/run-gluster.tmpfiles extras/benchmarking/Makefile extras/hook-scripts/Makefile extras/ocf/Makefile extras/ocf/glusterd extras/ocf/volume extras/LinuxRPM/Makefile extras/geo-rep/Makefile extras/firewalld/Makefile extras/hook-scripts/add-brick/Makefile extras/hook-scripts/add-brick/pre/Makefile extras/hook-scripts/add-brick/post/Makefile extras/hook-scripts/start/Makefile extras/hook-scripts/start/post/Makefile extras/hook-scripts/set/Makefile extras/hook-scripts/set/post/Makefile extras/hook-scripts/stop/Makefile extras/hook-scripts/stop/pre/Makefile extras/hook-scripts/reset/Makefile extras/hook-scripts/reset/post/Makefile extras/hook-scripts/reset/pre/Makefile extras/snap_scheduler/Makefile contrib/fuse-util/Makefile contrib/umountd/Makefile contrib/uuid/uuid_types.h glusterfs-api.pc libgfchangelog.pc libgfdb.pc api/Makefile api/src/Makefile api/examples/Makefile geo-replication/Makefile geo-replication/src/Makefile geo-replication/syncdaemon/Makefile tools/Makefile tools/gfind_missing_files/Makefile heal/Makefile heal/src/Makefile glusterfs.spec tools/glusterfind/src/tool.conf tools/glusterfind/glusterfind tools/glusterfind/Makefile tools/glusterfind/src/Makefile]) AC_CANONICAL_HOST AC_PROG_CC AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_SUBST([shrext_cmds]) AC_CHECK_PROG([RPCGEN], [rpcgen], [yes], [no]) if test "x$RPCGEN" = "xno"; then AC_MSG_ERROR([`rpcgen` not found, glusterfs needs `rpcgen` exiting..]) fi # Initialize CFLAGS before usage AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debug build options.])) if test "x$enable_debug" = "xyes"; then BUILD_DEBUG=yes CFLAGS="${CFLAGS} -g -O0 -DDEBUG" else BUILD_DEBUG=no CFLAGS="${CFLAGS} -g -O2" fi case $host_os in darwin*) if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 7; then AC_MSG_ERROR([You need at least OS X 10.7 (Lion) to build Glusterfs]) fi # OSX version lesser than 9 has llvm/clang optimization issues which leads to various segfaults if test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -lt 9; then CFLAGS="${CFLAGS} -g -O0 -DDEBUG" fi ;; esac AC_ARG_WITH([previous-options], [AS_HELP_STRING([--with-previous-options], [read config.status for configure options]) ], [ if test -r ./config.status && \ args=$(grep 'ac_cs_config=' config.status | \ sed -e 's/.*"\(.*\)".*/\1/'| sed -e "s/'//g") ; then echo "###" echo "### Rerunning as '$0 $args'" echo "###" exec $0 $args fi ]) AC_ARG_WITH(pkgconfigdir, [ --with-pkgconfigdir=DIR pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@], [pkgconfigdir=$withval], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST(pkgconfigdir) AC_ARG_WITH(mountutildir, [ --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@], [mountutildir=$withval], [mountutildir='/sbin']) AC_SUBST(mountutildir) AC_ARG_WITH(systemddir, [ --with-systemddir=DIR systemd service files in DIR @<:@/usr/lib/systemd/system@:>@], [systemddir=$withval], [systemddir='/usr/lib/systemd/system']) AC_SUBST(systemddir) AC_ARG_WITH(initdir, [ --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@], [initdir=$withval], [initdir='/etc/init.d']) AC_SUBST(initdir) AC_ARG_WITH(launchddir, [ --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@], [launchddir=$withval], [launchddir='/Library/LaunchDaemons']) AC_SUBST(launchddir) AC_ARG_WITH(tmpfilesdir, AC_HELP_STRING([--with-tmpfilesdir=DIR], [tmpfiles config in DIR, disabled by default]), [tmpfilesdir=$withval], [tmpfilesdir='']) AC_SUBST(tmpfilesdir) AC_ARG_WITH([ocf], [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])], , [OCF_SUBDIR='ocf'], ) AC_SUBST(OCF_SUBDIR) # LEX needs a check AC_PROG_LEX if test "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then AC_MSG_ERROR([Flex or lex required to build glusterfs.]) fi dnl dnl Word sizes... dnl AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) SIZEOF_SHORT=$ac_cv_sizeof_short SIZEOF_INT=$ac_cv_sizeof_int SIZEOF_LONG=$ac_cv_sizeof_long SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long AC_SUBST(SIZEOF_SHORT) AC_SUBST(SIZEOF_INT) AC_SUBST(SIZEOF_LONG) AC_SUBST(SIZEOF_LONG_LONG) # YACC needs a check AC_PROG_YACC if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then AC_MSG_ERROR([GNU Bison required to build glusterfs.]) fi AC_CHECK_TOOL([LD],[ld]) AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs])) AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs])) AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs]))) AC_CHECK_LIB([readline], [rl_do_undo], [RL_UNDO="yes"], [RL_UNDO="no"]) AC_CHECK_LIB([intl], [gettext]) AC_CHECK_HEADERS([sys/xattr.h]) AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sys/ioctl.h])) AC_CHECK_HEADERS([sys/extattr.h]) dnl Math library AC_CHECK_LIB([m], [pow], [MATH_LIB='-lm'], [MATH_LIB='']) AC_SUBST(MATH_LIB) dnl use libuuid.so or fall-back to contrib/uuid PKG_CHECK_MODULES([UUID], [uuid], [HAVE_LIBUUID=yes AC_DEFINE(HAVE_LIBUUID, 1, [have libuuid.so]) PKGCONFIG_UUID=uuid], [HAVE_LIBUUID=no UUID_CFLAGS='-I$(CONTRIBDIR)/uuid']) AM_CONDITIONAL([HAVE_LIBUUID], [test x$HAVE_LIBUUID = xyes]) dnl older version of libuuid (from e2fsprogs) require including uuid/uuid.h saved_CFLAGS=${CFLAGS} CFLAGS="${CFLAGS} ${UUID_CFLAGS}" AC_CHECK_HEADER([uuid.h], [], [AC_CHECK_HEADER([uuid/uuid.h])]) CFLAGS=${saved_CFLAGS} if test "x$ac_cv_header_uuid_uuid_h" = "xyes"; then UUID_CFLAGS="${UUID_CFLAGS} -I$(pkg-config --variable=includedir uuid)/uuid" fi dnl libglusterfs needs uuid.h, practically everything depends on it GF_CPPFLAGS="${GF_CPPFLAGS} ${UUID_CFLAGS}" dnl PKGCONFIG_UUID is used for the dependency in *.pc.in files AC_SUBST(PKGCONFIG_UUID) dnl NetBSD does not support POSIX ACLs :-( case $host_os in *netbsd*) AC_MSG_WARN([NetBSD does not support POSIX ACLs... disabling them]) ACL_LIBS='' USE_POSIX_ACLS='0' BUILD_POSIX_ACLS='no' ;; *) AC_CHECK_HEADERS([sys/acl.h], , AC_MSG_ERROR([Support for POSIX ACLs is required])) USE_POSIX_ACLS='1' BUILD_POSIX_ACLS='yes' case $host_os in linux*) ACL_LIBS='-lacl' ;; solaris*) ACL_LIBS='-lsec' ;; *freebsd*) ACL_LIBS='-lc' ;; darwin*) ACL_LIBS='-lc' ;; esac if test "x${ACL_LIBS}" = "x-lacl"; then AC_CHECK_HEADERS([acl/libacl.h], , AC_MSG_ERROR([libacl is required for building on ${host_os}])) fi ;; esac AC_SUBST(ACL_LIBS) AC_SUBST(USE_POSIX_ACLS) # libglusterfs/checksum AC_CHECK_HEADERS([openssl/md5.h]) AC_CHECK_LIB([z], [adler32], [ZLIB_LIBS="-lz"], AC_MSG_ERROR([zlib is required to build glusterfs])) AC_SUBST(ZLIB_LIBS) AC_CHECK_HEADERS([linux/falloc.h]) dnl Mac OS X does not have spinlocks AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes]) if test "x${have_spinlock}" = "xyes"; then AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock]) fi AC_SUBST(HAVE_SPINLOCK) dnl some os may not have GNU defined strnlen function AC_CHECK_FUNC([strnlen], [have_strnlen=yes]) if test "x${have_strnlen}" = "xyes"; then AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen]) fi AC_SUBST(HAVE_STRNLEN) AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes]) AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes]) if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid]) fi dnl test umount2 function AC_CHECK_FUNC([umount2], [have_umount2=yes]) if test "x${have_umount2}" = "xyes"; then AC_DEFINE(HAVE_UMOUNT2, 1, [define if found umount2]) fi # FUSE section AC_ARG_ENABLE([fuse-client], AC_HELP_STRING([--disable-fuse-client], [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client])) BUILD_FUSE_CLIENT=no if test "x$enable_fuse_client" != "xno"; then FUSE_CLIENT_SUBDIR=fuse BUILD_FUSE_CLIENT="yes" fi AC_ARG_ENABLE([bd-xlator], AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator])) if test "x$enable_bd_xlator" != "xno"; then AC_CHECK_LIB([lvm2app], [lvm_init,lvm_lv_from_name], [HAVE_BD_LIB="yes"], [HAVE_BD_LIB="no"]) if test "x$HAVE_BD_LIB" = "xyes"; then # lvm_lv_from_name() has been made public with lvm2-2.02.79 AC_CHECK_DECLS( [lvm_lv_from_name], [NEED_LVM_LV_FROM_NAME_DECL="no"], [NEED_LVM_LV_FROM_NAME_DECL="yes"], [[#include ]]) fi fi if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then echo "BD xlator requested but required lvm2 development library not found." exit 1 fi BUILD_BD_XLATOR=no if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then BUILD_BD_XLATOR=yes AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator enabled]) if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name() was not found in the lvm2app.h header, but can be linked]) fi fi AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes]) dnl check for old openssl AC_CHECK_LIB([crypto], CRYPTO_THREADID_set_callback, [AC_DEFINE([HAVE_CRYPTO_THREADID], [1], [use new OpenSSL functions])]) AC_CHECK_LIB([ssl], TLSv1_2_method, [AC_DEFINE([HAVE_TLSV1_2_METHOD], [1], [use new OpenSSL functions])]) # start encryption/crypt section AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no]) AC_ARG_ENABLE([crypt-xlator], AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator])) if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then AC_MSG_ERROR([Encryption xlator requires OpenSSL with cmac.h]) fi BUILD_CRYPT_XLATOR=no if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then BUILD_CRYPT_XLATOR=yes AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator]) fi AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes]) AC_SUBST(FUSE_CLIENT_SUBDIR) # end FUSE section # FUSERMOUNT section AC_ARG_ENABLE([fusermount], AC_HELP_STRING([--disable-fusermount], [Use system's fusermount])) BUILD_FUSERMOUNT="yes" if test "x$enable_fusermount" = "xno"; then BUILD_FUSERMOUNT="no" else AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount]) FUSERMOUNT_SUBDIR="contrib/fuse-util" fi AC_SUBST(FUSERMOUNT_SUBDIR) #end FUSERMOUNT section # QEMU_BLOCK section AC_ARG_ENABLE([qemu-block], AC_HELP_STRING([--enable-qemu-block], [Build QEMU Block formats translator])) if test "x$enable_qemu_block" != "xno"; then PKG_CHECK_MODULES([GLIB], [glib-2.0], [HAVE_GLIB_2="yes"], [HAVE_GLIB_2="no"]) fi if test "x$enable_qemu_block" = "xyes" -a "x$HAVE_GLIB_2" = "xno"; then echo "QEMU Block formats translator requires libglib-2.0, but missing." exit 1 fi BUILD_QEMU_BLOCK=no if test "x${enable_qemu_block}" != "xno" -a "x${HAVE_GLIB_2}" = "xyes"; then BUILD_QEMU_BLOCK=yes AC_DEFINE(HAVE_QEMU_BLOCK, 1, [define if libglib-2.0 library found and QEMU Block translator enabled]) fi # end QEMU_BLOCK section # EPOLL section AC_ARG_ENABLE([epoll], AC_HELP_STRING([--disable-epoll], [Use poll instead of epoll.])) BUILD_EPOLL=no if test "x$enable_epoll" != "xno"; then AC_CHECK_HEADERS([sys/epoll.h], [BUILD_EPOLL=yes], [BUILD_EPOLL=no]) fi # end EPOLL section # IBVERBS section AC_ARG_ENABLE([ibverbs], AC_HELP_STRING([--disable-ibverbs], [Do not build the ibverbs transport])) if test "x$enable_ibverbs" != "xno"; then AC_CHECK_LIB([ibverbs], [ibv_get_device_list], [HAVE_LIBIBVERBS="yes"], [HAVE_LIBIBVERBS="no"]) AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"]) if test "x$HAVE_RDMACM" = "xyes" ; then AC_CHECK_DECLS( [RDMA_OPTION_ID_REUSEADDR], [], [AC_ERROR([Need at least version 1.0.15 of librdmacm])], [[#include ]]) fi fi if test "x$enable_ibverbs" = "xyes"; then if test "x$HAVE_LIBIBVERBS" = "xno"; then echo "ibverbs-transport requested, but libibverbs is not present." exit 1 fi if test "x$HAVE_RDMACM" = "xno"; then echo "ibverbs-transport requested, but librdmacm is not present." exit 1 fi fi BUILD_RDMA=no BUILD_IBVERBS=no if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then IBVERBS_SUBDIR=ib-verbs BUILD_IBVERBS=yes RDMA_SUBDIR=rdma BUILD_RDMA=yes fi AC_SUBST(IBVERBS_SUBDIR) AC_SUBST(RDMA_SUBDIR) # end IBVERBS section # SYNCDAEMON section AC_ARG_ENABLE([georeplication], AC_HELP_STRING([--disable-georeplication], [Do not install georeplication components])) BUILD_SYNCDAEMON=no case $host_os in linux*) #do nothing ;; netbsd*) #do nothing ;; *) #disabling geo replication for non-linux platforms enable_georeplication=no ;; esac SYNCDAEMON_COMPILE=0 if test "x$enable_georeplication" != "xno"; then SYNCDAEMON_SUBDIR=geo-replication SYNCDAEMON_COMPILE=1 BUILD_SYNCDAEMON="yes" AM_PATH_PYTHON([2.4]) echo -n "checking if python is python 2.x... " if echo $PYTHON_VERSION | grep ^2; then : else echo no AC_MSG_ERROR([only python 2.x is supported]) fi echo -n "checking if python has ctypes support... " if "$PYTHON" -c 'import ctypes' 2>/dev/null; then echo yes else echo no AC_MSG_ERROR([python does not have ctypes support]) fi fi AC_SUBST(SYNCDAEMON_COMPILE) AC_SUBST(SYNCDAEMON_SUBDIR) # end SYNCDAEMON section # only install scripts from extras/geo-rep when enabled if test "x$enable_georeplication" != "xno"; then GEOREP_EXTRAS_SUBDIR=geo-rep fi AC_SUBST(GEOREP_EXTRAS_SUBDIR) AM_CONDITIONAL(USE_GEOREP, test "x$enable_georeplication" != "xno") # CDC xlator - check if libz is present if so enable HAVE_LIB_Z BUILD_CDC=yes PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],, [AC_CHECK_LIB([z], [deflate], [ZLIB_LIBS="-lz"], [BUILD_CDC=no])]) echo -n "features requiring zlib enabled: " if test "x$BUILD_CDC" = "xyes" ; then echo "yes" AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present]) else echo "no" fi AC_SUBST(ZLIB_CFLAGS) AC_SUBST(ZLIB_LIBS) # end CDC xlator secion #start firewalld section BUILD_FIREWALLD="no" AC_ARG_ENABLE([firewalld], AC_HELP_STRING([--enable-firewalld], [enable installation configuration for firewalld]), [BUILD_FIREWALLD="${enableval}"], [BUILD_FIREWALLD="no"]) if test "x${BUILD_FIREWALLD}" = "xyes"; then if !(which firewalld 1>/dev/null 2>&1) ; then BUILD_FIREWALLD="no (firewalld not installed)" fi fi AM_CONDITIONAL([USE_FIREWALLD],test ["x${BUILD_FIREWALLD}" = "xyes"]) #endof firewald section # Data tiering requires sqlite AC_ARG_ENABLE([tiering], AC_HELP_STRING([--disable-tiering], [Disable data classification/tiering]), [BUILD_GFDB="${enableval}"], [BUILD_GFDB="yes"]) if test "x${BUILD_GFDB}" = "xyes"; then PKG_CHECK_MODULES([SQLITE], [sqlite3], AC_DEFINE(USE_GFDB, 1), AC_MSG_ERROR([pass --disable-tiering to build without sqlite])) else AC_DEFINE(USE_GFDB, 0, [no sqlite, gfdb is disabled]) fi AC_SUBST(SQLITE_CFLAGS) AC_SUBST(SQLITE_LIBS) AM_CONDITIONAL(BUILD_GFDB, test "x${BUILD_GFDB}" = "xyes") AM_CONDITIONAL(USE_GFDB, test "x${BUILD_GFDB}" = "xyes") # check for systemtap/dtrace BUILD_SYSTEMTAP=no AC_MSG_CHECKING([whether to include systemtap tracing support]) AC_ARG_ENABLE([systemtap], [AS_HELP_STRING([--enable-systemtap], [Enable inclusion of systemtap trace support])], [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP="def"]) AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test "x${ENABLE_SYSTEMTAP}" = "xyes"]) AC_MSG_RESULT(${ENABLE_SYSTEMTAP}) if test "x${ENABLE_SYSTEMTAP}" != "xno"; then AC_CHECK_PROG(DTRACE, dtrace, "yes", "no") AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND="yes"], [SDT_H_FOUND="no"]) fi if test "x${ENABLE_SYSTEMTAP}" = "xyes"; then if test "x${DTRACE}" = "xno"; then AC_MSG_ERROR([dtrace not found]) elif test "$x{SDT_H_FOUND}" = "xno"; then AC_MSG_ERROR([systemtap support needs sys/sdt.h header]) fi fi if test "x${DTRACE}" = "xyes" -a "x${SDT_H_FOUND}" = "xyes"; then AC_MSG_CHECKING([x"${DTRACE}"xy"${SDT_H_FOUND}"y]) AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using probes.]) BUILD_SYSTEMTAP=yes fi # end of systemtap/dtrace # xml-output AC_ARG_ENABLE([xml-output], AC_HELP_STRING([--disable-xml-output], [Disable the xml output])) BUILD_XML_OUTPUT="yes" if test "x$enable_xml_output" != "xno"; then #check if libxml is present if so enable HAVE_LIB_XML m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes]) if test "x${no_xml}" = "x"; then AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.]) else if test "x$enable_georeplication" != "xno"; then AC_MSG_ERROR([libxml2 devel libraries not found]) else AC_MSG_WARN([libxml2 devel libraries not found disabling XML support]) BUILD_XML_OUTPUT="no" fi fi else if test "x$enable_georeplication" != "xno"; then AC_MSG_ERROR([geo-replication requires xml output]) fi BUILD_XML_OUTPUT="no" fi # end of xml-output AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes]) if test "x${have_backtrace}" = "xyes"; then AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace]) fi AC_SUBST(HAVE_BACKTRACE) if test "x${have_backtrace}" != "xyes"; then AC_TRY_COMPILE([#include ], [double x=0.0; x=ceil(0.0);], [], AC_MSG_ERROR([need math library for libexecinfo])) fi dnl glusterfs prints memory usage to stderr by sending it SIGUSR1 AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes]) if test "x${have_malloc_stats}" = "xyes"; then AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats]) fi AC_SUBST(HAVE_MALLOC_STATS) dnl Linux, Solaris, Cygwin AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec]) dnl FreeBSD, NetBSD AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec]) case $host_os in *netbsd*) CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063 -DCONFIG_MACHINE_BSWAP_H" ;; esac AC_CHECK_FUNC([linkat], [have_linkat=yes]) if test "x${have_linkat}" = "xyes"; then AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat]) fi AC_SUBST(HAVE_LINKAT) dnl check for Monotonic clock AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_WARN([System doesn't have monotonic clock using contrib])) dnl Check for argp AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp])) BUILD_ARGP_STANDALONE=no if test "x${ac_cv_header_argp_h}" = "xno"; then AC_CONFIG_SUBDIRS(contrib/argp-standalone) BUILD_ARGP_STANDALONE=yes ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/contrib/argp-standalone' ARGP_STANDALONE_LDADD='${top_builddir}/contrib/argp-standalone/libargp.a' ARGP_STANDALONE_DIR='${top_builddir}/contrib/argp-standalone' fi dnl libglusterfs needs argp.h, practically everything depends on it GF_CPPFLAGS="${GF_CPPFLAGS} ${ARGP_STANDALONE_CPPFLAGS}" AC_SUBST(ARGP_STANDALONE_CPPFLAGS) AC_SUBST(ARGP_STANDALONE_LDADD) AC_SUBST(ARGP_STANDALONE_DIR) AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h])) AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes]) if test "x${have_llistxattr}" = "xyes"; then AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists]) fi AC_CHECK_FUNC([fdatasync], [have_fdatasync=no]) if test "x${have_fdatasync}" = "xyes"; then AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists]) fi AC_CHECK_FUNC([fallocate], [have_fallocate=yes]) if test "x${have_fallocate}" = "xyes"; then AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists]) fi AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes]) if test "x${have_posix_fallocate}" = "xyes"; then AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists]) fi # Check the distribution where you are compiling glusterfs on GF_DISTRIBUTION= AC_CHECK_FILE([/etc/debian_version]) AC_CHECK_FILE([/etc/SuSE-release]) AC_CHECK_FILE([/etc/redhat-release]) if test "x$ac_cv_file__etc_debian_version" = "xyes"; then GF_DISTRIBUTION=Debian fi if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then GF_DISTRIBUTION=SuSE fi if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then GF_DISTRIBUTION=Redhat fi AC_SUBST(GF_DISTRIBUTION) GF_HOST_OS="" GF_LDFLAGS="-rdynamic" dnl check for gcc -Werror=format-security saved_CFLAGS=$CFLAGS CFLAGS="-Wformat -Werror=format-security" AC_MSG_CHECKING([whether $CC accepts -Werror=format-security]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no]) echo $cc_werror_format_security if test "x$cc_werror_format_security" = "xno"; then CFLAGS="$saved_CFLAGS" else CFLAGS="$saved_CFLAGS $CFLAGS" GF_CFLAGS="$GF_CFLAGS $CFLAGS" fi dnl check for gcc -Werror=implicit-function-declaration saved_CFLAGS=$CFLAGS CFLAGS="-Werror=implicit-function-declaration" AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no]) echo $cc_werror_implicit if test "x$cc_werror_implicit" = "xno"; then CFLAGS="$saved_CFLAGS" else CFLAGS="$saved_CFLAGS $CFLAGS" GF_CFLAGS="$GF_CFLAGS $CFLAGS" fi dnl clang is mostly GCC-compatible, but its version is much lower, dnl so we have to check for it. AC_MSG_CHECKING([if compiling with clang]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifndef __clang__ not clang #endif ]])], [CLANG=yes], [CLANG=no]) AC_MSG_RESULT([$CLANG]) if test "x$CLANG" = "xyes"; then GF_CFLAGS="${GF_CFLAGS} -Wno-gnu" fi if test "x$ac_cv_header_execinfo_h" = "xno"; then # The reason is that __builtin_frame_address(n) for n > 0 seems # to just crash on most platforms when -fomit-stack-pointer is # specified, which seems to be the default for many platforms on # -O2. The documentation says that __builtin_frame_address() # should return NULL in case it can't get the frame, but it # seems to crash instead. # execinfo.c in ./contrib/libexecinfo uses __builtin_frame_address(n) # for providing cross platform backtrace*() functions. if test "x$CLANG" = "xno"; then GF_CFLAGS="${GF_CFLAGS} -fno-omit-frame-pointer" fi fi old_prefix=$prefix if test "x$prefix" = xNONE; then prefix=$ac_default_prefix fi GLUSTERFS_LIBEXECDIR="$(eval echo $prefix)/libexec/glusterfs" GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd" prefix=$old_prefix ### Dirty hacky stuff to make LOCALSTATEDIR work if test "x$prefix" = xNONE; then test $localstatedir = '${prefix}/var' && localstatedir=$ac_default_prefix/var localstatedir=/var LOCALSTATEDIR=$(eval echo ${localstatedir}) else LOCALSTATEDIR=$(eval echo ${localstatedir}) fi old_prefix=$prefix if test "x$prefix" = xNONE; then prefix=$ac_default_prefix fi GLUSTERD_VOLFILE="$(eval echo ${sysconfdir})/glusterfs/glusterd.vol" prefix=$old_prefix case $host_os in linux*) GF_HOST_OS="GF_LINUX_HOST_OS" GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\"" GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd" ;; solaris*) GF_HOST_OS="GF_SOLARIS_HOST_OS" GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64" BUILD_FUSE_CLIENT=no FUSE_CLIENT_SUBDIR="" GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd" ;; *netbsd*) GF_HOST_OS="GF_BSD_HOST_OS" GF_CFLAGS="${GF_CFLAGS} -D_INCOMPLETE_XOPEN_C063" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME" GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\"" GF_LDADD="${ARGP_STANDALONE_LDADD}" if test "x$ac_cv_header_execinfo_h" = "xyes"; then GF_LDFLAGS="-lexecinfo" fi GF_FUSE_LDADD="-lperfuse" BUILD_FUSE_CLIENT=yes LEXLIB="" BUILD_FUSERMOUNT=no FUSERMOUNT_SUBDIR="" GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd" ;; *freebsd*) GF_HOST_OS="GF_BSD_HOST_OS" GF_CFLAGS="${GF_CFLAGS} ${ARGP_STANDALONE_CPPFLAGS} -O0" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME" GF_CFLAGS="${GF_CFLAGS} -D_LIBGEN_H_" GF_CFLAGS="${GF_CFLAGS} -DO_DSYNC=0" GF_CFLAGS="${GF_CFLAGS} -Dxdr_quad_t=xdr_longlong_t" GF_CFLAGS="${GF_CFLAGS} -Dxdr_u_quad_t=xdr_u_longlong_t" GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\"" GF_LDADD="${ARGP_STANDALONE_LDADD}" if test "x$ac_cv_header_execinfo_h" = "xyes"; then GF_LDFLAGS="-lexecinfo" fi BUILD_FUSE_CLIENT=yes BUILD_FUSERMOUNT=no FUSERMOUNT_SUBDIR="" GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd" ;; darwin*) GF_HOST_OS="GF_DARWIN_HOST_OS" LIBTOOL=glibtool GF_CFLAGS="${GF_CFLAGS} ${ARGP_STANDALONE_CPPFLAGS} " GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_XOPEN_SOURCE " GF_CFLAGS="${GF_CFLAGS} -D_DARWIN_USE_64_BIT_INODE " GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME" GF_LDADD="${ARGP_STANDALONE_LDADD}" GF_LDFLAGS="" GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse" BUILD_FUSERMOUNT="no" FUSERMOUNT_SUBDIR="" GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd" ;; esac case $host_os in darwin*) GFAPI_EXTRA_LDFLAGS='-Wl,-alias_list,$(top_srcdir)/api/src/gfapi.aliases' ;; *) GFAPI_EXTRA_LDFLAGS='-Wl,--version-script=$(top_srcdir)/api/src/gfapi.map' ;; esac # lazy umount emulation UMOUNTD_SUBDIR="" if test "x${GF_HOST_OS}" != "xGF_LINUX_HOST_OS" ; then UMOUNTD_SUBDIR="contrib/umountd" fi AC_SUBST(UMOUNTD_SUBDIR) # enable/disable QEMU AM_CONDITIONAL([ENABLE_QEMU_BLOCK], [test x$BUILD_QEMU_BLOCK = xyes]) # enable debug section AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debug build options.])) # syslog section AC_ARG_ENABLE([syslog], AC_HELP_STRING([--disable-syslog], [Disable syslog for logging])) USE_SYSLOG="yes" if test "x$enable_syslog" != "xno"; then AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging]) else USE_SYSLOG="no" fi AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes]) #end syslog section BUILD_READLINE=no AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"]) AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"]) AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"]) if test "x$RLLIBS" != "x"; then if test "x$RL_UNDO" = "xyes"; then AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI]) BUILD_READLINE=yes else BUILD_READLINE="no (present but missing undo)" fi fi BUILD_LIBAIO=no AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"]) if test "x$LIBAIO" != "x"; then AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled]) BUILD_LIBAIO=yes fi # glupy section BUILD_GLUPY=no have_python2=no have_Python_h=no AM_PATH_PYTHON() if echo $PYTHON_VERSION | grep ^2; then have_python2=yes fi # Save flags before testing python saved_CFLAGS=$CFLAGS saved_CPPFLAGS=$CPPFLAGS saved_LDFLAGS=$LDFLAGS # Use pkg-config to get runtime search patch missing from ${PYTHON}-config # Just do "true" on failure so that configure does not bail out PKG_CHECK_MODULES([PYTHON], "python-$PYTHON_VERSION",,true) CFLAGS="`${PYTHON}-config --cflags`" CPPFLAGS=$CFLAGS LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`" AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[]) AC_ARG_ENABLE([glupy], AS_HELP_STRING([--enable-glupy], [build glupy])) case x$enable_glupy in xyes) if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then BUILD_GLUPY=yes PYTHONDEV_CFLAGS="$CFLAGS" PYTHONDEV_CPPFLAGS="$CPPFLAGS" PYTHONDEV_LDFLAGS="$LDFLAGS" AC_SUBST(PYTHONDEV_CFLAGS) AC_SUBST(PYTHONDEV_CPPFLAGS) AC_SUBST(PYTHONDEV_LDFLAGS) else AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x]) fi ;; xno) ;; *) if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then BUILD_GLUPY=yes PYTHONDEV_CFLAGS="$CFLAGS" PYTHONDEV_CPPFLAGS="$CPPFLAGS" PYTHONDEV_LDFLAGS="$LDFLAGS" AC_SUBST(PYTHONDEV_CFLAGS) AC_SUBST(PYTHONDEV_CPPFLAGS) AC_SUBST(PYTHONDEV_LDFLAGS) else AC_MSG_WARN([ --------------------------------------------------------------------------------- cannot build glupy. python 2.x and python-devel/python-dev package are required. ---------------------------------------------------------------------------------]) fi ;; esac # Restore flags CFLAGS=$saved_CFLAGS CPPFLAGS=$saved_CPPFLAGS LDFLAGS=$saved_LDFLAGS case $host_os in darwin*) BUILD_GLUPY=no ;; esac if test "x$BUILD_GLUPY" = "xyes"; then BUILD_PYTHON_SITE_PACKAGES=`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"` BUILD_PYTHON_LIB=python$PYTHON_VERSION GLUPY_SUBDIR=glupy GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB" AC_SUBST(BUILD_PYTHON_SITE_PACKAGES) AC_SUBST(BUILD_PYTHON_INC) AC_SUBST(BUILD_PYTHON_LIB) AC_SUBST(GLUPY_SUBDIR) AC_SUBST(GLUPY_SUBDIR_MAKEFILE) AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE) fi # end glupy section dnl Check for userspace-rcu PKG_CHECK_MODULES([URCU], [liburcu-bp]) PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.8], [], [PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.7], [AC_DEFINE(URCU_0_7, 1, [Define if liburcu 0.7 is found])], [AC_MSG_ERROR([liburcu >= 0.7 required])])]) BUILD_UNITTEST="no" AC_ARG_ENABLE([cmocka], AC_HELP_STRING([--enable-cmocka], [Enable cmocka build options.])) if test "x$enable_cmocka" = "xyes"; then BUILD_UNITTEST="yes" PKG_CHECK_MODULES([UNITTEST], [cmocka >= 1.0.1], [BUILD_UNITTEST="yes"], [AC_MSG_ERROR([cmocka library is required to build glusterfs])] ) fi AM_CONDITIONAL([UNITTEST], [test x$BUILD_UNITTEST = xyes]) dnl Define UNIT_TESTING only for building cmocka binaries. UNITTEST_CFLAGS="${UNITTEST_CFLAGS} -DUNIT_TESTING=1" dnl Add cmocka for unit tests case $host_os in freebsd*) dnl remove --coverage on FreeBSD due to a known llvm packaging bug UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0" UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" ;; *) UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage" UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" ;; esac AC_SUBST(UNITTEST_CFLAGS) AC_SUBST(UNITTEST_LDFLAGS) AC_SUBST(CFLAGS) # end enable debug section dnl libglusterfs.so uses math functions GF_LDADD="${GF_LDADD} ${MATH_LIB}" AC_SUBST(GF_HOST_OS) AC_SUBST(GF_CFLAGS) AC_SUBST(GF_LDFLAGS) AC_SUBST(GF_LDADD) AC_SUBST(GF_FUSE_LDADD) AC_SUBST(GF_FUSE_CFLAGS) AC_SUBST(RLLIBS) AC_SUBST(LIBAIO) AC_SUBST(AM_MAKEFLAGS) AC_SUBST(AM_LIBTOOLFLAGS) CONTRIBDIR='$(top_srcdir)/contrib' AC_SUBST(CONTRIBDIR) GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)' GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src' GF_CPPFLAGS="$GF_CPPFLAGS $GF_CPPDEFINES $GF_CPPINCLUDES" AC_SUBST([GF_CPPFLAGS]) AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS") AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS") AM_CONDITIONAL([GF_BSD_HOST_OS], test "${GF_HOST_OS}" = "GF_BSD_HOST_OS") AC_SUBST(GLUSTERD_WORKDIR) AM_CONDITIONAL([GF_INSTALL_GLUSTERD_WORKDIR], test ! -d ${GLUSTERD_WORKDIR} && test -d ${sysconfdir}/glusterd ) AC_SUBST(GLUSTERD_VOLFILE) AC_SUBST(GLUSTERFS_LIBEXECDIR) AC_SUBST(GLUSTERFSD_MISCDIR) dnl pkg-config versioning dnl dnl Once we released gluster-api.pc with version=7. Since then we undid the dnl library versioning and replaced it with symbol-versioning. The current dnl libgfapi.so has version 0, but the symbols have the version from the main dnl package at the time they were added. dnl dnl Because other packages (like samba) use the pkg-config version, we can not dnl drop it, or decrease the version easily. The simplest solution is to keep dnl the version=7 and add sub-digits for the actual package/symbol versions. GFAPI_VERSION="7."${PACKAGE_VERSION} LIBGFCHANGELOG_VERSION="0.0.1" AC_SUBST(GFAPI_VERSION) AC_SUBST(LIBGFCHANGELOG_VERSION) LIBGFDB_VERSION="0.0.1" AC_SUBST(LIBGFDB_VERSION) dnl libtool versioning LIBGFXDR_LT_VERSION="0:1:0" LIBGFRPC_LT_VERSION="0:1:0" LIBGLUSTERFS_LT_VERSION="0:1:0" LIBGFCHANGELOG_LT_VERSION="0:1:0" GFAPI_LT_VERSION="0:0:0" AC_SUBST(LIBGFXDR_LT_VERSION) AC_SUBST(LIBGFRPC_LT_VERSION) AC_SUBST(LIBGLUSTERFS_LT_VERSION) AC_SUBST(LIBGFCHANGELOG_LT_VERSION) AC_SUBST(GFAPI_LT_VERSION) AC_SUBST(GFAPI_EXTRA_LDFLAGS) GFAPI_LIBS="${ACL_LIBS}" AC_SUBST(GFAPI_LIBS) dnl this change necessary for run-tests.sh AC_CONFIG_FILES([tests/env.rc],[ln -s ${ac_abs_builddir}/env.rc ${ac_abs_srcdir}/env.rc 2>/dev/null]) AC_OUTPUT echo echo "GlusterFS configure summary" echo "===========================" echo "FUSE client : $BUILD_FUSE_CLIENT" echo "Infiniband verbs : $BUILD_IBVERBS" echo "epoll IO multiplex : $BUILD_EPOLL" echo "argp-standalone : $BUILD_ARGP_STANDALONE" echo "fusermount : $BUILD_FUSERMOUNT" echo "readline : $BUILD_READLINE" echo "georeplication : $BUILD_SYNCDAEMON" echo "Linux-AIO : $BUILD_LIBAIO" echo "Enable Debug : $BUILD_DEBUG" ## echo "systemtap : $BUILD_SYSTEMTAP" echo "Block Device xlator : $BUILD_BD_XLATOR" echo "glupy : $BUILD_GLUPY" echo "Use syslog : $USE_SYSLOG" echo "XML output : $BUILD_XML_OUTPUT" echo "QEMU Block formats : $BUILD_QEMU_BLOCK" echo "Encryption xlator : $BUILD_CRYPT_XLATOR" echo "Unit Tests : $BUILD_UNITTEST" echo "POSIX ACLs : $BUILD_POSIX_ACLS" echo "Data Classification : $BUILD_GFDB" echo "firewalld-config : $BUILD_FIREWALLD" echo glusterfs-3.7.6/PaxHeaders.7244/heal0000644000076200007630000000012712617742653015376 xustar000000000000000029 mtime=1447019947.60724438 29 atime=1447019949.33221843 29 ctime=1447019947.60724438 glusterfs-3.7.6/heal/0000755000076200007630000000000012617742653015664 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/heal/PaxHeaders.7244/Makefile.am0000644000076200007630000000013212617742532017477 xustar000000000000000030 mtime=1447019866.113470396 30 atime=1447019866.403466033 30 ctime=1447019947.598244516 glusterfs-3.7.6/heal/Makefile.am0000644000076200007630000000003412617742532017711 0ustar00jenkinsjenkins00000000000000SUBDIRS = src CLEANFILES = glusterfs-3.7.6/heal/PaxHeaders.7244/src0000644000076200007630000000013112617742653016160 xustar000000000000000030 mtime=1447019947.672243402 29 atime=1447019949.33221843 30 ctime=1447019947.672243402 glusterfs-3.7.6/heal/src/0000755000076200007630000000000012617742653016453 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/heal/src/PaxHeaders.7244/Makefile.am0000644000076200007630000000013212617742532020266 xustar000000000000000030 mtime=1447019866.113470396 30 atime=1447019866.403466033 30 ctime=1447019947.666243493 glusterfs-3.7.6/heal/src/Makefile.am0000644000076200007630000000145412617742532020507 0ustar00jenkinsjenkins00000000000000sbin_PROGRAMS = glfsheal glfsheal_SOURCES = glfs-heal.c glfsheal_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)\ $(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/api/src/libgfapi.la \ $(XML_LIBS) $(GFAPI_LIBS) $(UUID_LIBS) glfsheal_LDFLAGS = $(GF_LDFLAGS) AM_CPPFLAGS = $(GF_CPPFLAGS) \ -I$(top_srcdir)/xlators/lib/src\ -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src\ -I$(top_srcdir)/rpc/xdr/src\ -I$(top_srcdir)/api/src\ -I$(top_srcdir)/contrib/argp-standalone\ -DDATADIR=\"$(localstatedir)\" \ -DSBIN_DIR=\"$(sbindir)\" \ $(XML_CPPFLAGS) AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = $(top_builddir)/libglusterfs/src/libglusterfs.la: $(MAKE) -C $(top_builddir)/libglusterfs/src/ all glusterfs-3.7.6/heal/src/PaxHeaders.7244/Makefile.in0000644000076200007630000000013212617742546020304 xustar000000000000000030 mtime=1447019878.514283829 30 atime=1447019919.670664656 30 ctime=1447019947.669243447 glusterfs-3.7.6/heal/src/Makefile.in0000644000076200007630000005143612617742546020532 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ sbin_PROGRAMS = glfsheal$(EXEEXT) subdir = heal/src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/contrib/aclocal/mkdirp.m4 \ $(top_srcdir)/contrib/aclocal/python.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) am_glfsheal_OBJECTS = glfs-heal.$(OBJEXT) glfsheal_OBJECTS = $(am_glfsheal_OBJECTS) am__DEPENDENCIES_1 = glfsheal_DEPENDENCIES = \ $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/api/src/libgfapi.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent glfsheal_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(glfsheal_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(glfsheal_SOURCES) DIST_SOURCES = $(glfsheal_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ACL_LIBS = @ACL_LIBS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LIBTOOLFLAGS = @AM_LIBTOOLFLAGS@ AM_MAKEFLAGS = @AM_MAKEFLAGS@ AR = @AR@ ARGP_STANDALONE_CPPFLAGS = @ARGP_STANDALONE_CPPFLAGS@ ARGP_STANDALONE_DIR = @ARGP_STANDALONE_DIR@ ARGP_STANDALONE_LDADD = @ARGP_STANDALONE_LDADD@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_PYTHON_INC = @BUILD_PYTHON_INC@ BUILD_PYTHON_LIB = @BUILD_PYTHON_LIB@ BUILD_PYTHON_SITE_PACKAGES = @BUILD_PYTHON_SITE_PACKAGES@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONTRIBDIR = @CONTRIBDIR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FUSERMOUNT_SUBDIR = @FUSERMOUNT_SUBDIR@ FUSE_CLIENT_SUBDIR = @FUSE_CLIENT_SUBDIR@ GEOREP_EXTRAS_SUBDIR = @GEOREP_EXTRAS_SUBDIR@ GFAPI_EXTRA_LDFLAGS = @GFAPI_EXTRA_LDFLAGS@ GFAPI_LIBS = @GFAPI_LIBS@ GFAPI_LT_VERSION = @GFAPI_LT_VERSION@ GFAPI_VERSION = @GFAPI_VERSION@ GF_CFLAGS = @GF_CFLAGS@ GF_CPPFLAGS = @GF_CPPFLAGS@ GF_DISTRIBUTION = @GF_DISTRIBUTION@ GF_FUSE_CFLAGS = @GF_FUSE_CFLAGS@ GF_FUSE_LDADD = @GF_FUSE_LDADD@ GF_HOST_OS = @GF_HOST_OS@ GF_LDADD = @GF_LDADD@ GF_LDFLAGS = @GF_LDFLAGS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GLUPY_SUBDIR = @GLUPY_SUBDIR@ GLUPY_SUBDIR_MAKEFILE = @GLUPY_SUBDIR_MAKEFILE@ GLUPY_SUBDIR_SRC_MAKEFILE = @GLUPY_SUBDIR_SRC_MAKEFILE@ GLUSTERD_VOLFILE = @GLUSTERD_VOLFILE@ GLUSTERD_WORKDIR = @GLUSTERD_WORKDIR@ GLUSTERFSD_MISCDIR = @GLUSTERFSD_MISCDIR@ GLUSTERFS_LIBEXECDIR = @GLUSTERFS_LIBEXECDIR@ GREP = @GREP@ HAVE_BACKTRACE = @HAVE_BACKTRACE@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_MALLOC_STATS = @HAVE_MALLOC_STATS@ HAVE_SPINLOCK = @HAVE_SPINLOCK@ HAVE_STRNLEN = @HAVE_STRNLEN@ IBVERBS_SUBDIR = @IBVERBS_SUBDIR@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBAIO = @LIBAIO@ LIBGFCHANGELOG_LT_VERSION = @LIBGFCHANGELOG_LT_VERSION@ LIBGFCHANGELOG_VERSION = @LIBGFCHANGELOG_VERSION@ LIBGFDB_VERSION = @LIBGFDB_VERSION@ LIBGFRPC_LT_VERSION = @LIBGFRPC_LT_VERSION@ LIBGFXDR_LT_VERSION = @LIBGFXDR_LT_VERSION@ LIBGLUSTERFS_LT_VERSION = @LIBGLUSTERFS_LT_VERSION@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCF_SUBDIR = @OCF_SUBDIR@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_RELEASE = @PACKAGE_RELEASE@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_UUID = @PKGCONFIG_UUID@ PKG_CONFIG = @PKG_CONFIG@ PYTHON = @PYTHON@ PYTHONDEV_CFLAGS = @PYTHONDEV_CFLAGS@ PYTHONDEV_CPPFLAGS = @PYTHONDEV_CPPFLAGS@ PYTHONDEV_LDFLAGS = @PYTHONDEV_LDFLAGS@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RDMA_SUBDIR = @RDMA_SUBDIR@ RLLIBS = @RLLIBS@ RPCGEN = @RPCGEN@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIZEOF_INT = @SIZEOF_INT@ SIZEOF_LONG = @SIZEOF_LONG@ SIZEOF_LONG_LONG = @SIZEOF_LONG_LONG@ SIZEOF_SHORT = @SIZEOF_SHORT@ SQLITE_CFLAGS = @SQLITE_CFLAGS@ SQLITE_LIBS = @SQLITE_LIBS@ STRIP = @STRIP@ SYNCDAEMON_COMPILE = @SYNCDAEMON_COMPILE@ SYNCDAEMON_SUBDIR = @SYNCDAEMON_SUBDIR@ UMOUNTD_SUBDIR = @UMOUNTD_SUBDIR@ UNITTEST_CFLAGS = @UNITTEST_CFLAGS@ UNITTEST_LDFLAGS = @UNITTEST_LDFLAGS@ UNITTEST_LIBS = @UNITTEST_LIBS@ URCU_CDS_CFLAGS = @URCU_CDS_CFLAGS@ URCU_CDS_LIBS = @URCU_CDS_LIBS@ URCU_CFLAGS = @URCU_CFLAGS@ URCU_LIBS = @URCU_LIBS@ USE_POSIX_ACLS = @USE_POSIX_ACLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ XML_LIBS = @XML_LIBS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ initdir = @initdir@ install_sh = @install_sh@ launchddir = @launchddir@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ mountutildir = @mountutildir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ shrext_cmds = @shrext_cmds@ srcdir = @srcdir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemddir = @systemddir@ target_alias = @target_alias@ tmpfilesdir = @tmpfilesdir@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ glfsheal_SOURCES = glfs-heal.c glfsheal_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)\ $(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/api/src/libgfapi.la \ $(XML_LIBS) $(GFAPI_LIBS) $(UUID_LIBS) glfsheal_LDFLAGS = $(GF_LDFLAGS) AM_CPPFLAGS = $(GF_CPPFLAGS) \ -I$(top_srcdir)/xlators/lib/src\ -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src\ -I$(top_srcdir)/rpc/xdr/src\ -I$(top_srcdir)/api/src\ -I$(top_srcdir)/contrib/argp-standalone\ -DDATADIR=\"$(localstatedir)\" \ -DSBIN_DIR=\"$(sbindir)\" \ $(XML_CPPFLAGS) AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign heal/src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign heal/src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list glfsheal$(EXEEXT): $(glfsheal_OBJECTS) $(glfsheal_DEPENDENCIES) @rm -f glfsheal$(EXEEXT) $(AM_V_CCLD)$(glfsheal_LINK) $(glfsheal_OBJECTS) $(glfsheal_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glfs-heal.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-sbinPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-sbinPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-sbinPROGRAMS ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-sbinPROGRAMS install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-sbinPROGRAMS $(top_builddir)/libglusterfs/src/libglusterfs.la: $(MAKE) -C $(top_builddir)/libglusterfs/src/ all # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/heal/src/PaxHeaders.7244/glfs-heal.c0000644000076200007630000000013212617742532020240 xustar000000000000000030 mtime=1447019866.113470396 30 atime=1447019866.403466033 30 ctime=1447019947.672243402 glusterfs-3.7.6/heal/src/glfs-heal.c0000644000076200007630000006576012617742532020473 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2014 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include "glfs.h" #include "glfs-handles.h" #include "glfs-internal.h" #include "protocol-common.h" #include "syncop.h" #include "syncop-utils.h" #include #include #define DEFAULT_HEAL_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" #define USAGE_STR "Usage: %s [bigger-file | "\ "source-brick [] | "\ "split-brain-info]\n" typedef void (*print_status) (dict_t *, char *, uuid_t, uint64_t *); int glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, char *file, dict_t *xattr_req); int glfsh_link_inode_update_loc (loc_t *loc, struct iatt *iattr) { inode_t *link_inode = NULL; int ret = -1; link_inode = inode_link (loc->inode, NULL, NULL, iattr); if (link_inode == NULL) goto out; inode_unref (loc->inode); loc->inode = link_inode; ret = 0; out: return ret; } int glfsh_get_index_dir_loc (loc_t *rootloc, xlator_t *xl, loc_t *dirloc, int32_t *op_errno) { void *index_gfid = NULL; int ret = 0; dict_t *xattr = NULL; struct iatt iattr = {0}; struct iatt parent = {0}; ret = syncop_getxattr (xl, rootloc, &xattr, GF_XATTROP_INDEX_GFID, NULL, NULL); if (ret < 0) { *op_errno = -ret; goto out; } ret = dict_get_ptr (xattr, GF_XATTROP_INDEX_GFID, &index_gfid); if (ret < 0) { *op_errno = EINVAL; goto out; } gf_uuid_copy (dirloc->gfid, index_gfid); dirloc->path = ""; dirloc->inode = inode_new (rootloc->inode->table); ret = syncop_lookup (xl, dirloc, &iattr, &parent, NULL, NULL); dirloc->path = NULL; if (ret < 0) { *op_errno = -ret; goto out; } ret = glfsh_link_inode_update_loc (dirloc, &iattr); if (ret) goto out; glfs_loc_touchup (dirloc); ret = 0; out: if (xattr) dict_unref (xattr); return ret; } static xlator_t* _get_ancestor (xlator_t *xl, gf_xl_afr_op_t heal_op) { static char *replica_xl[] = {"cluster/replicate", NULL}; static char *heal_xls[] = {"cluster/replicate", "cluster/disperse", NULL}; char **ancestors = NULL; if (heal_op == GF_SHD_OP_INDEX_SUMMARY) ancestors = heal_xls; else ancestors = replica_xl; if (!xl || !xl->parents) return NULL; while (xl->parents) { xl = xl->parents->xlator; if (!xl) break; if (gf_get_index_by_elem (ancestors, xl->type) != -1) return xl; } return NULL; } int glfsh_index_purge (xlator_t *subvol, inode_t *inode, char *name) { loc_t loc = {0, }; int ret = 0; loc.parent = inode_ref (inode); loc.name = name; ret = syncop_unlink (subvol, &loc, NULL, NULL); loc_wipe (&loc); return ret; } void glfsh_print_spb_status (dict_t *dict, char *path, uuid_t gfid, uint64_t *num_entries) { char *value = NULL; int ret = 0; ret = dict_get_str (dict, "heal-info", &value); if (ret) return; if (!strcmp (value, "split-brain")) { (*num_entries)++; printf ("%s\n", path ? path : uuid_utoa (gfid)); } return; } void glfsh_print_heal_status (dict_t *dict, char *path, uuid_t gfid, uint64_t *num_entries) { char *value = NULL; int ret = 0; char *status = NULL; ret = dict_get_str (dict, "heal-info", &value); if (ret || (!strcmp (value, "no-heal"))) return; (*num_entries)++; if (!strcmp (value, "heal")) { ret = gf_asprintf (&status, " "); } else if (!strcmp (value, "possibly-healing")) { ret = gf_asprintf (&status, " - Possibly undergoing heal\n"); } else if (!strcmp (value, "split-brain")) { ret = gf_asprintf (&status, " - Is in split-brain\n"); } if (ret == -1) status = NULL; printf ("%s%s\n", path ? path : uuid_utoa (gfid), status); if (status) GF_FREE (status); return; } static int glfsh_heal_entries (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, gf_dirent_t *entries, uint64_t *offset, uint64_t *num_entries, dict_t *xattr_req) { gf_dirent_t *entry = NULL; gf_dirent_t *tmp = NULL; int ret = 0; char file[64] = {0}; list_for_each_entry_safe (entry, tmp, &entries->list, list) { *offset = entry->d_off; if ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0)) continue; memset (file, 0, sizeof(file)); snprintf (file, sizeof(file), "gfid:%s", entry->d_name); ret = glfsh_heal_splitbrain_file (fs, top_subvol, rootloc, file, xattr_req); if (ret) continue; (*num_entries)++; } return ret; } static int glfsh_process_entries (xlator_t *xl, fd_t *fd, gf_dirent_t *entries, uint64_t *offset, uint64_t *num_entries, print_status glfsh_print_status) { gf_dirent_t *entry = NULL; gf_dirent_t *tmp = NULL; int ret = 0; char *path = NULL; uuid_t gfid = {0}; xlator_t *this = NULL; dict_t *dict = NULL; loc_t loc = {0,}; this = THIS; list_for_each_entry_safe (entry, tmp, &entries->list, list) { *offset = entry->d_off; if ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0)) continue; if (dict) { dict_unref (dict); dict = NULL; } gf_uuid_clear (gfid); GF_FREE (path); path = NULL; gf_uuid_parse (entry->d_name, gfid); gf_uuid_copy (loc.gfid, gfid); ret = syncop_getxattr (this, &loc, &dict, GF_HEAL_INFO, NULL, NULL); if (ret) continue; ret = syncop_gfid_to_path (this->itable, xl, gfid, &path); if (ret == -ENOENT || ret == -ESTALE) { glfsh_index_purge (xl, fd->inode, entry->d_name); ret = 0; continue; } if (dict) glfsh_print_status (dict, path, gfid, num_entries); } ret = 0; GF_FREE (path); if (dict) { dict_unref (dict); dict = NULL; } return ret; } static int glfsh_crawl_directory (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, xlator_t *readdir_xl, fd_t *fd, loc_t *loc, dict_t *xattr_req) { uint64_t offset = 0; gf_dirent_t entries; int ret = 0; gf_boolean_t free_entries = _gf_false; uint64_t num_entries = 0; int heal_op = -1; INIT_LIST_HEAD (&entries.list); ret = dict_get_int32 (xattr_req, "heal-op", &heal_op); if (ret) return ret; while (1) { ret = syncop_readdir (readdir_xl, fd, 131072, offset, &entries, NULL, NULL); if (ret <= 0) break; ret = 0; free_entries = _gf_true; if (list_empty (&entries.list)) goto out; if (heal_op == GF_SHD_OP_INDEX_SUMMARY) { ret = glfsh_process_entries (readdir_xl, fd, &entries, &offset, &num_entries, glfsh_print_heal_status); if (ret < 0) goto out; } else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) { ret = glfsh_process_entries (readdir_xl, fd, &entries, &offset, &num_entries, glfsh_print_spb_status); if (ret < 0) goto out; } else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) { ret = glfsh_heal_entries (fs, top_subvol, rootloc, &entries, &offset, &num_entries, xattr_req); } gf_dirent_free (&entries); free_entries = _gf_false; } ret = 0; out: if (free_entries) gf_dirent_free (&entries); if (ret < 0) { printf ("Failed to complete gathering info. " "Number of entries so far: %"PRIu64"\n", num_entries); } else { if (heal_op == GF_SHD_OP_INDEX_SUMMARY) printf ("Number of entries: %"PRIu64"\n", num_entries); else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) printf ("Number of entries in split-brain: %"PRIu64"\n" , num_entries); else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) printf ("Number of healed entries: %"PRIu64"\n", num_entries); } return ret; } static int glfsh_print_brick_from_xl (xlator_t *xl) { char *remote_host = NULL; char *remote_subvol = NULL; int ret = 0; ret = dict_get_str (xl->options, "remote-host", &remote_host); if (ret < 0) goto out; ret = dict_get_str (xl->options, "remote-subvolume", &remote_subvol); if (ret < 0) goto out; out: if (ret < 0) printf ("Brick - Not able to get brick information\n"); else printf ("Brick %s:%s\n", remote_host, remote_subvol); return ret; } void glfsh_print_pending_heals (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, xlator_t *xl, gf_xl_afr_op_t heal_op) { int ret = 0; loc_t dirloc = {0}; fd_t *fd = NULL; int32_t op_errno = 0; dict_t *xattr_req = NULL; xattr_req = dict_new(); if (!xattr_req) goto out; ret = dict_set_int32 (xattr_req, "heal-op", heal_op); if (ret) goto out; ret = glfsh_print_brick_from_xl (xl); if (ret < 0) goto out; ret = glfsh_get_index_dir_loc (rootloc, xl, &dirloc, &op_errno); if (ret < 0) { if (op_errno == ESTALE || op_errno == ENOENT) printf ("Number of entries: 0\n"); else printf ("Status: %s\n", strerror (op_errno)); goto out; } ret = syncop_dirfd (xl, &dirloc, &fd, GF_CLIENT_PID_GLFS_HEAL); if (ret) goto out; ret = glfsh_crawl_directory (fs, top_subvol, rootloc, xl, fd, &dirloc, xattr_req); if (fd) fd_unref (fd); if (xattr_req) dict_unref (xattr_req); if (ret < 0) { if (heal_op == GF_SHD_OP_INDEX_SUMMARY) printf ("Failed to find entries with pending" " self-heal\n"); if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) printf ("Failed to find entries in split-brain\n"); } out: loc_wipe (&dirloc); return; } static int glfsh_validate_volume (xlator_t *xl, gf_xl_afr_op_t heal_op) { xlator_t *heal_xl = NULL; int ret = -1; while (xl->next) xl = xl->next; while (xl) { if (strcmp (xl->type, "protocol/client") == 0) { heal_xl = _get_ancestor (xl, heal_op); if (heal_xl) { ret = 0; break; } } xl = xl->prev; } return ret; } static xlator_t* _brick_path_to_client_xlator (xlator_t *top_subvol, char *hostname, char *brickpath) { int ret = 0; xlator_t *xl = NULL; char *remote_host = NULL; char *remote_subvol = NULL; xl = top_subvol; while (xl->next) xl = xl->next; while (xl) { if (!strcmp (xl->type, "protocol/client")) { ret = dict_get_str (xl->options, "remote-host", &remote_host); if (ret < 0) goto out; ret = dict_get_str (xl->options, "remote-subvolume", &remote_subvol); if (ret < 0) goto out; if (!strcmp (hostname, remote_host) && !strcmp (brickpath, remote_subvol)) return xl; } xl = xl->prev; } out: return NULL; } int glfsh_gather_heal_info (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, gf_xl_afr_op_t heal_op) { xlator_t *xl = NULL; xlator_t *heal_xl = NULL; xlator_t *old_THIS = NULL; xl = top_subvol; while (xl->next) xl = xl->next; while (xl) { if (strcmp (xl->type, "protocol/client") == 0) { heal_xl = _get_ancestor (xl, heal_op); if (heal_xl) { old_THIS = THIS; THIS = heal_xl; glfsh_print_pending_heals (fs, top_subvol, rootloc, xl, heal_op); THIS = old_THIS; printf ("\n"); } } xl = xl->prev; } return 0; } int _validate_directory (dict_t *xattr_req, char *file) { int heal_op = -1; int ret = 0; ret = dict_get_int32 (xattr_req, "heal-op", &heal_op); if (ret) return ret; if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE) { printf ("'bigger-file' not a valid option for directories.\n"); ret = -1; } else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) { printf ("'source-brick' option used on a directory (%s). " "Performing conservative merge.\n", file); } return ret; } int glfsh_heal_splitbrain_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, char *file, dict_t *xattr_req) { int ret = -1; int reval = 0; loc_t loc = {0, }; char *path = NULL; char *filename = NULL; struct iatt iatt = {0, }; xlator_t *xl = top_subvol; dict_t *xattr_rsp = NULL; char *sh_fail_msg = NULL; int32_t op_errno = 0; if (!strncmp (file, "gfid:", 5)) { filename = gf_strdup(file); path = strtok (filename, ":"); path = strtok (NULL, ";"); gf_uuid_parse (path, loc.gfid); loc.path = gf_strdup (uuid_utoa (loc.gfid)); loc.inode = inode_new (rootloc->inode->table); ret = syncop_lookup (xl, &loc, &iatt, 0, xattr_req, &xattr_rsp); if (ret) { op_errno = -ret; printf ("Lookup failed on %s:%s.\n", file, strerror(op_errno)); goto out; } } else { if (file[0] != '/') { printf (" must be absolute path w.r.t. the " "volume, starting with '/'\n"); ret = -1; goto out; } retry: ret = glfs_resolve (fs, xl, file, &loc, &iatt, reval); ESTALE_RETRY (ret, errno, reval, &loc, retry); if (ret) { printf("Lookup failed on %s:%s\n", file, strerror (errno)); goto out; } } if (iatt.ia_type == IA_IFDIR) { ret = _validate_directory (xattr_req, file); if (ret) goto out; } ret = syncop_getxattr (xl, &loc, &xattr_rsp, GF_AFR_HEAL_SBRAIN, xattr_req, NULL); if (ret) { op_errno = -ret; printf ("Healing %s failed:%s.\n", file, strerror(op_errno)); goto out; } ret = dict_get_str (xattr_rsp, "sh-fail-msg", &sh_fail_msg); if (!ret) { printf ("Healing %s failed: %s.\n", file, sh_fail_msg); ret = -1; goto out; } printf ("Healed %s.\n", file); ret = 0; out: if (xattr_rsp) dict_unref (xattr_rsp); return ret; } int glfsh_heal_from_brick (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, char *hostname, char *brickpath, char *file) { int ret = -1; dict_t *xattr_req = NULL; xlator_t *client = NULL; fd_t *fd = NULL; loc_t dirloc = {0}; int32_t op_errno = 0; xattr_req = dict_new(); if (!xattr_req) goto out; ret = dict_set_int32 (xattr_req, "heal-op", GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK); if (ret) goto out; client = _brick_path_to_client_xlator (top_subvol, hostname, brickpath); if (!client) { printf("\"%s:%s\"- No such brick available in the volume.\n", hostname, brickpath); ret = -1; goto out; } ret = dict_set_str (xattr_req, "child-name", client->name); if (ret) goto out; if (file) ret = glfsh_heal_splitbrain_file (fs, top_subvol, rootloc, file, xattr_req); else { ret = glfsh_get_index_dir_loc (rootloc, client, &dirloc, &op_errno); ret = syncop_dirfd (client, &dirloc, &fd, GF_CLIENT_PID_GLFS_HEAL); if (ret) goto out; ret = glfsh_crawl_directory (fs, top_subvol, rootloc, client, fd, &dirloc, xattr_req); if (fd) fd_unref (fd); } out: if (xattr_req) dict_unref (xattr_req); loc_wipe (&dirloc); return ret; } int glfsh_heal_from_bigger_file (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, char *file) { int ret = -1; dict_t *xattr_req = NULL; xattr_req = dict_new(); if (!xattr_req) goto out; ret = dict_set_int32 (xattr_req, "heal-op", GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE); if (ret) goto out; ret = glfsh_heal_splitbrain_file (fs, top_subvol, rootloc, file, xattr_req); out: if (xattr_req) dict_unref (xattr_req); return ret; } static void cleanup (glfs_t *fs) { if (!fs) return; #if 0 /* glfs fini path is still racy and crashing the program. Since * this program any way has to die, we are not gonna call fini * in the released versions. i.e. final builds. For all * internal testing lets enable this so that glfs_fini code * path becomes stable. */ glfs_fini (fs); #endif } int main (int argc, char **argv) { glfs_t *fs = NULL; int ret = 0; char *volname = NULL; xlator_t *top_subvol = NULL; loc_t rootloc = {0}; char logfilepath[PATH_MAX] = {0}; char *hostname = NULL; char *path = NULL; char *file = NULL; gf_xl_afr_op_t heal_op = -1; if (argc < 2) { printf (USAGE_STR, argv[0]); ret = -1; goto out; } volname = argv[1]; switch (argc) { case 2: heal_op = GF_SHD_OP_INDEX_SUMMARY; break; case 3: if (!strcmp (argv[2], "split-brain-info")) { heal_op = GF_SHD_OP_SPLIT_BRAIN_FILES; } else { printf (USAGE_STR, argv[0]); ret = -1; goto out; } break; case 4: if (!strcmp (argv[2], "bigger-file")) { heal_op = GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE; file = argv[3]; } else if (!strcmp (argv[2], "source-brick")) { heal_op = GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK; hostname = strtok (argv[3], ":"); path = strtok (NULL, ":"); } else { printf (USAGE_STR, argv[0]); ret = -1; goto out; } break; case 5: if (!strcmp (argv[2], "source-brick")) { heal_op = GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK; hostname = strtok (argv[3], ":"); path = strtok (NULL, ":"); file = argv[4]; } else { printf (USAGE_STR, argv[0]); ret = -1; goto out; } break; default: printf (USAGE_STR, argv[0]); ret = -1; goto out; } fs = glfs_new (volname); if (!fs) { ret = -1; printf ("Not able to initialize volume '%s'\n", volname); goto out; } ret = glfs_set_volfile_server (fs, "tcp", "localhost", 24007); if (ret) { printf("Setting the volfile server failed, %s\n", strerror (errno)); goto out; } snprintf (logfilepath, sizeof (logfilepath), DEFAULT_HEAL_LOG_FILE_DIRECTORY"/glfsheal-%s.log", volname); ret = glfs_set_logging(fs, logfilepath, GF_LOG_INFO); if (ret < 0) { printf ("Failed to set the log file path, %s\n", strerror (errno)); goto out; } ret = glfs_init (fs); if (ret < 0) { ret = -1; if (errno == ENOENT) { printf ("Volume %s does not exist\n", volname); } else { printf ("%s: Not able to fetch volfile from " "glusterd\n", volname); } goto out; } sleep (2); top_subvol = glfs_active_subvol (fs); if (!top_subvol) { ret = -1; if (errno == ENOTCONN) { printf ("Volume %s is not started (Or) All the bricks " "are not running.\n", volname); } else { printf ("%s: Not able to mount the volume, %s\n", volname, strerror (errno)); } goto out; } ret = glfsh_validate_volume (top_subvol, heal_op); if (ret < 0) { printf ("Volume %s is not of type %s\n", volname, (heal_op == GF_SHD_OP_INDEX_SUMMARY) ? "replicate/disperse":"replicate"); goto out; } rootloc.inode = inode_ref (top_subvol->itable->root); glfs_loc_touchup (&rootloc); switch (heal_op) { case GF_SHD_OP_INDEX_SUMMARY: case GF_SHD_OP_SPLIT_BRAIN_FILES: ret = glfsh_gather_heal_info (fs, top_subvol, &rootloc, heal_op); break; case GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE: ret = glfsh_heal_from_bigger_file (fs, top_subvol, &rootloc, file); break; case GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK: ret = glfsh_heal_from_brick (fs, top_subvol, &rootloc, hostname, path, file); break; default: ret = -1; break; } loc_wipe (&rootloc); glfs_subvol_done (fs, top_subvol); cleanup (fs); return ret; out: if (fs && top_subvol) glfs_subvol_done (fs, top_subvol); loc_wipe (&rootloc); cleanup (fs); return ret; } glusterfs-3.7.6/heal/PaxHeaders.7244/Makefile.in0000644000076200007630000000013112617742546017514 xustar000000000000000030 mtime=1447019878.436285002 30 atime=1447019919.628665288 29 ctime=1447019947.60124447 glusterfs-3.7.6/heal/Makefile.in0000644000076200007630000004760512617742546017746 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = heal DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/contrib/aclocal/mkdirp.m4 \ $(top_srcdir)/contrib/aclocal/python.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ACL_LIBS = @ACL_LIBS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LIBTOOLFLAGS = @AM_LIBTOOLFLAGS@ AM_MAKEFLAGS = @AM_MAKEFLAGS@ AR = @AR@ ARGP_STANDALONE_CPPFLAGS = @ARGP_STANDALONE_CPPFLAGS@ ARGP_STANDALONE_DIR = @ARGP_STANDALONE_DIR@ ARGP_STANDALONE_LDADD = @ARGP_STANDALONE_LDADD@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_PYTHON_INC = @BUILD_PYTHON_INC@ BUILD_PYTHON_LIB = @BUILD_PYTHON_LIB@ BUILD_PYTHON_SITE_PACKAGES = @BUILD_PYTHON_SITE_PACKAGES@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONTRIBDIR = @CONTRIBDIR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FUSERMOUNT_SUBDIR = @FUSERMOUNT_SUBDIR@ FUSE_CLIENT_SUBDIR = @FUSE_CLIENT_SUBDIR@ GEOREP_EXTRAS_SUBDIR = @GEOREP_EXTRAS_SUBDIR@ GFAPI_EXTRA_LDFLAGS = @GFAPI_EXTRA_LDFLAGS@ GFAPI_LIBS = @GFAPI_LIBS@ GFAPI_LT_VERSION = @GFAPI_LT_VERSION@ GFAPI_VERSION = @GFAPI_VERSION@ GF_CFLAGS = @GF_CFLAGS@ GF_CPPFLAGS = @GF_CPPFLAGS@ GF_DISTRIBUTION = @GF_DISTRIBUTION@ GF_FUSE_CFLAGS = @GF_FUSE_CFLAGS@ GF_FUSE_LDADD = @GF_FUSE_LDADD@ GF_HOST_OS = @GF_HOST_OS@ GF_LDADD = @GF_LDADD@ GF_LDFLAGS = @GF_LDFLAGS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GLUPY_SUBDIR = @GLUPY_SUBDIR@ GLUPY_SUBDIR_MAKEFILE = @GLUPY_SUBDIR_MAKEFILE@ GLUPY_SUBDIR_SRC_MAKEFILE = @GLUPY_SUBDIR_SRC_MAKEFILE@ GLUSTERD_VOLFILE = @GLUSTERD_VOLFILE@ GLUSTERD_WORKDIR = @GLUSTERD_WORKDIR@ GLUSTERFSD_MISCDIR = @GLUSTERFSD_MISCDIR@ GLUSTERFS_LIBEXECDIR = @GLUSTERFS_LIBEXECDIR@ GREP = @GREP@ HAVE_BACKTRACE = @HAVE_BACKTRACE@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_MALLOC_STATS = @HAVE_MALLOC_STATS@ HAVE_SPINLOCK = @HAVE_SPINLOCK@ HAVE_STRNLEN = @HAVE_STRNLEN@ IBVERBS_SUBDIR = @IBVERBS_SUBDIR@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBAIO = @LIBAIO@ LIBGFCHANGELOG_LT_VERSION = @LIBGFCHANGELOG_LT_VERSION@ LIBGFCHANGELOG_VERSION = @LIBGFCHANGELOG_VERSION@ LIBGFDB_VERSION = @LIBGFDB_VERSION@ LIBGFRPC_LT_VERSION = @LIBGFRPC_LT_VERSION@ LIBGFXDR_LT_VERSION = @LIBGFXDR_LT_VERSION@ LIBGLUSTERFS_LT_VERSION = @LIBGLUSTERFS_LT_VERSION@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCF_SUBDIR = @OCF_SUBDIR@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_RELEASE = @PACKAGE_RELEASE@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_UUID = @PKGCONFIG_UUID@ PKG_CONFIG = @PKG_CONFIG@ PYTHON = @PYTHON@ PYTHONDEV_CFLAGS = @PYTHONDEV_CFLAGS@ PYTHONDEV_CPPFLAGS = @PYTHONDEV_CPPFLAGS@ PYTHONDEV_LDFLAGS = @PYTHONDEV_LDFLAGS@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RDMA_SUBDIR = @RDMA_SUBDIR@ RLLIBS = @RLLIBS@ RPCGEN = @RPCGEN@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIZEOF_INT = @SIZEOF_INT@ SIZEOF_LONG = @SIZEOF_LONG@ SIZEOF_LONG_LONG = @SIZEOF_LONG_LONG@ SIZEOF_SHORT = @SIZEOF_SHORT@ SQLITE_CFLAGS = @SQLITE_CFLAGS@ SQLITE_LIBS = @SQLITE_LIBS@ STRIP = @STRIP@ SYNCDAEMON_COMPILE = @SYNCDAEMON_COMPILE@ SYNCDAEMON_SUBDIR = @SYNCDAEMON_SUBDIR@ UMOUNTD_SUBDIR = @UMOUNTD_SUBDIR@ UNITTEST_CFLAGS = @UNITTEST_CFLAGS@ UNITTEST_LDFLAGS = @UNITTEST_LDFLAGS@ UNITTEST_LIBS = @UNITTEST_LIBS@ URCU_CDS_CFLAGS = @URCU_CDS_CFLAGS@ URCU_CDS_LIBS = @URCU_CDS_LIBS@ URCU_CFLAGS = @URCU_CFLAGS@ URCU_LIBS = @URCU_LIBS@ USE_POSIX_ACLS = @USE_POSIX_ACLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ XML_LIBS = @XML_LIBS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ initdir = @initdir@ install_sh = @install_sh@ launchddir = @launchddir@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ mountutildir = @mountutildir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ shrext_cmds = @shrext_cmds@ srcdir = @srcdir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemddir = @systemddir@ target_alias = @target_alias@ tmpfilesdir = @tmpfilesdir@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src CLEANFILES = all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign heal/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign heal/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ ctags ctags-recursive distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/PaxHeaders.7244/autogen.sh0000644000076200007630000000013112617742532016527 xustar000000000000000030 mtime=1447019866.012471916 30 atime=1447019866.359466695 29 ctime=1447019929.84651157 glusterfs-3.7.6/autogen.sh0000755000076200007630000000370312617742532016753 0ustar00jenkinsjenkins00000000000000#!/bin/sh echo echo ... GlusterFS autogen ... echo ## Check all dependencies are present MISSING="" # Check for aclocal env aclocal --version > /dev/null 2>&1 if [ $? -eq 0 ]; then ACLOCAL=aclocal else MISSING="$MISSING aclocal" fi # Check for autoconf env autoconf --version > /dev/null 2>&1 if [ $? -eq 0 ]; then AUTOCONF=autoconf else MISSING="$MISSING autoconf" fi # Check for autoheader env autoheader --version > /dev/null 2>&1 if [ $? -eq 0 ]; then AUTOHEADER=autoheader else MISSING="$MISSING autoheader" fi # Check for automake env automake --version > /dev/null 2>&1 if [ $? -eq 0 ]; then AUTOMAKE=automake else MISSING="$MISSING automake" fi # Check for libtoolize or glibtoolize env libtoolize --version > /dev/null 2>&1 if [ $? -eq 0 ]; then # libtoolize was found, so use it TOOL=libtoolize else # libtoolize wasn't found, so check for glibtoolize env glibtoolize --version > /dev/null 2>&1 if [ $? -eq 0 ]; then TOOL=glibtoolize else MISSING="$MISSING libtoolize/glibtoolize" fi fi # Check for tar env tar -cf /dev/null /dev/null > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING tar" fi ## If dependencies are missing, warn the user and abort if [ "x$MISSING" != "x" ]; then echo "Aborting." echo echo "The following build tools are missing:" echo for pkg in $MISSING; do echo " * $pkg" done echo echo "Please install them and try again." echo exit 1 fi ## Do the autogeneration echo Running ${ACLOCAL}... $ACLOCAL -I ./contrib/aclocal echo Running ${AUTOHEADER}... $AUTOHEADER echo Running ${TOOL}... $TOOL --automake --copy --force echo Running ${AUTOCONF}... $AUTOCONF echo Running ${AUTOMAKE}... $AUTOMAKE --add-missing --copy --foreign # Run autogen in the argp-standalone sub-directory echo "Running autogen.sh in argp-standalone ..." ( cd contrib/argp-standalone;./autogen.sh ) # Instruct user on next steps echo echo "Please proceed with configuring, compiling, and installing." glusterfs-3.7.6/PaxHeaders.7244/contrib0000644000076200007630000000013112617742653016120 xustar000000000000000030 mtime=1447019947.807241371 29 atime=1447019949.33221843 30 ctime=1447019947.807241371 glusterfs-3.7.6/contrib/0000755000076200007630000000000012617742653016413 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/PaxHeaders.7244/mount0000644000076200007630000000013112617742634017261 xustar000000000000000030 mtime=1447019932.244475495 29 atime=1447019949.33221843 30 ctime=1447019932.244475495 glusterfs-3.7.6/contrib/mount/0000755000076200007630000000000012617742634017554 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/mount/PaxHeaders.7244/mntent.c0000644000076200007630000000013112617742532021004 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019932.244475495 glusterfs-3.7.6/contrib/mount/mntent.c0000644000076200007630000001502012617742532021220 0ustar00jenkinsjenkins00000000000000/* * Copyright (c) 1980, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * Copyright (c) 2001 * David Rufino * Copyright (c) 2014 * Red Hat, Inc. * * 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. */ #if !defined(GF_LINUX_HOST_OS) #include #include #include #include #include #include "mntent_compat.h" #ifdef __NetBSD__ typedef struct statvfs gf_statfs_t; #else typedef struct statfs gf_statfs_t; #endif static int pos = -1; static int mntsize = -1; static struct mntent _mntent; char * hasmntopt (const struct mntent *mnt, const char *option) { int found; char *opt, *optbuf; optbuf = strdup(mnt->mnt_opts); found = 0; for (opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) { if (!strcasecmp(opt, option)) { opt = opt - optbuf + mnt->mnt_opts; free (optbuf); return (opt); } } free (optbuf); return (NULL); } static char * concatopt (char *s0, const char *s1) { size_t i; char *cp; if (s1 == NULL || *s1 == '\0') return s0; if (s0 && *s0) { i = strlen(s0) + strlen(s1) + 1 + 1; if ((cp = (char *)malloc(i)) == NULL) return (NULL); (void)snprintf(cp, i, "%s %s", s0, s1); } else cp = strdup(s1); if (s0) free(s0); return (cp); } static char * flags2opts (int flags) { char *res; res = NULL; res = concatopt(res, (flags & MNT_RDONLY) ? "ro" : "rw"); if (flags & MNT_SYNCHRONOUS) res = concatopt(res, "sync"); if (flags & MNT_NOEXEC) res = concatopt(res, "noexec"); if (flags & MNT_NOSUID) res = concatopt(res, "nosuid"); #if !defined(__FreeBSD__) if (flags & MNT_NODEV) res = concatopt(res, "nodev"); #endif /* __FreeBSD__ */ if (flags & MNT_UNION) res = concatopt(res, "union"); if (flags & MNT_ASYNC) res = concatopt(res, "async"); #if !defined(GF_DARWIN_HOST_OS) if (flags & MNT_NOATIME) res = concatopt(res, "noatime"); #if !defined(__NetBSD__) if (flags & MNT_NOCLUSTERR) res = concatopt(res, "noclusterr"); if (flags & MNT_NOCLUSTERW) res = concatopt(res, "noclusterw"); if (flags & MNT_NOSYMFOLLOW) res = concatopt(res, "nosymfollow"); if (flags & MNT_SUIDDIR) res = concatopt(res, "suiddir"); #endif /* !__NetBSD__ */ #endif /* !GF_DARWIN_HOS_OS */ return res; } static struct mntent * statfs_to_mntent (gf_statfs_t *mntbuf) { static char opts_buf[40], *tmp; int f_flags; _mntent.mnt_fsname = mntbuf->f_mntfromname; _mntent.mnt_dir = mntbuf->f_mntonname; _mntent.mnt_type = mntbuf->f_fstypename; #ifdef __NetBSD__ f_flags = mntbuf->f_flag; #else f_flags = mntbuf->f_flags; #endif tmp = flags2opts (f_flags); if (tmp) { opts_buf[sizeof(opts_buf)-1] = '\0'; strncpy (opts_buf, tmp, sizeof(opts_buf)-1); free (tmp); } else { *opts_buf = '\0'; } _mntent.mnt_opts = opts_buf; _mntent.mnt_freq = _mntent.mnt_passno = 0; return (&_mntent); } struct mntent * getmntent (FILE *fp) { gf_statfs_t *mntbuf; if (!fp) return NULL; if (pos == -1 || mntsize == -1) mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); ++pos; if (pos == mntsize) { pos = mntsize = -1; return (NULL); } return (statfs_to_mntent (&mntbuf[pos])); } /* Careful using this function ``buffer`` and ``bufsize`` are ignored since there is no stream with strings to populate them on OSX or NetBSD, if one wishes to populate them then perhaps a new function should be written in this source file which uses 'getmntinfo()' to stringify the mntent's */ struct mntent *getmntent_r (FILE *fp, struct mntent *result, char *buffer, int bufsize) { struct mntent *ment = NULL; if (!fp) return NULL; flockfile (fp); ment = getmntent (fp); memcpy (result, ment, sizeof(*ment)); funlockfile (fp); return result; } FILE * setmntent (const char *filename, const char *type) { FILE *fp = NULL; #ifdef GF_DARWIN_HOST_OS fp = fopen (filename, "w"); #else fp = fopen (filename, type); #endif return fp; } int endmntent (FILE *fp) { if (fp) fclose (fp); return 1; /* endmntent() always returns 1 */ } #endif /* !GF_LINUX_HOST_OS */ glusterfs-3.7.6/contrib/mount/PaxHeaders.7244/mntent_compat.h0000644000076200007630000000013012617742532022353 xustar000000000000000029 mtime=1447019866.03147163 29 atime=1447019866.36846656 30 ctime=1447019932.046478474 glusterfs-3.7.6/contrib/mount/mntent_compat.h0000644000076200007630000000206112617742532022571 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2014 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #ifndef _MNTENT_H #define _MNTENT_H #if !defined(GF_LINUX_HOST_OS) #include struct mntent { char *mnt_fsname; char *mnt_dir; char *mnt_type; char *mnt_opts; int mnt_freq; int mnt_passno; }; struct mntent *getmntent (FILE *fp); struct mntent *getmntent_r (FILE *fp, struct mntent *result, char *buffer, int bufsize); FILE *setmntent (const char *filename, const char *type); int endmntent(FILE *fp); char * hasmntopt (const struct mntent *mnt, const char *option); /* Dummy - /etc/mtab has no meaning on OSX platform */ #define _PATH_MOUNTED "/etc/mtab" #endif /* GF_DARWIN_HOST_OS || __NetBSD__ */ #endif /* _MNTENT_H */ glusterfs-3.7.6/contrib/PaxHeaders.7244/sunrpc0000644000076200007630000000013112617742635017432 xustar000000000000000030 mtime=1447019933.665454118 29 atime=1447019949.33221843 30 ctime=1447019933.665454118 glusterfs-3.7.6/contrib/sunrpc/0000755000076200007630000000000012617742635017725 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/sunrpc/PaxHeaders.7244/xdr_sizeof.c0000644000076200007630000000013112617742532022023 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019933.666454103 glusterfs-3.7.6/contrib/sunrpc/xdr_sizeof.c0000644000076200007630000001270112617742532022242 0ustar00jenkinsjenkins00000000000000/* * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights * Reserved. This file contains Original Code and/or Modifications of * Original Code as defined in and that are subject to the Apple Public * Source License Version 1.1 (the "License"). You may not use this file * except in compliance with the License. Please obtain a copy of the * License at http://www.apple.com/publicsource and read it before using * this file. * * The Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * xdr_sizeof.c * * Copyright 1990 Sun Microsystems, Inc. * * General purpose routine to see how much space something will use * when serialized using XDR. */ #ifdef GF_DARWIN_HOST_OS #include #include #include #include #include /* ARGSUSED */ #ifdef GF_DARWIN_HOST_OS static bool_t x_putlong (XDR *xdrs, const int *longp) { xdrs->x_handy += BYTES_PER_XDR_UNIT; return TRUE; } #else static bool_t x_putlong (XDR *xdrs, const long *longp) { xdrs->x_handy += BYTES_PER_XDR_UNIT; return TRUE; } #endif /* ARGSUSED */ static bool_t x_putbytes (XDR *xdrs, const char *bp, u_int len) { xdrs->x_handy += len; return TRUE; } #ifdef GF_DARWIN_HOST_OS static u_int x_getpostn (XDR *xdrs) { return xdrs->x_handy; } #else static u_int x_getpostn (const XDR *xdrs) { return xdrs->x_handy; } #endif /* ARGSUSED */ static bool_t x_setpostn (XDR *xdrs, u_int len) { /* This is not allowed */ return FALSE; } static int32_t * x_inline (XDR *xdrs, u_int len) { if (len == 0) return NULL; if (xdrs->x_op != XDR_ENCODE) return NULL; if (len < (u_int) (long int) xdrs->x_base) { /* x_private was already allocated */ xdrs->x_handy += len; return (int32_t *) xdrs->x_private; } else { /* Free the earlier space and allocate new area */ free (xdrs->x_private); if ((xdrs->x_private = (caddr_t) malloc (len)) == NULL) { xdrs->x_base = 0; return NULL; } xdrs->x_base = (void *) (long) len; xdrs->x_handy += len; return (int32_t *) xdrs->x_private; } } static int harmless (void) { /* Always return FALSE/NULL, as the case may be */ return 0; } static void x_destroy (XDR *xdrs) { xdrs->x_handy = 0; xdrs->x_base = 0; if (xdrs->x_private) { free (xdrs->x_private); xdrs->x_private = NULL; } return; } unsigned long xdr_sizeof (xdrproc_t func, void *data) { XDR x; struct xdr_ops ops; bool_t stat; #ifdef GF_DARWIN_HOST_OS typedef bool_t (*dummyfunc1) (XDR *, int *); #else typedef bool_t (*dummyfunc1) (XDR *, long *); #endif typedef bool_t (*dummyfunc2) (XDR *, caddr_t, u_int); ops.x_putlong = x_putlong; ops.x_putbytes = x_putbytes; ops.x_inline = x_inline; ops.x_getpostn = x_getpostn; ops.x_setpostn = x_setpostn; ops.x_destroy = x_destroy; /* the other harmless ones */ ops.x_getlong = (dummyfunc1) harmless; ops.x_getbytes = (dummyfunc2) harmless; x.x_op = XDR_ENCODE; x.x_ops = &ops; x.x_handy = 0; x.x_private = (caddr_t) NULL; x.x_base = (caddr_t) 0; stat = func (&x, data, 0); if (x.x_private) free (x.x_private); return (stat == TRUE ? (unsigned) x.x_handy : 0); } #endif /* GF_DARWIN_HOST_OS */ glusterfs-3.7.6/contrib/PaxHeaders.7244/ipaddr-py0000644000076200007630000000013212617742653020012 xustar000000000000000030 mtime=1447019947.855240648 30 atime=1447019949.333218415 30 ctime=1447019947.855240648 glusterfs-3.7.6/contrib/ipaddr-py/0000755000076200007630000000000012617742653020304 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/ipaddr-py/PaxHeaders.7244/ipaddr.py0000644000076200007630000000013112617742532021677 xustar000000000000000029 mtime=1447019866.02947166 30 atime=1447019866.367466575 30 ctime=1447019947.855240648 glusterfs-3.7.6/contrib/ipaddr-py/ipaddr.py0000644000076200007630000016730212617742532022126 0ustar00jenkinsjenkins00000000000000#!/usr/bin/python # # Copyright 2007 Google Inc. # Licensed to PSF under a Contributor Agreement. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. """A fast, lightweight IPv4/IPv6 manipulation library in Python. This library is used to create/poke/manipulate IPv4 and IPv6 addresses and networks. """ __version__ = 'trunk' import struct IPV4LENGTH = 32 IPV6LENGTH = 128 class AddressValueError(ValueError): """A Value Error related to the address.""" class NetmaskValueError(ValueError): """A Value Error related to the netmask.""" def IPAddress(address, version=None): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. version: An Integer, 4 or 6. If set, don't try to automatically determine what the IP address type is. important for things like IPAddress(1), which could be IPv4, '0.0.0.1', or IPv6, '::1'. Returns: An IPv4Address or IPv6Address object. Raises: ValueError: if the string passed isn't either a v4 or a v6 address. """ if version: if version == 4: return IPv4Address(address) elif version == 6: return IPv6Address(address) try: return IPv4Address(address) except (AddressValueError, NetmaskValueError): pass try: return IPv6Address(address) except (AddressValueError, NetmaskValueError): pass raise ValueError('%r does not appear to be an IPv4 or IPv6 address' % address) def IPNetwork(address, version=None, strict=False): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. version: An Integer, if set, don't try to automatically determine what the IP address type is. important for things like IPNetwork(1), which could be IPv4, '0.0.0.1/32', or IPv6, '::1/128'. Returns: An IPv4Network or IPv6Network object. Raises: ValueError: if the string passed isn't either a v4 or a v6 address. Or if a strict network was requested and a strict network wasn't given. """ if version: if version == 4: return IPv4Network(address, strict) elif version == 6: return IPv6Network(address, strict) try: return IPv4Network(address, strict) except (AddressValueError, NetmaskValueError): pass try: return IPv6Network(address, strict) except (AddressValueError, NetmaskValueError): pass raise ValueError('%r does not appear to be an IPv4 or IPv6 network' % address) def v4_int_to_packed(address): """The binary representation of this address. Args: address: An integer representation of an IPv4 IP address. Returns: The binary representation of this address. Raises: ValueError: If the integer is too large to be an IPv4 IP address. """ if address > _BaseV4._ALL_ONES: raise ValueError('Address too large for IPv4') return struct.pack('!I', address) def v6_int_to_packed(address): """The binary representation of this address. Args: address: An integer representation of an IPv4 IP address. Returns: The binary representation of this address. """ return struct.pack('!QQ', address >> 64, address & (2**64 - 1)) def _find_address_range(addresses): """Find a sequence of addresses. Args: addresses: a list of IPv4 or IPv6 addresses. Returns: A tuple containing the first and last IP addresses in the sequence. """ first = last = addresses[0] for ip in addresses[1:]: if ip._ip == last._ip + 1: last = ip else: break return (first, last) def _get_prefix_length(number1, number2, bits): """Get the number of leading bits that are same for two numbers. Args: number1: an integer. number2: another integer. bits: the maximum number of bits to compare. Returns: The number of leading bits that are the same for two numbers. """ for i in range(bits): if number1 >> i == number2 >> i: return bits - i return 0 def _count_righthand_zero_bits(number, bits): """Count the number of zero bits on the right hand side. Args: number: an integer. bits: maximum number of bits to count. Returns: The number of zero bits on the right hand side of the number. """ if number == 0: return bits for i in range(bits): if (number >> i) % 2: return i def summarize_address_range(first, last): """Summarize a network range given the first and last IP addresses. Example: >>> summarize_address_range(IPv4Address('1.1.1.0'), IPv4Address('1.1.1.130')) [IPv4Network('1.1.1.0/25'), IPv4Network('1.1.1.128/31'), IPv4Network('1.1.1.130/32')] Args: first: the first IPv4Address or IPv6Address in the range. last: the last IPv4Address or IPv6Address in the range. Returns: The address range collapsed to a list of IPv4Network's or IPv6Network's. Raise: TypeError: If the first and last objects are not IP addresses. If the first and last objects are not the same version. ValueError: If the last object is not greater than the first. If the version is not 4 or 6. """ if not (isinstance(first, _BaseIP) and isinstance(last, _BaseIP)): raise TypeError('first and last must be IP addresses, not networks') if first.version != last.version: raise TypeError("%s and %s are not of the same version" % ( str(first), str(last))) if first > last: raise ValueError('last IP address must be greater than first') networks = [] if first.version == 4: ip = IPv4Network elif first.version == 6: ip = IPv6Network else: raise ValueError('unknown IP version') ip_bits = first._max_prefixlen first_int = first._ip last_int = last._ip while first_int <= last_int: nbits = _count_righthand_zero_bits(first_int, ip_bits) current = None while nbits >= 0: addend = 2**nbits - 1 current = first_int + addend nbits -= 1 if current <= last_int: break prefix = _get_prefix_length(first_int, current, ip_bits) net = ip('%s/%d' % (str(first), prefix)) networks.append(net) if current == ip._ALL_ONES: break first_int = current + 1 first = IPAddress(first_int, version=first._version) return networks def _collapse_address_list_recursive(addresses): """Loops through the addresses, collapsing concurrent netblocks. Example: ip1 = IPv4Network('1.1.0.0/24') ip2 = IPv4Network('1.1.1.0/24') ip3 = IPv4Network('1.1.2.0/24') ip4 = IPv4Network('1.1.3.0/24') ip5 = IPv4Network('1.1.4.0/24') ip6 = IPv4Network('1.1.0.1/22') _collapse_address_list_recursive([ip1, ip2, ip3, ip4, ip5, ip6]) -> [IPv4Network('1.1.0.0/22'), IPv4Network('1.1.4.0/24')] This shouldn't be called directly; it is called via collapse_address_list([]). Args: addresses: A list of IPv4Network's or IPv6Network's Returns: A list of IPv4Network's or IPv6Network's depending on what we were passed. """ ret_array = [] optimized = False for cur_addr in addresses: if not ret_array: ret_array.append(cur_addr) continue if cur_addr in ret_array[-1]: optimized = True elif cur_addr == ret_array[-1].supernet().subnet()[1]: ret_array.append(ret_array.pop().supernet()) optimized = True else: ret_array.append(cur_addr) if optimized: return _collapse_address_list_recursive(ret_array) return ret_array def collapse_address_list(addresses): """Collapse a list of IP objects. Example: collapse_address_list([IPv4('1.1.0.0/24'), IPv4('1.1.1.0/24')]) -> [IPv4('1.1.0.0/23')] Args: addresses: A list of IPv4Network or IPv6Network objects. Returns: A list of IPv4Network or IPv6Network objects depending on what we were passed. Raises: TypeError: If passed a list of mixed version objects. """ i = 0 addrs = [] ips = [] nets = [] # split IP addresses and networks for ip in addresses: if isinstance(ip, _BaseIP): if ips and ips[-1]._version != ip._version: raise TypeError("%s and %s are not of the same version" % ( str(ip), str(ips[-1]))) ips.append(ip) elif ip._prefixlen == ip._max_prefixlen: if ips and ips[-1]._version != ip._version: raise TypeError("%s and %s are not of the same version" % ( str(ip), str(ips[-1]))) ips.append(ip.ip) else: if nets and nets[-1]._version != ip._version: raise TypeError("%s and %s are not of the same version" % ( str(ip), str(ips[-1]))) nets.append(ip) # sort and dedup ips = sorted(set(ips)) nets = sorted(set(nets)) while i < len(ips): (first, last) = _find_address_range(ips[i:]) i = ips.index(last) + 1 addrs.extend(summarize_address_range(first, last)) return _collapse_address_list_recursive(sorted( addrs + nets, key=_BaseNet._get_networks_key)) # backwards compatibility CollapseAddrList = collapse_address_list # Test whether this Python implementation supports byte objects that # are not identical to str ones. # We need to exclude platforms where bytes == str so that we can # distinguish between packed representations and strings, for example # b'12::' (the IPv4 address 49.50.58.58) and '12::' (an IPv6 address). try: _compat_has_real_bytes = bytes is not str except NameError: # other._ip return False # Shorthand for Integer addition and subtraction. This is not # meant to ever support addition/subtraction of addresses. def __add__(self, other): if not isinstance(other, int): return NotImplemented return IPAddress(int(self) + other, version=self._version) def __sub__(self, other): if not isinstance(other, int): return NotImplemented return IPAddress(int(self) - other, version=self._version) def __repr__(self): return '%s(%r)' % (self.__class__.__name__, str(self)) def __str__(self): return '%s' % self._string_from_ip_int(self._ip) def __hash__(self): return hash(hex(long(self._ip))) def _get_address_key(self): return (self._version, self) @property def version(self): raise NotImplementedError('BaseIP has no version') class _BaseNet(_IPAddrBase): """A generic IP object. This IP class contains the version independent methods which are used by networks. """ def __init__(self, address): self._cache = {} def __repr__(self): return '%s(%r)' % (self.__class__.__name__, str(self)) def iterhosts(self): """Generate Iterator over usable hosts in a network. This is like __iter__ except it doesn't return the network or broadcast addresses. """ cur = int(self.network) + 1 bcast = int(self.broadcast) - 1 while cur <= bcast: cur += 1 yield IPAddress(cur - 1, version=self._version) def __iter__(self): cur = int(self.network) bcast = int(self.broadcast) while cur <= bcast: cur += 1 yield IPAddress(cur - 1, version=self._version) def __getitem__(self, n): network = int(self.network) broadcast = int(self.broadcast) if n >= 0: if network + n > broadcast: raise IndexError return IPAddress(network + n, version=self._version) else: n += 1 if broadcast + n < network: raise IndexError return IPAddress(broadcast + n, version=self._version) def __lt__(self, other): if self._version != other._version: raise TypeError('%s and %s are not of the same version' % ( str(self), str(other))) if not isinstance(other, _BaseNet): raise TypeError('%s and %s are not of the same type' % ( str(self), str(other))) if self.network != other.network: return self.network < other.network if self.netmask != other.netmask: return self.netmask < other.netmask return False def __gt__(self, other): if self._version != other._version: raise TypeError('%s and %s are not of the same version' % ( str(self), str(other))) if not isinstance(other, _BaseNet): raise TypeError('%s and %s are not of the same type' % ( str(self), str(other))) if self.network != other.network: return self.network > other.network if self.netmask != other.netmask: return self.netmask > other.netmask return False def __le__(self, other): gt = self.__gt__(other) if gt is NotImplemented: return NotImplemented return not gt def __ge__(self, other): lt = self.__lt__(other) if lt is NotImplemented: return NotImplemented return not lt def __eq__(self, other): try: return (self._version == other._version and self.network == other.network and int(self.netmask) == int(other.netmask)) except AttributeError: if isinstance(other, _BaseIP): return (self._version == other._version and self._ip == other._ip) def __ne__(self, other): eq = self.__eq__(other) if eq is NotImplemented: return NotImplemented return not eq def __str__(self): return '%s/%s' % (str(self.ip), str(self._prefixlen)) def __hash__(self): return hash(int(self.network) ^ int(self.netmask)) def __contains__(self, other): # always false if one is v4 and the other is v6. if self._version != other._version: return False # dealing with another network. if isinstance(other, _BaseNet): return (self.network <= other.network and self.broadcast >= other.broadcast) # dealing with another address else: return (int(self.network) <= int(other._ip) <= int(self.broadcast)) def overlaps(self, other): """Tell if self is partly contained in other.""" return self.network in other or self.broadcast in other or ( other.network in self or other.broadcast in self) @property def network(self): x = self._cache.get('network') if x is None: x = IPAddress(self._ip & int(self.netmask), version=self._version) self._cache['network'] = x return x @property def broadcast(self): x = self._cache.get('broadcast') if x is None: x = IPAddress(self._ip | int(self.hostmask), version=self._version) self._cache['broadcast'] = x return x @property def hostmask(self): x = self._cache.get('hostmask') if x is None: x = IPAddress(int(self.netmask) ^ self._ALL_ONES, version=self._version) self._cache['hostmask'] = x return x @property def with_prefixlen(self): return '%s/%d' % (str(self.ip), self._prefixlen) @property def with_netmask(self): return '%s/%s' % (str(self.ip), str(self.netmask)) @property def with_hostmask(self): return '%s/%s' % (str(self.ip), str(self.hostmask)) @property def numhosts(self): """Number of hosts in the current subnet.""" return int(self.broadcast) - int(self.network) + 1 @property def version(self): raise NotImplementedError('BaseNet has no version') @property def prefixlen(self): return self._prefixlen def address_exclude(self, other): """Remove an address from a larger block. For example: addr1 = IPNetwork('10.1.1.0/24') addr2 = IPNetwork('10.1.1.0/26') addr1.address_exclude(addr2) = [IPNetwork('10.1.1.64/26'), IPNetwork('10.1.1.128/25')] or IPv6: addr1 = IPNetwork('::1/32') addr2 = IPNetwork('::1/128') addr1.address_exclude(addr2) = [IPNetwork('::0/128'), IPNetwork('::2/127'), IPNetwork('::4/126'), IPNetwork('::8/125'), ... IPNetwork('0:0:8000::/33')] Args: other: An IPvXNetwork object of the same type. Returns: A sorted list of IPvXNetwork objects addresses which is self minus other. Raises: TypeError: If self and other are of difffering address versions, or if other is not a network object. ValueError: If other is not completely contained by self. """ if not self._version == other._version: raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if not isinstance(other, _BaseNet): raise TypeError("%s is not a network object" % str(other)) if other not in self: raise ValueError('%s not contained in %s' % (str(other), str(self))) if other == self: return [] ret_addrs = [] # Make sure we're comparing the network of other. other = IPNetwork('%s/%s' % (str(other.network), str(other.prefixlen)), version=other._version) s1, s2 = self.subnet() while s1 != other and s2 != other: if other in s1: ret_addrs.append(s2) s1, s2 = s1.subnet() elif other in s2: ret_addrs.append(s1) s1, s2 = s2.subnet() else: # If we got here, there's a bug somewhere. assert True == False, ('Error performing exclusion: ' 's1: %s s2: %s other: %s' % (str(s1), str(s2), str(other))) if s1 == other: ret_addrs.append(s2) elif s2 == other: ret_addrs.append(s1) else: # If we got here, there's a bug somewhere. assert True == False, ('Error performing exclusion: ' 's1: %s s2: %s other: %s' % (str(s1), str(s2), str(other))) return sorted(ret_addrs, key=_BaseNet._get_networks_key) def compare_networks(self, other): """Compare two IP objects. This is only concerned about the comparison of the integer representation of the network addresses. This means that the host bits aren't considered at all in this method. If you want to compare host bits, you can easily enough do a 'HostA._ip < HostB._ip' Args: other: An IP object. Returns: If the IP versions of self and other are the same, returns: -1 if self < other: eg: IPv4('1.1.1.0/24') < IPv4('1.1.2.0/24') IPv6('1080::200C:417A') < IPv6('1080::200B:417B') 0 if self == other eg: IPv4('1.1.1.1/24') == IPv4('1.1.1.2/24') IPv6('1080::200C:417A/96') == IPv6('1080::200C:417B/96') 1 if self > other eg: IPv4('1.1.1.0/24') > IPv4('1.1.0.0/24') IPv6('1080::1:200C:417A/112') > IPv6('1080::0:200C:417A/112') If the IP versions of self and other are different, returns: -1 if self._version < other._version eg: IPv4('10.0.0.1/24') < IPv6('::1/128') 1 if self._version > other._version eg: IPv6('::1/128') > IPv4('255.255.255.0/24') """ if self._version < other._version: return -1 if self._version > other._version: return 1 # self._version == other._version below here: if self.network < other.network: return -1 if self.network > other.network: return 1 # self.network == other.network below here: if self.netmask < other.netmask: return -1 if self.netmask > other.netmask: return 1 # self.network == other.network and self.netmask == other.netmask return 0 def _get_networks_key(self): """Network-only key function. Returns an object that identifies this address' network and netmask. This function is a suitable "key" argument for sorted() and list.sort(). """ return (self._version, self.network, self.netmask) def _ip_int_from_prefix(self, prefixlen=None): """Turn the prefix length netmask into a int for comparison. Args: prefixlen: An integer, the prefix length. Returns: An integer. """ if not prefixlen and prefixlen != 0: prefixlen = self._prefixlen return self._ALL_ONES ^ (self._ALL_ONES >> prefixlen) def _prefix_from_ip_int(self, ip_int, mask=32): """Return prefix length from the decimal netmask. Args: ip_int: An integer, the IP address. mask: The netmask. Defaults to 32. Returns: An integer, the prefix length. """ while mask: if ip_int & 1 == 1: break ip_int >>= 1 mask -= 1 return mask def _ip_string_from_prefix(self, prefixlen=None): """Turn a prefix length into a dotted decimal string. Args: prefixlen: An integer, the netmask prefix length. Returns: A string, the dotted decimal netmask string. """ if not prefixlen: prefixlen = self._prefixlen return self._string_from_ip_int(self._ip_int_from_prefix(prefixlen)) def iter_subnets(self, prefixlen_diff=1, new_prefix=None): """The subnets which join to make the current subnet. In the case that self contains only one IP (self._prefixlen == 32 for IPv4 or self._prefixlen == 128 for IPv6), return a list with just ourself. Args: prefixlen_diff: An integer, the amount the prefix length should be increased by. This should not be set if new_prefix is also set. new_prefix: The desired new prefix length. This must be a larger number (smaller prefix) than the existing prefix. This should not be set if prefixlen_diff is also set. Returns: An iterator of IPv(4|6) objects. Raises: ValueError: The prefixlen_diff is too small or too large. OR prefixlen_diff and new_prefix are both set or new_prefix is a smaller number than the current prefix (smaller number means a larger network) """ if self._prefixlen == self._max_prefixlen: yield self return if new_prefix is not None: if new_prefix < self._prefixlen: raise ValueError('new prefix must be longer') if prefixlen_diff != 1: raise ValueError('cannot set prefixlen_diff and new_prefix') prefixlen_diff = new_prefix - self._prefixlen if prefixlen_diff < 0: raise ValueError('prefix length diff must be > 0') new_prefixlen = self._prefixlen + prefixlen_diff if not self._is_valid_netmask(str(new_prefixlen)): raise ValueError( 'prefix length diff %d is invalid for netblock %s' % ( new_prefixlen, str(self))) first = IPNetwork('%s/%s' % (str(self.network), str(self._prefixlen + prefixlen_diff)), version=self._version) yield first current = first while True: broadcast = current.broadcast if broadcast == self.broadcast: return new_addr = IPAddress(int(broadcast) + 1, version=self._version) current = IPNetwork('%s/%s' % (str(new_addr), str(new_prefixlen)), version=self._version) yield current def masked(self): """Return the network object with the host bits masked out.""" return IPNetwork('%s/%d' % (self.network, self._prefixlen), version=self._version) def subnet(self, prefixlen_diff=1, new_prefix=None): """Return a list of subnets, rather than an iterator.""" return list(self.iter_subnets(prefixlen_diff, new_prefix)) def supernet(self, prefixlen_diff=1, new_prefix=None): """The supernet containing the current network. Args: prefixlen_diff: An integer, the amount the prefix length of the network should be decreased by. For example, given a /24 network and a prefixlen_diff of 3, a supernet with a /21 netmask is returned. Returns: An IPv4 network object. Raises: ValueError: If self.prefixlen - prefixlen_diff < 0. I.e., you have a negative prefix length. OR If prefixlen_diff and new_prefix are both set or new_prefix is a larger number than the current prefix (larger number means a smaller network) """ if self._prefixlen == 0: return self if new_prefix is not None: if new_prefix > self._prefixlen: raise ValueError('new prefix must be shorter') if prefixlen_diff != 1: raise ValueError('cannot set prefixlen_diff and new_prefix') prefixlen_diff = self._prefixlen - new_prefix if self.prefixlen - prefixlen_diff < 0: raise ValueError( 'current prefixlen is %d, cannot have a prefixlen_diff of %d' % (self.prefixlen, prefixlen_diff)) return IPNetwork('%s/%s' % (str(self.network), str(self.prefixlen - prefixlen_diff)), version=self._version) # backwards compatibility Subnet = subnet Supernet = supernet AddressExclude = address_exclude CompareNetworks = compare_networks Contains = __contains__ class _BaseV4(object): """Base IPv4 object. The following methods are used by IPv4 objects in both single IP addresses and networks. """ # Equivalent to 255.255.255.255 or 32 bits of 1's. _ALL_ONES = (2**IPV4LENGTH) - 1 _DECIMAL_DIGITS = frozenset('0123456789') def __init__(self, address): self._version = 4 self._max_prefixlen = IPV4LENGTH def _explode_shorthand_ip_string(self, ip_str=None): if not ip_str: ip_str = str(self) return ip_str def _ip_int_from_string(self, ip_str): """Turn the given IP string into an integer for comparison. Args: ip_str: A string, the IP ip_str. Returns: The IP ip_str as an integer. Raises: AddressValueError: if ip_str isn't a valid IPv4 Address. """ octets = ip_str.split('.') if len(octets) != 4: raise AddressValueError(ip_str) packed_ip = 0 for oc in octets: try: packed_ip = (packed_ip << 8) | self._parse_octet(oc) except ValueError: raise AddressValueError(ip_str) return packed_ip def _parse_octet(self, octet_str): """Convert a decimal octet into an integer. Args: octet_str: A string, the number to parse. Returns: The octet as an integer. Raises: ValueError: if the octet isn't strictly a decimal from [0..255]. """ # Whitelist the characters, since int() allows a lot of bizarre stuff. if not self._DECIMAL_DIGITS.issuperset(octet_str): raise ValueError octet_int = int(octet_str, 10) # Disallow leading zeroes, because no clear standard exists on # whether these should be interpreted as decimal or octal. if octet_int > 255 or (octet_str[0] == '0' and len(octet_str) > 1): raise ValueError return octet_int def _string_from_ip_int(self, ip_int): """Turns a 32-bit integer into dotted decimal notation. Args: ip_int: An integer, the IP address. Returns: The IP address as a string in dotted decimal notation. """ octets = [] for _ in xrange(4): octets.insert(0, str(ip_int & 0xFF)) ip_int >>= 8 return '.'.join(octets) @property def max_prefixlen(self): return self._max_prefixlen @property def packed(self): """The binary representation of this address.""" return v4_int_to_packed(self._ip) @property def version(self): return self._version @property def is_reserved(self): """Test if the address is otherwise IETF reserved. Returns: A boolean, True if the address is within the reserved IPv4 Network range. """ return self in IPv4Network('240.0.0.0/4') @property def is_private(self): """Test if this address is allocated for private networks. Returns: A boolean, True if the address is reserved per RFC 1918. """ return (self in IPv4Network('10.0.0.0/8') or self in IPv4Network('172.16.0.0/12') or self in IPv4Network('192.168.0.0/16')) @property def is_multicast(self): """Test if the address is reserved for multicast use. Returns: A boolean, True if the address is multicast. See RFC 3171 for details. """ return self in IPv4Network('224.0.0.0/4') @property def is_unspecified(self): """Test if the address is unspecified. Returns: A boolean, True if this is the unspecified address as defined in RFC 5735 3. """ return self in IPv4Network('0.0.0.0') @property def is_loopback(self): """Test if the address is a loopback address. Returns: A boolean, True if the address is a loopback per RFC 3330. """ return self in IPv4Network('127.0.0.0/8') @property def is_link_local(self): """Test if the address is reserved for link-local. Returns: A boolean, True if the address is link-local per RFC 3927. """ return self in IPv4Network('169.254.0.0/16') class IPv4Address(_BaseV4, _BaseIP): """Represent and manipulate single IPv4 Addresses.""" def __init__(self, address): """ Args: address: A string or integer representing the IP '192.168.1.1' Additionally, an integer can be passed, so IPv4Address('192.168.1.1') == IPv4Address(3232235777). or, more generally IPv4Address(int(IPv4Address('192.168.1.1'))) == IPv4Address('192.168.1.1') Raises: AddressValueError: If ipaddr isn't a valid IPv4 address. """ _BaseIP.__init__(self, address) _BaseV4.__init__(self, address) # Efficient constructor from integer. if isinstance(address, (int, long)): self._ip = address if address < 0 or address > self._ALL_ONES: raise AddressValueError(address) return # Constructing from a packed address if _compat_has_real_bytes: if isinstance(address, bytes) and len(address) == 4: self._ip = struct.unpack('!I', address)[0] return # Assume input argument to be string or any object representation # which converts into a formatted IP string. addr_str = str(address) self._ip = self._ip_int_from_string(addr_str) class IPv4Network(_BaseV4, _BaseNet): """This class represents and manipulates 32-bit IPv4 networks. Attributes: [examples for IPv4Network('1.2.3.4/27')] ._ip: 16909060 .ip: IPv4Address('1.2.3.4') .network: IPv4Address('1.2.3.0') .hostmask: IPv4Address('0.0.0.31') .broadcast: IPv4Address('1.2.3.31') .netmask: IPv4Address('255.255.255.224') .prefixlen: 27 """ # the valid octets for host and netmasks. only useful for IPv4. _valid_mask_octets = set((255, 254, 252, 248, 240, 224, 192, 128, 0)) def __init__(self, address, strict=False): """Instantiate a new IPv4 network object. Args: address: A string or integer representing the IP [& network]. '192.168.1.1/24' '192.168.1.1/255.255.255.0' '192.168.1.1/0.0.0.255' are all functionally the same in IPv4. Similarly, '192.168.1.1' '192.168.1.1/255.255.255.255' '192.168.1.1/32' are also functionaly equivalent. That is to say, failing to provide a subnetmask will create an object with a mask of /32. If the mask (portion after the / in the argument) is given in dotted quad form, it is treated as a netmask if it starts with a non-zero field (e.g. /255.0.0.0 == /8) and as a hostmask if it starts with a zero field (e.g. 0.255.255.255 == /8), with the single exception of an all-zero mask which is treated as a netmask == /0. If no mask is given, a default of /32 is used. Additionally, an integer can be passed, so IPv4Network('192.168.1.1') == IPv4Network(3232235777). or, more generally IPv4Network(int(IPv4Network('192.168.1.1'))) == IPv4Network('192.168.1.1') strict: A boolean. If true, ensure that we have been passed A true network address, eg, 192.168.1.0/24 and not an IP address on a network, eg, 192.168.1.1/24. Raises: AddressValueError: If ipaddr isn't a valid IPv4 address. NetmaskValueError: If the netmask isn't valid for an IPv4 address. ValueError: If strict was True and a network address was not supplied. """ _BaseNet.__init__(self, address) _BaseV4.__init__(self, address) # Efficient constructor from integer. if isinstance(address, (int, long)): self._ip = address self.ip = IPv4Address(self._ip) self._prefixlen = self._max_prefixlen self.netmask = IPv4Address(self._ALL_ONES) if address < 0 or address > self._ALL_ONES: raise AddressValueError(address) return # Constructing from a packed address if _compat_has_real_bytes: if isinstance(address, bytes) and len(address) == 4: self._ip = struct.unpack('!I', address)[0] self.ip = IPv4Address(self._ip) self._prefixlen = self._max_prefixlen self.netmask = IPv4Address(self._ALL_ONES) return # Assume input argument to be string or any object representation # which converts into a formatted IP prefix string. addr = str(address).split('/') if len(addr) > 2: raise AddressValueError(address) self._ip = self._ip_int_from_string(addr[0]) self.ip = IPv4Address(self._ip) if len(addr) == 2: mask = addr[1].split('.') if len(mask) == 4: # We have dotted decimal netmask. if self._is_valid_netmask(addr[1]): self.netmask = IPv4Address(self._ip_int_from_string( addr[1])) elif self._is_hostmask(addr[1]): self.netmask = IPv4Address( self._ip_int_from_string(addr[1]) ^ self._ALL_ONES) else: raise NetmaskValueError('%s is not a valid netmask' % addr[1]) self._prefixlen = self._prefix_from_ip_int(int(self.netmask)) else: # We have a netmask in prefix length form. if not self._is_valid_netmask(addr[1]): raise NetmaskValueError(addr[1]) self._prefixlen = int(addr[1]) self.netmask = IPv4Address(self._ip_int_from_prefix( self._prefixlen)) else: self._prefixlen = self._max_prefixlen self.netmask = IPv4Address(self._ip_int_from_prefix( self._prefixlen)) if strict: if self.ip != self.network: raise ValueError('%s has host bits set' % self.ip) def _is_hostmask(self, ip_str): """Test if the IP string is a hostmask (rather than a netmask). Args: ip_str: A string, the potential hostmask. Returns: A boolean, True if the IP string is a hostmask. """ bits = ip_str.split('.') try: parts = [int(x) for x in bits if int(x) in self._valid_mask_octets] except ValueError: return False if len(parts) != len(bits): return False if parts[0] < parts[-1]: return True return False def _is_valid_netmask(self, netmask): """Verify that the netmask is valid. Args: netmask: A string, either a prefix or dotted decimal netmask. Returns: A boolean, True if the prefix represents a valid IPv4 netmask. """ mask = netmask.split('.') if len(mask) == 4: if [x for x in mask if int(x) not in self._valid_mask_octets]: return False if [y for idx, y in enumerate(mask) if idx > 0 and y > mask[idx - 1]]: return False return True try: netmask = int(netmask) except ValueError: return False return 0 <= netmask <= self._max_prefixlen # backwards compatibility IsRFC1918 = lambda self: self.is_private IsMulticast = lambda self: self.is_multicast IsLoopback = lambda self: self.is_loopback IsLinkLocal = lambda self: self.is_link_local class _BaseV6(object): """Base IPv6 object. The following methods are used by IPv6 objects in both single IP addresses and networks. """ _ALL_ONES = (2**IPV6LENGTH) - 1 _HEXTET_COUNT = 8 _HEX_DIGITS = frozenset('0123456789ABCDEFabcdef') def __init__(self, address): self._version = 6 self._max_prefixlen = IPV6LENGTH def _ip_int_from_string(self, ip_str): """Turn an IPv6 ip_str into an integer. Args: ip_str: A string, the IPv6 ip_str. Returns: A long, the IPv6 ip_str. Raises: AddressValueError: if ip_str isn't a valid IPv6 Address. """ parts = ip_str.split(':') # An IPv6 address needs at least 2 colons (3 parts). if len(parts) < 3: raise AddressValueError(ip_str) # If the address has an IPv4-style suffix, convert it to hexadecimal. if '.' in parts[-1]: ipv4_int = IPv4Address(parts.pop())._ip parts.append('%x' % ((ipv4_int >> 16) & 0xFFFF)) parts.append('%x' % (ipv4_int & 0xFFFF)) # An IPv6 address can't have more than 8 colons (9 parts). if len(parts) > self._HEXTET_COUNT + 1: raise AddressValueError(ip_str) # Disregarding the endpoints, find '::' with nothing in between. # This indicates that a run of zeroes has been skipped. try: skip_index, = ( [i for i in xrange(1, len(parts) - 1) if not parts[i]] or [None]) except ValueError: # Can't have more than one '::' raise AddressValueError(ip_str) # parts_hi is the number of parts to copy from above/before the '::' # parts_lo is the number of parts to copy from below/after the '::' if skip_index is not None: # If we found a '::', then check if it also covers the endpoints. parts_hi = skip_index parts_lo = len(parts) - skip_index - 1 if not parts[0]: parts_hi -= 1 if parts_hi: raise AddressValueError(ip_str) # ^: requires ^:: if not parts[-1]: parts_lo -= 1 if parts_lo: raise AddressValueError(ip_str) # :$ requires ::$ parts_skipped = self._HEXTET_COUNT - (parts_hi + parts_lo) if parts_skipped < 1: raise AddressValueError(ip_str) else: # Otherwise, allocate the entire address to parts_hi. The endpoints # could still be empty, but _parse_hextet() will check for that. if len(parts) != self._HEXTET_COUNT: raise AddressValueError(ip_str) parts_hi = len(parts) parts_lo = 0 parts_skipped = 0 try: # Now, parse the hextets into a 128-bit integer. ip_int = 0L for i in xrange(parts_hi): ip_int <<= 16 ip_int |= self._parse_hextet(parts[i]) ip_int <<= 16 * parts_skipped for i in xrange(-parts_lo, 0): ip_int <<= 16 ip_int |= self._parse_hextet(parts[i]) return ip_int except ValueError: raise AddressValueError(ip_str) def _parse_hextet(self, hextet_str): """Convert an IPv6 hextet string into an integer. Args: hextet_str: A string, the number to parse. Returns: The hextet as an integer. Raises: ValueError: if the input isn't strictly a hex number from [0..FFFF]. """ # Whitelist the characters, since int() allows a lot of bizarre stuff. if not self._HEX_DIGITS.issuperset(hextet_str): raise ValueError hextet_int = int(hextet_str, 16) if hextet_int > 0xFFFF: raise ValueError return hextet_int def _compress_hextets(self, hextets): """Compresses a list of hextets. Compresses a list of strings, replacing the longest continuous sequence of "0" in the list with "" and adding empty strings at the beginning or at the end of the string such that subsequently calling ":".join(hextets) will produce the compressed version of the IPv6 address. Args: hextets: A list of strings, the hextets to compress. Returns: A list of strings. """ best_doublecolon_start = -1 best_doublecolon_len = 0 doublecolon_start = -1 doublecolon_len = 0 for index in range(len(hextets)): if hextets[index] == '0': doublecolon_len += 1 if doublecolon_start == -1: # Start of a sequence of zeros. doublecolon_start = index if doublecolon_len > best_doublecolon_len: # This is the longest sequence of zeros so far. best_doublecolon_len = doublecolon_len best_doublecolon_start = doublecolon_start else: doublecolon_len = 0 doublecolon_start = -1 if best_doublecolon_len > 1: best_doublecolon_end = (best_doublecolon_start + best_doublecolon_len) # For zeros at the end of the address. if best_doublecolon_end == len(hextets): hextets += [''] hextets[best_doublecolon_start:best_doublecolon_end] = [''] # For zeros at the beginning of the address. if best_doublecolon_start == 0: hextets = [''] + hextets return hextets def _string_from_ip_int(self, ip_int=None): """Turns a 128-bit integer into hexadecimal notation. Args: ip_int: An integer, the IP address. Returns: A string, the hexadecimal representation of the address. Raises: ValueError: The address is bigger than 128 bits of all ones. """ if not ip_int and ip_int != 0: ip_int = int(self._ip) if ip_int > self._ALL_ONES: raise ValueError('IPv6 address is too large') hex_str = '%032x' % ip_int hextets = [] for x in range(0, 32, 4): hextets.append('%x' % int(hex_str[x:x+4], 16)) hextets = self._compress_hextets(hextets) return ':'.join(hextets) def _explode_shorthand_ip_string(self, ip_str=None): """Expand a shortened IPv6 address. Args: ip_str: A string, the IPv6 address. Returns: A string, the expanded IPv6 address. """ if not ip_str: ip_str = str(self) if isinstance(self, _BaseNet): ip_str = str(self.ip) ip_int = self._ip_int_from_string(ip_str) parts = [] for i in xrange(self._HEXTET_COUNT): parts.append('%04x' % (ip_int & 0xFFFF)) ip_int >>= 16 parts.reverse() return ':'.join(parts) @property def max_prefixlen(self): return self._max_prefixlen @property def packed(self): """The binary representation of this address.""" return v6_int_to_packed(self._ip) @property def version(self): return self._version @property def is_multicast(self): """Test if the address is reserved for multicast use. Returns: A boolean, True if the address is a multicast address. See RFC 2373 2.7 for details. """ return self in IPv6Network('ff00::/8') @property def is_reserved(self): """Test if the address is otherwise IETF reserved. Returns: A boolean, True if the address is within one of the reserved IPv6 Network ranges. """ return (self in IPv6Network('::/8') or self in IPv6Network('100::/8') or self in IPv6Network('200::/7') or self in IPv6Network('400::/6') or self in IPv6Network('800::/5') or self in IPv6Network('1000::/4') or self in IPv6Network('4000::/3') or self in IPv6Network('6000::/3') or self in IPv6Network('8000::/3') or self in IPv6Network('A000::/3') or self in IPv6Network('C000::/3') or self in IPv6Network('E000::/4') or self in IPv6Network('F000::/5') or self in IPv6Network('F800::/6') or self in IPv6Network('FE00::/9')) @property def is_unspecified(self): """Test if the address is unspecified. Returns: A boolean, True if this is the unspecified address as defined in RFC 2373 2.5.2. """ return self._ip == 0 and getattr(self, '_prefixlen', 128) == 128 @property def is_loopback(self): """Test if the address is a loopback address. Returns: A boolean, True if the address is a loopback address as defined in RFC 2373 2.5.3. """ return self._ip == 1 and getattr(self, '_prefixlen', 128) == 128 @property def is_link_local(self): """Test if the address is reserved for link-local. Returns: A boolean, True if the address is reserved per RFC 4291. """ return self in IPv6Network('fe80::/10') @property def is_site_local(self): """Test if the address is reserved for site-local. Note that the site-local address space has been deprecated by RFC 3879. Use is_private to test if this address is in the space of unique local addresses as defined by RFC 4193. Returns: A boolean, True if the address is reserved per RFC 3513 2.5.6. """ return self in IPv6Network('fec0::/10') @property def is_private(self): """Test if this address is allocated for private networks. Returns: A boolean, True if the address is reserved per RFC 4193. """ return self in IPv6Network('fc00::/7') @property def ipv4_mapped(self): """Return the IPv4 mapped address. Returns: If the IPv6 address is a v4 mapped address, return the IPv4 mapped address. Return None otherwise. """ if (self._ip >> 32) != 0xFFFF: return None return IPv4Address(self._ip & 0xFFFFFFFF) @property def teredo(self): """Tuple of embedded teredo IPs. Returns: Tuple of the (server, client) IPs or None if the address doesn't appear to be a teredo address (doesn't start with 2001::/32) """ if (self._ip >> 96) != 0x20010000: return None return (IPv4Address((self._ip >> 64) & 0xFFFFFFFF), IPv4Address(~self._ip & 0xFFFFFFFF)) @property def sixtofour(self): """Return the IPv4 6to4 embedded address. Returns: The IPv4 6to4-embedded address if present or None if the address doesn't appear to contain a 6to4 embedded address. """ if (self._ip >> 112) != 0x2002: return None return IPv4Address((self._ip >> 80) & 0xFFFFFFFF) class IPv6Address(_BaseV6, _BaseIP): """Represent and manipulate single IPv6 Addresses. """ def __init__(self, address): """Instantiate a new IPv6 address object. Args: address: A string or integer representing the IP Additionally, an integer can be passed, so IPv6Address('2001:4860::') == IPv6Address(42541956101370907050197289607612071936L). or, more generally IPv6Address(IPv6Address('2001:4860::')._ip) == IPv6Address('2001:4860::') Raises: AddressValueError: If address isn't a valid IPv6 address. """ _BaseIP.__init__(self, address) _BaseV6.__init__(self, address) # Efficient constructor from integer. if isinstance(address, (int, long)): self._ip = address if address < 0 or address > self._ALL_ONES: raise AddressValueError(address) return # Constructing from a packed address if _compat_has_real_bytes: if isinstance(address, bytes) and len(address) == 16: tmp = struct.unpack('!QQ', address) self._ip = (tmp[0] << 64) | tmp[1] return # Assume input argument to be string or any object representation # which converts into a formatted IP string. addr_str = str(address) if not addr_str: raise AddressValueError('') self._ip = self._ip_int_from_string(addr_str) class IPv6Network(_BaseV6, _BaseNet): """This class represents and manipulates 128-bit IPv6 networks. Attributes: [examples for IPv6('2001:658:22A:CAFE:200::1/64')] .ip: IPv6Address('2001:658:22a:cafe:200::1') .network: IPv6Address('2001:658:22a:cafe::') .hostmask: IPv6Address('::ffff:ffff:ffff:ffff') .broadcast: IPv6Address('2001:658:22a:cafe:ffff:ffff:ffff:ffff') .netmask: IPv6Address('ffff:ffff:ffff:ffff::') .prefixlen: 64 """ def __init__(self, address, strict=False): """Instantiate a new IPv6 Network object. Args: address: A string or integer representing the IPv6 network or the IP and prefix/netmask. '2001:4860::/128' '2001:4860:0000:0000:0000:0000:0000:0000/128' '2001:4860::' are all functionally the same in IPv6. That is to say, failing to provide a subnetmask will create an object with a mask of /128. Additionally, an integer can be passed, so IPv6Network('2001:4860::') == IPv6Network(42541956101370907050197289607612071936L). or, more generally IPv6Network(IPv6Network('2001:4860::')._ip) == IPv6Network('2001:4860::') strict: A boolean. If true, ensure that we have been passed A true network address, eg, 192.168.1.0/24 and not an IP address on a network, eg, 192.168.1.1/24. Raises: AddressValueError: If address isn't a valid IPv6 address. NetmaskValueError: If the netmask isn't valid for an IPv6 address. ValueError: If strict was True and a network address was not supplied. """ _BaseNet.__init__(self, address) _BaseV6.__init__(self, address) # Efficient constructor from integer. if isinstance(address, (int, long)): self._ip = address self.ip = IPv6Address(self._ip) self._prefixlen = self._max_prefixlen self.netmask = IPv6Address(self._ALL_ONES) if address < 0 or address > self._ALL_ONES: raise AddressValueError(address) return # Constructing from a packed address if _compat_has_real_bytes: if isinstance(address, bytes) and len(address) == 16: tmp = struct.unpack('!QQ', address) self._ip = (tmp[0] << 64) | tmp[1] self.ip = IPv6Address(self._ip) self._prefixlen = self._max_prefixlen self.netmask = IPv6Address(self._ALL_ONES) return # Assume input argument to be string or any object representation # which converts into a formatted IP prefix string. addr = str(address).split('/') if len(addr) > 2: raise AddressValueError(address) self._ip = self._ip_int_from_string(addr[0]) self.ip = IPv6Address(self._ip) if len(addr) == 2: if self._is_valid_netmask(addr[1]): self._prefixlen = int(addr[1]) else: raise NetmaskValueError(addr[1]) else: self._prefixlen = self._max_prefixlen self.netmask = IPv6Address(self._ip_int_from_prefix(self._prefixlen)) if strict: if self.ip != self.network: raise ValueError('%s has host bits set' % self.ip) def _is_valid_netmask(self, prefixlen): """Verify that the netmask/prefixlen is valid. Args: prefixlen: A string, the netmask in prefix length format. Returns: A boolean, True if the prefix represents a valid IPv6 netmask. """ try: prefixlen = int(prefixlen) except ValueError: return False return 0 <= prefixlen <= self._max_prefixlen @property def with_netmask(self): return self.with_prefixlen glusterfs-3.7.6/contrib/PaxHeaders.7244/rbtree0000644000076200007630000000013212617742634017403 xustar000000000000000030 mtime=1447019932.160476759 30 atime=1447019949.333218415 30 ctime=1447019932.160476759 glusterfs-3.7.6/contrib/rbtree/0000755000076200007630000000000012617742634017675 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/rbtree/PaxHeaders.7244/rb.c0000644000076200007630000000013112617742532020223 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019932.160476759 glusterfs-3.7.6/contrib/rbtree/rb.c0000644000076200007630000006120312617742532020443 0ustar00jenkinsjenkins00000000000000/* Produced by texiweb from libavl.w. */ /* libavl - library for manipulation of binary trees. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. This code is also covered by the following earlier license notice: 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 #include #include #include #include "rb.h" /* Creates and returns a new table with comparison function |compare| using parameter |param| and memory allocator |allocator|. Returns |NULL| if memory allocation failed. */ struct rb_table * rb_create (rb_comparison_func *compare, void *param, struct libavl_allocator *allocator) { struct rb_table *tree; assert (compare != NULL); if (allocator == NULL) allocator = &rb_allocator_default; tree = allocator->libavl_malloc (allocator, sizeof *tree); if (tree == NULL) return NULL; tree->rb_root = NULL; tree->rb_compare = compare; tree->rb_param = param; tree->rb_alloc = allocator; tree->rb_count = 0; tree->rb_generation = 0; return tree; } /* Search |tree| for an item matching |item|, and return it if found. Otherwise return |NULL|. */ void * rb_find (const struct rb_table *tree, const void *item) { const struct rb_node *p; assert (tree != NULL && item != NULL); for (p = tree->rb_root; p != NULL; ) { int cmp = tree->rb_compare (item, p->rb_data, tree->rb_param); if (cmp < 0) p = p->rb_link[0]; else if (cmp > 0) p = p->rb_link[1]; else /* |cmp == 0| */ return p->rb_data; } return NULL; } /* Inserts |item| into |tree| and returns a pointer to |item|'s address. If a duplicate item is found in the tree, returns a pointer to the duplicate without inserting |item|. Returns |NULL| in case of memory allocation failure. */ void ** rb_probe (struct rb_table *tree, void *item) { struct rb_node *pa[RB_MAX_HEIGHT]; /* Nodes on stack. */ unsigned char da[RB_MAX_HEIGHT]; /* Directions moved from stack nodes. */ int k; /* Stack height. */ struct rb_node *p; /* Traverses tree looking for insertion point. */ struct rb_node *n; /* Newly inserted node. */ assert (tree != NULL && item != NULL); pa[0] = (struct rb_node *) &tree->rb_root; da[0] = 0; k = 1; for (p = tree->rb_root; p != NULL; p = p->rb_link[da[k - 1]]) { int cmp = tree->rb_compare (item, p->rb_data, tree->rb_param); if (cmp == 0) return &p->rb_data; pa[k] = p; da[k++] = cmp > 0; } n = pa[k - 1]->rb_link[da[k - 1]] = tree->rb_alloc->libavl_malloc (tree->rb_alloc, sizeof *n); if (n == NULL) return NULL; n->rb_data = item; n->rb_link[0] = n->rb_link[1] = NULL; n->rb_color = RB_RED; tree->rb_count++; tree->rb_generation++; while (k >= 3 && pa[k - 1]->rb_color == RB_RED) { if (da[k - 2] == 0) { struct rb_node *y = pa[k - 2]->rb_link[1]; if (y != NULL && y->rb_color == RB_RED) { pa[k - 1]->rb_color = y->rb_color = RB_BLACK; pa[k - 2]->rb_color = RB_RED; k -= 2; } else { struct rb_node *x; if (da[k - 1] == 0) y = pa[k - 1]; else { x = pa[k - 1]; y = x->rb_link[1]; x->rb_link[1] = y->rb_link[0]; y->rb_link[0] = x; pa[k - 2]->rb_link[0] = y; } x = pa[k - 2]; x->rb_color = RB_RED; y->rb_color = RB_BLACK; x->rb_link[0] = y->rb_link[1]; y->rb_link[1] = x; pa[k - 3]->rb_link[da[k - 3]] = y; break; } } else { struct rb_node *y = pa[k - 2]->rb_link[0]; if (y != NULL && y->rb_color == RB_RED) { pa[k - 1]->rb_color = y->rb_color = RB_BLACK; pa[k - 2]->rb_color = RB_RED; k -= 2; } else { struct rb_node *x; if (da[k - 1] == 1) y = pa[k - 1]; else { x = pa[k - 1]; y = x->rb_link[0]; x->rb_link[0] = y->rb_link[1]; y->rb_link[1] = x; pa[k - 2]->rb_link[1] = y; } x = pa[k - 2]; x->rb_color = RB_RED; y->rb_color = RB_BLACK; x->rb_link[1] = y->rb_link[0]; y->rb_link[0] = x; pa[k - 3]->rb_link[da[k - 3]] = y; break; } } } tree->rb_root->rb_color = RB_BLACK; return &n->rb_data; } /* Inserts |item| into |table|. Returns |NULL| if |item| was successfully inserted or if a memory allocation error occurred. Otherwise, returns the duplicate item. */ void * rb_insert (struct rb_table *table, void *item) { void **p = rb_probe (table, item); return p == NULL || *p == item ? NULL : *p; } /* Inserts |item| into |table|, replacing any duplicate item. Returns |NULL| if |item| was inserted without replacing a duplicate, or if a memory allocation error occurred. Otherwise, returns the item that was replaced. */ void * rb_replace (struct rb_table *table, void *item) { void **p = rb_probe (table, item); if (p == NULL || *p == item) return NULL; else { void *r = *p; *p = item; return r; } } /* Deletes from |tree| and returns an item matching |item|. Returns a null pointer if no matching item found. */ void * rb_delete (struct rb_table *tree, const void *item) { struct rb_node *pa[RB_MAX_HEIGHT]; /* Nodes on stack. */ unsigned char da[RB_MAX_HEIGHT]; /* Directions moved from stack nodes. */ int k; /* Stack height. */ struct rb_node *p; /* The node to delete, or a node part way to it. */ int cmp; /* Result of comparison between |item| and |p|. */ assert (tree != NULL && item != NULL); k = 0; p = (struct rb_node *) &tree->rb_root; for (cmp = -1; cmp != 0; cmp = tree->rb_compare (item, p->rb_data, tree->rb_param)) { int dir = cmp > 0; pa[k] = p; da[k++] = dir; p = p->rb_link[dir]; if (p == NULL) return NULL; } item = p->rb_data; if (p->rb_link[1] == NULL) pa[k - 1]->rb_link[da[k - 1]] = p->rb_link[0]; else { enum rb_color t; struct rb_node *r = p->rb_link[1]; if (r->rb_link[0] == NULL) { r->rb_link[0] = p->rb_link[0]; t = r->rb_color; r->rb_color = p->rb_color; p->rb_color = t; pa[k - 1]->rb_link[da[k - 1]] = r; da[k] = 1; pa[k++] = r; } else { struct rb_node *s; int j = k++; for (;;) { da[k] = 0; pa[k++] = r; s = r->rb_link[0]; if (s->rb_link[0] == NULL) break; r = s; } da[j] = 1; pa[j] = s; pa[j - 1]->rb_link[da[j - 1]] = s; s->rb_link[0] = p->rb_link[0]; r->rb_link[0] = s->rb_link[1]; s->rb_link[1] = p->rb_link[1]; t = s->rb_color; s->rb_color = p->rb_color; p->rb_color = t; } } if (p->rb_color == RB_BLACK) { for (;;) { struct rb_node *x = pa[k - 1]->rb_link[da[k - 1]]; if (x != NULL && x->rb_color == RB_RED) { x->rb_color = RB_BLACK; break; } if (k < 2) break; if (da[k - 1] == 0) { struct rb_node *w = pa[k - 1]->rb_link[1]; if (w->rb_color == RB_RED) { w->rb_color = RB_BLACK; pa[k - 1]->rb_color = RB_RED; pa[k - 1]->rb_link[1] = w->rb_link[0]; w->rb_link[0] = pa[k - 1]; pa[k - 2]->rb_link[da[k - 2]] = w; pa[k] = pa[k - 1]; da[k] = 0; pa[k - 1] = w; k++; w = pa[k - 1]->rb_link[1]; } if ((w->rb_link[0] == NULL || w->rb_link[0]->rb_color == RB_BLACK) && (w->rb_link[1] == NULL || w->rb_link[1]->rb_color == RB_BLACK)) w->rb_color = RB_RED; else { if (w->rb_link[1] == NULL || w->rb_link[1]->rb_color == RB_BLACK) { struct rb_node *y = w->rb_link[0]; y->rb_color = RB_BLACK; w->rb_color = RB_RED; w->rb_link[0] = y->rb_link[1]; y->rb_link[1] = w; w = pa[k - 1]->rb_link[1] = y; } w->rb_color = pa[k - 1]->rb_color; pa[k - 1]->rb_color = RB_BLACK; w->rb_link[1]->rb_color = RB_BLACK; pa[k - 1]->rb_link[1] = w->rb_link[0]; w->rb_link[0] = pa[k - 1]; pa[k - 2]->rb_link[da[k - 2]] = w; break; } } else { struct rb_node *w = pa[k - 1]->rb_link[0]; if (w->rb_color == RB_RED) { w->rb_color = RB_BLACK; pa[k - 1]->rb_color = RB_RED; pa[k - 1]->rb_link[0] = w->rb_link[1]; w->rb_link[1] = pa[k - 1]; pa[k - 2]->rb_link[da[k - 2]] = w; pa[k] = pa[k - 1]; da[k] = 1; pa[k - 1] = w; k++; w = pa[k - 1]->rb_link[0]; } if ((w->rb_link[0] == NULL || w->rb_link[0]->rb_color == RB_BLACK) && (w->rb_link[1] == NULL || w->rb_link[1]->rb_color == RB_BLACK)) w->rb_color = RB_RED; else { if (w->rb_link[0] == NULL || w->rb_link[0]->rb_color == RB_BLACK) { struct rb_node *y = w->rb_link[1]; y->rb_color = RB_BLACK; w->rb_color = RB_RED; w->rb_link[1] = y->rb_link[0]; y->rb_link[0] = w; w = pa[k - 1]->rb_link[0] = y; } w->rb_color = pa[k - 1]->rb_color; pa[k - 1]->rb_color = RB_BLACK; w->rb_link[0]->rb_color = RB_BLACK; pa[k - 1]->rb_link[0] = w->rb_link[1]; w->rb_link[1] = pa[k - 1]; pa[k - 2]->rb_link[da[k - 2]] = w; break; } } k--; } } tree->rb_alloc->libavl_free (tree->rb_alloc, p); tree->rb_count--; tree->rb_generation++; return (void *) item; } /* Refreshes the stack of parent pointers in |trav| and updates its generation number. */ static void trav_refresh (struct rb_traverser *trav) { assert (trav != NULL); trav->rb_generation = trav->rb_table->rb_generation; if (trav->rb_node != NULL) { rb_comparison_func *cmp = trav->rb_table->rb_compare; void *param = trav->rb_table->rb_param; struct rb_node *node = trav->rb_node; struct rb_node *i; trav->rb_height = 0; for (i = trav->rb_table->rb_root; i != node; ) { assert (trav->rb_height < RB_MAX_HEIGHT); assert (i != NULL); trav->rb_stack[trav->rb_height++] = i; i = i->rb_link[cmp (node->rb_data, i->rb_data, param) > 0]; } } } /* Initializes |trav| for use with |tree| and selects the null node. */ void rb_t_init (struct rb_traverser *trav, struct rb_table *tree) { trav->rb_table = tree; trav->rb_node = NULL; trav->rb_height = 0; trav->rb_generation = tree->rb_generation; } /* Initializes |trav| for |tree| and selects and returns a pointer to its least-valued item. Returns |NULL| if |tree| contains no nodes. */ void * rb_t_first (struct rb_traverser *trav, struct rb_table *tree) { struct rb_node *x; assert (tree != NULL && trav != NULL); trav->rb_table = tree; trav->rb_height = 0; trav->rb_generation = tree->rb_generation; x = tree->rb_root; if (x != NULL) while (x->rb_link[0] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[0]; } trav->rb_node = x; return x != NULL ? x->rb_data : NULL; } /* Initializes |trav| for |tree| and selects and returns a pointer to its greatest-valued item. Returns |NULL| if |tree| contains no nodes. */ void * rb_t_last (struct rb_traverser *trav, struct rb_table *tree) { struct rb_node *x; assert (tree != NULL && trav != NULL); trav->rb_table = tree; trav->rb_height = 0; trav->rb_generation = tree->rb_generation; x = tree->rb_root; if (x != NULL) while (x->rb_link[1] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[1]; } trav->rb_node = x; return x != NULL ? x->rb_data : NULL; } /* Searches for |item| in |tree|. If found, initializes |trav| to the item found and returns the item as well. If there is no matching item, initializes |trav| to the null item and returns |NULL|. */ void * rb_t_find (struct rb_traverser *trav, struct rb_table *tree, void *item) { struct rb_node *p, *q; assert (trav != NULL && tree != NULL && item != NULL); trav->rb_table = tree; trav->rb_height = 0; trav->rb_generation = tree->rb_generation; for (p = tree->rb_root; p != NULL; p = q) { int cmp = tree->rb_compare (item, p->rb_data, tree->rb_param); if (cmp < 0) q = p->rb_link[0]; else if (cmp > 0) q = p->rb_link[1]; else /* |cmp == 0| */ { trav->rb_node = p; return p->rb_data; } assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = p; } trav->rb_height = 0; trav->rb_node = NULL; return NULL; } /* Attempts to insert |item| into |tree|. If |item| is inserted successfully, it is returned and |trav| is initialized to its location. If a duplicate is found, it is returned and |trav| is initialized to its location. No replacement of the item occurs. If a memory allocation failure occurs, |NULL| is returned and |trav| is initialized to the null item. */ void * rb_t_insert (struct rb_traverser *trav, struct rb_table *tree, void *item) { void **p; assert (trav != NULL && tree != NULL && item != NULL); p = rb_probe (tree, item); if (p != NULL) { trav->rb_table = tree; trav->rb_node = ((struct rb_node *) ((char *) p - offsetof (struct rb_node, rb_data))); trav->rb_generation = tree->rb_generation - 1; return *p; } else { rb_t_init (trav, tree); return NULL; } } /* Initializes |trav| to have the same current node as |src|. */ void * rb_t_copy (struct rb_traverser *trav, const struct rb_traverser *src) { assert (trav != NULL && src != NULL); if (trav != src) { trav->rb_table = src->rb_table; trav->rb_node = src->rb_node; trav->rb_generation = src->rb_generation; if (trav->rb_generation == trav->rb_table->rb_generation) { trav->rb_height = src->rb_height; memcpy (trav->rb_stack, (const void *) src->rb_stack, sizeof *trav->rb_stack * trav->rb_height); } } return trav->rb_node != NULL ? trav->rb_node->rb_data : NULL; } /* Returns the next data item in inorder within the tree being traversed with |trav|, or if there are no more data items returns |NULL|. */ void * rb_t_next (struct rb_traverser *trav) { struct rb_node *x; assert (trav != NULL); if (trav->rb_generation != trav->rb_table->rb_generation) trav_refresh (trav); x = trav->rb_node; if (x == NULL) { return rb_t_first (trav, trav->rb_table); } else if (x->rb_link[1] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[1]; while (x->rb_link[0] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[0]; } } else { struct rb_node *y; do { if (trav->rb_height == 0) { trav->rb_node = NULL; return NULL; } y = x; x = trav->rb_stack[--trav->rb_height]; } while (y == x->rb_link[1]); } trav->rb_node = x; return x->rb_data; } /* Returns the previous data item in inorder within the tree being traversed with |trav|, or if there are no more data items returns |NULL|. */ void * rb_t_prev (struct rb_traverser *trav) { struct rb_node *x; assert (trav != NULL); if (trav->rb_generation != trav->rb_table->rb_generation) trav_refresh (trav); x = trav->rb_node; if (x == NULL) { return rb_t_last (trav, trav->rb_table); } else if (x->rb_link[0] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[0]; while (x->rb_link[1] != NULL) { assert (trav->rb_height < RB_MAX_HEIGHT); trav->rb_stack[trav->rb_height++] = x; x = x->rb_link[1]; } } else { struct rb_node *y; do { if (trav->rb_height == 0) { trav->rb_node = NULL; return NULL; } y = x; x = trav->rb_stack[--trav->rb_height]; } while (y == x->rb_link[0]); } trav->rb_node = x; return x->rb_data; } /* Returns |trav|'s current item. */ void * rb_t_cur (struct rb_traverser *trav) { assert (trav != NULL); return trav->rb_node != NULL ? trav->rb_node->rb_data : NULL; } /* Replaces the current item in |trav| by |new| and returns the item replaced. |trav| must not have the null item selected. The new item must not upset the ordering of the tree. */ void * rb_t_replace (struct rb_traverser *trav, void *new) { void *old; assert (trav != NULL && trav->rb_node != NULL && new != NULL); old = trav->rb_node->rb_data; trav->rb_node->rb_data = new; return old; } /* Destroys |new| with |rb_destroy (new, destroy)|, first setting right links of nodes in |stack| within |new| to null pointers to avoid touching uninitialized data. */ static void copy_error_recovery (struct rb_node **stack, int height, struct rb_table *new, rb_item_func *destroy) { assert (stack != NULL && height >= 0 && new != NULL); for (; height > 2; height -= 2) stack[height - 1]->rb_link[1] = NULL; rb_destroy (new, destroy); } /* Copies |org| to a newly created tree, which is returned. If |copy != NULL|, each data item in |org| is first passed to |copy|, and the return values are inserted into the tree, with |NULL| return values taken as indications of failure. On failure, destroys the partially created new tree, applying |destroy|, if non-null, to each item in the new tree so far, and returns |NULL|. If |allocator != NULL|, it is used for allocation in the new tree. Otherwise, the same allocator used for |org| is used. */ struct rb_table * rb_copy (const struct rb_table *org, rb_copy_func *copy, rb_item_func *destroy, struct libavl_allocator *allocator) { struct rb_node *stack[2 * (RB_MAX_HEIGHT + 1)]; int height = 0; struct rb_table *new; const struct rb_node *x; struct rb_node *y; assert (org != NULL); new = rb_create (org->rb_compare, org->rb_param, allocator != NULL ? allocator : org->rb_alloc); if (new == NULL) return NULL; new->rb_count = org->rb_count; if (new->rb_count == 0) return new; x = (const struct rb_node *) &org->rb_root; y = (struct rb_node *) &new->rb_root; for (;;) { while (x->rb_link[0] != NULL) { assert (height < 2 * (RB_MAX_HEIGHT + 1)); y->rb_link[0] = new->rb_alloc->libavl_malloc (new->rb_alloc, sizeof *y->rb_link[0]); if (y->rb_link[0] == NULL) { if (y != (struct rb_node *) &new->rb_root) { y->rb_data = NULL; y->rb_link[1] = NULL; } copy_error_recovery (stack, height, new, destroy); return NULL; } stack[height++] = (struct rb_node *) x; stack[height++] = y; x = x->rb_link[0]; y = y->rb_link[0]; } y->rb_link[0] = NULL; for (;;) { y->rb_color = x->rb_color; if (copy == NULL) y->rb_data = x->rb_data; else { y->rb_data = copy (x->rb_data, org->rb_param); if (y->rb_data == NULL) { y->rb_link[1] = NULL; copy_error_recovery (stack, height, new, destroy); return NULL; } } if (x->rb_link[1] != NULL) { y->rb_link[1] = new->rb_alloc->libavl_malloc (new->rb_alloc, sizeof *y->rb_link[1]); if (y->rb_link[1] == NULL) { copy_error_recovery (stack, height, new, destroy); return NULL; } x = x->rb_link[1]; y = y->rb_link[1]; break; } else y->rb_link[1] = NULL; if (height <= 2) return new; y = stack[--height]; x = stack[--height]; } } } /* Frees storage allocated for |tree|. If |destroy != NULL|, applies it to each data item in inorder. */ void rb_destroy (struct rb_table *tree, rb_item_func *destroy) { struct rb_node *p, *q; assert (tree != NULL); for (p = tree->rb_root; p != NULL; p = q) if (p->rb_link[0] == NULL) { q = p->rb_link[1]; if (destroy != NULL && p->rb_data != NULL) destroy (p->rb_data, tree->rb_param); tree->rb_alloc->libavl_free (tree->rb_alloc, p); } else { q = p->rb_link[0]; p->rb_link[0] = q->rb_link[1]; q->rb_link[1] = p; } tree->rb_alloc->libavl_free (tree->rb_alloc, tree); } /* Allocates |size| bytes of space using |malloc()|. Returns a null pointer if allocation fails. */ void * rb_malloc (struct libavl_allocator *allocator, size_t size) { assert (allocator != NULL && size > 0); return malloc (size); } /* Frees |block|. */ void rb_free (struct libavl_allocator *allocator, void *block) { assert (allocator != NULL && block != NULL); free (block); } /* Default memory allocator that uses |malloc()| and |free()|. */ struct libavl_allocator rb_allocator_default = { rb_malloc, rb_free }; #undef NDEBUG #include /* Asserts that |rb_insert()| succeeds at inserting |item| into |table|. */ void (rb_assert_insert) (struct rb_table *table, void *item) { void **p = rb_probe (table, item); assert (p != NULL && *p == item); } /* Asserts that |rb_delete()| really removes |item| from |table|, and returns the removed item. */ void * (rb_assert_delete) (struct rb_table *table, void *item) { void *p = rb_delete (table, item); assert (p != NULL); return p; } glusterfs-3.7.6/contrib/rbtree/PaxHeaders.7244/rb.h0000644000076200007630000000013112617742532020230 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019931.951479903 glusterfs-3.7.6/contrib/rbtree/rb.h0000644000076200007630000001106612617742532020452 0ustar00jenkinsjenkins00000000000000/* Produced by texiweb from libavl.w. */ /* libavl - library for manipulation of binary trees. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. This code is also covered by the following earlier license notice: 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 RB_H #define RB_H 1 #include /* Function types. */ typedef int rb_comparison_func (const void *rb_a, const void *rb_b, void *rb_param); typedef void rb_item_func (void *rb_item, void *rb_param); typedef void *rb_copy_func (void *rb_item, void *rb_param); #ifndef LIBAVL_ALLOCATOR #define LIBAVL_ALLOCATOR /* Memory allocator. */ struct libavl_allocator { void *(*libavl_malloc) (struct libavl_allocator *, size_t libavl_size); void (*libavl_free) (struct libavl_allocator *, void *libavl_block); }; #endif /* Default memory allocator. */ extern struct libavl_allocator rb_allocator_default; void *rb_malloc (struct libavl_allocator *, size_t); void rb_free (struct libavl_allocator *, void *); /* Maximum RB height. */ #ifndef RB_MAX_HEIGHT #define RB_MAX_HEIGHT 128 #endif /* Tree data structure. */ struct rb_table { struct rb_node *rb_root; /* Tree's root. */ rb_comparison_func *rb_compare; /* Comparison function. */ void *rb_param; /* Extra argument to |rb_compare|. */ struct libavl_allocator *rb_alloc; /* Memory allocator. */ size_t rb_count; /* Number of items in tree. */ unsigned long rb_generation; /* Generation number. */ }; /* Color of a red-black node. */ enum rb_color { RB_BLACK, /* Black. */ RB_RED /* Red. */ }; /* A red-black tree node. */ struct rb_node { struct rb_node *rb_link[2]; /* Subtrees. */ void *rb_data; /* Pointer to data. */ unsigned char rb_color; /* Color. */ }; /* RB traverser structure. */ struct rb_traverser { struct rb_table *rb_table; /* Tree being traversed. */ struct rb_node *rb_node; /* Current node in tree. */ struct rb_node *rb_stack[RB_MAX_HEIGHT]; /* All the nodes above |rb_node|. */ size_t rb_height; /* Number of nodes in |rb_parent|. */ unsigned long rb_generation; /* Generation number. */ }; /* Table functions. */ struct rb_table *rb_create (rb_comparison_func *, void *, struct libavl_allocator *); struct rb_table *rb_copy (const struct rb_table *, rb_copy_func *, rb_item_func *, struct libavl_allocator *); void rb_destroy (struct rb_table *, rb_item_func *); void **rb_probe (struct rb_table *, void *); void *rb_insert (struct rb_table *, void *); void *rb_replace (struct rb_table *, void *); void *rb_delete (struct rb_table *, const void *); void *rb_find (const struct rb_table *, const void *); void rb_assert_insert (struct rb_table *, void *); void *rb_assert_delete (struct rb_table *, void *); #define rb_count(table) ((size_t) (table)->rb_count) /* Table traverser functions. */ void rb_t_init (struct rb_traverser *, struct rb_table *); void *rb_t_first (struct rb_traverser *, struct rb_table *); void *rb_t_last (struct rb_traverser *, struct rb_table *); void *rb_t_find (struct rb_traverser *, struct rb_table *, void *); void *rb_t_insert (struct rb_traverser *, struct rb_table *, void *); void *rb_t_copy (struct rb_traverser *, const struct rb_traverser *); void *rb_t_next (struct rb_traverser *); void *rb_t_prev (struct rb_traverser *); void *rb_t_cur (struct rb_traverser *); void *rb_t_replace (struct rb_traverser *, void *); #endif /* rb.h */ glusterfs-3.7.6/contrib/PaxHeaders.7244/qemu0000644000076200007630000000013212617742645017071 xustar000000000000000030 mtime=1447019941.660333844 30 atime=1447019949.333218415 30 ctime=1447019941.660333844 glusterfs-3.7.6/contrib/qemu/0000755000076200007630000000000012617742645017363 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qemu-coroutine-lock.c0000644000076200007630000000013212617742532023207 xustar000000000000000030 mtime=1447019866.042471464 30 atime=1447019866.373466485 30 ctime=1447019941.647334039 glusterfs-3.7.6/contrib/qemu/qemu-coroutine-lock.c0000644000076200007630000001130012617742532023417 0ustar00jenkinsjenkins00000000000000/* * coroutine queues and locks * * Copyright (c) 2011 Kevin Wolf * * 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. */ #include "qemu-common.h" #include "block/coroutine.h" #include "block/coroutine_int.h" #include "qemu/queue.h" #include "trace.h" void qemu_co_queue_init(CoQueue *queue) { QTAILQ_INIT(&queue->entries); } void coroutine_fn qemu_co_queue_wait(CoQueue *queue) { Coroutine *self = qemu_coroutine_self(); QTAILQ_INSERT_TAIL(&queue->entries, self, co_queue_next); qemu_coroutine_yield(); assert(qemu_in_coroutine()); } void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue) { Coroutine *self = qemu_coroutine_self(); QTAILQ_INSERT_HEAD(&queue->entries, self, co_queue_next); qemu_coroutine_yield(); assert(qemu_in_coroutine()); } /** * qemu_co_queue_run_restart: * * Enter each coroutine that was previously marked for restart by * qemu_co_queue_next() or qemu_co_queue_restart_all(). This function is * invoked by the core coroutine code when the current coroutine yields or * terminates. */ void qemu_co_queue_run_restart(Coroutine *co) { Coroutine *next; trace_qemu_co_queue_run_restart(co); while ((next = QTAILQ_FIRST(&co->co_queue_wakeup))) { QTAILQ_REMOVE(&co->co_queue_wakeup, next, co_queue_next); qemu_coroutine_enter(next, NULL); } } static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) { Coroutine *self = qemu_coroutine_self(); Coroutine *next; if (QTAILQ_EMPTY(&queue->entries)) { return false; } while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) { QTAILQ_REMOVE(&queue->entries, next, co_queue_next); QTAILQ_INSERT_TAIL(&self->co_queue_wakeup, next, co_queue_next); trace_qemu_co_queue_next(next); if (single) { break; } } return true; } bool qemu_co_queue_next(CoQueue *queue) { return qemu_co_queue_do_restart(queue, true); } void qemu_co_queue_restart_all(CoQueue *queue) { qemu_co_queue_do_restart(queue, false); } bool qemu_co_queue_empty(CoQueue *queue) { return (QTAILQ_FIRST(&queue->entries) == NULL); } void qemu_co_mutex_init(CoMutex *mutex) { memset(mutex, 0, sizeof(*mutex)); qemu_co_queue_init(&mutex->queue); } void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex) { Coroutine *self = qemu_coroutine_self(); trace_qemu_co_mutex_lock_entry(mutex, self); while (mutex->locked) { qemu_co_queue_wait(&mutex->queue); } mutex->locked = true; trace_qemu_co_mutex_lock_return(mutex, self); } void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex) { Coroutine *self = qemu_coroutine_self(); trace_qemu_co_mutex_unlock_entry(mutex, self); assert(mutex->locked == true); assert(qemu_in_coroutine()); mutex->locked = false; qemu_co_queue_next(&mutex->queue); trace_qemu_co_mutex_unlock_return(mutex, self); } void qemu_co_rwlock_init(CoRwlock *lock) { memset(lock, 0, sizeof(*lock)); qemu_co_queue_init(&lock->queue); } void qemu_co_rwlock_rdlock(CoRwlock *lock) { while (lock->writer) { qemu_co_queue_wait(&lock->queue); } lock->reader++; } void qemu_co_rwlock_unlock(CoRwlock *lock) { assert(qemu_in_coroutine()); if (lock->writer) { lock->writer = false; qemu_co_queue_restart_all(&lock->queue); } else { lock->reader--; assert(lock->reader >= 0); /* Wakeup only one waiting writer */ if (!lock->reader) { qemu_co_queue_next(&lock->queue); } } } void qemu_co_rwlock_wrlock(CoRwlock *lock) { while (lock->writer || lock->reader) { qemu_co_queue_wait(&lock->queue); } lock->writer = true; } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qmp-commands.h0000644000076200007630000000013012617742532021704 xustar000000000000000030 mtime=1447019866.042471464 29 atime=1447019866.37446647 29 ctime=1447019941.42333741 glusterfs-3.7.6/contrib/qemu/qmp-commands.h0000644000076200007630000003545112617742532022133 0ustar00jenkinsjenkins00000000000000/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ /* * schema-defined QAPI function prototypes * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QMP_COMMANDS_H #define QMP_COMMANDS_H #include "qapi-types.h" #include "qapi/qmp/qdict.h" #include "qapi/error.h" void qmp_add_client(const char * protocol, const char * fdname, bool has_skipauth, bool skipauth, bool has_tls, bool tls, Error **errp); int qmp_marshal_input_add_client(Monitor *mon, const QDict *qdict, QObject **ret); NameInfo * qmp_query_name(Error **errp); int qmp_marshal_input_query_name(Monitor *mon, const QDict *qdict, QObject **ret); VersionInfo * qmp_query_version(Error **errp); int qmp_marshal_input_query_version(Monitor *mon, const QDict *qdict, QObject **ret); KvmInfo * qmp_query_kvm(Error **errp); int qmp_marshal_input_query_kvm(Monitor *mon, const QDict *qdict, QObject **ret); StatusInfo * qmp_query_status(Error **errp); int qmp_marshal_input_query_status(Monitor *mon, const QDict *qdict, QObject **ret); UuidInfo * qmp_query_uuid(Error **errp); int qmp_marshal_input_query_uuid(Monitor *mon, const QDict *qdict, QObject **ret); ChardevInfoList * qmp_query_chardev(Error **errp); int qmp_marshal_input_query_chardev(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_ringbuf_write(const char * device, const char * data, bool has_format, DataFormat format, Error **errp); int qmp_marshal_input_ringbuf_write(Monitor *mon, const QDict *qdict, QObject **ret); char * qmp_ringbuf_read(const char * device, int64_t size, bool has_format, DataFormat format, Error **errp); int qmp_marshal_input_ringbuf_read(Monitor *mon, const QDict *qdict, QObject **ret); CommandInfoList * qmp_query_commands(Error **errp); int qmp_marshal_input_query_commands(Monitor *mon, const QDict *qdict, QObject **ret); EventInfoList * qmp_query_events(Error **errp); int qmp_marshal_input_query_events(Monitor *mon, const QDict *qdict, QObject **ret); MigrationInfo * qmp_query_migrate(Error **errp); int qmp_marshal_input_query_migrate(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate_set_capabilities(MigrationCapabilityStatusList * capabilities, Error **errp); int qmp_marshal_input_migrate_set_capabilities(Monitor *mon, const QDict *qdict, QObject **ret); MigrationCapabilityStatusList * qmp_query_migrate_capabilities(Error **errp); int qmp_marshal_input_query_migrate_capabilities(Monitor *mon, const QDict *qdict, QObject **ret); MouseInfoList * qmp_query_mice(Error **errp); int qmp_marshal_input_query_mice(Monitor *mon, const QDict *qdict, QObject **ret); CpuInfoList * qmp_query_cpus(Error **errp); int qmp_marshal_input_query_cpus(Monitor *mon, const QDict *qdict, QObject **ret); BlockInfoList * qmp_query_block(Error **errp); int qmp_marshal_input_query_block(Monitor *mon, const QDict *qdict, QObject **ret); BlockStatsList * qmp_query_blockstats(Error **errp); int qmp_marshal_input_query_blockstats(Monitor *mon, const QDict *qdict, QObject **ret); VncInfo * qmp_query_vnc(Error **errp); int qmp_marshal_input_query_vnc(Monitor *mon, const QDict *qdict, QObject **ret); SpiceInfo * qmp_query_spice(Error **errp); int qmp_marshal_input_query_spice(Monitor *mon, const QDict *qdict, QObject **ret); BalloonInfo * qmp_query_balloon(Error **errp); int qmp_marshal_input_query_balloon(Monitor *mon, const QDict *qdict, QObject **ret); PciInfoList * qmp_query_pci(Error **errp); int qmp_marshal_input_query_pci(Monitor *mon, const QDict *qdict, QObject **ret); BlockJobInfoList * qmp_query_block_jobs(Error **errp); int qmp_marshal_input_query_block_jobs(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_quit(Error **errp); int qmp_marshal_input_quit(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_stop(Error **errp); int qmp_marshal_input_stop(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_system_reset(Error **errp); int qmp_marshal_input_system_reset(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_system_powerdown(Error **errp); int qmp_marshal_input_system_powerdown(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_cpu(int64_t index, Error **errp); int qmp_marshal_input_cpu(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_cpu_add(int64_t id, Error **errp); int qmp_marshal_input_cpu_add(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_memsave(int64_t val, int64_t size, const char * filename, bool has_cpu_index, int64_t cpu_index, Error **errp); int qmp_marshal_input_memsave(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_pmemsave(int64_t val, int64_t size, const char * filename, Error **errp); int qmp_marshal_input_pmemsave(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_cont(Error **errp); int qmp_marshal_input_cont(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_system_wakeup(Error **errp); int qmp_marshal_input_system_wakeup(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_inject_nmi(Error **errp); int qmp_marshal_input_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_set_link(const char * name, bool up, Error **errp); int qmp_marshal_input_set_link(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_passwd(const char * device, const char * password, Error **errp); int qmp_marshal_input_block_passwd(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_balloon(int64_t value, Error **errp); int qmp_marshal_input_balloon(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_resize(const char * device, int64_t size, Error **errp); int qmp_marshal_input_block_resize(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_transaction(TransactionActionList * actions, Error **errp); int qmp_marshal_input_transaction(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_blockdev_snapshot_sync(const char * device, const char * snapshot_file, bool has_format, const char * format, bool has_mode, NewImageMode mode, Error **errp); int qmp_marshal_input_blockdev_snapshot_sync(Monitor *mon, const QDict *qdict, QObject **ret); char * qmp_human_monitor_command(const char * command_line, bool has_cpu_index, int64_t cpu_index, Error **errp); int qmp_marshal_input_human_monitor_command(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_commit(const char * device, bool has_base, const char * base, const char * top, bool has_speed, int64_t speed, Error **errp); int qmp_marshal_input_block_commit(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_drive_backup(const char * device, const char * target, bool has_format, const char * format, MirrorSyncMode sync, bool has_mode, NewImageMode mode, bool has_speed, int64_t speed, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, Error **errp); int qmp_marshal_input_drive_backup(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_drive_mirror(const char * device, const char * target, bool has_format, const char * format, MirrorSyncMode sync, bool has_mode, NewImageMode mode, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, Error **errp); int qmp_marshal_input_drive_mirror(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate_cancel(Error **errp); int qmp_marshal_input_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate_set_downtime(double value, Error **errp); int qmp_marshal_input_migrate_set_downtime(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate_set_speed(int64_t value, Error **errp); int qmp_marshal_input_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate_set_cache_size(int64_t value, Error **errp); int qmp_marshal_input_migrate_set_cache_size(Monitor *mon, const QDict *qdict, QObject **ret); int64_t qmp_query_migrate_cache_size(Error **errp); int qmp_marshal_input_query_migrate_cache_size(Monitor *mon, const QDict *qdict, QObject **ret); ObjectPropertyInfoList * qmp_qom_list(const char * path, Error **errp); int qmp_marshal_input_qom_list(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_set_password(const char * protocol, const char * password, bool has_connected, const char * connected, Error **errp); int qmp_marshal_input_set_password(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_expire_password(const char * protocol, const char * time, Error **errp); int qmp_marshal_input_expire_password(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_eject(const char * device, bool has_force, bool force, Error **errp); int qmp_marshal_input_eject(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_change_vnc_password(const char * password, Error **errp); int qmp_marshal_input_change_vnc_password(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_change(const char * device, const char * target, bool has_arg, const char * arg, Error **errp); int qmp_marshal_input_change(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_set_io_throttle(const char * device, int64_t bps, int64_t bps_rd, int64_t bps_wr, int64_t iops, int64_t iops_rd, int64_t iops_wr, Error **errp); int qmp_marshal_input_block_set_io_throttle(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_stream(const char * device, bool has_base, const char * base, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, Error **errp); int qmp_marshal_input_block_stream(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_job_set_speed(const char * device, int64_t speed, Error **errp); int qmp_marshal_input_block_job_set_speed(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_job_cancel(const char * device, bool has_force, bool force, Error **errp); int qmp_marshal_input_block_job_cancel(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_job_pause(const char * device, Error **errp); int qmp_marshal_input_block_job_pause(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_job_resume(const char * device, Error **errp); int qmp_marshal_input_block_job_resume(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_block_job_complete(const char * device, Error **errp); int qmp_marshal_input_block_job_complete(Monitor *mon, const QDict *qdict, QObject **ret); ObjectTypeInfoList * qmp_qom_list_types(bool has_implements, const char * implements, bool has_abstract, bool abstract, Error **errp); int qmp_marshal_input_qom_list_types(Monitor *mon, const QDict *qdict, QObject **ret); DevicePropertyInfoList * qmp_device_list_properties(const char * typename, Error **errp); int qmp_marshal_input_device_list_properties(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_migrate(const char * uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, Error **errp); int qmp_marshal_input_migrate(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_xen_save_devices_state(const char * filename, Error **errp); int qmp_marshal_input_xen_save_devices_state(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_xen_set_global_dirty_log(bool enable, Error **errp); int qmp_marshal_input_xen_set_global_dirty_log(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_device_del(const char * id, Error **errp); int qmp_marshal_input_device_del(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_dump_guest_memory(bool paging, const char * protocol, bool has_begin, int64_t begin, bool has_length, int64_t length, Error **errp); int qmp_marshal_input_dump_guest_memory(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_netdev_del(const char * id, Error **errp); int qmp_marshal_input_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_getfd(const char * fdname, Error **errp); int qmp_marshal_input_getfd(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_closefd(const char * fdname, Error **errp); int qmp_marshal_input_closefd(Monitor *mon, const QDict *qdict, QObject **ret); MachineInfoList * qmp_query_machines(Error **errp); int qmp_marshal_input_query_machines(Monitor *mon, const QDict *qdict, QObject **ret); CpuDefinitionInfoList * qmp_query_cpu_definitions(Error **errp); int qmp_marshal_input_query_cpu_definitions(Monitor *mon, const QDict *qdict, QObject **ret); AddfdInfo * qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, const char * opaque, Error **errp); int qmp_marshal_input_add_fd(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **errp); int qmp_marshal_input_remove_fd(Monitor *mon, const QDict *qdict, QObject **ret); FdsetInfoList * qmp_query_fdsets(Error **errp); int qmp_marshal_input_query_fdsets(Monitor *mon, const QDict *qdict, QObject **ret); TargetInfo * qmp_query_target(Error **errp); int qmp_marshal_input_query_target(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_send_key(KeyValueList * keys, bool has_hold_time, int64_t hold_time, Error **errp); int qmp_marshal_input_send_key(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_screendump(const char * filename, Error **errp); int qmp_marshal_input_screendump(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_nbd_server_start(SocketAddress * addr, Error **errp); int qmp_marshal_input_nbd_server_start(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_nbd_server_add(const char * device, bool has_writable, bool writable, Error **errp); int qmp_marshal_input_nbd_server_add(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_nbd_server_stop(Error **errp); int qmp_marshal_input_nbd_server_stop(Monitor *mon, const QDict *qdict, QObject **ret); ChardevReturn * qmp_chardev_add(const char * id, ChardevBackend * backend, Error **errp); int qmp_marshal_input_chardev_add(Monitor *mon, const QDict *qdict, QObject **ret); void qmp_chardev_remove(const char * id, Error **errp); int qmp_marshal_input_chardev_remove(Monitor *mon, const QDict *qdict, QObject **ret); TpmModelList * qmp_query_tpm_models(Error **errp); int qmp_marshal_input_query_tpm_models(Monitor *mon, const QDict *qdict, QObject **ret); TpmTypeList * qmp_query_tpm_types(Error **errp); int qmp_marshal_input_query_tpm_types(Monitor *mon, const QDict *qdict, QObject **ret); TPMInfoList * qmp_query_tpm(Error **errp); int qmp_marshal_input_query_tpm(Monitor *mon, const QDict *qdict, QObject **ret); CommandLineOptionInfoList * qmp_query_command_line_options(bool has_option, const char * option, Error **errp); int qmp_marshal_input_query_command_line_options(Monitor *mon, const QDict *qdict, QObject **ret); RxFilterInfoList * qmp_query_rx_filter(bool has_name, const char * name, Error **errp); int qmp_marshal_input_query_rx_filter(Monitor *mon, const QDict *qdict, QObject **ret); #endif glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qemu-coroutine-sleep.c0000644000076200007630000000013012617742532023365 xustar000000000000000030 mtime=1447019866.042471464 29 atime=1447019866.37446647 29 ctime=1447019941.65133398 glusterfs-3.7.6/contrib/qemu/qemu-coroutine-sleep.c0000644000076200007630000000160212617742532023603 0ustar00jenkinsjenkins00000000000000/* * QEMU coroutine sleep * * Copyright IBM, Corp. 2011 * * Authors: * Stefan Hajnoczi * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "block/coroutine.h" #include "qemu/timer.h" typedef struct CoSleepCB { QEMUTimer *ts; Coroutine *co; } CoSleepCB; static void co_sleep_cb(void *opaque) { CoSleepCB *sleep_cb = opaque; qemu_coroutine_enter(sleep_cb->co, NULL); } void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns) { CoSleepCB sleep_cb = { .co = qemu_coroutine_self(), }; sleep_cb.ts = qemu_new_timer(clock, SCALE_NS, co_sleep_cb, &sleep_cb); qemu_mod_timer(sleep_cb.ts, qemu_get_clock_ns(clock) + ns); qemu_coroutine_yield(); qemu_del_timer(sleep_cb.ts); qemu_free_timer(sleep_cb.ts); } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/include0000644000076200007630000000013212617742645020514 xustar000000000000000030 mtime=1447019941.439337167 30 atime=1447019949.333218415 30 ctime=1447019941.439337167 glusterfs-3.7.6/contrib/qemu/include/0000755000076200007630000000000012617742645021006 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/monitor0000644000076200007630000000013212617742645022203 xustar000000000000000030 mtime=1447019941.491336388 30 atime=1447019949.333218415 30 ctime=1447019941.491336388 glusterfs-3.7.6/contrib/qemu/include/monitor/0000755000076200007630000000000012617742645022475 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/monitor/PaxHeaders.7244/readline.h0000644000076200007630000000013012617742532024205 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.491336388 glusterfs-3.7.6/contrib/qemu/include/monitor/readline.h0000644000076200007630000000302612617742532024425 0ustar00jenkinsjenkins00000000000000#ifndef READLINE_H #define READLINE_H #include "qemu-common.h" #define READLINE_CMD_BUF_SIZE 4095 #define READLINE_MAX_CMDS 64 #define READLINE_MAX_COMPLETIONS 256 typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); typedef void ReadLineCompletionFunc(const char *cmdline); typedef struct ReadLineState { char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; int cmd_buf_index; int cmd_buf_size; char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; int last_cmd_buf_index; int last_cmd_buf_size; int esc_state; int esc_param; char *history[READLINE_MAX_CMDS]; int hist_entry; ReadLineCompletionFunc *completion_finder; char *completions[READLINE_MAX_COMPLETIONS]; int nb_completions; int completion_index; ReadLineFunc *readline_func; void *readline_opaque; int read_password; char prompt[256]; Monitor *mon; } ReadLineState; void readline_add_completion(ReadLineState *rs, const char *str); void readline_set_completion_index(ReadLineState *rs, int completion_index); const char *readline_get_history(ReadLineState *rs, unsigned int index); void readline_handle_byte(ReadLineState *rs, int ch); void readline_start(ReadLineState *rs, const char *prompt, int read_password, ReadLineFunc *readline_func, void *opaque); void readline_restart(ReadLineState *rs); void readline_show_prompt(ReadLineState *rs); ReadLineState *readline_init(Monitor *mon, ReadLineCompletionFunc *completion_finder); #endif /* !READLINE_H */ glusterfs-3.7.6/contrib/qemu/include/monitor/PaxHeaders.7244/monitor.h0000644000076200007630000000012712617742532024117 xustar000000000000000029 mtime=1447019866.03747154 28 atime=1447019866.3724665 30 ctime=1447019941.488336432 glusterfs-3.7.6/contrib/qemu/include/monitor/monitor.h0000644000076200007630000000635712617742532024343 0ustar00jenkinsjenkins00000000000000#ifndef MONITOR_H #define MONITOR_H #include "qemu-common.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qdict.h" #include "block/block.h" #include "monitor/readline.h" extern Monitor *cur_mon; extern Monitor *default_mon; /* flags for monitor_init */ #define MONITOR_IS_DEFAULT 0x01 #define MONITOR_USE_READLINE 0x02 #define MONITOR_USE_CONTROL 0x04 #define MONITOR_USE_PRETTY 0x08 /* flags for monitor commands */ #define MONITOR_CMD_ASYNC 0x0001 /* QMP events */ typedef enum MonitorEvent { QEVENT_SHUTDOWN, QEVENT_RESET, QEVENT_POWERDOWN, QEVENT_STOP, QEVENT_RESUME, QEVENT_VNC_CONNECTED, QEVENT_VNC_INITIALIZED, QEVENT_VNC_DISCONNECTED, QEVENT_BLOCK_IO_ERROR, QEVENT_RTC_CHANGE, QEVENT_WATCHDOG, QEVENT_SPICE_CONNECTED, QEVENT_SPICE_INITIALIZED, QEVENT_SPICE_DISCONNECTED, QEVENT_BLOCK_JOB_COMPLETED, QEVENT_BLOCK_JOB_CANCELLED, QEVENT_BLOCK_JOB_ERROR, QEVENT_BLOCK_JOB_READY, QEVENT_DEVICE_DELETED, QEVENT_DEVICE_TRAY_MOVED, QEVENT_NIC_RX_FILTER_CHANGED, QEVENT_SUSPEND, QEVENT_SUSPEND_DISK, QEVENT_WAKEUP, QEVENT_BALLOON_CHANGE, QEVENT_SPICE_MIGRATE_COMPLETED, QEVENT_GUEST_PANICKED, /* Add to 'monitor_event_names' array in monitor.c when * defining new events here */ QEVENT_MAX, } MonitorEvent; int monitor_cur_is_qmp(void); void monitor_protocol_event(MonitorEvent event, QObject *data); void monitor_init(CharDriverState *chr, int flags); int monitor_suspend(Monitor *mon); void monitor_resume(Monitor *mon); int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, BlockDriverCompletionFunc *completion_cb, void *opaque); int monitor_read_block_device_key(Monitor *mon, const char *device, BlockDriverCompletionFunc *completion_cb, void *opaque); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_handle_fd_param(Monitor *mon, const char *fdname); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_print_filename(Monitor *mon, const char *filename); void monitor_flush(Monitor *mon); int monitor_set_cpu(int cpu_index); int monitor_get_cpu_index(void); typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); void monitor_set_error(Monitor *mon, QError *qerror); void monitor_read_command(Monitor *mon, int show_prompt); ReadLineState *monitor_get_rs(Monitor *mon); int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, void *opaque); int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, bool has_opaque, const char *opaque, Error **errp); int monitor_fdset_get_fd(int64_t fdset_id, int flags); int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); int monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); #endif /* !MONITOR_H */ glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/config.h0000644000076200007630000000013212617742532022202 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.430337304 glusterfs-3.7.6/contrib/qemu/include/config.h0000644000076200007630000000006412617742532022417 0ustar00jenkinsjenkins00000000000000#include "config-host.h" #include "config-target.h" glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/qapi0000644000076200007630000000013212617742645021446 xustar000000000000000030 mtime=1447019941.494336341 30 atime=1447019949.333218415 30 ctime=1447019941.494336341 glusterfs-3.7.6/contrib/qemu/include/qapi/0000755000076200007630000000000012617742645021740 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/qapi/PaxHeaders.7244/qmp0000644000076200007630000000013212617742645022243 xustar000000000000000030 mtime=1447019941.536335711 30 atime=1447019949.333218415 30 ctime=1447019941.536335711 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/0000755000076200007630000000000012617742645022535 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qfloat.h0000644000076200007630000000013012617742532023750 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.516336011 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qfloat.h0000644000076200007630000000107312617742532024170 0ustar00jenkinsjenkins00000000000000/* * QFloat Module * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QFLOAT_H #define QFLOAT_H #include #include "qapi/qmp/qobject.h" typedef struct QFloat { QObject_HEAD; double value; } QFloat; QFloat *qfloat_from_double(double value); double qfloat_get_double(const QFloat *qi); QFloat *qobject_to_qfloat(const QObject *obj); #endif /* QFLOAT_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qlist.h0000644000076200007630000000012712617742532023624 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 29 ctime=1447019941.52633586 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qlist.h0000644000076200007630000000303112617742532024032 0ustar00jenkinsjenkins00000000000000/* * QList Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QLIST_H #define QLIST_H #include "qapi/qmp/qobject.h" #include "qemu/queue.h" typedef struct QListEntry { QObject *value; QTAILQ_ENTRY(QListEntry) next; } QListEntry; typedef struct QList { QObject_HEAD; QTAILQ_HEAD(,QListEntry) head; } QList; #define qlist_append(qlist, obj) \ qlist_append_obj(qlist, QOBJECT(obj)) #define QLIST_FOREACH_ENTRY(qlist, var) \ for ((var) = ((qlist)->head.tqh_first); \ (var); \ (var) = ((var)->next.tqe_next)) static inline QObject *qlist_entry_obj(const QListEntry *entry) { return entry->value; } QList *qlist_new(void); QList *qlist_copy(QList *src); void qlist_append_obj(QList *qlist, QObject *obj); void qlist_iter(const QList *qlist, void (*iter)(QObject *obj, void *opaque), void *opaque); QObject *qlist_pop(QList *qlist); QObject *qlist_peek(QList *qlist); int qlist_empty(const QList *qlist); size_t qlist_size(const QList *qlist); QList *qobject_to_qlist(const QObject *obj); static inline const QListEntry *qlist_first(const QList *qlist) { return QTAILQ_FIRST(&qlist->head); } static inline const QListEntry *qlist_next(const QListEntry *entry) { return QTAILQ_NEXT(entry, next); } #endif /* QLIST_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qerror.h0000644000076200007630000000013012617742532023774 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.513336057 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qerror.h0000644000076200007630000002013212617742532024211 0ustar00jenkinsjenkins00000000000000/* * QError Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QERROR_H #define QERROR_H #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi-types.h" #include typedef struct QError { QObject_HEAD; Location loc; char *err_msg; ErrorClass err_class; } QError; QString *qerror_human(const QError *qerror); void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void qerror_report_err(Error *err); void assert_no_error(Error *err); /* * QError class list * Please keep the definitions in alphabetical order. * Use scripts/check-qerror.sh to check. */ #define QERR_ADD_CLIENT_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Could not add client" #define QERR_AMBIGUOUS_PATH \ ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object" #define QERR_BAD_BUS_FOR_DEVICE \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus" #define QERR_BASE_NOT_FOUND \ ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found" #define QERR_BLOCK_JOB_NOT_ACTIVE \ ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'" #define QERR_BLOCK_JOB_PAUSED \ ERROR_CLASS_GENERIC_ERROR, "The block job for device '%s' is currently paused" #define QERR_BLOCK_JOB_NOT_READY \ ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed" #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'" #define QERR_BUFFER_OVERRUN \ ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran" #define QERR_BUS_NO_HOTPLUG \ ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging" #define QERR_BUS_NOT_FOUND \ ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found" #define QERR_COMMAND_DISABLED \ ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance" #define QERR_COMMAND_NOT_FOUND \ ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found" #define QERR_DEVICE_ENCRYPTED \ ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted" #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \ ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'" #define QERR_DEVICE_HAS_NO_MEDIUM \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium" #define QERR_DEVICE_INIT_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized" #define QERR_DEVICE_IN_USE \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use" #define QERR_DEVICE_IS_READ_ONLY \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only" #define QERR_DEVICE_LOCKED \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked" #define QERR_DEVICE_MULTIPLE_BUSSES \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses" #define QERR_DEVICE_NO_BUS \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus" #define QERR_DEVICE_NO_HOTPLUG \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging" #define QERR_DEVICE_NOT_ACTIVE \ ERROR_CLASS_DEVICE_NOT_ACTIVE, "Device '%s' has not been activated" #define QERR_DEVICE_NOT_ENCRYPTED \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted" #define QERR_DEVICE_NOT_FOUND \ ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found" #define QERR_DEVICE_NOT_REMOVABLE \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable" #define QERR_DUPLICATE_ID \ ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s" #define QERR_FD_NOT_FOUND \ ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found" #define QERR_FD_NOT_SUPPLIED \ ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS" #define QERR_FEATURE_DISABLED \ ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled" #define QERR_INVALID_BLOCK_FORMAT \ ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'" #define QERR_INVALID_OPTION_GROUP \ ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'" #define QERR_INVALID_PARAMETER \ ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'" #define QERR_INVALID_PARAMETER_COMBINATION \ ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination" #define QERR_INVALID_PARAMETER_TYPE \ ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s" #define QERR_INVALID_PARAMETER_VALUE \ ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s" #define QERR_INVALID_PASSWORD \ ERROR_CLASS_GENERIC_ERROR, "Password incorrect" #define QERR_IO_ERROR \ ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred" #define QERR_JSON_PARSE_ERROR \ ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s" #define QERR_JSON_PARSING \ ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax" #define QERR_KVM_MISSING_CAP \ ERROR_CLASS_K_V_M_MISSING_CAP, "Using KVM without %s, %s unavailable" #define QERR_MIGRATION_ACTIVE \ ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress" #define QERR_MIGRATION_NOT_SUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'" #define QERR_MISSING_PARAMETER \ ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing" #define QERR_NO_BUS_FOR_DEVICE \ ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'" #define QERR_NOT_SUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "Not supported" #define QERR_PERMISSION_DENIED \ ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation" #define QERR_PROPERTY_NOT_FOUND \ ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found" #define QERR_PROPERTY_VALUE_BAD \ ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'" #define QERR_PROPERTY_VALUE_IN_USE \ ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use" #define QERR_PROPERTY_VALUE_NOT_FOUND \ ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'" #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \ ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2" #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")" #define QERR_QGA_COMMAND_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'" #define QERR_QGA_LOGGING_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement" #define QERR_QMP_BAD_INPUT_OBJECT \ ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input" #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \ ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'" #define QERR_QMP_EXTRA_MEMBER \ ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected" #define QERR_RESET_REQUIRED \ ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required" #define QERR_SET_PASSWD_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Could not set password" #define QERR_TOO_MANY_FILES \ ERROR_CLASS_GENERIC_ERROR, "Too many open files" #define QERR_UNDEFINED_ERROR \ ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred" #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \ ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s" #define QERR_UNSUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported" #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \ ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'" #define QERR_SOCKET_CONNECT_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket" #define QERR_SOCKET_LISTEN_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode" #define QERR_SOCKET_BIND_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket" #define QERR_SOCKET_CREATE_FAILED \ ERROR_CLASS_GENERIC_ERROR, "Failed to create socket" #endif /* QERROR_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qdict.h0000644000076200007630000000013012617742532023566 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.510336101 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qdict.h0000644000076200007630000000427512617742532024015 0ustar00jenkinsjenkins00000000000000/* * QDict Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QDICT_H #define QDICT_H #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" #include "qemu/queue.h" #include #define QDICT_BUCKET_MAX 512 typedef struct QDictEntry { char *key; QObject *value; QLIST_ENTRY(QDictEntry) next; } QDictEntry; typedef struct QDict { QObject_HEAD; size_t size; QLIST_HEAD(,QDictEntry) table[QDICT_BUCKET_MAX]; } QDict; /* Object API */ QDict *qdict_new(void); const char *qdict_entry_key(const QDictEntry *entry); QObject *qdict_entry_value(const QDictEntry *entry); size_t qdict_size(const QDict *qdict); void qdict_put_obj(QDict *qdict, const char *key, QObject *value); void qdict_del(QDict *qdict, const char *key); int qdict_haskey(const QDict *qdict, const char *key); QObject *qdict_get(const QDict *qdict, const char *key); QDict *qobject_to_qdict(const QObject *obj); void qdict_iter(const QDict *qdict, void (*iter)(const char *key, QObject *obj, void *opaque), void *opaque); const QDictEntry *qdict_first(const QDict *qdict); const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry); /* Helper to qdict_put_obj(), accepts any object */ #define qdict_put(qdict, key, obj) \ qdict_put_obj(qdict, key, QOBJECT(obj)) /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key); int qdict_get_bool(const QDict *qdict, const char *key); QList *qdict_get_qlist(const QDict *qdict, const char *key); QDict *qdict_get_qdict(const QDict *qdict, const char *key); const char *qdict_get_str(const QDict *qdict, const char *key); int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value); int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value); const char *qdict_get_try_str(const QDict *qdict, const char *key); QDict *qdict_clone_shallow(const QDict *src); #endif /* QDICT_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qstring.h0000644000076200007630000000012712617742532024157 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.533335755 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qstring.h0000644000076200007630000000166012617742532024373 0ustar00jenkinsjenkins00000000000000/* * QString Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QSTRING_H #define QSTRING_H #include #include "qapi/qmp/qobject.h" typedef struct QString { QObject_HEAD; char *string; size_t length; size_t capacity; } QString; QString *qstring_new(void); QString *qstring_from_str(const char *str); QString *qstring_from_substr(const char *str, int start, int end); size_t qstring_get_length(const QString *qstring); const char *qstring_get_str(const QString *qstring); void qstring_append_int(QString *qstring, int64_t value); void qstring_append(QString *qstring, const char *str); void qstring_append_chr(QString *qstring, int c); QString *qobject_to_qstring(const QObject *obj); #endif /* QSTRING_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qint.h0000644000076200007630000000012712617742532023443 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 29 ctime=1447019941.52033595 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qint.h0000644000076200007630000000104412617742532023653 0ustar00jenkinsjenkins00000000000000/* * QInt Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QINT_H #define QINT_H #include #include "qapi/qmp/qobject.h" typedef struct QInt { QObject_HEAD; int64_t value; } QInt; QInt *qint_from_int(int64_t value); int64_t qint_get_int(const QInt *qi); QInt *qobject_to_qint(const QObject *obj); #endif /* QINT_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/types.h0000644000076200007630000000012712617742532023634 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.536335711 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/types.h0000644000076200007630000000110212617742532024037 0ustar00jenkinsjenkins00000000000000/* * Include all QEMU objects. * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef QEMU_OBJECTS_H #define QEMU_OBJECTS_H #include "qapi/qmp/qobject.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qjson.h" #endif /* QEMU_OBJECTS_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/json-streamer.h0000644000076200007630000000013012617742532025253 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.504336191 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/json-streamer.h0000644000076200007630000000175212617742532025477 0ustar00jenkinsjenkins00000000000000/* * JSON streaming support * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QEMU_JSON_STREAMER_H #define QEMU_JSON_STREAMER_H #include "qapi/qmp/qlist.h" #include "qapi/qmp/json-lexer.h" typedef struct JSONMessageParser { void (*emit)(struct JSONMessageParser *parser, QList *tokens); JSONLexer lexer; int brace_count; int bracket_count; QList *tokens; uint64_t token_size; } JSONMessageParser; void json_message_parser_init(JSONMessageParser *parser, void (*func)(JSONMessageParser *, QList *)); int json_message_parser_feed(JSONMessageParser *parser, const char *buffer, size_t size); int json_message_parser_flush(JSONMessageParser *parser); void json_message_parser_destroy(JSONMessageParser *parser); #endif glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qobject.h0000644000076200007630000000013012617742532024111 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.529335814 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qobject.h0000644000076200007630000000540612617742532024335 0ustar00jenkinsjenkins00000000000000/* * QEMU Object Model. * * Based on ideas by Avi Kivity * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * * QObject Reference Counts Terminology * ------------------------------------ * * - Returning references: A function that returns an object may * return it as either a weak or a strong reference. If the reference * is strong, you are responsible for calling QDECREF() on the reference * when you are done. * * If the reference is weak, the owner of the reference may free it at * any time in the future. Before storing the reference anywhere, you * should call QINCREF() to make the reference strong. * * - Transferring ownership: when you transfer ownership of a reference * by calling a function, you are no longer responsible for calling * QDECREF() when the reference is no longer needed. In other words, * when the function returns you must behave as if the reference to the * passed object was weak. */ #ifndef QOBJECT_H #define QOBJECT_H #include #include typedef enum { QTYPE_NONE, QTYPE_QINT, QTYPE_QSTRING, QTYPE_QDICT, QTYPE_QLIST, QTYPE_QFLOAT, QTYPE_QBOOL, QTYPE_QERROR, } qtype_code; struct QObject; typedef struct QType { qtype_code code; void (*destroy)(struct QObject *); } QType; typedef struct QObject { const QType *type; size_t refcnt; } QObject; /* Objects definitions must include this */ #define QObject_HEAD \ QObject base /* Get the 'base' part of an object */ #define QOBJECT(obj) (&(obj)->base) /* High-level interface for qobject_incref() */ #define QINCREF(obj) \ qobject_incref(QOBJECT(obj)) /* High-level interface for qobject_decref() */ #define QDECREF(obj) \ qobject_decref(obj ? QOBJECT(obj) : NULL) /* Initialize an object to default values */ #define QOBJECT_INIT(obj, qtype_type) \ obj->base.refcnt = 1; \ obj->base.type = qtype_type /** * qobject_incref(): Increment QObject's reference count */ static inline void qobject_incref(QObject *obj) { if (obj) obj->refcnt++; } /** * qobject_decref(): Decrement QObject's reference count, deallocate * when it reaches zero */ static inline void qobject_decref(QObject *obj) { if (obj && --obj->refcnt == 0) { assert(obj->type != NULL); assert(obj->type->destroy != NULL); obj->type->destroy(obj); } } /** * qobject_type(): Return the QObject's type */ static inline qtype_code qobject_type(const QObject *obj) { assert(obj->type != NULL); return obj->type->code; } #endif /* QOBJECT_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/json-lexer.h0000644000076200007630000000013012617742532024550 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.497336296 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/json-lexer.h0000644000076200007630000000176312617742532024776 0ustar00jenkinsjenkins00000000000000/* * JSON lexer * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QEMU_JSON_LEXER_H #define QEMU_JSON_LEXER_H #include "qapi/qmp/qstring.h" #include "qapi/qmp/qlist.h" typedef enum json_token_type { JSON_OPERATOR = 100, JSON_INTEGER, JSON_FLOAT, JSON_KEYWORD, JSON_STRING, JSON_ESCAPE, JSON_SKIP, JSON_ERROR, } JSONTokenType; typedef struct JSONLexer JSONLexer; typedef void (JSONLexerEmitter)(JSONLexer *, QString *, JSONTokenType, int x, int y); struct JSONLexer { JSONLexerEmitter *emit; int state; QString *token; int x, y; }; void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func); int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size); int json_lexer_flush(JSONLexer *lexer); void json_lexer_destroy(JSONLexer *lexer); #endif glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qjson.h0000644000076200007630000000013012617742532023614 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.523335905 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qjson.h0000644000076200007630000000136112617742532024034 0ustar00jenkinsjenkins00000000000000/* * QObject JSON integration * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QJSON_H #define QJSON_H #include #include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" QObject *qobject_from_json(const char *string) GCC_FMT_ATTR(1, 0); QObject *qobject_from_jsonf(const char *string, ...) GCC_FMT_ATTR(1, 2); QObject *qobject_from_jsonv(const char *string, va_list *ap) GCC_FMT_ATTR(1, 0); QString *qobject_to_json(const QObject *obj); QString *qobject_to_json_pretty(const QObject *obj); #endif /* QJSON_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/json-parser.h0000644000076200007630000000013012617742532024725 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.501336236 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/json-parser.h0000644000076200007630000000102012617742532025135 0ustar00jenkinsjenkins00000000000000/* * JSON Parser * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QEMU_JSON_PARSER_H #define QEMU_JSON_PARSER_H #include "qemu-common.h" #include "qapi/qmp/qlist.h" #include "qapi/error.h" QObject *json_parser_parse(QList *tokens, va_list *ap); QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp); #endif glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/PaxHeaders.7244/qbool.h0000644000076200007630000000013012617742532023576 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.507336144 glusterfs-3.7.6/contrib/qemu/include/qapi/qmp/qbool.h0000644000076200007630000000104012617742532024010 0ustar00jenkinsjenkins00000000000000/* * QBool Module * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QBOOL_H #define QBOOL_H #include #include "qapi/qmp/qobject.h" typedef struct QBool { QObject_HEAD; int value; } QBool; QBool *qbool_from_int(int value); int qbool_get_int(const QBool *qb); QBool *qobject_to_qbool(const QObject *obj); #endif /* QBOOL_H */ glusterfs-3.7.6/contrib/qemu/include/qapi/PaxHeaders.7244/error.h0000644000076200007630000000013012617742532023016 xustar000000000000000030 mtime=1447019866.038471525 28 atime=1447019866.3724665 30 ctime=1447019941.494336341 glusterfs-3.7.6/contrib/qemu/include/qapi/error.h0000644000076200007630000000432712617742532023243 0ustar00jenkinsjenkins00000000000000/* * QEMU Error Objects * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2. See * the COPYING.LIB file in the top-level directory. */ #ifndef ERROR_H #define ERROR_H #include "qemu/compiler.h" #include "qapi-types.h" #include /** * A class representing internal errors within QEMU. An error has a ErrorClass * code and a human message. */ typedef struct Error Error; /** * Set an indirect pointer to an error given a ErrorClass value and a * printf-style human message. This function is not meant to be used outside * of QEMU. */ void error_set(Error **err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4); /** * Set an indirect pointer to an error given a ErrorClass value and a * printf-style human message, followed by a strerror() string if * @os_error is not zero. */ void error_set_errno(Error **err, int os_error, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(4, 5); /** * Same as error_set(), but sets a generic error */ #define error_setg(err, fmt, ...) \ error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__) #define error_setg_errno(err, os_error, fmt, ...) \ error_set_errno(err, os_error, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__) /** * Helper for open() errors */ void error_setg_file_open(Error **errp, int os_errno, const char *filename); /** * Returns true if an indirect pointer to an error is pointing to a valid * error object. */ bool error_is_set(Error **err); /* * Get the error class of an error object. */ ErrorClass error_get_class(const Error *err); /** * Returns an exact copy of the error passed as an argument. */ Error *error_copy(const Error *err); /** * Get a human readable representation of an error object. */ const char *error_get_pretty(Error *err); /** * Propagate an error to an indirect pointer to an error. This function will * always transfer ownership of the error reference and handles the case where * dst_err is NULL correctly. Errors after the first are discarded. */ void error_propagate(Error **dst_err, Error *local_err); /** * Free an error object. */ void error_free(Error *err); #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/exec0000644000076200007630000000013212617742645021440 xustar000000000000000030 mtime=1447019941.472336672 30 atime=1447019949.333218415 30 ctime=1447019941.472336672 glusterfs-3.7.6/contrib/qemu/include/exec/0000755000076200007630000000000012617742645021732 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/exec/PaxHeaders.7244/cpu-common.h0000644000076200007630000000013212617742532023736 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.465336778 glusterfs-3.7.6/contrib/qemu/include/exec/cpu-common.h0000644000076200007630000000727112617742532024162 0ustar00jenkinsjenkins00000000000000#ifndef CPU_COMMON_H #define CPU_COMMON_H 1 /* CPU interfaces that are target independent. */ #ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" #endif #ifndef NEED_CPU_H #include "exec/poison.h" #endif #include "qemu/bswap.h" #include "qemu/queue.h" /** * CPUListState: * @cpu_fprintf: Print function. * @file: File to print to using @cpu_fprint. * * State commonly used for iterating over CPU models. */ typedef struct CPUListState { fprintf_function cpu_fprintf; FILE *file; } CPUListState; #if !defined(CONFIG_USER_ONLY) enum device_endian { DEVICE_NATIVE_ENDIAN, DEVICE_BIG_ENDIAN, DEVICE_LITTLE_ENDIAN, }; /* address in the RAM (different from a physical address) */ #if defined(CONFIG_XEN_BACKEND) typedef uint64_t ram_addr_t; # define RAM_ADDR_MAX UINT64_MAX # define RAM_ADDR_FMT "%" PRIx64 #else typedef uintptr_t ram_addr_t; # define RAM_ADDR_MAX UINTPTR_MAX # define RAM_ADDR_FMT "%" PRIxPTR #endif /* memory API */ typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); /* This should not be used by devices. */ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev); void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write); static inline void cpu_physical_memory_read(hwaddr addr, void *buf, int len) { cpu_physical_memory_rw(addr, buf, len, 0); } static inline void cpu_physical_memory_write(hwaddr addr, const void *buf, int len) { cpu_physical_memory_rw(addr, (void *)buf, len, 1); } void *cpu_physical_memory_map(hwaddr addr, hwaddr *plen, int is_write); void cpu_physical_memory_unmap(void *buffer, hwaddr len, int is_write, hwaddr access_len); void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); bool cpu_physical_memory_is_io(hwaddr phys_addr); /* Coalesced MMIO regions are areas where write operations can be reordered. * This usually implies that write operations are side-effect free. This allows * batching which can make a major impact on performance when using * virtualization. */ void qemu_flush_coalesced_mmio_buffer(void); uint32_t ldub_phys(hwaddr addr); uint32_t lduw_le_phys(hwaddr addr); uint32_t lduw_be_phys(hwaddr addr); uint32_t ldl_le_phys(hwaddr addr); uint32_t ldl_be_phys(hwaddr addr); uint64_t ldq_le_phys(hwaddr addr); uint64_t ldq_be_phys(hwaddr addr); void stb_phys(hwaddr addr, uint32_t val); void stw_le_phys(hwaddr addr, uint32_t val); void stw_be_phys(hwaddr addr, uint32_t val); void stl_le_phys(hwaddr addr, uint32_t val); void stl_be_phys(hwaddr addr, uint32_t val); void stq_le_phys(hwaddr addr, uint64_t val); void stq_be_phys(hwaddr addr, uint64_t val); #ifdef NEED_CPU_H uint32_t lduw_phys(hwaddr addr); uint32_t ldl_phys(hwaddr addr); uint64_t ldq_phys(hwaddr addr); void stl_phys_notdirty(hwaddr addr, uint32_t val); void stw_phys(hwaddr addr, uint32_t val); void stl_phys(hwaddr addr, uint32_t val); void stq_phys(hwaddr addr, uint64_t val); #endif void cpu_physical_memory_write_rom(hwaddr addr, const uint8_t *buf, int len); extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_notdirty; typedef void (RAMBlockIterFunc)(void *host_addr, ram_addr_t offset, ram_addr_t length, void *opaque); void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); #endif #endif /* !CPU_COMMON_H */ glusterfs-3.7.6/contrib/qemu/include/exec/PaxHeaders.7244/hwaddr.h0000644000076200007630000000013212617742532023132 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.468336734 glusterfs-3.7.6/contrib/qemu/include/exec/hwaddr.h0000644000076200007630000000071112617742532023346 0ustar00jenkinsjenkins00000000000000/* Define hwaddr if it exists. */ #ifndef HWADDR_H #define HWADDR_H #define HWADDR_BITS 64 /* hwaddr is the type of a physical address (its size can be different from 'target_ulong'). */ typedef uint64_t hwaddr; #define HWADDR_MAX UINT64_MAX #define TARGET_FMT_plx "%016" PRIx64 #define HWADDR_PRId PRId64 #define HWADDR_PRIi PRIi64 #define HWADDR_PRIo PRIo64 #define HWADDR_PRIu PRIu64 #define HWADDR_PRIx PRIx64 #define HWADDR_PRIX PRIX64 #endif glusterfs-3.7.6/contrib/qemu/include/exec/PaxHeaders.7244/poison.h0000644000076200007630000000013112617742532023167 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.472336672 glusterfs-3.7.6/contrib/qemu/include/exec/poison.h0000644000076200007630000000341012617742532023403 0ustar00jenkinsjenkins00000000000000/* Poison identifiers that should not be used when building target independent device code. */ #ifndef HW_POISON_H #define HW_POISON_H #ifdef __GNUC__ #pragma GCC poison TARGET_I386 #pragma GCC poison TARGET_X86_64 #pragma GCC poison TARGET_ALPHA #pragma GCC poison TARGET_ARM #pragma GCC poison TARGET_CRIS #pragma GCC poison TARGET_LM32 #pragma GCC poison TARGET_M68K #pragma GCC poison TARGET_MIPS #pragma GCC poison TARGET_MIPS64 #pragma GCC poison TARGET_OPENRISC #pragma GCC poison TARGET_PPC #pragma GCC poison TARGET_PPCEMB #pragma GCC poison TARGET_PPC64 #pragma GCC poison TARGET_ABI32 #pragma GCC poison TARGET_SH4 #pragma GCC poison TARGET_SPARC #pragma GCC poison TARGET_SPARC64 #pragma GCC poison TARGET_WORDS_BIGENDIAN #pragma GCC poison BSWAP_NEEDED #pragma GCC poison TARGET_LONG_BITS #pragma GCC poison TARGET_FMT_lx #pragma GCC poison TARGET_FMT_ld #pragma GCC poison TARGET_PAGE_SIZE #pragma GCC poison TARGET_PAGE_MASK #pragma GCC poison TARGET_PAGE_BITS #pragma GCC poison TARGET_PAGE_ALIGN #pragma GCC poison CPUArchState #pragma GCC poison env #pragma GCC poison lduw_phys #pragma GCC poison ldl_phys #pragma GCC poison ldq_phys #pragma GCC poison stl_phys_notdirty #pragma GCC poison stw_phys #pragma GCC poison stl_phys #pragma GCC poison stq_phys #pragma GCC poison CPU_INTERRUPT_HARD #pragma GCC poison CPU_INTERRUPT_EXITTB #pragma GCC poison CPU_INTERRUPT_HALT #pragma GCC poison CPU_INTERRUPT_DEBUG #pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 #pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 #pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 #pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 #pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 #pragma GCC poison CPU_INTERRUPT_TGT_INT_0 #pragma GCC poison CPU_INTERRUPT_TGT_INT_1 #pragma GCC poison CPU_INTERRUPT_TGT_INT_2 #endif #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/migration0000644000076200007630000000013212617742645022505 xustar000000000000000030 mtime=1447019941.485336475 30 atime=1447019949.333218415 30 ctime=1447019941.485336475 glusterfs-3.7.6/contrib/qemu/include/migration/0000755000076200007630000000000012617742645022777 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/migration/PaxHeaders.7244/vmstate.h0000644000076200007630000000013112617742532024410 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.485336475 glusterfs-3.7.6/contrib/qemu/include/migration/vmstate.h0000644000076200007630000010471712617742532024640 0ustar00jenkinsjenkins00000000000000/* * QEMU migration/snapshot declarations * * Copyright (c) 2009-2011 Red Hat, Inc. * * Original author: Juan Quintela * * 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. */ #ifndef QEMU_VMSTATE_H #define QEMU_VMSTATE_H 1 #ifndef CONFIG_USER_ONLY #include #endif typedef void SaveStateHandler(QEMUFile *f, void *opaque); typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ void (*set_params)(const MigrationParams *params, void * opaque); SaveStateHandler *save_state; void (*cancel)(void *opaque); int (*save_live_complete)(QEMUFile *f, void *opaque); /* This runs both outside and inside the iothread lock. */ bool (*is_active)(void *opaque); /* This runs outside the iothread lock in the migration case, and * within the lock in the savevm case. The callback had better only * use data that is local to the migration thread or protected * by other locks. */ int (*save_live_iterate)(QEMUFile *f, void *opaque); /* This runs outside the iothread lock! */ int (*save_live_setup)(QEMUFile *f, void *opaque); uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size); LoadStateHandler *load_state; } SaveVMHandlers; int register_savevm(DeviceState *dev, const char *idstr, int instance_id, int version_id, SaveStateHandler *save_state, LoadStateHandler *load_state, void *opaque); int register_savevm_live(DeviceState *dev, const char *idstr, int instance_id, int version_id, SaveVMHandlers *ops, void *opaque); void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); void register_device_unmigratable(DeviceState *dev, const char *idstr, void *opaque); typedef struct VMStateInfo VMStateInfo; typedef struct VMStateDescription VMStateDescription; struct VMStateInfo { const char *name; int (*get)(QEMUFile *f, void *pv, size_t size); void (*put)(QEMUFile *f, void *pv, size_t size); }; enum VMStateFlags { VMS_SINGLE = 0x001, VMS_POINTER = 0x002, VMS_ARRAY = 0x004, VMS_STRUCT = 0x008, VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ VMS_BUFFER = 0x020, /* static sized buffer */ VMS_ARRAY_OF_POINTER = 0x040, VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ }; typedef struct { const char *name; size_t offset; size_t size; size_t start; int num; size_t num_offset; size_t size_offset; const VMStateInfo *info; enum VMStateFlags flags; const VMStateDescription *vmsd; int version_id; bool (*field_exists)(void *opaque, int version_id); } VMStateField; typedef struct VMStateSubsection { const VMStateDescription *vmsd; bool (*needed)(void *opaque); } VMStateSubsection; struct VMStateDescription { const char *name; int unmigratable; int version_id; int minimum_version_id; int minimum_version_id_old; LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); void (*pre_save)(void *opaque); VMStateField *fields; const VMStateSubsection *subsections; }; #ifdef CONFIG_USER_ONLY extern const VMStateDescription vmstate_dummy; #endif extern const VMStateInfo vmstate_info_bool; extern const VMStateInfo vmstate_info_int8; extern const VMStateInfo vmstate_info_int16; extern const VMStateInfo vmstate_info_int32; extern const VMStateInfo vmstate_info_int64; extern const VMStateInfo vmstate_info_uint8_equal; extern const VMStateInfo vmstate_info_uint16_equal; extern const VMStateInfo vmstate_info_int32_equal; extern const VMStateInfo vmstate_info_uint32_equal; extern const VMStateInfo vmstate_info_uint64_equal; extern const VMStateInfo vmstate_info_int32_le; extern const VMStateInfo vmstate_info_uint8; extern const VMStateInfo vmstate_info_uint16; extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; extern const VMStateInfo vmstate_info_float64; extern const VMStateInfo vmstate_info_timer; extern const VMStateInfo vmstate_info_buffer; extern const VMStateInfo vmstate_info_unused_buffer; extern const VMStateInfo vmstate_info_bitmap; #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0) #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) #define vmstate_offset_value(_state, _field, _type) \ (offsetof(_state, _field) + \ type_check(_type, typeof_field(_state, _field))) #define vmstate_offset_pointer(_state, _field, _type) \ (offsetof(_state, _field) + \ type_check_pointer(_type, typeof_field(_state, _field))) #define vmstate_offset_array(_state, _field, _type, _num) \ (offsetof(_state, _field) + \ type_check_array(_type, typeof_field(_state, _field), _num)) #define vmstate_offset_2darray(_state, _field, _type, _n1, _n2) \ (offsetof(_state, _field) + \ type_check_2darray(_type, typeof_field(_state, _field), _n1, _n2)) #define vmstate_offset_sub_array(_state, _field, _type, _start) \ (offsetof(_state, _field[_start])) #define vmstate_offset_buffer(_state, _field) \ vmstate_offset_array(_state, _field, uint8_t, \ sizeof(typeof_field(_state, _field))) #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .size = sizeof(_type), \ .info = &(_info), \ .flags = VMS_SINGLE, \ .offset = vmstate_offset_value(_state, _field, _type), \ } #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_SINGLE|VMS_POINTER, \ .offset = vmstate_offset_value(_state, _field, _type), \ } #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \ .name = (stringify(_field)), \ .info = &(_info), \ .field_exists = (_test), \ .size = sizeof(_type), \ .flags = VMS_SINGLE|VMS_POINTER, \ .offset = vmstate_offset_value(_state, _field, _type), \ } #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ .num = (_num), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_array(_state, _field, _type, _num), \ } #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .num = (_n1) * (_n2), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \ } #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ .name = (stringify(_field)), \ .field_exists = (_test), \ .num = (_num), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_array(_state, _field, _type, _num),\ } #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .num = (_num), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ } #define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\ .name = (stringify(_field)), \ .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_VARRAY_INT32, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_VARRAY_INT32|VMS_POINTER, \ .offset = vmstate_offset_pointer(_state, _field, _type), \ } #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_VARRAY_UINT32|VMS_POINTER, \ .offset = vmstate_offset_pointer(_state, _field, _type), \ } #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_VARRAY_UINT16, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT, \ .offset = vmstate_offset_value(_state, _field, _type), \ } #define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \ .name = (stringify(_field)), \ .field_exists = (_test), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT|VMS_POINTER, \ .offset = vmstate_offset_value(_state, _field, _type), \ } #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ .num = (_num), \ .info = &(_info), \ .size = sizeof(_type), \ .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ .offset = vmstate_offset_array(_state, _field, _type, _num), \ } #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num = (_num), \ .field_exists = (_test), \ .version_id = (_version), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT|VMS_ARRAY, \ .offset = vmstate_offset_array(_state, _field, _type, _num),\ } #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ .version_id = (_version), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \ .name = (stringify(_field)), \ .version_id = 0, \ .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ .size = sizeof(_type), \ .vmsd = &(_vmsd), \ .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ .offset = vmstate_offset_pointer(_state, _field, _type), \ } #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \ .name = (stringify(_field)), \ .version_id = 0, \ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ .size = sizeof(_type), \ .vmsd = &(_vmsd), \ .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ .offset = vmstate_offset_pointer(_state, _field, _type), \ } #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \ .name = (stringify(_field)), \ .version_id = 0, \ .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ .size = sizeof(_type), \ .vmsd = &(_vmsd), \ .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ .offset = vmstate_offset_pointer(_state, _field, _type), \ } #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ .version_id = (_version), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT|VMS_VARRAY_INT32, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \ .version_id = (_version), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \ .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .size = (_size - _start), \ .info = &vmstate_info_buffer, \ .flags = VMS_BUFFER, \ .offset = vmstate_offset_buffer(_state, _field) + _start, \ } #define VMSTATE_VBUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ .size = (_multiply), \ .info = &vmstate_info_buffer, \ .flags = VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \ .offset = offsetof(_state, _field), \ .start = (_start), \ } #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ .info = &vmstate_info_buffer, \ .flags = VMS_VBUFFER|VMS_POINTER, \ .offset = offsetof(_state, _field), \ .start = (_start), \ } #define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .field_exists = (_test), \ .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ .info = &vmstate_info_buffer, \ .flags = VMS_VBUFFER|VMS_POINTER, \ .offset = offsetof(_state, _field), \ .start = (_start), \ } #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .size = (_size), \ .info = &(_info), \ .flags = VMS_BUFFER, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .size = (_size), \ .info = &vmstate_info_buffer, \ .flags = VMS_BUFFER|VMS_POINTER, \ .offset = offsetof(_state, _field), \ } #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \ .name = "unused", \ .field_exists = (_test), \ .version_id = (_version), \ .size = (_size), \ .info = &vmstate_info_unused_buffer, \ .flags = VMS_BUFFER, \ } /* _field_size should be a int32_t field in the _state struct giving the * size of the bitmap _field in bits. */ #define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ .info = &vmstate_info_bitmap, \ .flags = VMS_VBUFFER|VMS_POINTER, \ .offset = offsetof(_state, _field), \ } /* _f : field name _f_n : num of elements field_name _n : num of elements _s : struct state name _v : version */ #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \ VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type) #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \ VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \ VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \ VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \ _vmsd, _type) #define VMSTATE_BOOL_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool) #define VMSTATE_INT8_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) #define VMSTATE_INT16_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) #define VMSTATE_INT32_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) #define VMSTATE_INT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) #define VMSTATE_UINT8_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) #define VMSTATE_UINT16_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) #define VMSTATE_UINT32_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) #define VMSTATE_UINT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) #define VMSTATE_BOOL(_f, _s) \ VMSTATE_BOOL_V(_f, _s, 0) #define VMSTATE_INT8(_f, _s) \ VMSTATE_INT8_V(_f, _s, 0) #define VMSTATE_INT16(_f, _s) \ VMSTATE_INT16_V(_f, _s, 0) #define VMSTATE_INT32(_f, _s) \ VMSTATE_INT32_V(_f, _s, 0) #define VMSTATE_INT64(_f, _s) \ VMSTATE_INT64_V(_f, _s, 0) #define VMSTATE_UINT8(_f, _s) \ VMSTATE_UINT8_V(_f, _s, 0) #define VMSTATE_UINT16(_f, _s) \ VMSTATE_UINT16_V(_f, _s, 0) #define VMSTATE_UINT32(_f, _s) \ VMSTATE_UINT32_V(_f, _s, 0) #define VMSTATE_UINT64(_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) #define VMSTATE_UINT8_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) #define VMSTATE_UINT16_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) #define VMSTATE_INT32_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) #define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t) #define VMSTATE_UINT32_EQUAL(_f, _s) \ VMSTATE_UINT32_EQUAL_V(_f, _s, 0) #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t) #define VMSTATE_UINT64_EQUAL(_f, _s) \ VMSTATE_UINT64_EQUAL_V(_f, _s, 0) #define VMSTATE_INT32_LE(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) #define VMSTATE_UINT8_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t) #define VMSTATE_UINT16_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t) #define VMSTATE_UINT32_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t) #define VMSTATE_FLOAT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64) #define VMSTATE_FLOAT64(_f, _s) \ VMSTATE_FLOAT64_V(_f, _s, 0) #define VMSTATE_TIMER_TEST(_f, _s, _test) \ VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *) #define VMSTATE_TIMER_V(_f, _s, _v) \ VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) #define VMSTATE_TIMER(_f, _s) \ VMSTATE_TIMER_V(_f, _s, 0) #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t) #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0) #define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t) #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0) #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \ VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) #define VMSTATE_INT16_ARRAY(_f, _s, _n) \ VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) #define VMSTATE_INT32_ARRAY(_f, _s, _n) \ VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t) #define VMSTATE_INT64_ARRAY(_f, _s, _n) \ VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64) #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \ VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0) #define VMSTATE_BUFFER_V(_f, _s, _v) \ VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f))) #define VMSTATE_BUFFER(_f, _s) \ VMSTATE_BUFFER_V(_f, _s, 0) #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size) #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \ VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \ VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size) #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \ VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size) #define VMSTATE_BUFFER_TEST(_f, _s, _test) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \ VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size) #define VMSTATE_UNUSED_V(_v, _size) \ VMSTATE_UNUSED_BUFFER(NULL, _v, _size) #define VMSTATE_UNUSED(_size) \ VMSTATE_UNUSED_V(0, _size) #define VMSTATE_UNUSED_TEST(_test, _size) \ VMSTATE_UNUSED_BUFFER(_test, 0, _size) #define VMSTATE_END_OF_LIST() \ {} int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id); void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque); int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version); static inline int vmstate_register(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque) { return vmstate_register_with_alias_id(dev, instance_id, vmsd, opaque, -1, 0); } void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, void *opaque); struct MemoryRegion; void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_register_ram_global(struct MemoryRegion *memory); #endif glusterfs-3.7.6/contrib/qemu/include/migration/PaxHeaders.7244/qemu-file.h0000644000076200007630000000013112617742532024611 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.481336537 glusterfs-3.7.6/contrib/qemu/include/migration/qemu-file.h0000644000076200007630000001702412617742532025033 0ustar00jenkinsjenkins00000000000000/* * QEMU System Emulator * * Copyright (c) 2003-2008 Fabrice Bellard * * 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. */ #ifndef QEMU_FILE_H #define QEMU_FILE_H 1 #include "exec/cpu-common.h" /* This function writes a chunk of data to a file at the given position. * The pos argument can be ignored if the file is only being used for * streaming. The handler should try to write all of the data it can. */ typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, int64_t pos, int size); /* Read a chunk of data from a file at the given position. The pos argument * can be ignored if the file is only be used for streaming. The number of * bytes actually read should be returned. */ typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, int64_t pos, int size); /* Close a file * * Return negative error number on error, 0 or positive value on success. * * The meaning of return value on success depends on the specific back-end being * used. */ typedef int (QEMUFileCloseFunc)(void *opaque); /* Called to return the OS file descriptor associated to the QEMUFile. */ typedef int (QEMUFileGetFD)(void *opaque); /* * This function writes an iovec to file. */ typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov, int iovcnt, int64_t pos); /* * This function provides hooks around different * stages of RAM migration. */ typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque, uint64_t flags); /* * Constants used by ram_control_* hooks */ #define RAM_CONTROL_SETUP 0 #define RAM_CONTROL_ROUND 1 #define RAM_CONTROL_HOOK 2 #define RAM_CONTROL_FINISH 3 /* * This function allows override of where the RAM page * is saved (such as RDMA, for example.) */ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, void *opaque, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent); typedef struct QEMUFileOps { QEMUFilePutBufferFunc *put_buffer; QEMUFileGetBufferFunc *get_buffer; QEMUFileCloseFunc *close; QEMUFileGetFD *get_fd; QEMUFileWritevBufferFunc *writev_buffer; QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; } QEMUFileOps; QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); QEMUFile *qemu_fopen(const char *filename, const char *mode); QEMUFile *qemu_fdopen(int fd, const char *mode); QEMUFile *qemu_fopen_socket(int fd, const char *mode); QEMUFile *qemu_popen_cmd(const char *command, const char *mode); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); int64_t qemu_ftell(QEMUFile *f); void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); void qemu_put_byte(QEMUFile *f, int v); /* * put_buffer without copying the buffer. * The buffer should be available till it is sent asynchronously. */ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size); bool qemu_file_mode_is_not_valid(const char *mode); static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) { qemu_put_byte(f, (int)v); } #define qemu_put_sbyte qemu_put_byte void qemu_put_be16(QEMUFile *f, unsigned int v); void qemu_put_be32(QEMUFile *f, unsigned int v); void qemu_put_be64(QEMUFile *f, uint64_t v); int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); int qemu_get_byte(QEMUFile *f); void qemu_update_position(QEMUFile *f, size_t size); static inline unsigned int qemu_get_ubyte(QEMUFile *f) { return (unsigned int)qemu_get_byte(f); } #define qemu_get_sbyte qemu_get_byte unsigned int qemu_get_be16(QEMUFile *f); unsigned int qemu_get_be32(QEMUFile *f); uint64_t qemu_get_be64(QEMUFile *f); int qemu_file_rate_limit(QEMUFile *f); void qemu_file_reset_rate_limit(QEMUFile *f); void qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error(QEMUFile *f); void qemu_fflush(QEMUFile *f); static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) { qemu_put_be64(f, *pv); } static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) { qemu_put_be32(f, *pv); } static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) { qemu_put_be16(f, *pv); } static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) { qemu_put_byte(f, *pv); } static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) { *pv = qemu_get_be64(f); } static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) { *pv = qemu_get_be32(f); } static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) { *pv = qemu_get_be16(f); } static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) { *pv = qemu_get_byte(f); } // Signed versions for type safety static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) { qemu_put_buffer(f, (const uint8_t *)buf, size); } static inline void qemu_put_sbe16(QEMUFile *f, int v) { qemu_put_be16(f, (unsigned int)v); } static inline void qemu_put_sbe32(QEMUFile *f, int v) { qemu_put_be32(f, (unsigned int)v); } static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) { qemu_put_be64(f, (uint64_t)v); } static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) { return qemu_get_buffer(f, (uint8_t *)buf, size); } static inline int qemu_get_sbe16(QEMUFile *f) { return (int)qemu_get_be16(f); } static inline int qemu_get_sbe32(QEMUFile *f) { return (int)qemu_get_be32(f); } static inline int64_t qemu_get_sbe64(QEMUFile *f) { return (int64_t)qemu_get_be64(f); } static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) { qemu_put_8s(f, (const uint8_t *)pv); } static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) { qemu_put_be16s(f, (const uint16_t *)pv); } static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) { qemu_put_be32s(f, (const uint32_t *)pv); } static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) { qemu_put_be64s(f, (const uint64_t *)pv); } static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) { qemu_get_8s(f, (uint8_t *)pv); } static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) { qemu_get_be16s(f, (uint16_t *)pv); } static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) { qemu_get_be32s(f, (uint32_t *)pv); } static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) { qemu_get_be64s(f, (uint64_t *)pv); } #endif glusterfs-3.7.6/contrib/qemu/include/migration/PaxHeaders.7244/migration.h0000644000076200007630000000013112617742532024716 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.478336582 glusterfs-3.7.6/contrib/qemu/include/migration/migration.h0000644000076200007630000001067112617742532025141 0ustar00jenkinsjenkins00000000000000/* * QEMU live migration * * Copyright IBM, Corp. 2008 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * */ #ifndef QEMU_MIGRATION_H #define QEMU_MIGRATION_H #include "qapi/qmp/qdict.h" #include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" #include "qapi/error.h" #include "migration/vmstate.h" #include "qapi-types.h" #include "exec/cpu-common.h" struct MigrationParams { bool blk; bool shared; }; typedef struct MigrationState MigrationState; struct MigrationState { int64_t bandwidth_limit; size_t bytes_xfer; size_t xfer_limit; QemuThread thread; QEMUBH *cleanup_bh; QEMUFile *file; int state; MigrationParams params; double mbps; int64_t total_time; int64_t downtime; int64_t expected_downtime; int64_t dirty_pages_rate; int64_t dirty_bytes_rate; bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; int64_t xbzrle_cache_size; }; void process_incoming_migration(QEMUFile *f); void qemu_start_incoming_migration(const char *uri, Error **errp); uint64_t migrate_max_downtime(void); void do_info_migrate_print(Monitor *mon, const QObject *data); void do_info_migrate(Monitor *mon, QObject **ret_data); void exec_start_incoming_migration(const char *host_port, Error **errp); void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); void tcp_start_incoming_migration(const char *host_port, Error **errp); void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); void unix_start_incoming_migration(const char *path, Error **errp); void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp); void fd_start_incoming_migration(const char *path, Error **errp); void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); void migrate_fd_error(MigrationState *s); void migrate_fd_connect(MigrationState *s); int migrate_fd_close(MigrationState *s); void add_migration_state_change_notifier(Notifier *notify); void remove_migration_state_change_notifier(Notifier *notify); bool migration_is_active(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); MigrationState *migrate_get_current(void); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_transferred(void); uint64_t ram_bytes_total(void); void acct_update_position(QEMUFile *f, size_t size, bool zero); extern SaveVMHandlers savevm_ram_handlers; uint64_t dup_mig_bytes_transferred(void); uint64_t dup_mig_pages_transferred(void); uint64_t skipped_mig_bytes_transferred(void); uint64_t skipped_mig_pages_transferred(void); uint64_t norm_mig_bytes_transferred(void); uint64_t norm_mig_pages_transferred(void); uint64_t xbzrle_mig_bytes_transferred(void); uint64_t xbzrle_mig_pages_transferred(void); uint64_t xbzrle_mig_pages_overflow(void); uint64_t xbzrle_mig_pages_cache_miss(void); /** * @migrate_add_blocker - prevent migration from proceeding * * @reason - an error to be returned whenever migration is attempted */ void migrate_add_blocker(Error *reason); /** * @migrate_del_blocker - remove a blocking error from migration * * @reason - the error blocking migration */ void migrate_del_blocker(Error *reason); bool migrate_rdma_pin_all(void); bool migrate_auto_converge(void); int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, uint8_t *dst, int dlen); int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen); int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); int64_t xbzrle_cache_resize(int64_t new_size); void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); void ram_control_load_hook(QEMUFile *f, uint64_t flags); /* Whenever this is found in the data stream, the flags * will be passed to ram_control_load_hook in the incoming-migration * side. This lets before_ram_iterate/after_ram_iterate add * transport-specific sections to the RAM migration data. */ #define RAM_SAVE_FLAG_HOOK 0x80 #define RAM_SAVE_CONTROL_NOT_SUPP -1000 #define RAM_SAVE_CONTROL_DELAYED -2000 size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent); #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/qemu0000644000076200007630000000013212617742645021463 xustar000000000000000030 mtime=1447019941.610334595 30 atime=1447019949.333218415 30 ctime=1447019941.610334595 glusterfs-3.7.6/contrib/qemu/include/qemu/0000755000076200007630000000000012617742645021755 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/typedefs.h0000644000076200007630000000013112617742532023526 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.610334595 glusterfs-3.7.6/contrib/qemu/include/qemu/typedefs.h0000644000076200007630000000461012617742532023745 0ustar00jenkinsjenkins00000000000000#ifndef QEMU_TYPEDEFS_H #define QEMU_TYPEDEFS_H /* A load of opaque types so that device init declarations don't have to pull in all the real definitions. */ typedef struct QEMUTimer QEMUTimer; typedef struct QEMUFile QEMUFile; typedef struct QEMUBH QEMUBH; struct Monitor; typedef struct Monitor Monitor; typedef struct MigrationParams MigrationParams; typedef struct Property Property; typedef struct PropertyInfo PropertyInfo; typedef struct CompatProperty CompatProperty; typedef struct DeviceState DeviceState; typedef struct BusState BusState; typedef struct BusClass BusClass; typedef struct AddressSpace AddressSpace; typedef struct MemoryRegion MemoryRegion; typedef struct MemoryRegionSection MemoryRegionSection; typedef struct MemoryMappingList MemoryMappingList; typedef struct NICInfo NICInfo; typedef struct HCIInfo HCIInfo; typedef struct AudioState AudioState; typedef struct BlockDriverState BlockDriverState; typedef struct DriveInfo DriveInfo; typedef struct DisplayState DisplayState; typedef struct DisplayChangeListener DisplayChangeListener; typedef struct DisplaySurface DisplaySurface; typedef struct PixelFormat PixelFormat; typedef struct QemuConsole QemuConsole; typedef struct CharDriverState CharDriverState; typedef struct MACAddr MACAddr; typedef struct NetClientState NetClientState; typedef struct i2c_bus i2c_bus; typedef struct ISABus ISABus; typedef struct ISADevice ISADevice; typedef struct SMBusDevice SMBusDevice; typedef struct PCIHostState PCIHostState; typedef struct PCIExpressHost PCIExpressHost; typedef struct PCIBus PCIBus; typedef struct PCIDevice PCIDevice; typedef struct PCIExpressDevice PCIExpressDevice; typedef struct PCIBridge PCIBridge; typedef struct PCIEAERMsg PCIEAERMsg; typedef struct PCIEAERLog PCIEAERLog; typedef struct PCIEAERErr PCIEAERErr; typedef struct PCIEPort PCIEPort; typedef struct PCIESlot PCIESlot; typedef struct MSIMessage MSIMessage; typedef struct SerialState SerialState; typedef struct PCMCIACardState PCMCIACardState; typedef struct MouseTransformInfo MouseTransformInfo; typedef struct uWireSlave uWireSlave; typedef struct I2SCodec I2SCodec; typedef struct SSIBus SSIBus; typedef struct EventNotifier EventNotifier; typedef struct VirtIODevice VirtIODevice; typedef struct QEMUSGList QEMUSGList; typedef struct SHPCDevice SHPCDevice; typedef struct FWCfgState FWCfgState; typedef struct PcGuestInfo PcGuestInfo; #endif /* QEMU_TYPEDEFS_H */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/notify.h0000644000076200007630000000013212617742532023214 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.581335032 glusterfs-3.7.6/contrib/qemu/include/qemu/notify.h0000644000076200007630000000351212617742532023432 0ustar00jenkinsjenkins00000000000000/* * Notifier lists * * Copyright IBM, Corp. 2010 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * */ #ifndef QEMU_NOTIFY_H #define QEMU_NOTIFY_H #include "qemu/queue.h" typedef struct Notifier Notifier; struct Notifier { void (*notify)(Notifier *notifier, void *data); QLIST_ENTRY(Notifier) node; }; typedef struct NotifierList { QLIST_HEAD(, Notifier) notifiers; } NotifierList; #define NOTIFIER_LIST_INITIALIZER(head) \ { QLIST_HEAD_INITIALIZER((head).notifiers) } void notifier_list_init(NotifierList *list); void notifier_list_add(NotifierList *list, Notifier *notifier); void notifier_remove(Notifier *notifier); void notifier_list_notify(NotifierList *list, void *data); /* Same as Notifier but allows .notify() to return errors */ typedef struct NotifierWithReturn NotifierWithReturn; struct NotifierWithReturn { /** * Return 0 on success (next notifier will be invoked), otherwise * notifier_with_return_list_notify() will stop and return the value. */ int (*notify)(NotifierWithReturn *notifier, void *data); QLIST_ENTRY(NotifierWithReturn) node; }; typedef struct NotifierWithReturnList { QLIST_HEAD(, NotifierWithReturn) notifiers; } NotifierWithReturnList; #define NOTIFIER_WITH_RETURN_LIST_INITIALIZER(head) \ { QLIST_HEAD_INITIALIZER((head).notifiers) } void notifier_with_return_list_init(NotifierWithReturnList *list); void notifier_with_return_list_add(NotifierWithReturnList *list, NotifierWithReturn *notifier); void notifier_with_return_remove(NotifierWithReturn *notifier); int notifier_with_return_list_notify(NotifierWithReturnList *list, void *data); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/main-loop.h0000644000076200007630000000013212617742532023577 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.574335138 glusterfs-3.7.6/contrib/qemu/include/qemu/main-loop.h0000644000076200007630000002721312617742532024021 0ustar00jenkinsjenkins00000000000000/* * QEMU System Emulator * * Copyright (c) 2003-2008 Fabrice Bellard * * 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. */ #ifndef QEMU_MAIN_LOOP_H #define QEMU_MAIN_LOOP_H 1 #include "block/aio.h" #define SIG_IPI SIGUSR1 /** * qemu_init_main_loop: Set up the process so that it can run the main loop. * * This includes setting up signal handlers. It should be called before * any other threads are created. In addition, threads other than the * main one should block signals that are trapped by the main loop. * For simplicity, you can consider these signals to be safe: SIGUSR1, * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time * signals if available. Remember that Windows in practice does not have * signals, though. * * In the case of QEMU tools, this will also start/initialize timers. */ int qemu_init_main_loop(void); /** * main_loop_wait: Run one iteration of the main loop. * * If @nonblocking is true, poll for events, otherwise suspend until * one actually occurs. The main loop usually consists of a loop that * repeatedly calls main_loop_wait(false). * * Main loop services include file descriptor callbacks, bottom halves * and timers (defined in qemu-timer.h). Bottom halves are similar to timers * that execute immediately, but have a lower overhead and scheduling them * is wait-free, thread-safe and signal-safe. * * It is sometimes useful to put a whole program in a coroutine. In this * case, the coroutine actually should be started from within the main loop, * so that the main loop can run whenever the coroutine yields. To do this, * you can use a bottom half to enter the coroutine as soon as the main loop * starts: * * void enter_co_bh(void *opaque) { * QEMUCoroutine *co = opaque; * qemu_coroutine_enter(co, NULL); * } * * ... * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); * qemu_bh_schedule(start_bh); * while (...) { * main_loop_wait(false); * } * * (In the future we may provide a wrapper for this). * * @nonblocking: Whether the caller should block until an event occurs. */ int main_loop_wait(int nonblocking); /** * qemu_get_aio_context: Return the main loop's AioContext */ AioContext *qemu_get_aio_context(void); /** * qemu_notify_event: Force processing of pending events. * * Similar to signaling a condition variable, qemu_notify_event forces * main_loop_wait to look at pending events and exit. The caller of * main_loop_wait will usually call it again very soon, so qemu_notify_event * also has the side effect of recalculating the sets of file descriptors * that the main loop waits for. * * Calling qemu_notify_event is rarely necessary, because main loop * services (bottom halves and timers) call it themselves. One notable * exception occurs when using qemu_set_fd_handler2 (see below). */ void qemu_notify_event(void); #ifdef _WIN32 /* return TRUE if no sleep should be done afterwards */ typedef int PollingFunc(void *opaque); /** * qemu_add_polling_cb: Register a Windows-specific polling callback * * Currently, under Windows some events are polled rather than waited for. * Polling callbacks do not ensure that @func is called timely, because * the main loop might wait for an arbitrarily long time. If possible, * you should instead create a separate thread that does a blocking poll * and set a Win32 event object. The event can then be passed to * qemu_add_wait_object. * * Polling callbacks really have nothing Windows specific in them, but * as they are a hack and are currently not necessary under POSIX systems, * they are only available when QEMU is running under Windows. * * @func: The function that does the polling, and returns 1 to force * immediate completion of main_loop_wait. * @opaque: A pointer-size value that is passed to @func. */ int qemu_add_polling_cb(PollingFunc *func, void *opaque); /** * qemu_del_polling_cb: Unregister a Windows-specific polling callback * * This function removes a callback that was registered with * qemu_add_polling_cb. * * @func: The function that was passed to qemu_add_polling_cb. * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. */ void qemu_del_polling_cb(PollingFunc *func, void *opaque); /* Wait objects handling */ typedef void WaitObjectFunc(void *opaque); /** * qemu_add_wait_object: Register a callback for a Windows handle * * Under Windows, the iohandler mechanism can only be used with sockets. * QEMU must use the WaitForMultipleObjects API to wait on other handles. * This function registers a #HANDLE with QEMU, so that it will be included * in the main loop's calls to WaitForMultipleObjects. When the handle * is in a signaled state, QEMU will call @func. * * @handle: The Windows handle to be observed. * @func: A function to be called when @handle is in a signaled state. * @opaque: A pointer-size value that is passed to @func. */ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); /** * qemu_del_wait_object: Unregister a callback for a Windows handle * * This function removes a callback that was registered with * qemu_add_wait_object. * * @func: The function that was passed to qemu_add_wait_object. * @opaque: A pointer-size value that was passed to qemu_add_wait_object. */ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); #endif /* async I/O support */ typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); typedef int IOCanReadHandler(void *opaque); /** * qemu_set_fd_handler2: Register a file descriptor with the main loop * * This function tells the main loop to wake up whenever one of the * following conditions is true: * * 1) if @fd_write is not %NULL, when the file descriptor is writable; * * 2) if @fd_read is not %NULL, when the file descriptor is readable. * * @fd_read_poll can be used to disable the @fd_read callback temporarily. * This is useful to avoid calling qemu_set_fd_handler2 every time the * client becomes interested in reading (or dually, stops being interested). * A typical example is when @fd is a listening socket and you want to bound * the number of active clients. Remember to call qemu_notify_event whenever * the condition may change from %false to %true. * * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. * If @fd_read does not read from @fd, or @fd_write does not write to @fd * until its buffers are full, they will be called again on the next * iteration. * * @fd: The file descriptor to be observed. Under Windows it must be * a #SOCKET. * * @fd_read_poll: A function that returns 1 if the @fd_read callback * should be fired. If the function returns 0, the main loop will not * end its iteration even if @fd becomes readable. * * @fd_read: A level-triggered callback that is fired if @fd is readable * at the beginning of a main loop iteration, or if it becomes readable * during one. * * @fd_write: A level-triggered callback that is fired when @fd is writable * at the beginning of a main loop iteration, or if it becomes writable * during one. * * @opaque: A pointer-sized value that is passed to @fd_read_poll, * @fd_read and @fd_write. */ int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, IOHandler *fd_read, IOHandler *fd_write, void *opaque); /** * qemu_set_fd_handler: Register a file descriptor with the main loop * * This function tells the main loop to wake up whenever one of the * following conditions is true: * * 1) if @fd_write is not %NULL, when the file descriptor is writable; * * 2) if @fd_read is not %NULL, when the file descriptor is readable. * * The callbacks that are set up by qemu_set_fd_handler are level-triggered. * If @fd_read does not read from @fd, or @fd_write does not write to @fd * until its buffers are full, they will be called again on the next * iteration. * * @fd: The file descriptor to be observed. Under Windows it must be * a #SOCKET. * * @fd_read: A level-triggered callback that is fired if @fd is readable * at the beginning of a main loop iteration, or if it becomes readable * during one. * * @fd_write: A level-triggered callback that is fired when @fd is writable * at the beginning of a main loop iteration, or if it becomes writable * during one. * * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. */ int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write, void *opaque); #ifdef CONFIG_POSIX /** * qemu_add_child_watch: Register a child process for reaping. * * Under POSIX systems, a parent process must read the exit status of * its child processes using waitpid, or the operating system will not * free some of the resources attached to that process. * * This function directs the QEMU main loop to observe a child process * and call waitpid as soon as it exits; the watch is then removed * automatically. It is useful whenever QEMU forks a child process * but will find out about its termination by other means such as a * "broken pipe". * * @pid: The pid that QEMU should observe. */ int qemu_add_child_watch(pid_t pid); #endif /** * qemu_mutex_lock_iothread: Lock the main loop mutex. * * This function locks the main loop mutex. The mutex is taken by * qemu_init_main_loop and always taken except while waiting on * external events (such as with select). The mutex should be taken * by threads other than the main loop thread when calling * qemu_bh_new(), qemu_set_fd_handler() and basically all other * functions documented in this file. * * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread * is a no-op there. */ void qemu_mutex_lock_iothread(void); /** * qemu_mutex_unlock_iothread: Unlock the main loop mutex. * * This function unlocks the main loop mutex. The mutex is taken by * qemu_init_main_loop and always taken except while waiting on * external events (such as with select). The mutex should be unlocked * as soon as possible by threads other than the main loop thread, * because it prevents the main loop from processing callbacks, * including timers and bottom halves. * * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread * is a no-op there. */ void qemu_mutex_unlock_iothread(void); /* internal interfaces */ void qemu_fd_register(int fd); void qemu_iohandler_fill(GArray *pollfds); void qemu_iohandler_poll(GArray *pollfds, int rc); QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); void qemu_bh_schedule_idle(QEMUBH *bh); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/host-utils.h0000644000076200007630000000013012617742532024015 xustar000000000000000030 mtime=1447019866.040471495 28 atime=1447019866.3724665 30 ctime=1447019941.568335228 glusterfs-3.7.6/contrib/qemu/include/qemu/host-utils.h0000644000076200007630000001677012617742532024247 0ustar00jenkinsjenkins00000000000000/* * Utility compute operations used by translated code. * * Copyright (c) 2007 Thiemo Seufer * Copyright (c) 2007 Jocelyn Mayer * * 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. */ #ifndef HOST_UTILS_H #define HOST_UTILS_H 1 #include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ #include #ifdef CONFIG_INT128 static inline void mulu64(uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) { __uint128_t r = (__uint128_t)a * b; *plow = r; *phigh = r >> 64; } static inline void muls64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) { __int128_t r = (__int128_t)a * b; *plow = r; *phigh = r >> 64; } #else void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); #endif /** * clz32 - count leading zeros in a 32-bit value. * @val: The value to search * * Returns 32 if the value is zero. Note that the GCC builtin is * undefined if the value is zero. */ static inline int clz32(uint32_t val) { #if QEMU_GNUC_PREREQ(3, 4) return val ? __builtin_clz(val) : 32; #else /* Binary search for the leading one bit. */ int cnt = 0; if (!(val & 0xFFFF0000U)) { cnt += 16; val <<= 16; } if (!(val & 0xFF000000U)) { cnt += 8; val <<= 8; } if (!(val & 0xF0000000U)) { cnt += 4; val <<= 4; } if (!(val & 0xC0000000U)) { cnt += 2; val <<= 2; } if (!(val & 0x80000000U)) { cnt++; val <<= 1; } if (!(val & 0x80000000U)) { cnt++; } return cnt; #endif } /** * clo32 - count leading ones in a 32-bit value. * @val: The value to search * * Returns 32 if the value is -1. */ static inline int clo32(uint32_t val) { return clz32(~val); } /** * clz64 - count leading zeros in a 64-bit value. * @val: The value to search * * Returns 64 if the value is zero. Note that the GCC builtin is * undefined if the value is zero. */ static inline int clz64(uint64_t val) { #if QEMU_GNUC_PREREQ(3, 4) return val ? __builtin_clzll(val) : 64; #else int cnt = 0; if (!(val >> 32)) { cnt += 32; } else { val >>= 32; } return cnt + clz32(val); #endif } /** * clo64 - count leading ones in a 64-bit value. * @val: The value to search * * Returns 64 if the value is -1. */ static inline int clo64(uint64_t val) { return clz64(~val); } /** * ctz32 - count trailing zeros in a 32-bit value. * @val: The value to search * * Returns 32 if the value is zero. Note that the GCC builtin is * undefined if the value is zero. */ static inline int ctz32(uint32_t val) { #if QEMU_GNUC_PREREQ(3, 4) return val ? __builtin_ctz(val) : 32; #else /* Binary search for the trailing one bit. */ int cnt; cnt = 0; if (!(val & 0x0000FFFFUL)) { cnt += 16; val >>= 16; } if (!(val & 0x000000FFUL)) { cnt += 8; val >>= 8; } if (!(val & 0x0000000FUL)) { cnt += 4; val >>= 4; } if (!(val & 0x00000003UL)) { cnt += 2; val >>= 2; } if (!(val & 0x00000001UL)) { cnt++; val >>= 1; } if (!(val & 0x00000001UL)) { cnt++; } return cnt; #endif } /** * cto32 - count trailing ones in a 32-bit value. * @val: The value to search * * Returns 32 if the value is -1. */ static inline int cto32(uint32_t val) { return ctz32(~val); } /** * ctz64 - count trailing zeros in a 64-bit value. * @val: The value to search * * Returns 64 if the value is zero. Note that the GCC builtin is * undefined if the value is zero. */ static inline int ctz64(uint64_t val) { #if QEMU_GNUC_PREREQ(3, 4) return val ? __builtin_ctzll(val) : 64; #else int cnt; cnt = 0; if (!((uint32_t)val)) { cnt += 32; val >>= 32; } return cnt + ctz32(val); #endif } /** * ctz64 - count trailing ones in a 64-bit value. * @val: The value to search * * Returns 64 if the value is -1. */ static inline int cto64(uint64_t val) { return ctz64(~val); } /** * ctpop8 - count the population of one bits in an 8-bit value. * @val: The value to search */ static inline int ctpop8(uint8_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcount(val); #else val = (val & 0x55) + ((val >> 1) & 0x55); val = (val & 0x33) + ((val >> 2) & 0x33); val = (val & 0x0f) + ((val >> 4) & 0x0f); return val; #endif } /** * ctpop16 - count the population of one bits in a 16-bit value. * @val: The value to search */ static inline int ctpop16(uint16_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcount(val); #else val = (val & 0x5555) + ((val >> 1) & 0x5555); val = (val & 0x3333) + ((val >> 2) & 0x3333); val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); val = (val & 0x00ff) + ((val >> 8) & 0x00ff); return val; #endif } /** * ctpop32 - count the population of one bits in a 32-bit value. * @val: The value to search */ static inline int ctpop32(uint32_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcount(val); #else val = (val & 0x55555555) + ((val >> 1) & 0x55555555); val = (val & 0x33333333) + ((val >> 2) & 0x33333333); val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); return val; #endif } /** * ctpop64 - count the population of one bits in a 64-bit value. * @val: The value to search */ static inline int ctpop64(uint64_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcountll(val); #else val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); return val; #endif } /* Host type specific sizes of these routines. */ #if ULONG_MAX == UINT32_MAX # define clzl clz32 # define ctzl ctz32 # define clol clo32 # define ctol cto32 # define ctpopl ctpop32 #elif ULONG_MAX == UINT64_MAX # define clzl clz64 # define ctzl ctz64 # define clol clo64 # define ctol cto64 # define ctpopl ctpop64 #else # error Unknown sizeof long #endif #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/aes.h0000644000076200007630000000012712617742532022460 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.539335665 glusterfs-3.7.6/contrib/qemu/include/qemu/aes.h0000644000076200007630000000245412617742532022676 0ustar00jenkinsjenkins00000000000000#ifndef QEMU_AES_H #define QEMU_AES_H #define AES_MAXNR 14 #define AES_BLOCK_SIZE 16 struct aes_key_st { uint32_t rd_key[4 *(AES_MAXNR + 1)]; int rounds; }; typedef struct aes_key_st AES_KEY; int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, const int enc); /* AES_Te0[x] = S [x].[02, 01, 01, 03]; AES_Te1[x] = S [x].[03, 02, 01, 01]; AES_Te2[x] = S [x].[01, 03, 02, 01]; AES_Te3[x] = S [x].[01, 01, 03, 02]; AES_Te4[x] = S [x].[01, 01, 01, 01]; AES_Td0[x] = Si[x].[0e, 09, 0d, 0b]; AES_Td1[x] = Si[x].[0b, 0e, 09, 0d]; AES_Td2[x] = Si[x].[0d, 0b, 0e, 09]; AES_Td3[x] = Si[x].[09, 0d, 0b, 0e]; AES_Td4[x] = Si[x].[01, 01, 01, 01]; */ extern const uint32_t AES_Te0[256], AES_Te1[256], AES_Te2[256], AES_Te3[256], AES_Te4[256]; extern const uint32_t AES_Td0[256], AES_Td1[256], AES_Td2[256], AES_Td3[256], AES_Td4[256]; #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/sockets.h0000644000076200007630000000013112617742532023356 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.597334792 glusterfs-3.7.6/contrib/qemu/include/qemu/sockets.h0000644000076200007630000000537212617742532023603 0ustar00jenkinsjenkins00000000000000/* headers to use the BSD sockets */ #ifndef QEMU_SOCKET_H #define QEMU_SOCKET_H #ifdef _WIN32 #include #include #include #define socket_error() WSAGetLastError() int inet_aton(const char *cp, struct in_addr *ia); #else #include #include #include #include #include #include #include #define socket_error() errno #define closesocket(s) close(s) #endif /* !_WIN32 */ #include "qemu/option.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" extern QemuOptsList socket_optslist; /* misc helpers */ int qemu_socket(int domain, int type, int protocol); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int socket_set_cork(int fd, int v); int socket_set_nodelay(int fd); void qemu_set_block(int fd); void qemu_set_nonblock(int fd); int send_all(int fd, const void *buf, int len1); int recv_all(int fd, void *buf, int len1, bool single_read); /* callback function for nonblocking connect * valid fd on success, negative error code on failure */ typedef void NonBlockingConnectHandler(int fd, void *opaque); InetSocketAddress *inet_parse(const char *str, Error **errp); int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); int inet_listen(const char *str, char *ostr, int olen, int socktype, int port_offset, Error **errp); int inet_connect_opts(QemuOpts *opts, Error **errp, NonBlockingConnectHandler *callback, void *opaque); int inet_connect(const char *str, Error **errp); int inet_nonblocking_connect(const char *str, NonBlockingConnectHandler *callback, void *opaque, Error **errp); int inet_dgram_opts(QemuOpts *opts, Error **errp); const char *inet_strfamily(int family); int unix_listen_opts(QemuOpts *opts, Error **errp); int unix_listen(const char *path, char *ostr, int olen, Error **errp); int unix_connect_opts(QemuOpts *opts, Error **errp, NonBlockingConnectHandler *callback, void *opaque); int unix_connect(const char *path, Error **errp); int unix_nonblocking_connect(const char *str, NonBlockingConnectHandler *callback, void *opaque, Error **errp); SocketAddress *socket_parse(const char *str, Error **errp); int socket_connect(SocketAddress *addr, Error **errp, NonBlockingConnectHandler *callback, void *opaque); int socket_listen(SocketAddress *addr, Error **errp); int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp); /* Old, ipv4 only bits. Don't use for new code. */ int parse_host_port(struct sockaddr_in *saddr, const char *str); int socket_init(void); #endif /* QEMU_SOCKET_H */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/iov.h0000644000076200007630000000013212617742532022501 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.571335183 glusterfs-3.7.6/contrib/qemu/include/qemu/iov.h0000644000076200007630000001067312617742532022725 0ustar00jenkinsjenkins00000000000000/* * Helpers for using (partial) iovecs. * * Copyright (C) 2010 Red Hat, Inc. * * Author(s): * Amit Shah * Michael Tokarev * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. */ #ifndef IOV_H #define IOV_H #include "qemu-common.h" /** * count and return data size, in bytes, of an iovec * starting at `iov' of `iov_cnt' number of elements. */ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); /** * Copy from single continuous buffer to scatter-gather vector of buffers * (iovec) and back like memcpy() between two continuous memory regions. * Data in single continuous buffer starting at address `buf' and * `bytes' bytes long will be copied to/from an iovec `iov' with * `iov_cnt' number of elements, starting at byte position `offset' * within the iovec. If the iovec does not contain enough space, * only part of data will be copied, up to the end of the iovec. * Number of bytes actually copied will be returned, which is * min(bytes, iov_size(iov)-offset) * `Offset' must point to the inside of iovec. * It is okay to use very large value for `bytes' since we're * limited by the size of the iovec anyway, provided that the * buffer pointed to by buf has enough space. One possible * such "large" value is -1 (sinice size_t is unsigned), * so specifying `-1' as `bytes' means 'up to the end of iovec'. */ size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, size_t offset, const void *buf, size_t bytes); size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, size_t offset, void *buf, size_t bytes); /** * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, * starting at byte offset `start', to value `fillc', repeating it * `bytes' number of times. `Offset' must point to the inside of iovec. * If `bytes' is large enough, only last bytes portion of iovec, * up to the end of it, will be filled with the specified value. * Function return actual number of bytes processed, which is * min(size, iov_size(iov) - offset). * Again, it is okay to use large value for `bytes' to mean "up to the end". */ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t offset, int fillc, size_t bytes); /* * Send/recv data from/to iovec buffers directly * * `offset' bytes in the beginning of iovec buffer are skipped and * next `bytes' bytes are used, which must be within data of iovec. * * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); * * is logically equivalent to * * char *buf = malloc(bytes); * iov_to_buf(iov, iovcnt, offset, buf, bytes); * r = send(sockfd, buf, bytes, 0); * free(buf); * * For iov_send_recv() _whole_ area being sent or received * should be within the iovec, not only beginning of it. */ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, size_t offset, size_t bytes, bool do_send); #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) #define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) /** * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements * in file `fp', prefixing each line with `prefix' and processing not more * than `limit' data bytes. */ void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, FILE *fp, const char *prefix, size_t limit); /* * Partial copy of vector from iov to dst_iov (data is not copied). * dst_iov overlaps iov at a specified offset. * size of dst_iov is at most bytes. dst vector count is returned. */ unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, const struct iovec *iov, unsigned int iov_cnt, size_t offset, size_t bytes); /* * Remove a given number of bytes from the front or back of a vector. * This may update iov and/or iov_cnt to exclude iovec elements that are * no longer required. * * The number of bytes actually discarded is returned. This number may be * smaller than requested if the vector is too small. */ size_t iov_discard_front(struct iovec **iov, unsigned int *iov_cnt, size_t bytes); size_t iov_discard_back(struct iovec *iov, unsigned int *iov_cnt, size_t bytes); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/atomic.h0000644000076200007630000000012712617742532023164 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.542335618 glusterfs-3.7.6/contrib/qemu/include/qemu/atomic.h0000644000076200007630000001514612617742532023404 0ustar00jenkinsjenkins00000000000000/* * Simple interface for atomic operations. * * Copyright (C) 2013 Red Hat, Inc. * * Author: Paolo Bonzini * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. * */ #ifndef __QEMU_ATOMIC_H #define __QEMU_ATOMIC_H 1 #include "qemu/compiler.h" /* For C11 atomic ops */ /* Compiler barrier */ #define barrier() ({ asm volatile("" ::: "memory"); (void)0; }) #ifndef __ATOMIC_RELAXED /* * We use GCC builtin if it's available, as that can use mfence on * 32-bit as well, e.g. if built with -march=pentium-m. However, on * i386 the spec is buggy, and the implementation followed it until * 4.3 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36793). */ #if defined(__i386__) || defined(__x86_64__) #if !QEMU_GNUC_PREREQ(4, 4) #if defined __x86_64__ #define smp_mb() ({ asm volatile("mfence" ::: "memory"); (void)0; }) #else #define smp_mb() ({ asm volatile("lock; addl $0,0(%%esp) " ::: "memory"); (void)0; }) #endif #endif #endif #ifdef __alpha__ #define smp_read_barrier_depends() asm volatile("mb":::"memory") #endif #if defined(__i386__) || defined(__x86_64__) || defined(__s390x__) /* * Because of the strongly ordered storage model, wmb() and rmb() are nops * here (a compiler barrier only). QEMU doesn't do accesses to write-combining * qemu memory or non-temporal load/stores from C code. */ #define smp_wmb() barrier() #define smp_rmb() barrier() /* * __sync_lock_test_and_set() is documented to be an acquire barrier only, * but it is a full barrier at the hardware level. Add a compiler barrier * to make it a full barrier also at the compiler level. */ #define atomic_xchg(ptr, i) (barrier(), __sync_lock_test_and_set(ptr, i)) /* * Load/store with Java volatile semantics. */ #define atomic_mb_set(ptr, i) ((void)atomic_xchg(ptr, i)) #elif defined(_ARCH_PPC) /* * We use an eieio() for wmb() on powerpc. This assumes we don't * need to order cacheable and non-cacheable stores with respect to * each other. * * smp_mb has the same problem as on x86 for not-very-new GCC * (http://patchwork.ozlabs.org/patch/126184/, Nov 2011). */ #define smp_wmb() ({ asm volatile("eieio" ::: "memory"); (void)0; }) #if defined(__powerpc64__) #define smp_rmb() ({ asm volatile("lwsync" ::: "memory"); (void)0; }) #else #define smp_rmb() ({ asm volatile("sync" ::: "memory"); (void)0; }) #endif #define smp_mb() ({ asm volatile("sync" ::: "memory"); (void)0; }) #endif /* _ARCH_PPC */ #endif /* C11 atomics */ /* * For (host) platforms we don't have explicit barrier definitions * for, we use the gcc __sync_synchronize() primitive to generate a * full barrier. This should be safe on all platforms, though it may * be overkill for smp_wmb() and smp_rmb(). */ #ifndef smp_mb #define smp_mb() __sync_synchronize() #endif #ifndef smp_wmb #ifdef __ATOMIC_RELEASE #define smp_wmb() __atomic_thread_fence(__ATOMIC_RELEASE) #else #define smp_wmb() __sync_synchronize() #endif #endif #ifndef smp_rmb #ifdef __ATOMIC_ACQUIRE #define smp_rmb() __atomic_thread_fence(__ATOMIC_ACQUIRE) #else #define smp_rmb() __sync_synchronize() #endif #endif #ifndef smp_read_barrier_depends #ifdef __ATOMIC_CONSUME #define smp_read_barrier_depends() __atomic_thread_fence(__ATOMIC_CONSUME) #else #define smp_read_barrier_depends() barrier() #endif #endif #ifndef atomic_read #define atomic_read(ptr) (*(__typeof__(*ptr) *volatile) (ptr)) #endif #ifndef atomic_set #define atomic_set(ptr, i) ((*(__typeof__(*ptr) *volatile) (ptr)) = (i)) #endif /* These have the same semantics as Java volatile variables. * See http://gee.cs.oswego.edu/dl/jmm/cookbook.html: * "1. Issue a StoreStore barrier (wmb) before each volatile store." * 2. Issue a StoreLoad barrier after each volatile store. * Note that you could instead issue one before each volatile load, but * this would be slower for typical programs using volatiles in which * reads greatly outnumber writes. Alternatively, if available, you * can implement volatile store as an atomic instruction (for example * XCHG on x86) and omit the barrier. This may be more efficient if * atomic instructions are cheaper than StoreLoad barriers. * 3. Issue LoadLoad and LoadStore barriers after each volatile load." * * If you prefer to think in terms of "pairing" of memory barriers, * an atomic_mb_read pairs with an atomic_mb_set. * * And for the few ia64 lovers that exist, an atomic_mb_read is a ld.acq, * while an atomic_mb_set is a st.rel followed by a memory barrier. * * These are a bit weaker than __atomic_load/store with __ATOMIC_SEQ_CST * (see docs/atomics.txt), and I'm not sure that __ATOMIC_ACQ_REL is enough. * Just always use the barriers manually by the rules above. */ #ifndef atomic_mb_read #define atomic_mb_read(ptr) ({ \ typeof(*ptr) _val = atomic_read(ptr); \ smp_rmb(); \ _val; \ }) #endif #ifndef atomic_mb_set #define atomic_mb_set(ptr, i) do { \ smp_wmb(); \ atomic_set(ptr, i); \ smp_mb(); \ } while (0) #endif #ifndef atomic_xchg #ifdef __ATOMIC_SEQ_CST #define atomic_xchg(ptr, i) ({ \ typeof(*ptr) _new = (i), _old; \ __atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ _old; \ }) #elif defined __clang__ #define atomic_xchg(ptr, i) __sync_exchange(ptr, i) #else /* __sync_lock_test_and_set() is documented to be an acquire barrier only. */ #define atomic_xchg(ptr, i) (smp_mb(), __sync_lock_test_and_set(ptr, i)) #endif #endif /* Provide shorter names for GCC atomic builtins. */ #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1) #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1) #define atomic_fetch_add __sync_fetch_and_add #define atomic_fetch_sub __sync_fetch_and_sub #define atomic_fetch_and __sync_fetch_and_and #define atomic_fetch_or __sync_fetch_and_or #define atomic_cmpxchg __sync_val_compare_and_swap /* And even shorter names that return void. */ #define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1)) #define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1)) #define atomic_add(ptr, n) ((void) __sync_fetch_and_add(ptr, n)) #define atomic_sub(ptr, n) ((void) __sync_fetch_and_sub(ptr, n)) #define atomic_and(ptr, n) ((void) __sync_fetch_and_and(ptr, n)) #define atomic_or(ptr, n) ((void) __sync_fetch_and_or(ptr, n)) #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/option_int.h0000644000076200007630000000013212617742532024066 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.587334942 glusterfs-3.7.6/contrib/qemu/include/qemu/option_int.h0000644000076200007630000000330212617742532024301 0ustar00jenkinsjenkins00000000000000/* * Commandline option parsing functions * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2009 Kevin Wolf * * 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. */ #ifndef QEMU_OPTIONS_INTERNAL_H #define QEMU_OPTIONS_INTERNAL_H #include "qemu/option.h" #include "qemu/error-report.h" struct QemuOpt { const char *name; const char *str; const QemuOptDesc *desc; union { bool boolean; uint64_t uint; } value; QemuOpts *opts; QTAILQ_ENTRY(QemuOpt) next; }; struct QemuOpts { char *id; QemuOptsList *list; Location loc; QTAILQ_HEAD(QemuOptHead, QemuOpt) head; QTAILQ_ENTRY(QemuOpts) next; }; #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/error-report.h0000644000076200007630000000013012617742532024344 xustar000000000000000030 mtime=1447019866.040471495 28 atime=1447019866.3724665 30 ctime=1447019941.558335379 glusterfs-3.7.6/contrib/qemu/include/qemu/error-report.h0000644000076200007630000000241212617742532024562 0ustar00jenkinsjenkins00000000000000/* * Error reporting * * Copyright (C) 2010 Red Hat Inc. * * Authors: * Markus Armbruster , * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef QEMU_ERROR_H #define QEMU_ERROR_H #include #include #include "qemu/compiler.h" typedef struct Location { /* all members are private to qemu-error.c */ enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; int num; const void *ptr; struct Location *prev; } Location; Location *loc_push_restore(Location *loc); Location *loc_push_none(Location *loc); Location *loc_pop(Location *loc); Location *loc_save(Location *loc); void loc_restore(Location *loc); void loc_set_none(void); void loc_set_cmdline(char **argv, int idx, int cnt); void loc_set_file(const char *fname, int lno); void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_print_loc(void); void error_set_progname(const char *argv0); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); const char *error_get_progname(void); extern bool enable_timestamp_msg; #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/timer.h0000644000076200007630000000013112617742532023023 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.606334657 glusterfs-3.7.6/contrib/qemu/include/qemu/timer.h0000644000076200007630000002001312617742532023235 0ustar00jenkinsjenkins00000000000000#ifndef QEMU_TIMER_H #define QEMU_TIMER_H #include "qemu-common.h" #include "qemu/main-loop.h" #include "qemu/notify.h" /* timers */ #define SCALE_MS 1000000 #define SCALE_US 1000 #define SCALE_NS 1 typedef struct QEMUClock QEMUClock; typedef void QEMUTimerCB(void *opaque); /* The real time clock should be used only for stuff which does not change the virtual machine state, as it is run even if the virtual machine is stopped. The real time clock has a frequency of 1000 Hz. */ extern QEMUClock *rt_clock; /* The virtual clock is only run during the emulation. It is stopped when the virtual machine is stopped. Virtual timers use a high precision clock, usually cpu cycles (use ticks_per_sec). */ extern QEMUClock *vm_clock; /* The host clock should be use for device models that emulate accurate real time sources. It will continue to run when the virtual machine is suspended, and it will reflect system time changes the host may undergo (e.g. due to NTP). The host clock has the same precision as the virtual clock. */ extern QEMUClock *host_clock; int64_t qemu_get_clock_ns(QEMUClock *clock); int64_t qemu_clock_has_timers(QEMUClock *clock); int64_t qemu_clock_expired(QEMUClock *clock); int64_t qemu_clock_deadline(QEMUClock *clock); void qemu_clock_enable(QEMUClock *clock, bool enabled); void qemu_clock_warp(QEMUClock *clock); void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); void qemu_unregister_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, QEMUTimerCB *cb, void *opaque); void qemu_free_timer(QEMUTimer *ts); void qemu_del_timer(QEMUTimer *ts); void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); bool qemu_timer_pending(QEMUTimer *ts); bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); void qemu_run_timers(QEMUClock *clock); void qemu_run_all_timers(void); void configure_alarms(char const *opt); void init_clocks(void); int init_timer_alarm(void); int64_t cpu_get_ticks(void); void cpu_enable_ticks(void); void cpu_disable_ticks(void); static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) { return qemu_new_timer(clock, SCALE_NS, cb, opaque); } static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) { return qemu_new_timer(clock, SCALE_MS, cb, opaque); } static inline int64_t qemu_get_clock_ms(QEMUClock *clock) { return qemu_get_clock_ns(clock) / SCALE_MS; } static inline int64_t get_ticks_per_sec(void) { return 1000000000LL; } /* real time host monotonic timer */ static inline int64_t get_clock_realtime(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); } /* Warning: don't insert tracepoints into these functions, they are also used by simpletrace backend and tracepoints would cause an infinite recursion! */ #ifdef _WIN32 extern int64_t clock_freq; static inline int64_t get_clock(void) { LARGE_INTEGER ti; QueryPerformanceCounter(&ti); return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); } #else extern int use_rt_clock; static inline int64_t get_clock(void) { #ifdef CLOCK_MONOTONIC if (use_rt_clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000LL + ts.tv_nsec; } else #endif { /* XXX: using gettimeofday leads to problems if the date changes, so it should be avoided. */ return get_clock_realtime(); } } #endif void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); /* icount */ int64_t cpu_get_icount(void); int64_t cpu_get_clock(void); /*******************************************/ /* host CPU ticks (if available) */ #if defined(_ARCH_PPC) static inline int64_t cpu_get_real_ticks(void) { int64_t retval; #ifdef _ARCH_PPC64 /* This reads timebase in one 64bit go and includes Cell workaround from: http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html */ __asm__ __volatile__ ("mftb %0\n\t" "cmpwi %0,0\n\t" "beq- $-8" : "=r" (retval)); #else /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ unsigned long junk; __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ "mfspr %L0,268\n\t" /* mftb */ "mfspr %0,269\n\t" /* mftbu */ "cmpw %0,%1\n\t" "bne $-16" : "=r" (retval), "=r" (junk)); #endif return retval; } #elif defined(__i386__) static inline int64_t cpu_get_real_ticks(void) { int64_t val; asm volatile ("rdtsc" : "=A" (val)); return val; } #elif defined(__x86_64__) static inline int64_t cpu_get_real_ticks(void) { uint32_t low,high; int64_t val; asm volatile("rdtsc" : "=a" (low), "=d" (high)); val = high; val <<= 32; val |= low; return val; } #elif defined(__hppa__) static inline int64_t cpu_get_real_ticks(void) { int val; asm volatile ("mfctl %%cr16, %0" : "=r"(val)); return val; } #elif defined(__ia64) static inline int64_t cpu_get_real_ticks(void) { int64_t val; asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); return val; } #elif defined(__s390__) static inline int64_t cpu_get_real_ticks(void) { int64_t val; asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); return val; } #elif defined(__sparc__) static inline int64_t cpu_get_real_ticks (void) { #if defined(_LP64) uint64_t rval; asm volatile("rd %%tick,%0" : "=r"(rval)); return rval; #else /* We need an %o or %g register for this. For recent enough gcc there is an "h" constraint for that. Don't bother with that. */ union { uint64_t i64; struct { uint32_t high; uint32_t low; } i32; } rval; asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); return rval.i64; #endif } #elif defined(__mips__) && \ ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) /* * binutils wants to use rdhwr only on mips32r2 * but as linux kernel emulate it, it's fine * to use it. * */ #define MIPS_RDHWR(rd, value) { \ __asm__ __volatile__ (".set push\n\t" \ ".set mips32r2\n\t" \ "rdhwr %0, "rd"\n\t" \ ".set pop" \ : "=r" (value)); \ } static inline int64_t cpu_get_real_ticks(void) { /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ uint32_t count; static uint32_t cyc_per_count = 0; if (!cyc_per_count) { MIPS_RDHWR("$3", cyc_per_count); } MIPS_RDHWR("$2", count); return (int64_t)(count * cyc_per_count); } #elif defined(__alpha__) static inline int64_t cpu_get_real_ticks(void) { uint64_t cc; uint32_t cur, ofs; asm volatile("rpcc %0" : "=r"(cc)); cur = cc; ofs = cc >> 32; return cur - ofs; } #else /* The host CPU doesn't have an easily accessible cycle counter. Just return a monotonically increasing value. This will be totally wrong, but hopefully better than nothing. */ static inline int64_t cpu_get_real_ticks (void) { static int64_t ticks = 0; return ticks++; } #endif #ifdef CONFIG_PROFILER static inline int64_t profile_getclock(void) { return cpu_get_real_ticks(); } extern int64_t qemu_time, qemu_time_start; extern int64_t tlb_flush_time; extern int64_t dev_time; #endif #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/thread-posix.h0000644000076200007630000000013112617742532024312 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.600334745 glusterfs-3.7.6/contrib/qemu/include/qemu/thread-posix.h0000644000076200007630000000064712617742532024537 0ustar00jenkinsjenkins00000000000000#ifndef __QEMU_THREAD_POSIX_H #define __QEMU_THREAD_POSIX_H 1 #include "pthread.h" #include struct QemuMutex { pthread_mutex_t lock; }; struct QemuCond { pthread_cond_t cond; }; struct QemuSemaphore { #if defined(__APPLE__) || defined(__NetBSD__) pthread_mutex_t lock; pthread_cond_t cond; int count; #else sem_t sem; #endif }; struct QemuThread { pthread_t thread; }; #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/module.h0000644000076200007630000000013212617742532023171 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.578335077 glusterfs-3.7.6/contrib/qemu/include/qemu/module.h0000644000076200007630000000220712617742532023407 0ustar00jenkinsjenkins00000000000000/* * QEMU Module Infrastructure * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * */ #ifndef QEMU_MODULE_H #define QEMU_MODULE_H /* This should not be used directly. Use block_init etc. instead. */ #define module_init(function, type) \ static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ register_module_init(function, type); \ } typedef enum { MODULE_INIT_BLOCK, MODULE_INIT_MACHINE, MODULE_INIT_QAPI, MODULE_INIT_QOM, MODULE_INIT_MAX } module_init_type; #define block_init(function) module_init(function, MODULE_INIT_BLOCK) #define machine_init(function) module_init(function, MODULE_INIT_MACHINE) #define qapi_init(function) module_init(function, MODULE_INIT_QAPI) #define type_init(function) module_init(function, MODULE_INIT_QOM) void register_module_init(void (*fn)(void), module_init_type type); void module_call_init(module_init_type type); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/bswap.h0000644000076200007630000000012712617742532023024 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.552335468 glusterfs-3.7.6/contrib/qemu/include/qemu/bswap.h0000644000076200007630000002212612617742532023240 0ustar00jenkinsjenkins00000000000000#ifndef BSWAP_H #define BSWAP_H #include "config-host.h" #include #include #include #include "fpu/softfloat.h" #ifdef CONFIG_MACHINE_BSWAP_H # include # include # include #elif defined(__FreeBSD__) # include #elif defined(CONFIG_BYTESWAP_H) #ifdef GF_DARWIN_HOST_OS # include #define bswap_16(x) OSSwapInt16(x) #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) #else # include #endif static inline uint16_t bswap16(uint16_t x) { return bswap_16(x); } static inline uint32_t bswap32(uint32_t x) { return bswap_32(x); } static inline uint64_t bswap64(uint64_t x) { return bswap_64(x); } # else static inline uint16_t bswap16(uint16_t x) { return (((x & 0x00ff) << 8) | ((x & 0xff00) >> 8)); } static inline uint32_t bswap32(uint32_t x) { return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) | ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24)); } static inline uint64_t bswap64(uint64_t x) { return (((x & 0x00000000000000ffULL) << 56) | ((x & 0x000000000000ff00ULL) << 40) | ((x & 0x0000000000ff0000ULL) << 24) | ((x & 0x00000000ff000000ULL) << 8) | ((x & 0x000000ff00000000ULL) >> 8) | ((x & 0x0000ff0000000000ULL) >> 24) | ((x & 0x00ff000000000000ULL) >> 40) | ((x & 0xff00000000000000ULL) >> 56)); } #endif /* ! CONFIG_MACHINE_BSWAP_H */ static inline void bswap16s(uint16_t *s) { *s = bswap16(*s); } static inline void bswap32s(uint32_t *s) { *s = bswap32(*s); } static inline void bswap64s(uint64_t *s) { *s = bswap64(*s); } #if defined(HOST_WORDS_BIGENDIAN) #define be_bswap(v, size) (v) #define le_bswap(v, size) glue(bswap, size)(v) #define be_bswaps(v, size) #define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) #else #define le_bswap(v, size) (v) #define be_bswap(v, size) glue(bswap, size)(v) #define le_bswaps(v, size) #define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) #endif #define CPU_CONVERT(endian, size, type)\ static inline type endian ## size ## _to_cpu(type v)\ {\ return glue(endian, _bswap)(v, size);\ }\ \ static inline type cpu_to_ ## endian ## size(type v)\ {\ return glue(endian, _bswap)(v, size);\ }\ \ static inline void endian ## size ## _to_cpus(type *p)\ {\ glue(endian, _bswaps)(p, size);\ }\ \ static inline void cpu_to_ ## endian ## size ## s(type *p)\ {\ glue(endian, _bswaps)(p, size);\ }\ \ static inline type endian ## size ## _to_cpup(const type *p)\ {\ return glue(glue(endian, size), _to_cpu)(*p);\ }\ \ static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ {\ *p = glue(glue(cpu_to_, endian), size)(v);\ } CPU_CONVERT(be, 16, uint16_t) CPU_CONVERT(be, 32, uint32_t) CPU_CONVERT(be, 64, uint64_t) CPU_CONVERT(le, 16, uint16_t) CPU_CONVERT(le, 32, uint32_t) CPU_CONVERT(le, 64, uint64_t) /* len must be one of 1, 2, 4 */ static inline uint32_t qemu_bswap_len(uint32_t value, int len) { return bswap32(value) >> (32 - 8 * len); } /* Unions for reinterpreting between floats and integers. */ typedef union { float32 f; uint32_t l; } CPU_FloatU; typedef union { float64 d; #if defined(HOST_WORDS_BIGENDIAN) struct { uint32_t upper; uint32_t lower; } l; #else struct { uint32_t lower; uint32_t upper; } l; #endif uint64_t ll; } CPU_DoubleU; typedef union { floatx80 d; struct { uint64_t lower; uint16_t upper; } l; } CPU_LDoubleU; typedef union { float128 q; #if defined(HOST_WORDS_BIGENDIAN) struct { uint32_t upmost; uint32_t upper; uint32_t lower; uint32_t lowest; } l; struct { uint64_t upper; uint64_t lower; } ll; #else struct { uint32_t lowest; uint32_t lower; uint32_t upper; uint32_t upmost; } l; struct { uint64_t lower; uint64_t upper; } ll; #endif } CPU_QuadU; /* unaligned/endian-independent pointer access */ /* * the generic syntax is: * * load: ld{type}{sign}{size}{endian}_p(ptr) * * store: st{type}{size}{endian}_p(ptr, val) * * Note there are small differences with the softmmu access API! * * type is: * (empty): integer access * f : float access * * sign is: * (empty): for floats or 32 bit size * u : unsigned * s : signed * * size is: * b: 8 bits * w: 16 bits * l: 32 bits * q: 64 bits * * endian is: * (empty): host endian * be : big endian * le : little endian */ static inline int ldub_p(const void *ptr) { return *(uint8_t *)ptr; } static inline int ldsb_p(const void *ptr) { return *(int8_t *)ptr; } static inline void stb_p(void *ptr, int v) { *(uint8_t *)ptr = v; } /* Any compiler worth its salt will turn these memcpy into native unaligned operations. Thus we don't need to play games with packed attributes, or inline byte-by-byte stores. */ static inline int lduw_p(const void *ptr) { uint16_t r; memcpy(&r, ptr, sizeof(r)); return r; } static inline int ldsw_p(const void *ptr) { int16_t r; memcpy(&r, ptr, sizeof(r)); return r; } static inline void stw_p(void *ptr, uint16_t v) { memcpy(ptr, &v, sizeof(v)); } static inline int ldl_p(const void *ptr) { int32_t r; memcpy(&r, ptr, sizeof(r)); return r; } static inline void stl_p(void *ptr, uint32_t v) { memcpy(ptr, &v, sizeof(v)); } static inline uint64_t ldq_p(const void *ptr) { uint64_t r; memcpy(&r, ptr, sizeof(r)); return r; } static inline void stq_p(void *ptr, uint64_t v) { memcpy(ptr, &v, sizeof(v)); } static inline int lduw_le_p(const void *ptr) { return (uint16_t)le_bswap(lduw_p(ptr), 16); } static inline int ldsw_le_p(const void *ptr) { return (int16_t)le_bswap(lduw_p(ptr), 16); } static inline int ldl_le_p(const void *ptr) { return le_bswap(ldl_p(ptr), 32); } static inline uint64_t ldq_le_p(const void *ptr) { return le_bswap(ldq_p(ptr), 64); } static inline void stw_le_p(void *ptr, int v) { stw_p(ptr, le_bswap(v, 16)); } static inline void stl_le_p(void *ptr, int v) { stl_p(ptr, le_bswap(v, 32)); } static inline void stq_le_p(void *ptr, uint64_t v) { stq_p(ptr, le_bswap(v, 64)); } /* float access */ static inline float32 ldfl_le_p(const void *ptr) { CPU_FloatU u; u.l = ldl_le_p(ptr); return u.f; } static inline void stfl_le_p(void *ptr, float32 v) { CPU_FloatU u; u.f = v; stl_le_p(ptr, u.l); } static inline float64 ldfq_le_p(const void *ptr) { CPU_DoubleU u; u.ll = ldq_le_p(ptr); return u.d; } static inline void stfq_le_p(void *ptr, float64 v) { CPU_DoubleU u; u.d = v; stq_le_p(ptr, u.ll); } static inline int lduw_be_p(const void *ptr) { return (uint16_t)be_bswap(lduw_p(ptr), 16); } static inline int ldsw_be_p(const void *ptr) { return (int16_t)be_bswap(lduw_p(ptr), 16); } static inline int ldl_be_p(const void *ptr) { return be_bswap(ldl_p(ptr), 32); } static inline uint64_t ldq_be_p(const void *ptr) { return be_bswap(ldq_p(ptr), 64); } static inline void stw_be_p(void *ptr, int v) { stw_p(ptr, be_bswap(v, 16)); } static inline void stl_be_p(void *ptr, int v) { stl_p(ptr, be_bswap(v, 32)); } static inline void stq_be_p(void *ptr, uint64_t v) { stq_p(ptr, be_bswap(v, 64)); } /* float access */ static inline float32 ldfl_be_p(const void *ptr) { CPU_FloatU u; u.l = ldl_be_p(ptr); return u.f; } static inline void stfl_be_p(void *ptr, float32 v) { CPU_FloatU u; u.f = v; stl_be_p(ptr, u.l); } static inline float64 ldfq_be_p(const void *ptr) { CPU_DoubleU u; u.ll = ldq_be_p(ptr); return u.d; } static inline void stfq_be_p(void *ptr, float64 v) { CPU_DoubleU u; u.d = v; stq_be_p(ptr, u.ll); } /* Legacy unaligned versions. Note that we never had a complete set. */ static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) { stw_le_p(p, v); } static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) { stl_le_p(p, v); } static inline uint16_t le16_to_cpupu(const uint16_t *p) { return lduw_le_p(p); } static inline uint32_t le32_to_cpupu(const uint32_t *p) { return ldl_le_p(p); } static inline uint32_t be32_to_cpupu(const uint32_t *p) { return ldl_be_p(p); } static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) { stw_be_p(p, v); } static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) { stl_be_p(p, v); } static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) { stq_be_p(p, v); } static inline void cpu_to_32wu(uint32_t *p, uint32_t v) { stl_p(p, v); } static inline unsigned long leul_to_cpu(unsigned long v) { /* In order to break an include loop between here and qemu-common.h, don't rely on HOST_LONG_BITS. */ #if ULONG_MAX == UINT32_MAX return le_bswap(v, 32); #elif ULONG_MAX == UINT64_MAX return le_bswap(v, 64); #else # error Unknown sizeof long #endif } #undef le_bswap #undef be_bswap #undef le_bswaps #undef be_bswaps #endif /* BSWAP_H */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/bitops.h0000644000076200007630000000012712617742532023210 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.549335514 glusterfs-3.7.6/contrib/qemu/include/qemu/bitops.h0000644000076200007630000002001012617742532023412 0ustar00jenkinsjenkins00000000000000/* * Bitops Module * * Copyright (C) 2010 Corentin Chary * * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef BITOPS_H #define BITOPS_H #include "qemu-common.h" #include "host-utils.h" #define BITS_PER_BYTE CHAR_BIT #define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) #define BIT(nr) (1UL << (nr)) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) /** * set_bit - Set a bit in memory * @nr: the bit to set * @addr: the address to start counting from */ static inline void set_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); *p |= mask; } /** * clear_bit - Clears a bit in memory * @nr: Bit to clear * @addr: Address to start counting from */ static inline void clear_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); *p &= ~mask; } /** * change_bit - Toggle a bit in memory * @nr: Bit to change * @addr: Address to start counting from */ static inline void change_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); *p ^= mask; } /** * test_and_set_bit - Set a bit and return its old value * @nr: Bit to set * @addr: Address to count from */ static inline int test_and_set_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); unsigned long old = *p; *p = old | mask; return (old & mask) != 0; } /** * test_and_clear_bit - Clear a bit and return its old value * @nr: Bit to clear * @addr: Address to count from */ static inline int test_and_clear_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); unsigned long old = *p; *p = old & ~mask; return (old & mask) != 0; } /** * test_and_change_bit - Change a bit and return its old value * @nr: Bit to change * @addr: Address to count from */ static inline int test_and_change_bit(int nr, unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = addr + BIT_WORD(nr); unsigned long old = *p; *p = old ^ mask; return (old & mask) != 0; } /** * test_bit - Determine whether a bit is set * @nr: bit number to test * @addr: Address to start counting from */ static inline int test_bit(int nr, const unsigned long *addr) { return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); } /** * find_last_bit - find the last set bit in a memory region * @addr: The address to start the search at * @size: The maximum size to search * * Returns the bit number of the first set bit, or size. */ unsigned long find_last_bit(const unsigned long *addr, unsigned long size); /** * find_next_bit - find the next set bit in a memory region * @addr: The address to base the search on * @offset: The bitnumber to start searching at * @size: The bitmap size in bits */ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset); /** * find_next_zero_bit - find the next cleared bit in a memory region * @addr: The address to base the search on * @offset: The bitnumber to start searching at * @size: The bitmap size in bits */ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset); /** * find_first_bit - find the first set bit in a memory region * @addr: The address to start the search at * @size: The maximum size to search * * Returns the bit number of the first set bit. */ static inline unsigned long find_first_bit(const unsigned long *addr, unsigned long size) { return find_next_bit(addr, size, 0); } /** * find_first_zero_bit - find the first cleared bit in a memory region * @addr: The address to start the search at * @size: The maximum size to search * * Returns the bit number of the first cleared bit. */ static inline unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) { return find_next_zero_bit(addr, size, 0); } static inline unsigned long hweight_long(unsigned long w) { unsigned long count; for (count = 0; w; w >>= 1) { count += w & 1; } return count; } /** * extract32: * @value: the value to extract the bit field from * @start: the lowest bit in the bit field (numbered from 0) * @length: the length of the bit field * * Extract from the 32 bit input @value the bit field specified by the * @start and @length parameters, and return it. The bit field must * lie entirely within the 32 bit word. It is valid to request that * all 32 bits are returned (ie @length 32 and @start 0). * * Returns: the value of the bit field extracted from the input value. */ static inline uint32_t extract32(uint32_t value, int start, int length) { assert(start >= 0 && length > 0 && length <= 32 - start); return (value >> start) & (~0U >> (32 - length)); } /** * extract64: * @value: the value to extract the bit field from * @start: the lowest bit in the bit field (numbered from 0) * @length: the length of the bit field * * Extract from the 64 bit input @value the bit field specified by the * @start and @length parameters, and return it. The bit field must * lie entirely within the 64 bit word. It is valid to request that * all 64 bits are returned (ie @length 64 and @start 0). * * Returns: the value of the bit field extracted from the input value. */ static inline uint64_t extract64(uint64_t value, int start, int length) { assert(start >= 0 && length > 0 && length <= 64 - start); return (value >> start) & (~0ULL >> (64 - length)); } /** * deposit32: * @value: initial value to insert bit field into * @start: the lowest bit in the bit field (numbered from 0) * @length: the length of the bit field * @fieldval: the value to insert into the bit field * * Deposit @fieldval into the 32 bit @value at the bit field specified * by the @start and @length parameters, and return the modified * @value. Bits of @value outside the bit field are not modified. * Bits of @fieldval above the least significant @length bits are * ignored. The bit field must lie entirely within the 32 bit word. * It is valid to request that all 32 bits are modified (ie @length * 32 and @start 0). * * Returns: the modified @value. */ static inline uint32_t deposit32(uint32_t value, int start, int length, uint32_t fieldval) { uint32_t mask; assert(start >= 0 && length > 0 && length <= 32 - start); mask = (~0U >> (32 - length)) << start; return (value & ~mask) | ((fieldval << start) & mask); } /** * deposit64: * @value: initial value to insert bit field into * @start: the lowest bit in the bit field (numbered from 0) * @length: the length of the bit field * @fieldval: the value to insert into the bit field * * Deposit @fieldval into the 64 bit @value at the bit field specified * by the @start and @length parameters, and return the modified * @value. Bits of @value outside the bit field are not modified. * Bits of @fieldval above the least significant @length bits are * ignored. The bit field must lie entirely within the 64 bit word. * It is valid to request that all 64 bits are modified (ie @length * 64 and @start 0). * * Returns: the modified @value. */ static inline uint64_t deposit64(uint64_t value, int start, int length, uint64_t fieldval) { uint64_t mask; assert(start >= 0 && length > 0 && length <= 64 - start); mask = (~0ULL >> (64 - length)) << start; return (value & ~mask) | ((fieldval << start) & mask); } #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/osdep.h0000644000076200007630000000013112617742532023015 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.590334897 glusterfs-3.7.6/contrib/qemu/include/qemu/osdep.h0000644000076200007630000001241312617742532023234 0ustar00jenkinsjenkins00000000000000#ifndef QEMU_OSDEP_H #define QEMU_OSDEP_H #include "config-host.h" #include #include #include #include #ifdef __OpenBSD__ #include #endif #ifndef _WIN32 #include #else #define WIFEXITED(x) 1 #define WEXITSTATUS(x) (x) #endif #include #if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 /* [u]int_fast*_t not in */ typedef unsigned char uint_fast8_t; typedef unsigned int uint_fast16_t; typedef signed int int_fast16_t; #endif #ifndef glue #define xglue(x, y) x ## y #define glue(x, y) xglue(x, y) #define stringify(s) tostring(s) #define tostring(s) #s #endif #ifndef likely #if __GNUC__ < 3 #define __builtin_expect(x, n) (x) #endif #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif #ifndef container_of #define container_of(ptr, type, member) ({ \ const typeof(((type *) 0)->member) *__mptr = (ptr); \ (type *) ((char *) __mptr - offsetof(type, member));}) #endif /* Convert from a base type to a parent type, with compile time checking. */ #ifdef __GNUC__ #define DO_UPCAST(type, field, dev) ( __extension__ ( { \ char __attribute__((unused)) offset_must_be_zero[ \ -offsetof(type, field)]; \ container_of(dev, type, field);})) #else #define DO_UPCAST(type, field, dev) container_of(dev, type, field) #endif #define typeof_field(type, field) typeof(((type *)0)->field) #define type_check(t1,t2) ((t1*)0 - (t2*)0) #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif #ifndef ROUND_UP #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d)) #endif #ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) #endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif #ifndef always_inline #if !((__GNUC__ < 3) || defined(__APPLE__)) #ifdef __OPTIMIZE__ #undef inline #define inline __attribute__ (( always_inline )) __inline__ #endif #endif #else #undef inline #define inline always_inline #endif #define qemu_printf printf int qemu_daemon(int nochdir, int noclose); void *qemu_memalign(size_t alignment, size_t size); void *qemu_anon_ram_alloc(size_t size); void qemu_vfree(void *ptr); void qemu_anon_ram_free(void *ptr, size_t size); #define QEMU_MADV_INVALID -1 #if defined(CONFIG_MADVISE) #define QEMU_MADV_WILLNEED MADV_WILLNEED #define QEMU_MADV_DONTNEED MADV_DONTNEED #ifdef MADV_DONTFORK #define QEMU_MADV_DONTFORK MADV_DONTFORK #else #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID #endif #ifdef MADV_MERGEABLE #define QEMU_MADV_MERGEABLE MADV_MERGEABLE #else #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID #endif #ifdef MADV_DONTDUMP #define QEMU_MADV_DONTDUMP MADV_DONTDUMP #else #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID #endif #ifdef MADV_HUGEPAGE #define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE #else #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #endif #elif defined(CONFIG_POSIX_MADVISE) #define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED #define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #else /* no-op */ #define QEMU_MADV_WILLNEED QEMU_MADV_INVALID #define QEMU_MADV_DONTNEED QEMU_MADV_INVALID #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #endif int qemu_madvise(void *addr, size_t len, int advice); int qemu_open(const char *name, int flags, ...); int qemu_close(int fd); #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" #elif defined(WIN64) #define FMT_pid "%" PRId64 #else #define FMT_pid "%d" #endif int qemu_create_pidfile(const char *filename); int qemu_get_thread_id(void); #ifndef CONFIG_IOVEC struct iovec { void *iov_base; size_t iov_len; }; /* * Use the same value as Linux for now. */ #define IOV_MAX 1024 ssize_t readv(int fd, const struct iovec *iov, int iov_cnt); ssize_t writev(int fd, const struct iovec *iov, int iov_cnt); #else #include #endif #ifdef _WIN32 static inline void qemu_timersub(const struct timeval *val1, const struct timeval *val2, struct timeval *res) { res->tv_sec = val1->tv_sec - val2->tv_sec; if (val1->tv_usec < val2->tv_usec) { res->tv_sec--; res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; } else { res->tv_usec = val1->tv_usec - val2->tv_usec; } } #else #define qemu_timersub timersub #endif void qemu_set_cloexec(int fd); void qemu_set_version(const char *); const char *qemu_get_version(void); void fips_set_state(bool requested); bool fips_get_state(void); /* Return a dynamically allocated pathname denoting a file or directory that is * appropriate for storing local state. * * @relative_pathname need not start with a directory separator; one will be * added automatically. * * The caller is responsible for releasing the value returned with g_free() * after use. */ char *qemu_get_local_state_pathname(const char *relative_pathname); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/option.h0000644000076200007630000000013212617742532023214 xustar000000000000000030 mtime=1447019866.040471495 30 atime=1447019866.373466485 30 ctime=1447019941.584334987 glusterfs-3.7.6/contrib/qemu/include/qemu/option.h0000644000076200007630000001435112617742532023435 0ustar00jenkinsjenkins00000000000000/* * Commandline option parsing functions * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2009 Kevin Wolf * * 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. */ #ifndef QEMU_OPTIONS_H #define QEMU_OPTIONS_H #include #include "qemu/queue.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" enum QEMUOptionParType { OPT_FLAG, OPT_NUMBER, OPT_SIZE, OPT_STRING, }; typedef struct QEMUOptionParameter { const char *name; enum QEMUOptionParType type; union { uint64_t n; char* s; } value; const char *help; } QEMUOptionParameter; const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); const char *get_opt_value(char *buf, int buf_size, const char *p); int get_next_param_value(char *buf, int buf_size, const char *tag, const char **pstr); int get_param_value(char *buf, int buf_size, const char *tag, const char *str); /* * The following functions take a parameter list as input. This is a pointer to * the first element of a QEMUOptionParameter array which is terminated by an * entry with entry->name == NULL. */ QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, const char *name); int set_option_parameter(QEMUOptionParameter *list, const char *name, const char *value); int set_option_parameter_int(QEMUOptionParameter *list, const char *name, uint64_t value); QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, QEMUOptionParameter *list); QEMUOptionParameter *parse_option_parameters(const char *param, QEMUOptionParameter *list, QEMUOptionParameter *dest); void free_option_parameters(QEMUOptionParameter *list); void print_option_parameters(QEMUOptionParameter *list); void print_option_help(QEMUOptionParameter *list); /* ------------------------------------------------------------------ */ typedef struct QemuOpt QemuOpt; typedef struct QemuOpts QemuOpts; typedef struct QemuOptsList QemuOptsList; enum QemuOptType { QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ QEMU_OPT_BOOL, /* on/off */ QEMU_OPT_NUMBER, /* simple number */ QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ }; typedef struct QemuOptDesc { const char *name; enum QemuOptType type; const char *help; } QemuOptDesc; struct QemuOptsList { const char *name; const char *implied_opt_name; bool merge_lists; /* Merge multiple uses of option into a single list? */ QTAILQ_HEAD(, QemuOpts) head; QemuOptDesc desc[]; }; const char *qemu_opt_get(QemuOpts *opts, const char *name); /** * qemu_opt_has_help_opt: * @opts: options to search for a help request * * Check whether the options specified by @opts include one of the * standard strings which indicate that the user is asking for a * list of the valid values for a command line option (as defined * by is_help_option()). * * Returns: true if @opts includes 'help' or equivalent. */ bool qemu_opt_has_help_opt(QemuOpts *opts); bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, Error **errp); int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, int abort_on_failure); QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists, Error **errp); QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); void qemu_opts_reset(QemuOptsList *list); void qemu_opts_loc_restore(QemuOpts *opts); int qemu_opts_set(QemuOptsList *list, const char *id, const char *name, const char *value); const char *qemu_opts_id(QemuOpts *opts); void qemu_opts_del(QemuOpts *opts); void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); void qemu_opts_set_defaults(QemuOptsList *list, const char *params, int permit_abbrev); QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, Error **errp); QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp); typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); int qemu_opts_print(QemuOpts *opts, void *dummy); int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, int abort_on_failure); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/hbitmap.h0000644000076200007630000000013012617742532023326 xustar000000000000000030 mtime=1447019866.040471495 28 atime=1447019866.3724665 30 ctime=1447019941.565335272 glusterfs-3.7.6/contrib/qemu/include/qemu/hbitmap.h0000644000076200007630000001316312617742532023551 0ustar00jenkinsjenkins00000000000000/* * Hierarchical Bitmap Data Type * * Copyright Red Hat, Inc., 2012 * * Author: Paolo Bonzini * * This work is licensed under the terms of the GNU GPL, version 2 or * later. See the COPYING file in the top-level directory. */ #ifndef HBITMAP_H #define HBITMAP_H 1 #include #include #include #include "bitops.h" #include "host-utils.h" typedef struct HBitmap HBitmap; typedef struct HBitmapIter HBitmapIter; #define BITS_PER_LEVEL (BITS_PER_LONG == 32 ? 5 : 6) /* For 32-bit, the largest that fits in a 4 GiB address space. * For 64-bit, the number of sectors in 1 PiB. Good luck, in * either case... :) */ #define HBITMAP_LOG_MAX_SIZE (BITS_PER_LONG == 32 ? 34 : 41) /* We need to place a sentinel in level 0 to speed up iteration. Thus, * we do this instead of HBITMAP_LOG_MAX_SIZE / BITS_PER_LEVEL. The * difference is that it allocates an extra level when HBITMAP_LOG_MAX_SIZE * is an exact multiple of BITS_PER_LEVEL. */ #define HBITMAP_LEVELS ((HBITMAP_LOG_MAX_SIZE / BITS_PER_LEVEL) + 1) struct HBitmapIter { const HBitmap *hb; /* Copied from hb for access in the inline functions (hb is opaque). */ int granularity; /* Entry offset into the last-level array of longs. */ size_t pos; /* The currently-active path in the tree. Each item of cur[i] stores * the bits (i.e. the subtrees) yet to be processed under that node. */ unsigned long cur[HBITMAP_LEVELS]; }; /** * hbitmap_alloc: * @size: Number of bits in the bitmap. * @granularity: Granularity of the bitmap. Aligned groups of 2^@granularity * bits will be represented by a single bit. Each operation on a * range of bits first rounds the bits to determine which group they land * in, and then affect the entire set; iteration will only visit the first * bit of each group. * * Allocate a new HBitmap. */ HBitmap *hbitmap_alloc(uint64_t size, int granularity); /** * hbitmap_empty: * @hb: HBitmap to operate on. * * Return whether the bitmap is empty. */ bool hbitmap_empty(const HBitmap *hb); /** * hbitmap_granularity: * @hb: HBitmap to operate on. * * Return the granularity of the HBitmap. */ int hbitmap_granularity(const HBitmap *hb); /** * hbitmap_count: * @hb: HBitmap to operate on. * * Return the number of bits set in the HBitmap. */ uint64_t hbitmap_count(const HBitmap *hb); /** * hbitmap_set: * @hb: HBitmap to operate on. * @start: First bit to set (0-based). * @count: Number of bits to set. * * Set a consecutive range of bits in an HBitmap. */ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count); /** * hbitmap_reset: * @hb: HBitmap to operate on. * @start: First bit to reset (0-based). * @count: Number of bits to reset. * * Reset a consecutive range of bits in an HBitmap. */ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count); /** * hbitmap_get: * @hb: HBitmap to operate on. * @item: Bit to query (0-based). * * Return whether the @item-th bit in an HBitmap is set. */ bool hbitmap_get(const HBitmap *hb, uint64_t item); /** * hbitmap_free: * @hb: HBitmap to operate on. * * Free an HBitmap and all of its associated memory. */ void hbitmap_free(HBitmap *hb); /** * hbitmap_iter_init: * @hbi: HBitmapIter to initialize. * @hb: HBitmap to iterate on. * @first: First bit to visit (0-based, must be strictly less than the * size of the bitmap). * * Set up @hbi to iterate on the HBitmap @hb. hbitmap_iter_next will return * the lowest-numbered bit that is set in @hb, starting at @first. * * Concurrent setting of bits is acceptable, and will at worst cause the * iteration to miss some of those bits. Resetting bits before the current * position of the iterator is also okay. However, concurrent resetting of * bits can lead to unexpected behavior if the iterator has not yet reached * those bits. */ void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first); /* hbitmap_iter_skip_words: * @hbi: HBitmapIter to operate on. * * Internal function used by hbitmap_iter_next and hbitmap_iter_next_word. */ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi); /** * hbitmap_iter_next: * @hbi: HBitmapIter to operate on. * * Return the next bit that is set in @hbi's associated HBitmap, * or -1 if all remaining bits are zero. */ static inline int64_t hbitmap_iter_next(HBitmapIter *hbi) { unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1]; int64_t item; if (cur == 0) { cur = hbitmap_iter_skip_words(hbi); if (cur == 0) { return -1; } } /* The next call will resume work from the next bit. */ hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1); item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur); return item << hbi->granularity; } /** * hbitmap_iter_next_word: * @hbi: HBitmapIter to operate on. * @p_cur: Location where to store the next non-zero word. * * Return the index of the next nonzero word that is set in @hbi's * associated HBitmap, and set *p_cur to the content of that word * (bits before the index that was passed to hbitmap_iter_init are * trimmed on the first call). Return -1, and set *p_cur to zero, * if all remaining words are zero. */ static inline size_t hbitmap_iter_next_word(HBitmapIter *hbi, unsigned long *p_cur) { unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1]; if (cur == 0) { cur = hbitmap_iter_skip_words(hbi); if (cur == 0) { *p_cur = 0; return -1; } } /* The next call will resume work from the next word. */ hbi->cur[HBITMAP_LEVELS - 1] = 0; *p_cur = cur; return hbi->pos; } #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/compiler.h0000644000076200007630000000013012617742532023514 xustar000000000000000030 mtime=1447019866.040471495 28 atime=1447019866.3724665 30 ctime=1447019941.555335423 glusterfs-3.7.6/contrib/qemu/include/qemu/compiler.h0000644000076200007630000000331012617742532023730 0ustar00jenkinsjenkins00000000000000/* public domain */ #ifndef COMPILER_H #define COMPILER_H #include "config-host.h" /*---------------------------------------------------------------------------- | The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. | The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. *----------------------------------------------------------------------------*/ #if defined(__GNUC__) && defined(__GNUC_MINOR__) # define QEMU_GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) #else # define QEMU_GNUC_PREREQ(maj, min) 0 #endif #define QEMU_NORETURN __attribute__ ((__noreturn__)) #if QEMU_GNUC_PREREQ(3, 4) #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #else #define QEMU_WARN_UNUSED_RESULT #endif #if defined(_WIN32) # define QEMU_PACKED __attribute__((gcc_struct, packed)) #else # define QEMU_PACKED __attribute__((packed)) #endif #define cat(x,y) x ## y #define cat2(x,y) cat(x,y) #define QEMU_BUILD_BUG_ON(x) \ typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused)); #if defined __GNUC__ # if !QEMU_GNUC_PREREQ(4, 4) /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) # else /* Use gnu_printf when supported (qemu uses standard format strings). */ # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) # if defined(_WIN32) /* Map __printf__ to __gnu_printf__ because we want standard format strings * even when MinGW or GLib include files use __printf__. */ # define __printf__ __gnu_printf__ # endif # endif #else #define GCC_FMT_ATTR(n, m) #endif #endif /* COMPILER_H */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/bitmap.h0000644000076200007630000000012712617742532023164 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.545335574 glusterfs-3.7.6/contrib/qemu/include/qemu/bitmap.h0000644000076200007630000001644712617742532023411 0ustar00jenkinsjenkins00000000000000/* * Bitmap Module * * Copyright (C) 2010 Corentin Chary * * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #ifndef BITMAP_H #define BITMAP_H #include "qemu-common.h" #include "qemu/bitops.h" /* * The available bitmap operations and their rough meaning in the * case that the bitmap is a single unsigned long are thus: * * Note that nbits should be always a compile time evaluable constant. * Otherwise many inlines will generate horrible code. * * bitmap_zero(dst, nbits) *dst = 0UL * bitmap_fill(dst, nbits) *dst = ~0UL * bitmap_copy(dst, src, nbits) *dst = *src * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) * bitmap_complement(dst, src, nbits) *dst = ~(*src) * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? * bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_set(dst, pos, nbits) Set specified bit area * bitmap_clear(dst, pos, nbits) Clear specified bit area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area */ /* * Also the following operations apply to bitmaps. * * set_bit(bit, addr) *addr |= bit * clear_bit(bit, addr) *addr &= ~bit * change_bit(bit, addr) *addr ^= bit * test_bit(bit, addr) Is bit set in *addr? * test_and_set_bit(bit, addr) Set bit and return old value * test_and_clear_bit(bit, addr) Clear bit and return old value * test_and_change_bit(bit, addr) Change bit and return old value * find_first_zero_bit(addr, nbits) Position first zero bit in *addr * find_first_bit(addr, nbits) Position first set bit in *addr * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit */ #define BITMAP_LAST_WORD_MASK(nbits) \ ( \ ((nbits) % BITS_PER_LONG) ? \ (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ ) #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] #define small_nbits(nbits) \ ((nbits) <= BITS_PER_LONG) int slow_bitmap_empty(const unsigned long *bitmap, int bits); int slow_bitmap_full(const unsigned long *bitmap, int bits); int slow_bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, int bits); void slow_bitmap_shift_right(unsigned long *dst, const unsigned long *src, int shift, int bits); void slow_bitmap_shift_left(unsigned long *dst, const unsigned long *src, int shift, int bits); int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); int slow_bitmap_intersects(const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); static inline unsigned long *bitmap_new(int nbits) { int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); return g_malloc0(len); } static inline void bitmap_zero(unsigned long *dst, int nbits) { if (small_nbits(nbits)) { *dst = 0UL; } else { int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); memset(dst, 0, len); } } static inline void bitmap_fill(unsigned long *dst, int nbits) { size_t nlongs = BITS_TO_LONGS(nbits); if (!small_nbits(nbits)) { int len = (nlongs - 1) * sizeof(unsigned long); memset(dst, 0xff, len); } dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); } static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, int nbits) { if (small_nbits(nbits)) { *dst = *src; } else { int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); memcpy(dst, src, len); } } static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { return (*dst = *src1 & *src2) != 0; } return slow_bitmap_and(dst, src1, src2, nbits); } static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { *dst = *src1 | *src2; } else { slow_bitmap_or(dst, src1, src2, nbits); } } static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { *dst = *src1 ^ *src2; } else { slow_bitmap_xor(dst, src1, src2, nbits); } } static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { return (*dst = *src1 & ~(*src2)) != 0; } return slow_bitmap_andnot(dst, src1, src2, nbits); } static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, int nbits) { if (small_nbits(nbits)) { *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); } else { slow_bitmap_complement(dst, src, nbits); } } static inline int bitmap_equal(const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); } else { return slow_bitmap_equal(src1, src2, nbits); } } static inline int bitmap_empty(const unsigned long *src, int nbits) { if (small_nbits(nbits)) { return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); } else { return slow_bitmap_empty(src, nbits); } } static inline int bitmap_full(const unsigned long *src, int nbits) { if (small_nbits(nbits)) { return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); } else { return slow_bitmap_full(src, nbits); } } static inline int bitmap_intersects(const unsigned long *src1, const unsigned long *src2, int nbits) { if (small_nbits(nbits)) { return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; } else { return slow_bitmap_intersects(src1, src2, nbits); } } void bitmap_set(unsigned long *map, int i, int len); void bitmap_clear(unsigned long *map, int start, int nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long align_mask); #endif /* BITMAP_H */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/thread.h0000644000076200007630000000013112617742532023152 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.603334703 glusterfs-3.7.6/contrib/qemu/include/qemu/thread.h0000644000076200007630000000321712617742532023373 0ustar00jenkinsjenkins00000000000000#ifndef __QEMU_THREAD_H #define __QEMU_THREAD_H 1 #include #include typedef struct QemuMutex QemuMutex; typedef struct QemuCond QemuCond; typedef struct QemuSemaphore QemuSemaphore; typedef struct QemuThread QemuThread; #ifdef _WIN32 #include "qemu/thread-win32.h" #else #include "qemu/thread-posix.h" #endif #define QEMU_THREAD_JOINABLE 0 #define QEMU_THREAD_DETACHED 1 void qemu_mutex_init(QemuMutex *mutex); void qemu_mutex_destroy(QemuMutex *mutex); void qemu_mutex_lock(QemuMutex *mutex); int qemu_mutex_trylock(QemuMutex *mutex); void qemu_mutex_unlock(QemuMutex *mutex); #define rcu_read_lock() do { } while (0) #define rcu_read_unlock() do { } while (0) void qemu_cond_init(QemuCond *cond); void qemu_cond_destroy(QemuCond *cond); /* * IMPORTANT: The implementation does not guarantee that pthread_cond_signal * and pthread_cond_broadcast can be called except while the same mutex is * held as in the corresponding pthread_cond_wait calls! */ void qemu_cond_signal(QemuCond *cond); void qemu_cond_broadcast(QemuCond *cond); void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); void qemu_sem_init(QemuSemaphore *sem, int init); void qemu_sem_post(QemuSemaphore *sem); void qemu_sem_wait(QemuSemaphore *sem); int qemu_sem_timedwait(QemuSemaphore *sem, int ms); void qemu_sem_destroy(QemuSemaphore *sem); void qemu_thread_create(QemuThread *thread, void *(*start_routine)(void *), void *arg, int mode); void *qemu_thread_join(QemuThread *thread); void qemu_thread_get_self(QemuThread *thread); bool qemu_thread_is_self(QemuThread *thread); void qemu_thread_exit(void *retval); #endif glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/queue.h0000644000076200007630000000013112617742532023027 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.594334837 glusterfs-3.7.6/contrib/qemu/include/qemu/queue.h0000644000076200007630000004703112617742532023252 0ustar00jenkinsjenkins00000000000000/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ /* * QEMU version: Copy from netbsd, removed debug code, removed some of * the implementations. Left in singly-linked lists, lists, simple * queues, and tail queues. */ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. 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. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 */ #ifndef QEMU_SYS_QUEUE_H_ #define QEMU_SYS_QUEUE_H_ /* * This file defines four types of data structures: singly-linked lists, * lists, simple queues, and tail queues. * * A singly-linked list is headed by a single forward pointer. The * elements are singly linked for minimum space and pointer manipulation * overhead at the expense of O(n) removal for arbitrary elements. New * elements can be added to the list after an existing element or at the * head of the list. Elements being removed from the head of the list * should use the explicit macro for this purpose for optimum * efficiency. A singly-linked list may only be traversed in the forward * direction. Singly-linked lists are ideal for applications with large * datasets and few or no removals or for implementing a LIFO queue. * * A list is headed by a single forward pointer (or an array of forward * pointers for a hash table header). The elements are doubly linked * so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before * or after an existing element or at the head of the list. A list * may only be traversed in the forward direction. * * A simple queue is headed by a pair of pointers, one the head of the * list and the other to the tail of the list. The elements are singly * linked to save space, so elements can only be removed from the * head of the list. New elements can be added to the list after * an existing element, at the head of the list, or at the end of the * list. A simple queue may only be traversed in the forward direction. * * A tail queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or * after an existing element, at the head of the list, or at the end of * the list. A tail queue may be traversed in either direction. * * For details on the use of these macros, see the queue(3) manual page. */ #include "qemu/atomic.h" /* for smp_wmb() */ /* * List definitions. */ #define QLIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } #define QLIST_HEAD_INITIALIZER(head) \ { NULL } #define QLIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } /* * List functions. */ #define QLIST_INIT(head) do { \ (head)->lh_first = NULL; \ } while (/*CONSTCOND*/0) #define QLIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ &(elm)->field.le_next; \ (listelm)->field.le_next = (elm); \ (elm)->field.le_prev = &(listelm)->field.le_next; \ } while (/*CONSTCOND*/0) #define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_next = (listelm); \ *(listelm)->field.le_prev = (elm); \ (listelm)->field.le_prev = &(elm)->field.le_next; \ } while (/*CONSTCOND*/0) #define QLIST_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.le_next = (head)->lh_first) != NULL) \ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ (head)->lh_first = (elm); \ (elm)->field.le_prev = &(head)->lh_first; \ } while (/*CONSTCOND*/0) #define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ (elm)->field.le_prev = &(head)->lh_first; \ (elm)->field.le_next = (head)->lh_first; \ smp_wmb(); /* fill elm before linking it */ \ if ((head)->lh_first != NULL) { \ (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ } \ (head)->lh_first = (elm); \ smp_wmb(); \ } while (/* CONSTCOND*/0) #define QLIST_REMOVE(elm, field) do { \ if ((elm)->field.le_next != NULL) \ (elm)->field.le_next->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = (elm)->field.le_next; \ } while (/*CONSTCOND*/0) #define QLIST_FOREACH(var, head, field) \ for ((var) = ((head)->lh_first); \ (var); \ (var) = ((var)->field.le_next)) #define QLIST_FOREACH_SAFE(var, head, field, next_var) \ for ((var) = ((head)->lh_first); \ (var) && ((next_var) = ((var)->field.le_next), 1); \ (var) = (next_var)) /* * List access methods. */ #define QLIST_EMPTY(head) ((head)->lh_first == NULL) #define QLIST_FIRST(head) ((head)->lh_first) #define QLIST_NEXT(elm, field) ((elm)->field.le_next) /* * Singly-linked List definitions. */ #define QSLIST_HEAD(name, type) \ struct name { \ struct type *slh_first; /* first element */ \ } #define QSLIST_HEAD_INITIALIZER(head) \ { NULL } #define QSLIST_ENTRY(type) \ struct { \ struct type *sle_next; /* next element */ \ } /* * Singly-linked List functions. */ #define QSLIST_INIT(head) do { \ (head)->slh_first = NULL; \ } while (/*CONSTCOND*/0) #define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ (elm)->field.sle_next = (slistelm)->field.sle_next; \ (slistelm)->field.sle_next = (elm); \ } while (/*CONSTCOND*/0) #define QSLIST_INSERT_HEAD(head, elm, field) do { \ (elm)->field.sle_next = (head)->slh_first; \ (head)->slh_first = (elm); \ } while (/*CONSTCOND*/0) #define QSLIST_REMOVE_HEAD(head, field) do { \ (head)->slh_first = (head)->slh_first->field.sle_next; \ } while (/*CONSTCOND*/0) #define QSLIST_REMOVE_AFTER(slistelm, field) do { \ (slistelm)->field.sle_next = \ QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ } while (/*CONSTCOND*/0) #define QSLIST_FOREACH(var, head, field) \ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) #define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = QSLIST_FIRST((head)); \ (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ (var) = (tvar)) /* * Singly-linked List access methods. */ #define QSLIST_EMPTY(head) ((head)->slh_first == NULL) #define QSLIST_FIRST(head) ((head)->slh_first) #define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) /* * Simple queue definitions. */ #define QSIMPLEQ_HEAD(name, type) \ struct name { \ struct type *sqh_first; /* first element */ \ struct type **sqh_last; /* addr of last next element */ \ } #define QSIMPLEQ_HEAD_INITIALIZER(head) \ { NULL, &(head).sqh_first } #define QSIMPLEQ_ENTRY(type) \ struct { \ struct type *sqe_next; /* next element */ \ } /* * Simple queue functions. */ #define QSIMPLEQ_INIT(head) do { \ (head)->sqh_first = NULL; \ (head)->sqh_last = &(head)->sqh_first; \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ (head)->sqh_last = &(elm)->field.sqe_next; \ (head)->sqh_first = (elm); \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.sqe_next = NULL; \ *(head)->sqh_last = (elm); \ (head)->sqh_last = &(elm)->field.sqe_next; \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ (head)->sqh_last = &(elm)->field.sqe_next; \ (listelm)->field.sqe_next = (elm); \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ (head)->sqh_last = &(head)->sqh_first; \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ if ((head)->sqh_first == (elm)) { \ QSIMPLEQ_REMOVE_HEAD((head), field); \ } else { \ struct type *curelm = (head)->sqh_first; \ while (curelm->field.sqe_next != (elm)) \ curelm = curelm->field.sqe_next; \ if ((curelm->field.sqe_next = \ curelm->field.sqe_next->field.sqe_next) == NULL) \ (head)->sqh_last = &(curelm)->field.sqe_next; \ } \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_FOREACH(var, head, field) \ for ((var) = ((head)->sqh_first); \ (var); \ (var) = ((var)->field.sqe_next)) #define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ for ((var) = ((head)->sqh_first); \ (var) && ((next = ((var)->field.sqe_next)), 1); \ (var) = (next)) #define QSIMPLEQ_CONCAT(head1, head2) do { \ if (!QSIMPLEQ_EMPTY((head2))) { \ *(head1)->sqh_last = (head2)->sqh_first; \ (head1)->sqh_last = (head2)->sqh_last; \ QSIMPLEQ_INIT((head2)); \ } \ } while (/*CONSTCOND*/0) #define QSIMPLEQ_LAST(head, type, field) \ (QSIMPLEQ_EMPTY((head)) ? \ NULL : \ ((struct type *)(void *) \ ((char *)((head)->sqh_last) - offsetof(struct type, field)))) /* * Simple queue access methods. */ #define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) #define QSIMPLEQ_FIRST(head) ((head)->sqh_first) #define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) /* * Tail queue definitions. */ #define Q_TAILQ_HEAD(name, type, qual) \ struct name { \ qual type *tqh_first; /* first element */ \ qual type *qual *tqh_last; /* addr of last next element */ \ } #define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) #define QTAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first } #define Q_TAILQ_ENTRY(type, qual) \ struct { \ qual type *tqe_next; /* next element */ \ qual type *qual *tqe_prev; /* address of previous next element */\ } #define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) /* * Tail queue functions. */ #define QTAILQ_INIT(head) do { \ (head)->tqh_first = NULL; \ (head)->tqh_last = &(head)->tqh_first; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ (head)->tqh_first->field.tqe_prev = \ &(elm)->field.tqe_next; \ else \ (head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_first = (elm); \ (elm)->field.tqe_prev = &(head)->tqh_first; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.tqe_next = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &(elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ (elm)->field.tqe_next->field.tqe_prev = \ &(elm)->field.tqe_next; \ else \ (head)->tqh_last = &(elm)->field.tqe_next; \ (listelm)->field.tqe_next = (elm); \ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_next = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) #define QTAILQ_REMOVE(head, elm, field) do { \ if (((elm)->field.tqe_next) != NULL) \ (elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_prev; \ else \ (head)->tqh_last = (elm)->field.tqe_prev; \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) #define QTAILQ_FOREACH(var, head, field) \ for ((var) = ((head)->tqh_first); \ (var); \ (var) = ((var)->field.tqe_next)) #define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ for ((var) = ((head)->tqh_first); \ (var) && ((next_var) = ((var)->field.tqe_next), 1); \ (var) = (next_var)) #define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ (var); \ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) /* * Tail queue access methods. */ #define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) #define QTAILQ_FIRST(head) ((head)->tqh_first) #define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define QTAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) #define QTAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) #endif /* !QEMU_SYS_QUEUE_H_ */ glusterfs-3.7.6/contrib/qemu/include/qemu/PaxHeaders.7244/event_notifier.h0000644000076200007630000000013012617742532024722 xustar000000000000000030 mtime=1447019866.040471495 28 atime=1447019866.3724665 30 ctime=1447019941.562335319 glusterfs-3.7.6/contrib/qemu/include/qemu/event_notifier.h0000644000076200007630000000174212617742532025145 0ustar00jenkinsjenkins00000000000000/* * event notifier support * * Copyright Red Hat, Inc. 2010 * * Authors: * Michael S. Tsirkin * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef QEMU_EVENT_NOTIFIER_H #define QEMU_EVENT_NOTIFIER_H #include "qemu-common.h" #ifdef _WIN32 #include #endif struct EventNotifier { #ifdef _WIN32 HANDLE event; #else int rfd; int wfd; #endif }; typedef void EventNotifierHandler(EventNotifier *); int event_notifier_init(EventNotifier *, int active); void event_notifier_cleanup(EventNotifier *); int event_notifier_set(EventNotifier *); int event_notifier_test_and_clear(EventNotifier *); int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); #ifdef CONFIG_POSIX void event_notifier_init_fd(EventNotifier *, int fd); int event_notifier_get_fd(EventNotifier *); #else HANDLE event_notifier_get_handle(EventNotifier *); #endif #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/fpu0000644000076200007630000000013212617742645021306 xustar000000000000000030 mtime=1447019941.475336627 30 atime=1447019949.333218415 30 ctime=1447019941.475336627 glusterfs-3.7.6/contrib/qemu/include/fpu/0000755000076200007630000000000012617742645021600 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/fpu/PaxHeaders.7244/softfloat.h0000644000076200007630000000013112617742532023527 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.475336627 glusterfs-3.7.6/contrib/qemu/include/fpu/softfloat.h0000644000076200007630000006045512617742532023757 0ustar00jenkinsjenkins00000000000000/* * QEMU float support * * Derived from SoftFloat. */ /*============================================================================ This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic Package, Release 2b. Written by John R. Hauser. This work was made possible in part by the International Computer Science Institute, located at Suite 600, 1947 Center Street, Berkeley, California 94704. Funding was partially provided by the National Science Foundation under grant MIP-9311980. The original version of this code was written as part of a project to build a fixed-point vector processor in collaboration with the University of California at Berkeley, overseen by Profs. Nelson Morgan and John Wawrzynek. More information is available through the Web page `http://www.cs.berkeley.edu/~jhauser/ arithmetic/SoftFloat.html'. THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES, COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE. Derivative works are acceptable, even for commercial purposes, so long as (1) the source code for the derivative work includes prominent notice that the work is derivative, and (2) the source code includes prominent notice with these four paragraphs for those parts of this code that are retained. =============================================================================*/ #ifndef SOFTFLOAT_H #define SOFTFLOAT_H #if defined(CONFIG_SOLARIS) && defined(CONFIG_NEEDS_LIBSUNMATH) #include #endif #include #include "config-host.h" #include "qemu/osdep.h" /*---------------------------------------------------------------------------- | Each of the following `typedef's defines the most convenient type that holds | integers of at least as many bits as specified. For example, `uint8' should | be the most convenient type that can hold unsigned integers of as many as | 8 bits. The `flag' type must be able to hold either a 0 or 1. For most | implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed | to the same as `int'. *----------------------------------------------------------------------------*/ typedef uint8_t flag; typedef uint8_t uint8; typedef int8_t int8; typedef unsigned int uint32; typedef signed int int32; typedef uint64_t uint64; typedef int64_t int64; #define LIT64( a ) a##LL #define INLINE static inline #define STATUS_PARAM , float_status *status #define STATUS(field) status->field #define STATUS_VAR , status /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point ordering relations *----------------------------------------------------------------------------*/ enum { float_relation_less = -1, float_relation_equal = 0, float_relation_greater = 1, float_relation_unordered = 2 }; /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point types. *----------------------------------------------------------------------------*/ /* Use structures for soft-float types. This prevents accidentally mixing them with native int/float types. A sufficiently clever compiler and sane ABI should be able to see though these structs. However x86/gcc 3.x seems to struggle a bit, so leave them disabled by default. */ //#define USE_SOFTFLOAT_STRUCT_TYPES #ifdef USE_SOFTFLOAT_STRUCT_TYPES typedef struct { uint16_t v; } float16; #define float16_val(x) (((float16)(x)).v) #define make_float16(x) __extension__ ({ float16 f16_val = {x}; f16_val; }) #define const_float16(x) { x } typedef struct { uint32_t v; } float32; /* The cast ensures an error if the wrong type is passed. */ #define float32_val(x) (((float32)(x)).v) #define make_float32(x) __extension__ ({ float32 f32_val = {x}; f32_val; }) #define const_float32(x) { x } typedef struct { uint64_t v; } float64; #define float64_val(x) (((float64)(x)).v) #define make_float64(x) __extension__ ({ float64 f64_val = {x}; f64_val; }) #define const_float64(x) { x } #else typedef uint16_t float16; typedef uint32_t float32; typedef uint64_t float64; #define float16_val(x) (x) #define float32_val(x) (x) #define float64_val(x) (x) #define make_float16(x) (x) #define make_float32(x) (x) #define make_float64(x) (x) #define const_float16(x) (x) #define const_float32(x) (x) #define const_float64(x) (x) #endif typedef struct { uint64_t low; uint16_t high; } floatx80; #define make_floatx80(exp, mant) ((floatx80) { mant, exp }) #define make_floatx80_init(exp, mant) { .low = mant, .high = exp } typedef struct { #ifdef HOST_WORDS_BIGENDIAN uint64_t high, low; #else uint64_t low, high; #endif } float128; #define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ }) #define make_float128_init(high_, low_) { .high = high_, .low = low_ } /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point underflow tininess-detection mode. *----------------------------------------------------------------------------*/ enum { float_tininess_after_rounding = 0, float_tininess_before_rounding = 1 }; /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point rounding mode. *----------------------------------------------------------------------------*/ enum { float_round_nearest_even = 0, float_round_down = 1, float_round_up = 2, float_round_to_zero = 3 }; /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point exception flags. *----------------------------------------------------------------------------*/ enum { float_flag_invalid = 1, float_flag_divbyzero = 4, float_flag_overflow = 8, float_flag_underflow = 16, float_flag_inexact = 32, float_flag_input_denormal = 64, float_flag_output_denormal = 128 }; typedef struct float_status { signed char float_detect_tininess; signed char float_rounding_mode; signed char float_exception_flags; signed char floatx80_rounding_precision; /* should denormalised results go to zero and set the inexact flag? */ flag flush_to_zero; /* should denormalised inputs go to zero and set the input_denormal flag? */ flag flush_inputs_to_zero; flag default_nan_mode; } float_status; void set_float_rounding_mode(int val STATUS_PARAM); void set_float_exception_flags(int val STATUS_PARAM); INLINE void set_float_detect_tininess(int val STATUS_PARAM) { STATUS(float_detect_tininess) = val; } INLINE void set_flush_to_zero(flag val STATUS_PARAM) { STATUS(flush_to_zero) = val; } INLINE void set_flush_inputs_to_zero(flag val STATUS_PARAM) { STATUS(flush_inputs_to_zero) = val; } INLINE void set_default_nan_mode(flag val STATUS_PARAM) { STATUS(default_nan_mode) = val; } INLINE int get_float_exception_flags(float_status *status) { return STATUS(float_exception_flags); } void set_floatx80_rounding_precision(int val STATUS_PARAM); /*---------------------------------------------------------------------------- | Routine to raise any or all of the software IEC/IEEE floating-point | exception flags. *----------------------------------------------------------------------------*/ void float_raise( int8 flags STATUS_PARAM); /*---------------------------------------------------------------------------- | Options to indicate which negations to perform in float*_muladd() | Using these differs from negating an input or output before calling | the muladd function in that this means that a NaN doesn't have its | sign bit inverted before it is propagated. *----------------------------------------------------------------------------*/ enum { float_muladd_negate_c = 1, float_muladd_negate_product = 2, float_muladd_negate_result = 4, }; /*---------------------------------------------------------------------------- | Software IEC/IEEE integer-to-floating-point conversion routines. *----------------------------------------------------------------------------*/ float32 int32_to_float32( int32 STATUS_PARAM ); float64 int32_to_float64( int32 STATUS_PARAM ); float32 uint32_to_float32( uint32 STATUS_PARAM ); float64 uint32_to_float64( uint32 STATUS_PARAM ); floatx80 int32_to_floatx80( int32 STATUS_PARAM ); float128 int32_to_float128( int32 STATUS_PARAM ); float32 int64_to_float32( int64 STATUS_PARAM ); float32 uint64_to_float32( uint64 STATUS_PARAM ); float64 int64_to_float64( int64 STATUS_PARAM ); float64 uint64_to_float64( uint64 STATUS_PARAM ); floatx80 int64_to_floatx80( int64 STATUS_PARAM ); float128 int64_to_float128( int64 STATUS_PARAM ); float128 uint64_to_float128( uint64 STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software half-precision conversion routines. *----------------------------------------------------------------------------*/ float16 float32_to_float16( float32, flag STATUS_PARAM ); float32 float16_to_float32( float16, flag STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software half-precision operations. *----------------------------------------------------------------------------*/ int float16_is_quiet_nan( float16 ); int float16_is_signaling_nan( float16 ); float16 float16_maybe_silence_nan( float16 ); INLINE int float16_is_any_nan(float16 a) { return ((float16_val(a) & ~0x8000) > 0x7c00); } /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/ extern const float16 float16_default_nan; /*---------------------------------------------------------------------------- | Software IEC/IEEE single-precision conversion routines. *----------------------------------------------------------------------------*/ int_fast16_t float32_to_int16_round_to_zero(float32 STATUS_PARAM); uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM); int32 float32_to_int32( float32 STATUS_PARAM ); int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM ); uint32 float32_to_uint32( float32 STATUS_PARAM ); uint32 float32_to_uint32_round_to_zero( float32 STATUS_PARAM ); int64 float32_to_int64( float32 STATUS_PARAM ); int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM ); float64 float32_to_float64( float32 STATUS_PARAM ); floatx80 float32_to_floatx80( float32 STATUS_PARAM ); float128 float32_to_float128( float32 STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software IEC/IEEE single-precision operations. *----------------------------------------------------------------------------*/ float32 float32_round_to_int( float32 STATUS_PARAM ); float32 float32_add( float32, float32 STATUS_PARAM ); float32 float32_sub( float32, float32 STATUS_PARAM ); float32 float32_mul( float32, float32 STATUS_PARAM ); float32 float32_div( float32, float32 STATUS_PARAM ); float32 float32_rem( float32, float32 STATUS_PARAM ); float32 float32_muladd(float32, float32, float32, int STATUS_PARAM); float32 float32_sqrt( float32 STATUS_PARAM ); float32 float32_exp2( float32 STATUS_PARAM ); float32 float32_log2( float32 STATUS_PARAM ); int float32_eq( float32, float32 STATUS_PARAM ); int float32_le( float32, float32 STATUS_PARAM ); int float32_lt( float32, float32 STATUS_PARAM ); int float32_unordered( float32, float32 STATUS_PARAM ); int float32_eq_quiet( float32, float32 STATUS_PARAM ); int float32_le_quiet( float32, float32 STATUS_PARAM ); int float32_lt_quiet( float32, float32 STATUS_PARAM ); int float32_unordered_quiet( float32, float32 STATUS_PARAM ); int float32_compare( float32, float32 STATUS_PARAM ); int float32_compare_quiet( float32, float32 STATUS_PARAM ); float32 float32_min(float32, float32 STATUS_PARAM); float32 float32_max(float32, float32 STATUS_PARAM); int float32_is_quiet_nan( float32 ); int float32_is_signaling_nan( float32 ); float32 float32_maybe_silence_nan( float32 ); float32 float32_scalbn( float32, int STATUS_PARAM ); INLINE float32 float32_abs(float32 a) { /* Note that abs does *not* handle NaN specially, nor does * it flush denormal inputs to zero. */ return make_float32(float32_val(a) & 0x7fffffff); } INLINE float32 float32_chs(float32 a) { /* Note that chs does *not* handle NaN specially, nor does * it flush denormal inputs to zero. */ return make_float32(float32_val(a) ^ 0x80000000); } INLINE int float32_is_infinity(float32 a) { return (float32_val(a) & 0x7fffffff) == 0x7f800000; } INLINE int float32_is_neg(float32 a) { return float32_val(a) >> 31; } INLINE int float32_is_zero(float32 a) { return (float32_val(a) & 0x7fffffff) == 0; } INLINE int float32_is_any_nan(float32 a) { return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); } INLINE int float32_is_zero_or_denormal(float32 a) { return (float32_val(a) & 0x7f800000) == 0; } INLINE float32 float32_set_sign(float32 a, int sign) { return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); } #define float32_zero make_float32(0) #define float32_one make_float32(0x3f800000) #define float32_ln2 make_float32(0x3f317218) #define float32_pi make_float32(0x40490fdb) #define float32_half make_float32(0x3f000000) #define float32_infinity make_float32(0x7f800000) /*---------------------------------------------------------------------------- | The pattern for a default generated single-precision NaN. *----------------------------------------------------------------------------*/ extern const float32 float32_default_nan; /*---------------------------------------------------------------------------- | Software IEC/IEEE double-precision conversion routines. *----------------------------------------------------------------------------*/ int_fast16_t float64_to_int16_round_to_zero(float64 STATUS_PARAM); uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM); int32 float64_to_int32( float64 STATUS_PARAM ); int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM ); uint32 float64_to_uint32( float64 STATUS_PARAM ); uint32 float64_to_uint32_round_to_zero( float64 STATUS_PARAM ); int64 float64_to_int64( float64 STATUS_PARAM ); int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM ); uint64 float64_to_uint64 (float64 a STATUS_PARAM); uint64 float64_to_uint64_round_to_zero (float64 a STATUS_PARAM); float32 float64_to_float32( float64 STATUS_PARAM ); floatx80 float64_to_floatx80( float64 STATUS_PARAM ); float128 float64_to_float128( float64 STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software IEC/IEEE double-precision operations. *----------------------------------------------------------------------------*/ float64 float64_round_to_int( float64 STATUS_PARAM ); float64 float64_trunc_to_int( float64 STATUS_PARAM ); float64 float64_add( float64, float64 STATUS_PARAM ); float64 float64_sub( float64, float64 STATUS_PARAM ); float64 float64_mul( float64, float64 STATUS_PARAM ); float64 float64_div( float64, float64 STATUS_PARAM ); float64 float64_rem( float64, float64 STATUS_PARAM ); float64 float64_muladd(float64, float64, float64, int STATUS_PARAM); float64 float64_sqrt( float64 STATUS_PARAM ); float64 float64_log2( float64 STATUS_PARAM ); int float64_eq( float64, float64 STATUS_PARAM ); int float64_le( float64, float64 STATUS_PARAM ); int float64_lt( float64, float64 STATUS_PARAM ); int float64_unordered( float64, float64 STATUS_PARAM ); int float64_eq_quiet( float64, float64 STATUS_PARAM ); int float64_le_quiet( float64, float64 STATUS_PARAM ); int float64_lt_quiet( float64, float64 STATUS_PARAM ); int float64_unordered_quiet( float64, float64 STATUS_PARAM ); int float64_compare( float64, float64 STATUS_PARAM ); int float64_compare_quiet( float64, float64 STATUS_PARAM ); float64 float64_min(float64, float64 STATUS_PARAM); float64 float64_max(float64, float64 STATUS_PARAM); int float64_is_quiet_nan( float64 a ); int float64_is_signaling_nan( float64 ); float64 float64_maybe_silence_nan( float64 ); float64 float64_scalbn( float64, int STATUS_PARAM ); INLINE float64 float64_abs(float64 a) { /* Note that abs does *not* handle NaN specially, nor does * it flush denormal inputs to zero. */ return make_float64(float64_val(a) & 0x7fffffffffffffffLL); } INLINE float64 float64_chs(float64 a) { /* Note that chs does *not* handle NaN specially, nor does * it flush denormal inputs to zero. */ return make_float64(float64_val(a) ^ 0x8000000000000000LL); } INLINE int float64_is_infinity(float64 a) { return (float64_val(a) & 0x7fffffffffffffffLL ) == 0x7ff0000000000000LL; } INLINE int float64_is_neg(float64 a) { return float64_val(a) >> 63; } INLINE int float64_is_zero(float64 a) { return (float64_val(a) & 0x7fffffffffffffffLL) == 0; } INLINE int float64_is_any_nan(float64 a) { return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); } INLINE int float64_is_zero_or_denormal(float64 a) { return (float64_val(a) & 0x7ff0000000000000LL) == 0; } INLINE float64 float64_set_sign(float64 a, int sign) { return make_float64((float64_val(a) & 0x7fffffffffffffffULL) | ((int64_t)sign << 63)); } #define float64_zero make_float64(0) #define float64_one make_float64(0x3ff0000000000000LL) #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) #define float64_pi make_float64(0x400921fb54442d18LL) #define float64_half make_float64(0x3fe0000000000000LL) #define float64_infinity make_float64(0x7ff0000000000000LL) /*---------------------------------------------------------------------------- | The pattern for a default generated double-precision NaN. *----------------------------------------------------------------------------*/ extern const float64 float64_default_nan; /*---------------------------------------------------------------------------- | Software IEC/IEEE extended double-precision conversion routines. *----------------------------------------------------------------------------*/ int32 floatx80_to_int32( floatx80 STATUS_PARAM ); int32 floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM ); int64 floatx80_to_int64( floatx80 STATUS_PARAM ); int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM ); float32 floatx80_to_float32( floatx80 STATUS_PARAM ); float64 floatx80_to_float64( floatx80 STATUS_PARAM ); float128 floatx80_to_float128( floatx80 STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software IEC/IEEE extended double-precision operations. *----------------------------------------------------------------------------*/ floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM ); floatx80 floatx80_add( floatx80, floatx80 STATUS_PARAM ); floatx80 floatx80_sub( floatx80, floatx80 STATUS_PARAM ); floatx80 floatx80_mul( floatx80, floatx80 STATUS_PARAM ); floatx80 floatx80_div( floatx80, floatx80 STATUS_PARAM ); floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM ); floatx80 floatx80_sqrt( floatx80 STATUS_PARAM ); int floatx80_eq( floatx80, floatx80 STATUS_PARAM ); int floatx80_le( floatx80, floatx80 STATUS_PARAM ); int floatx80_lt( floatx80, floatx80 STATUS_PARAM ); int floatx80_unordered( floatx80, floatx80 STATUS_PARAM ); int floatx80_eq_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_unordered_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_compare( floatx80, floatx80 STATUS_PARAM ); int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_is_quiet_nan( floatx80 ); int floatx80_is_signaling_nan( floatx80 ); floatx80 floatx80_maybe_silence_nan( floatx80 ); floatx80 floatx80_scalbn( floatx80, int STATUS_PARAM ); INLINE floatx80 floatx80_abs(floatx80 a) { a.high &= 0x7fff; return a; } INLINE floatx80 floatx80_chs(floatx80 a) { a.high ^= 0x8000; return a; } INLINE int floatx80_is_infinity(floatx80 a) { return (a.high & 0x7fff) == 0x7fff && a.low == 0x8000000000000000LL; } INLINE int floatx80_is_neg(floatx80 a) { return a.high >> 15; } INLINE int floatx80_is_zero(floatx80 a) { return (a.high & 0x7fff) == 0 && a.low == 0; } INLINE int floatx80_is_zero_or_denormal(floatx80 a) { return (a.high & 0x7fff) == 0; } INLINE int floatx80_is_any_nan(floatx80 a) { return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); } #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL) #define floatx80_one make_floatx80(0x3fff, 0x8000000000000000LL) #define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL) #define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL) #define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL) #define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL) /*---------------------------------------------------------------------------- | The pattern for a default generated extended double-precision NaN. *----------------------------------------------------------------------------*/ extern const floatx80 floatx80_default_nan; /*---------------------------------------------------------------------------- | Software IEC/IEEE quadruple-precision conversion routines. *----------------------------------------------------------------------------*/ int32 float128_to_int32( float128 STATUS_PARAM ); int32 float128_to_int32_round_to_zero( float128 STATUS_PARAM ); int64 float128_to_int64( float128 STATUS_PARAM ); int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM ); float32 float128_to_float32( float128 STATUS_PARAM ); float64 float128_to_float64( float128 STATUS_PARAM ); floatx80 float128_to_floatx80( float128 STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software IEC/IEEE quadruple-precision operations. *----------------------------------------------------------------------------*/ float128 float128_round_to_int( float128 STATUS_PARAM ); float128 float128_add( float128, float128 STATUS_PARAM ); float128 float128_sub( float128, float128 STATUS_PARAM ); float128 float128_mul( float128, float128 STATUS_PARAM ); float128 float128_div( float128, float128 STATUS_PARAM ); float128 float128_rem( float128, float128 STATUS_PARAM ); float128 float128_sqrt( float128 STATUS_PARAM ); int float128_eq( float128, float128 STATUS_PARAM ); int float128_le( float128, float128 STATUS_PARAM ); int float128_lt( float128, float128 STATUS_PARAM ); int float128_unordered( float128, float128 STATUS_PARAM ); int float128_eq_quiet( float128, float128 STATUS_PARAM ); int float128_le_quiet( float128, float128 STATUS_PARAM ); int float128_lt_quiet( float128, float128 STATUS_PARAM ); int float128_unordered_quiet( float128, float128 STATUS_PARAM ); int float128_compare( float128, float128 STATUS_PARAM ); int float128_compare_quiet( float128, float128 STATUS_PARAM ); int float128_is_quiet_nan( float128 ); int float128_is_signaling_nan( float128 ); float128 float128_maybe_silence_nan( float128 ); float128 float128_scalbn( float128, int STATUS_PARAM ); INLINE float128 float128_abs(float128 a) { a.high &= 0x7fffffffffffffffLL; return a; } INLINE float128 float128_chs(float128 a) { a.high ^= 0x8000000000000000LL; return a; } INLINE int float128_is_infinity(float128 a) { return (a.high & 0x7fffffffffffffffLL) == 0x7fff000000000000LL && a.low == 0; } INLINE int float128_is_neg(float128 a) { return a.high >> 63; } INLINE int float128_is_zero(float128 a) { return (a.high & 0x7fffffffffffffffLL) == 0 && a.low == 0; } INLINE int float128_is_zero_or_denormal(float128 a) { return (a.high & 0x7fff000000000000LL) == 0; } INLINE int float128_is_any_nan(float128 a) { return ((a.high >> 48) & 0x7fff) == 0x7fff && ((a.low != 0) || ((a.high & 0xffffffffffffLL) != 0)); } #define float128_zero make_float128(0, 0) /*---------------------------------------------------------------------------- | The pattern for a default generated quadruple-precision NaN. *----------------------------------------------------------------------------*/ extern const float128 float128_default_nan; #endif /* !SOFTFLOAT_H */ glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/sysemu0000644000076200007630000000013212617742645022041 xustar000000000000000030 mtime=1447019941.616334506 30 atime=1447019949.333218415 30 ctime=1447019941.616334506 glusterfs-3.7.6/contrib/qemu/include/sysemu/0000755000076200007630000000000012617742645022333 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/sysemu/PaxHeaders.7244/os-posix.h0000644000076200007630000000013112617742532024042 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.616334506 glusterfs-3.7.6/contrib/qemu/include/sysemu/os-posix.h0000644000076200007630000000355112617742532024264 0ustar00jenkinsjenkins00000000000000/* * posix specific declarations * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2010 Jes Sorensen * * 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. */ #ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H void os_set_line_buffering(void); void os_set_proc_name(const char *s); void os_setup_signal_handling(void); void os_daemonize(void); void os_setup_post(void); int os_mlock(void); typedef struct timeval qemu_timeval; #define qemu_gettimeofday(tp) gettimeofday(tp, NULL) #if !defined(CONFIG_UTIMENSAT) || defined(__FreeBSD__) || defined(__APPLE__) #ifndef UTIME_NOW # define UTIME_NOW ((1l << 30) - 1l) #endif #ifndef UTIME_OMIT # define UTIME_OMIT ((1l << 30) - 2l) #endif #endif typedef struct timespec qemu_timespec; int qemu_utimens(const char *path, const qemu_timespec *times); bool is_daemonized(void); #endif glusterfs-3.7.6/contrib/qemu/include/sysemu/PaxHeaders.7244/sysemu.h0000644000076200007630000000013112617742532023606 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.613334551 glusterfs-3.7.6/contrib/qemu/include/sysemu/sysemu.h0000644000076200007630000001342212617742532024026 0ustar00jenkinsjenkins00000000000000#ifndef SYSEMU_H #define SYSEMU_H /* Misc. things related to the system emulator. */ #include "qemu/typedefs.h" #include "qemu/option.h" #include "qemu/queue.h" #include "qemu/timer.h" #include "qapi-types.h" #include "qemu/notify.h" #include "qemu/main-loop.h" /* vl.c */ extern const char *bios_name; extern const char *qemu_name; extern uint8_t qemu_uuid[]; int qemu_uuid_parse(const char *str, uint8_t *uuid); #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); bool runstate_needs_reset(void); typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running, RunState state); VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, void *opaque); void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); void vm_state_notify(int running, RunState state); #define VMRESET_SILENT false #define VMRESET_REPORT true void vm_start(void); int vm_stop(RunState state); int vm_stop_force_state(RunState state); typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER = 0, QEMU_WAKEUP_REASON_RTC, QEMU_WAKEUP_REASON_PMTIMER, } WakeupReason; void qemu_system_reset_request(void); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); void qemu_system_wakeup_request(WakeupReason reason); void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); void qemu_system_shutdown_request(void); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_system_debug_request(void); void qemu_system_vmstop_request(RunState reason); int qemu_shutdown_requested_get(void); int qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_devices_reset(void); void qemu_system_reset(bool report); void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); void qemu_add_machine_init_done_notifier(Notifier *notify); void do_savevm(Monitor *mon, const QDict *qdict); int load_vmstate(const char *name); void do_delvm(Monitor *mon, const QDict *qdict); void do_info_snapshots(Monitor *mon, const QDict *qdict); void qemu_announce_self(void); bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_begin(QEMUFile *f, const MigrationParams *params); int qemu_savevm_state_iterate(QEMUFile *f); void qemu_savevm_state_complete(QEMUFile *f); void qemu_savevm_state_cancel(void); uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); typedef enum DisplayType { DT_DEFAULT, DT_CURSES, DT_SDL, DT_GTK, DT_NOGRAPHIC, DT_NONE, } DisplayType; extern int autostart; typedef enum { VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL, } VGAInterfaceType; extern int vga_interface_type; #define xenfb_enabled (vga_interface_type == VGA_XENFB) #define qxl_enabled (vga_interface_type == VGA_QXL) extern int graphic_width; extern int graphic_height; extern int graphic_depth; extern DisplayType display_type; extern const char *keyboard_layout; extern int win2k_install_hack; extern int alt_grab; extern int ctrl_grab; extern int smp_cpus; extern int max_cpus; extern int cursor_hide; extern int graphic_rotate; extern int no_quit; extern int no_shutdown; extern int semihosting_enabled; extern int old_param; extern int boot_menu; extern uint8_t *boot_splash_filedata; extern size_t boot_splash_filedata_size; extern uint8_t qemu_extra_params_fw[2]; extern QEMUClock *rtc_clock; #define MAX_NODES 64 #define MAX_CPUMASK_BITS 255 extern int nb_numa_nodes; extern uint64_t node_mem[MAX_NODES]; extern unsigned long *node_cpumask[MAX_NODES]; #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { const char *name; int32_t bootindex; } QEMUOptionRom; extern QEMUOptionRom option_rom[MAX_OPTION_ROMS]; extern int nb_option_roms; #define MAX_PROM_ENVS 128 extern const char *prom_envs[MAX_PROM_ENVS]; extern unsigned int nb_prom_envs; /* pci-hotplug */ void pci_device_hot_add(Monitor *mon, const QDict *qdict); int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo); void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict); /* generic hotplug */ void drive_hot_add(Monitor *mon, const QDict *qdict); /* CPU hotplug */ void qemu_register_cpu_added_notifier(Notifier *notifier); /* pcie aer error injection */ void pcie_aer_inject_error_print(Monitor *mon, const QObject *data); int do_pcie_aer_inject_error(Monitor *mon, const QDict *qdict, QObject **ret_data); /* serial ports */ #define MAX_SERIAL_PORTS 4 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; /* parallel ports */ #define MAX_PARALLEL_PORTS 3 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; void do_usb_add(Monitor *mon, const QDict *qdict); void do_usb_del(Monitor *mon, const QDict *qdict); void usb_info(Monitor *mon, const QDict *qdict); void rtc_change_mon_event(struct tm *tm); void add_boot_device_path(int32_t bootindex, DeviceState *dev, const char *suffix); char *get_boot_devices_list(size_t *size); DeviceState *get_boot_device(uint32_t position); QemuOpts *qemu_get_machine_opts(void); bool usb_enabled(bool default_usb); extern QemuOptsList qemu_drive_opts; extern QemuOptsList qemu_chardev_opts; extern QemuOptsList qemu_device_opts; extern QemuOptsList qemu_netdev_opts; extern QemuOptsList qemu_net_opts; extern QemuOptsList qemu_global_opts; extern QemuOptsList qemu_mon_opts; #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/qemu-common.h0000644000076200007630000000012712617742532023176 xustar000000000000000029 mtime=1447019866.03947151 28 atime=1447019866.3724665 30 ctime=1447019941.436337214 glusterfs-3.7.6/contrib/qemu/include/qemu-common.h0000644000076200007630000003370512617742532023417 0ustar00jenkinsjenkins00000000000000 /* Common header file that is included by all of QEMU. * * This file is supposed to be included only by .c files. No header file should * depend on qemu-common.h, as this would easily lead to circular header * dependencies. * * If a header file uses a definition from qemu-common.h, that definition * must be moved to a separate header file, and the header that uses it * must include that header. */ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H #include "qemu/compiler.h" #include "config-host.h" #include "qemu/typedefs.h" #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) #define WORDS_ALIGNED #endif #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) /* we put basic includes here to avoid repeating them in device drivers */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "glib-compat.h" #ifdef _WIN32 #include "sysemu/os-win32.h" #endif #ifdef CONFIG_POSIX #include "sysemu/os-posix.h" #endif #ifndef O_LARGEFILE #define O_LARGEFILE 0 #endif #ifndef O_BINARY #define O_BINARY 0 #endif #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif #ifndef ENOMEDIUM #define ENOMEDIUM ENODEV #endif #if !defined(ENOTSUP) #define ENOTSUP 4096 #endif #if !defined(ECANCELED) #define ECANCELED 4097 #endif #if !defined(EMEDIUMTYPE) #define EMEDIUMTYPE 4098 #endif #ifndef TIME_MAX #define TIME_MAX LONG_MAX #endif /* HOST_LONG_BITS is the size of a native pointer in bits. */ #if UINTPTR_MAX == UINT32_MAX # define HOST_LONG_BITS 32 #elif UINTPTR_MAX == UINT64_MAX # define HOST_LONG_BITS 64 #else # error Unknown pointer size #endif typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) GCC_FMT_ATTR(2, 3); #ifdef _WIN32 #define fsync _commit #if !defined(lseek) # define lseek _lseeki64 #endif int qemu_ftruncate64(int, int64_t); #if !defined(ftruncate) # define ftruncate qemu_ftruncate64 #endif static inline char *realpath(const char *path, char *resolved_path) { _fullpath(resolved_path, path, _MAX_PATH); return resolved_path; } #endif /* icount */ void configure_icount(const char *option); extern int use_icount; #include "qemu/osdep.h" #include "qemu/bswap.h" /* FIXME: Remove NEED_CPU_H. */ #ifdef NEED_CPU_H #include "cpu.h" #endif /* !defined(NEED_CPU_H) */ /* main function, renamed */ #if defined(CONFIG_COCOA) int qemu_main(int argc, char **argv, char **envp); #endif void qemu_get_timedate(struct tm *tm, int offset); int qemu_timedate_diff(struct tm *tm); #if !GLIB_CHECK_VERSION(2, 20, 0) /* * Glib before 2.20.0 doesn't implement g_poll, so wrap it to compile properly * on older systems. */ static inline gint g_poll(GPollFD *fds, guint nfds, gint timeout) { GMainContext *ctx = g_main_context_default(); return g_main_context_get_poll_func(ctx)(fds, nfds, timeout); } #endif /** * is_help_option: * @s: string to test * * Check whether @s is one of the standard strings which indicate * that the user is asking for a list of the valid values for a * command option like -cpu or -M. The current accepted strings * are 'help' and '?'. '?' is deprecated (it is a shell wildcard * which makes it annoying to use in a reliable way) but provided * for backwards compatibility. * * Returns: true if @s is a request for a list. */ static inline bool is_help_option(const char *s) { return !strcmp(s, "?") || !strcmp(s, "help"); } /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); void strpadcpy(char *buf, int buf_size, const char *str, char pad); char *pstrcat(char *buf, int buf_size, const char *s); int strstart(const char *str, const char *val, const char **ptr); int stristart(const char *str, const char *val, const char **ptr); int qemu_strnlen(const char *s, int max_len); char *qemu_strsep(char **input, const char *delim); time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); int qemu_parse_fd(const char *param); int parse_uint(const char *s, unsigned long long *value, char **endptr, int base); int parse_uint_full(const char *s, unsigned long long *value, int base); /* * strtosz() suffixes used to specify the default treatment of an * argument passed to strtosz() without an explicit suffix. * These should be defined using upper case characters in the range * A-Z, as strtosz() will use qemu_toupper() on the given argument * prior to comparison. */ #define STRTOSZ_DEFSUFFIX_EB 'E' #define STRTOSZ_DEFSUFFIX_PB 'P' #define STRTOSZ_DEFSUFFIX_TB 'T' #define STRTOSZ_DEFSUFFIX_GB 'G' #define STRTOSZ_DEFSUFFIX_MB 'M' #define STRTOSZ_DEFSUFFIX_KB 'K' #define STRTOSZ_DEFSUFFIX_B 'B' int64_t strtosz(const char *nptr, char **end); int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix); int64_t strtosz_suffix_unit(const char *nptr, char **end, const char default_suffix, int64_t unit); /* path.c */ void init_paths(const char *prefix); const char *path(const char *pathname); #define qemu_isalnum(c) isalnum((unsigned char)(c)) #define qemu_isalpha(c) isalpha((unsigned char)(c)) #define qemu_iscntrl(c) iscntrl((unsigned char)(c)) #define qemu_isdigit(c) isdigit((unsigned char)(c)) #define qemu_isgraph(c) isgraph((unsigned char)(c)) #define qemu_islower(c) islower((unsigned char)(c)) #define qemu_isprint(c) isprint((unsigned char)(c)) #define qemu_ispunct(c) ispunct((unsigned char)(c)) #define qemu_isspace(c) isspace((unsigned char)(c)) #define qemu_isupper(c) isupper((unsigned char)(c)) #define qemu_isxdigit(c) isxdigit((unsigned char)(c)) #define qemu_tolower(c) tolower((unsigned char)(c)) #define qemu_toupper(c) toupper((unsigned char)(c)) #define qemu_isascii(c) isascii((unsigned char)(c)) #define qemu_toascii(c) toascii((unsigned char)(c)) void *qemu_oom_check(void *ptr); ssize_t qemu_write_full(int fd, const void *buf, size_t count) QEMU_WARN_UNUSED_RESULT; ssize_t qemu_send_full(int fd, const void *buf, size_t count, int flags) QEMU_WARN_UNUSED_RESULT; ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags) QEMU_WARN_UNUSED_RESULT; #ifndef _WIN32 int qemu_pipe(int pipefd[2]); /* like openpty() but also makes it raw; return master fd */ int qemu_openpty_raw(int *aslave, char *pty_name); #endif #ifdef _WIN32 /* MinGW needs type casts for the 'buf' and 'optval' arguments. */ #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \ getsockopt(sockfd, level, optname, (void *)optval, optlen) #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \ setsockopt(sockfd, level, optname, (const void *)optval, optlen) #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags) #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen) #else #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \ getsockopt(sockfd, level, optname, optval, optlen) #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \ setsockopt(sockfd, level, optname, optval, optlen) #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags) #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ sendto(sockfd, buf, len, flags, destaddr, addrlen) #endif /* Error handling. */ void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); struct ParallelIOArg { void *buffer; int count; }; typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); typedef uint64_t pcibus_t; typedef enum LostTickPolicy { LOST_TICK_DISCARD, LOST_TICK_DELAY, LOST_TICK_MERGE, LOST_TICK_SLEW, LOST_TICK_MAX } LostTickPolicy; typedef struct PCIHostDeviceAddress { unsigned int domain; unsigned int bus; unsigned int slot; unsigned int function; } PCIHostDeviceAddress; void tcg_exec_init(unsigned long tb_size); bool tcg_enabled(void); void cpu_exec_init_all(void); /* CPU save/load. */ #ifdef CPU_SAVE_VERSION void cpu_save(QEMUFile *f, void *opaque); int cpu_load(QEMUFile *f, void *opaque, int version_id); #endif /* Unblock cpu */ void qemu_cpu_kick_self(void); /* work queue */ struct qemu_work_item { struct qemu_work_item *next; void (*func)(void *data); void *data; int done; bool free; }; /** * Sends a (part of) iovec down a socket, yielding when the socket is full, or * Receives data into a (part of) iovec from a socket, * yielding when there is no data in the socket. * The same interface as qemu_sendv_recvv(), with added yielding. * XXX should mark these as coroutine_fn */ ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, size_t offset, size_t bytes, bool do_send); #define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \ qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false) #define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \ qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true) /** * The same as above, but with just a single buffer */ ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send); #define qemu_co_recv(sockfd, buf, bytes) \ qemu_co_send_recv(sockfd, buf, bytes, false) #define qemu_co_send(sockfd, buf, bytes) \ qemu_co_send_recv(sockfd, buf, bytes, true) typedef struct QEMUIOVector { struct iovec *iov; int niov; int nalloc; size_t size; } QEMUIOVector; void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov); void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes); void qemu_iovec_concat_iov(QEMUIOVector *dst, struct iovec *src_iov, unsigned int src_cnt, size_t soffset, size_t sbytes); void qemu_iovec_destroy(QEMUIOVector *qiov); void qemu_iovec_reset(QEMUIOVector *qiov); size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, void *buf, size_t bytes); size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, const void *buf, size_t bytes); size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int fillc, size_t bytes); bool buffer_is_zero(const void *buf, size_t len); void qemu_progress_init(int enabled, float min_skip); void qemu_progress_end(void); void qemu_progress_print(float delta, int max); const char *qemu_get_vm_name(void); #define QEMU_FILE_TYPE_BIOS 0 #define QEMU_FILE_TYPE_KEYMAP 1 char *qemu_find_file(int type, const char *name); /* OS specific functions */ void os_setup_early_signal_handling(void); char *os_find_datadir(const char *argv0); void os_parse_cmd_args(int index, const char *optarg); void os_pidfile_error(void); /* Convert a byte between binary and BCD. */ static inline uint8_t to_bcd(uint8_t val) { return ((val / 10) << 4) | (val % 10); } static inline uint8_t from_bcd(uint8_t val) { return ((val >> 4) * 10) + (val & 0x0f); } /* compute with 96 bit intermediate result: (a*b)/c */ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) { union { uint64_t ll; struct { #ifdef HOST_WORDS_BIGENDIAN uint32_t high, low; #else uint32_t low, high; #endif } l; } u, res; uint64_t rl, rh; u.ll = a; rl = (uint64_t)u.l.low * (uint64_t)b; rh = (uint64_t)u.l.high * (uint64_t)b; rh += (rl >> 32); res.l.high = rh / c; res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c; return res.ll; } /* Round number down to multiple */ #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) /* Round number up to multiple */ #define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) static inline bool is_power_of_2(uint64_t value) { if (!value) { return 0; } return !(value & (value - 1)); } /* round down to the nearest power of 2*/ int64_t pow2floor(int64_t value); #include "qemu/module.h" /* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) * Input is limited to 14-bit numbers */ int uleb128_encode_small(uint8_t *out, uint32_t n); int uleb128_decode_small(const uint8_t *in, uint32_t *n); /* unicode.c */ int mod_utf8_codepoint(const char *s, size_t n, char **end); /* * Hexdump a buffer to a file. An optional string prefix is added to every line */ void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); /* vector definitions */ #ifdef __ALTIVEC__ #include /* The altivec.h header says we're allowed to undef these for * C++ compatibility. Here we don't care about C++, but we * undef them anyway to avoid namespace pollution. */ #undef vector #undef pixel #undef bool #define VECTYPE __vector unsigned char #define SPLAT(p) vec_splat(vec_ld(0, p), 0) #define ALL_EQ(v1, v2) vec_all_eq(v1, v2) /* altivec.h may redefine the bool macro as vector type. * Reset it to POSIX semantics. */ #define bool _Bool #elif defined __SSE2__ #include #define VECTYPE __m128i #define SPLAT(p) _mm_set1_epi8(*(p)) #define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF) #else #define VECTYPE unsigned long #define SPLAT(p) (*(p) * (~0UL / 255)) #define ALL_EQ(v1, v2) ((v1) == (v2)) #endif #define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8 static inline bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len) { return (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR * sizeof(VECTYPE)) == 0 && ((uintptr_t) buf) % sizeof(VECTYPE) == 0); } size_t buffer_find_nonzero_offset(const void *buf, size_t len); /* * helper to parse debug environment variables */ int parse_debug_env(const char *name, int max, int initial); #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/block0000644000076200007630000000013212617742645021606 xustar000000000000000030 mtime=1447019941.462336821 30 atime=1447019949.333218415 30 ctime=1447019941.462336821 glusterfs-3.7.6/contrib/qemu/include/block/0000755000076200007630000000000012617742645022100 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/block.h0000644000076200007630000000013212617742532023121 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.449337018 glusterfs-3.7.6/contrib/qemu/include/block/block.h0000644000076200007630000004304312617742532023342 0ustar00jenkinsjenkins00000000000000#ifndef BLOCK_H #define BLOCK_H #include "block/aio.h" #include "qemu-common.h" #include "qemu/option.h" #include "block/coroutine.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" /* block.c */ typedef struct BlockDriver BlockDriver; typedef struct BlockJob BlockJob; typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */ int cluster_size; /* offset at which the VM state can be saved (0 if not possible) */ int64_t vm_state_offset; bool is_dirty; } BlockDriverInfo; typedef struct BlockFragInfo { uint64_t allocated_clusters; uint64_t total_clusters; uint64_t fragmented_clusters; uint64_t compressed_clusters; } BlockFragInfo; /* Callbacks for block device models */ typedef struct BlockDevOps { /* * Runs when virtual media changed (monitor commands eject, change) * Argument load is true on load and false on eject. * Beware: doesn't run when a host device's physical media * changes. Sure would be useful if it did. * Device models with removable media must implement this callback. */ void (*change_media_cb)(void *opaque, bool load); /* * Runs when an eject request is issued from the monitor, the tray * is closed, and the medium is locked. * Device models that do not implement is_medium_locked will not need * this callback. Device models that can lock the medium or tray might * want to implement the callback and unlock the tray when "force" is * true, even if they do not support eject requests. */ void (*eject_request_cb)(void *opaque, bool force); /* * Is the virtual tray open? * Device models implement this only when the device has a tray. */ bool (*is_tray_open)(void *opaque); /* * Is the virtual medium locked into the device? * Device models implement this only when device has such a lock. */ bool (*is_medium_locked)(void *opaque); /* * Runs when the size changed (e.g. monitor command block_resize) */ void (*resize_cb)(void *opaque); } BlockDevOps; #define BDRV_O_RDWR 0x0002 #define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */ #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */ #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */ #define BDRV_O_NATIVE_AIO 0x0080 /* use native AIO instead of the thread pool */ #define BDRV_O_NO_BACKING 0x0100 /* don't open the backing file */ #define BDRV_O_NO_FLUSH 0x0200 /* disable flushing on this disk */ #define BDRV_O_COPY_ON_READ 0x0400 /* copy read backing sectors into image */ #define BDRV_O_INCOMING 0x0800 /* consistency hint for incoming migration */ #define BDRV_O_CHECK 0x1000 /* open solely for consistency check */ #define BDRV_O_ALLOW_RDWR 0x2000 /* allow reopen to change from r/o to r/w */ #define BDRV_O_UNMAP 0x4000 /* execute guest UNMAP/TRIM operations */ #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH) #define BDRV_SECTOR_BITS 9 #define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) #define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) typedef enum { BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP } BlockErrorAction; typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { BlockDriverState *bs; int flags; void *opaque; } BDRVReopenState; void bdrv_iostatus_enable(BlockDriverState *bs); void bdrv_iostatus_reset(BlockDriverState *bs); void bdrv_iostatus_disable(BlockDriverState *bs); bool bdrv_iostatus_is_enabled(const BlockDriverState *bs); void bdrv_iostatus_set_err(BlockDriverState *bs, int error); void bdrv_info_print(Monitor *mon, const QObject *data); void bdrv_info(Monitor *mon, QObject **ret_data); void bdrv_stats_print(Monitor *mon, const QObject *data); void bdrv_info_stats(Monitor *mon, QObject **ret_data); /* disk I/O throttling */ void bdrv_io_limits_enable(BlockDriverState *bs); void bdrv_io_limits_disable(BlockDriverState *bs); bool bdrv_io_limits_enabled(BlockDriverState *bs); void bdrv_init(void); void bdrv_init_with_whitelist(void); BlockDriver *bdrv_find_protocol(const char *filename, bool allow_protocol_prefix); BlockDriver *bdrv_find_format(const char *format_name); BlockDriver *bdrv_find_whitelisted_format(const char *format_name, bool readonly); int bdrv_create(BlockDriver *drv, const char* filename, QEMUOptionParameter *options); int bdrv_create_file(const char* filename, QEMUOptionParameter *options); BlockDriverState *bdrv_new(const char *device_name); void bdrv_make_anon(BlockDriverState *bs); void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old); void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); void bdrv_delete(BlockDriverState *bs); int bdrv_parse_cache_flags(const char *mode, int *flags); int bdrv_parse_discard_flags(const char *mode, int *flags); int bdrv_file_open(BlockDriverState **pbs, const char *filename, QDict *options, int flags); int bdrv_open_backing_file(BlockDriverState *bs, QDict *options); int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, int flags, BlockDriver *drv); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, int flags); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp); void bdrv_reopen_commit(BDRVReopenState *reopen_state); void bdrv_reopen_abort(BDRVReopenState *reopen_state); void bdrv_close(BlockDriverState *bs); void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify); int bdrv_attach_dev(BlockDriverState *bs, void *dev); void bdrv_attach_dev_nofail(BlockDriverState *bs, void *dev); void bdrv_detach_dev(BlockDriverState *bs, void *dev); void *bdrv_get_attached_dev(BlockDriverState *bs); void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, void *opaque); void bdrv_dev_eject_request(BlockDriverState *bs, bool force); bool bdrv_dev_has_removable_media(BlockDriverState *bs); bool bdrv_dev_is_tray_open(BlockDriverState *bs); bool bdrv_dev_is_medium_locked(BlockDriverState *bs); int bdrv_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); int bdrv_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov); int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int count); int bdrv_pwrite(BlockDriverState *bs, int64_t offset, const void *buf, int count); int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov); int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, const void *buf, int count); int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); /* * Efficiently zero a region of the disk image. Note that this is a regular * I/O request like read or write and should have a reasonable size. This * function is not suitable for zeroing the entire image in a single request * because it may allocate memory for the entire region. */ int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); int bdrv_get_backing_file_depth(BlockDriverState *bs); int bdrv_truncate(BlockDriverState *bs, int64_t offset); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); int bdrv_commit(BlockDriverState *bs); int bdrv_commit_all(void); int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); void bdrv_register(BlockDriver *bdrv); int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, BlockDriverState *base); BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs); BlockDriverState *bdrv_find_base(BlockDriverState *bs); typedef struct BdrvCheckResult { int corruptions; int leaks; int check_errors; int corruptions_fixed; int leaks_fixed; int64_t image_end_offset; BlockFragInfo bfi; } BdrvCheckResult; typedef enum { BDRV_FIX_LEAKS = 1, BDRV_FIX_ERRORS = 2, } BdrvCheckMode; int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); /* async block I/O */ typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector, int sector_num); BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *iov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *iov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); void bdrv_aio_cancel(BlockDriverAIOCB *acb); typedef struct BlockRequest { /* Fields to be filled by multiwrite caller */ int64_t sector; int nb_sectors; QEMUIOVector *qiov; BlockDriverCompletionFunc *cb; void *opaque; /* Filled by multiwrite implementation */ int error; } BlockRequest; int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs); /* sg packet commands */ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf); BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque); /* Invalidate any cached metadata used by image formats */ void bdrv_invalidate_cache(BlockDriverState *bs); void bdrv_invalidate_cache_all(void); void bdrv_clear_incoming_migration_all(void); /* Ensure contents are flushed to disk. */ int bdrv_flush(BlockDriverState *bs); int coroutine_fn bdrv_co_flush(BlockDriverState *bs); int bdrv_flush_all(void); void bdrv_close_all(void); void bdrv_drain_all(void); int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int bdrv_has_zero_init_1(BlockDriverState *bs); int bdrv_has_zero_init(BlockDriverState *bs); int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error, BlockdevOnError on_write_error); BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read); BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error); void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error); int bdrv_is_read_only(BlockDriverState *bs); int bdrv_is_sg(BlockDriverState *bs); int bdrv_enable_write_cache(BlockDriverState *bs); void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce); int bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); void bdrv_lock_medium(BlockDriverState *bs, bool locked); void bdrv_eject(BlockDriverState *bs, bool eject_flag); const char *bdrv_get_format_name(BlockDriverState *bs); BlockDriverState *bdrv_find(const char *name); BlockDriverState *bdrv_next(BlockDriverState *bs); void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque); int bdrv_is_encrypted(BlockDriverState *bs); int bdrv_key_required(BlockDriverState *bs); int bdrv_set_key(BlockDriverState *bs, const char *key); int bdrv_query_missing_keys(void); void bdrv_iterate_format(void (*it)(void *opaque, const char *name), void *opaque); const char *bdrv_get_device_name(BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); void bdrv_round_to_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int64_t *cluster_sector_num, int *cluster_nb_sectors); const char *bdrv_get_encrypted_filename(BlockDriverState *bs); void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size); void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size_t sz); int bdrv_is_snapshot(BlockDriverState *bs); int path_is_absolute(const char *path); void path_combine(char *dest, int dest_size, const char *base_path, const char *filename); int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size); int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size); void bdrv_img_create(const char *filename, const char *fmt, const char *base_filename, const char *base_fmt, char *options, uint64_t img_size, int flags, Error **errp, bool quiet); void bdrv_set_buffer_alignment(BlockDriverState *bs, int align); void *qemu_blockalign(BlockDriverState *bs, size_t size); bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov); struct HBitmapIter; void bdrv_set_dirty_tracking(BlockDriverState *bs, int granularity); int bdrv_get_dirty(BlockDriverState *bs, int64_t sector); void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); void bdrv_dirty_iter_init(BlockDriverState *bs, struct HBitmapIter *hbi); int64_t bdrv_get_dirty_count(BlockDriverState *bs); void bdrv_enable_copy_on_read(BlockDriverState *bs); void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_set_in_use(BlockDriverState *bs, int in_use); int bdrv_in_use(BlockDriverState *bs); #ifdef CONFIG_LINUX_AIO int raw_get_aio_fd(BlockDriverState *bs); #else static inline int raw_get_aio_fd(BlockDriverState *bs) { return -ENOTSUP; } #endif enum BlockAcctType { BDRV_ACCT_READ, BDRV_ACCT_WRITE, BDRV_ACCT_FLUSH, BDRV_MAX_IOTYPE, }; typedef struct BlockAcctCookie { int64_t bytes; int64_t start_time_ns; enum BlockAcctType type; } BlockAcctCookie; void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type); void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie); typedef enum { BLKDBG_L1_UPDATE, BLKDBG_L1_GROW_ALLOC_TABLE, BLKDBG_L1_GROW_WRITE_TABLE, BLKDBG_L1_GROW_ACTIVATE_TABLE, BLKDBG_L2_LOAD, BLKDBG_L2_UPDATE, BLKDBG_L2_UPDATE_COMPRESSED, BLKDBG_L2_ALLOC_COW_READ, BLKDBG_L2_ALLOC_WRITE, BLKDBG_READ_AIO, BLKDBG_READ_BACKING_AIO, BLKDBG_READ_COMPRESSED, BLKDBG_WRITE_AIO, BLKDBG_WRITE_COMPRESSED, BLKDBG_VMSTATE_LOAD, BLKDBG_VMSTATE_SAVE, BLKDBG_COW_READ, BLKDBG_COW_WRITE, BLKDBG_REFTABLE_LOAD, BLKDBG_REFTABLE_GROW, BLKDBG_REFBLOCK_LOAD, BLKDBG_REFBLOCK_UPDATE, BLKDBG_REFBLOCK_UPDATE_PART, BLKDBG_REFBLOCK_ALLOC, BLKDBG_REFBLOCK_ALLOC_HOOKUP, BLKDBG_REFBLOCK_ALLOC_WRITE, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE, BLKDBG_CLUSTER_ALLOC, BLKDBG_CLUSTER_ALLOC_BYTES, BLKDBG_CLUSTER_FREE, BLKDBG_FLUSH_TO_OS, BLKDBG_FLUSH_TO_DISK, BLKDBG_EVENT_MAX, } BlkDebugEvent; #define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt) void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event); int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, const char *tag); int bdrv_debug_resume(BlockDriverState *bs, const char *tag); bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag); #endif glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/snapshot.h0000644000076200007630000000013212617742532023666 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.462336821 glusterfs-3.7.6/contrib/qemu/include/block/snapshot.h0000644000076200007630000000441612617742532024110 0ustar00jenkinsjenkins00000000000000/* * Block layer snapshot related functions * * Copyright (c) 2003-2008 Fabrice Bellard * * 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. */ #ifndef SNAPSHOT_H #define SNAPSHOT_H #include "qemu-common.h" typedef struct QEMUSnapshotInfo { char id_str[128]; /* unique snapshot id */ /* the following fields are informative. They are not needed for the consistency of the snapshot */ char name[256]; /* user chosen name */ uint64_t vm_state_size; /* VM state info size */ uint32_t date_sec; /* UTC date of the snapshot */ uint32_t date_nsec; uint64_t vm_clock_nsec; /* VM clock relative to boot */ } QEMUSnapshotInfo; int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, const char *name); int bdrv_can_snapshot(BlockDriverState *bs); int bdrv_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); int bdrv_snapshot_goto(BlockDriverState *bs, const char *snapshot_id); int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id); int bdrv_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_info); int bdrv_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name); #endif glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/coroutine.h0000644000076200007630000000013112617742532024035 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 29 ctime=1447019941.44333711 glusterfs-3.7.6/contrib/qemu/include/block/coroutine.h0000644000076200007630000001345512617742532024263 0ustar00jenkinsjenkins00000000000000/* * QEMU coroutine implementation * * Copyright IBM, Corp. 2011 * * Authors: * Stefan Hajnoczi * Kevin Wolf * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QEMU_COROUTINE_H #define QEMU_COROUTINE_H #include #include "qemu/queue.h" #include "qemu/timer.h" /** * Coroutines are a mechanism for stack switching and can be used for * cooperative userspace threading. These functions provide a simple but * useful flavor of coroutines that is suitable for writing sequential code, * rather than callbacks, for operations that need to give up control while * waiting for events to complete. * * These functions are re-entrant and may be used outside the global mutex. */ /** * Mark a function that executes in coroutine context * * Functions that execute in coroutine context cannot be called directly from * normal functions. In the future it would be nice to enable compiler or * static checker support for catching such errors. This annotation might make * it possible and in the meantime it serves as documentation. * * For example: * * static void coroutine_fn foo(void) { * .... * } */ #define coroutine_fn typedef struct Coroutine Coroutine; /** * Coroutine entry point * * When the coroutine is entered for the first time, opaque is passed in as an * argument. * * When this function returns, the coroutine is destroyed automatically and * execution continues in the caller who last entered the coroutine. */ typedef void coroutine_fn CoroutineEntry(void *opaque); /** * Create a new coroutine * * Use qemu_coroutine_enter() to actually transfer control to the coroutine. */ Coroutine *qemu_coroutine_create(CoroutineEntry *entry); /** * Transfer control to a coroutine * * The opaque argument is passed as the argument to the entry point when * entering the coroutine for the first time. It is subsequently ignored. */ void qemu_coroutine_enter(Coroutine *coroutine, void *opaque); /** * Transfer control back to a coroutine's caller * * This function does not return until the coroutine is re-entered using * qemu_coroutine_enter(). */ void coroutine_fn qemu_coroutine_yield(void); /** * Get the currently executing coroutine */ Coroutine *coroutine_fn qemu_coroutine_self(void); /** * Return whether or not currently inside a coroutine * * This can be used to write functions that work both when in coroutine context * and when not in coroutine context. Note that such functions cannot use the * coroutine_fn annotation since they work outside coroutine context. */ bool qemu_in_coroutine(void); /** * CoQueues are a mechanism to queue coroutines in order to continue executing * them later. They provide the fundamental primitives on which coroutine locks * are built. */ typedef struct CoQueue { QTAILQ_HEAD(, Coroutine) entries; AioContext *ctx; } CoQueue; /** * Initialise a CoQueue. This must be called before any other operation is used * on the CoQueue. */ void qemu_co_queue_init(CoQueue *queue); /** * Adds the current coroutine to the CoQueue and transfers control to the * caller of the coroutine. */ void coroutine_fn qemu_co_queue_wait(CoQueue *queue); /** * Adds the current coroutine to the head of the CoQueue and transfers control to the * caller of the coroutine. */ void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue); /** * Restarts the next coroutine in the CoQueue and removes it from the queue. * * Returns true if a coroutine was restarted, false if the queue is empty. */ bool qemu_co_queue_next(CoQueue *queue); /** * Restarts all coroutines in the CoQueue and leaves the queue empty. */ void qemu_co_queue_restart_all(CoQueue *queue); /** * Checks if the CoQueue is empty. */ bool qemu_co_queue_empty(CoQueue *queue); /** * Provides a mutex that can be used to synchronise coroutines */ typedef struct CoMutex { bool locked; CoQueue queue; } CoMutex; /** * Initialises a CoMutex. This must be called before any other operation is used * on the CoMutex. */ void qemu_co_mutex_init(CoMutex *mutex); /** * Locks the mutex. If the lock cannot be taken immediately, control is * transferred to the caller of the current coroutine. */ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex); /** * Unlocks the mutex and schedules the next coroutine that was waiting for this * lock to be run. */ void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex); typedef struct CoRwlock { bool writer; int reader; CoQueue queue; } CoRwlock; /** * Initialises a CoRwlock. This must be called before any other operation * is used on the CoRwlock */ void qemu_co_rwlock_init(CoRwlock *lock); /** * Read locks the CoRwlock. If the lock cannot be taken immediately because * of a parallel writer, control is transferred to the caller of the current * coroutine. */ void qemu_co_rwlock_rdlock(CoRwlock *lock); /** * Write Locks the mutex. If the lock cannot be taken immediately because * of a parallel reader, control is transferred to the caller of the current * coroutine. */ void qemu_co_rwlock_wrlock(CoRwlock *lock); /** * Unlocks the read/write lock and schedules the next coroutine that was * waiting for this lock to be run. */ void qemu_co_rwlock_unlock(CoRwlock *lock); /** * Yield the coroutine for a given duration * * Note this function uses timers and hence only works when a main loop is in * use. See main-loop.h and do not use from qemu-tool programs. */ void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns); /** * Yield until a file descriptor becomes readable * * Note that this function clobbers the handlers for the file descriptor. */ void coroutine_fn yield_until_fd_readable(int fd); #endif /* QEMU_COROUTINE_H */ glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/blockjob.h0000644000076200007630000000013212617742532023614 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.456336913 glusterfs-3.7.6/contrib/qemu/include/block/blockjob.h0000644000076200007630000002023212617742532024030 0ustar00jenkinsjenkins00000000000000/* * Declarations for long-running block device operations * * Copyright (c) 2011 IBM Corp. * Copyright (c) 2012 Red Hat, Inc. * * 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. */ #ifndef BLOCKJOB_H #define BLOCKJOB_H 1 #include "block/block.h" /** * BlockJobType: * * A class type for block job objects. */ typedef struct BlockJobType { /** Derived BlockJob struct size */ size_t instance_size; /** String describing the operation, part of query-block-jobs QMP API */ const char *job_type; /** Optional callback for job types that support setting a speed limit */ void (*set_speed)(BlockJob *job, int64_t speed, Error **errp); /** Optional callback for job types that need to forward I/O status reset */ void (*iostatus_reset)(BlockJob *job); /** * Optional callback for job types whose completion must be triggered * manually. */ void (*complete)(BlockJob *job, Error **errp); } BlockJobType; /** * BlockJob: * * Long-running operation on a BlockDriverState. */ struct BlockJob { /** The job type, including the job vtable. */ const BlockJobType *job_type; /** The block device on which the job is operating. */ BlockDriverState *bs; /** * The coroutine that executes the job. If not NULL, it is * reentered when busy is false and the job is cancelled. */ Coroutine *co; /** * Set to true if the job should cancel itself. The flag must * always be tested just before toggling the busy flag from false * to true. After a job has been cancelled, it should only yield * if #qemu_aio_wait will ("sooner or later") reenter the coroutine. */ bool cancelled; /** * Set to true if the job is either paused, or will pause itself * as soon as possible (if busy == true). */ bool paused; /** * Set to false by the job while it is in a quiescent state, where * no I/O is pending and the job has yielded on any condition * that is not detected by #qemu_aio_wait, such as a timer. */ bool busy; /** Status that is published by the query-block-jobs QMP API */ BlockDeviceIoStatus iostatus; /** Offset that is published by the query-block-jobs QMP API */ int64_t offset; /** Length that is published by the query-block-jobs QMP API */ int64_t len; /** Speed that was set with @block_job_set_speed. */ int64_t speed; /** The completion function that will be called when the job completes. */ BlockDriverCompletionFunc *cb; /** The opaque value that is passed to the completion function. */ void *opaque; }; /** * block_job_create: * @job_type: The class object for the newly-created job. * @bs: The block * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @errp: Error object. * * Create a new long-running block device job and return it. The job * will call @cb asynchronously when the job completes. Note that * @bs may have been closed at the time the @cb it is called. If * this is the case, the job may be reported as either cancelled or * completed. * * This function is not part of the public job interface; it should be * called from a wrapper that is specific to the job type. */ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, void *opaque, Error **errp); /** * block_job_sleep_ns: * @job: The job that calls the function. * @clock: The clock to sleep on. * @ns: How many nanoseconds to stop for. * * Put the job to sleep (assuming that it wasn't canceled) for @ns * nanoseconds. Canceling the job will interrupt the wait immediately. */ void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns); /** * block_job_completed: * @job: The job being completed. * @ret: The status code. * * Call the completion function that was registered at creation time, and * free @job. */ void block_job_completed(BlockJob *job, int ret); /** * block_job_set_speed: * @job: The job to set the speed for. * @speed: The new value * @errp: Error object. * * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. */ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); /** * block_job_cancel: * @job: The job to be canceled. * * Asynchronously cancel the specified job. */ void block_job_cancel(BlockJob *job); /** * block_job_complete: * @job: The job to be completed. * @errp: Error object. * * Asynchronously complete the specified job. */ void block_job_complete(BlockJob *job, Error **errp); /** * block_job_is_cancelled: * @job: The job being queried. * * Returns whether the job is scheduled for cancellation. */ bool block_job_is_cancelled(BlockJob *job); /** * block_job_query: * @job: The job to get information about. * * Return information about a job. */ BlockJobInfo *block_job_query(BlockJob *job); /** * block_job_pause: * @job: The job to be paused. * * Asynchronously pause the specified job. */ void block_job_pause(BlockJob *job); /** * block_job_resume: * @job: The job to be resumed. * * Resume the specified job. */ void block_job_resume(BlockJob *job); /** * qobject_from_block_job: * @job: The job whose information is requested. * * Return a QDict corresponding to @job's query-block-jobs entry. */ QObject *qobject_from_block_job(BlockJob *job); /** * block_job_ready: * @job: The job which is now ready to complete. * * Send a BLOCK_JOB_READY event for the specified job. */ void block_job_ready(BlockJob *job); /** * block_job_is_paused: * @job: The job being queried. * * Returns whether the job is currently paused, or will pause * as soon as it reaches a sleeping point. */ bool block_job_is_paused(BlockJob *job); /** * block_job_cancel_sync: * @job: The job to be canceled. * * Synchronously cancel the job. The completion callback is called * before the function returns. The job may actually complete * instead of canceling itself; the circumstances under which this * happens depend on the kind of job that is active. * * Returns the return value from the job if the job actually completed * during the call, or -ECANCELED if it was canceled. */ int block_job_cancel_sync(BlockJob *job); /** * block_job_iostatus_reset: * @job: The job whose I/O status should be reset. * * Reset I/O status on @job and on BlockDriverState objects it uses, * other than job->bs. */ void block_job_iostatus_reset(BlockJob *job); /** * block_job_error_action: * @job: The job to signal an error for. * @bs: The block device on which to set an I/O error. * @on_err: The error action setting. * @is_read: Whether the operation was a read. * @error: The error that was reported. * * Report an I/O error for a block job and possibly stop the VM. Return the * action that was selected based on @on_err and @error. */ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, BlockdevOnError on_err, int is_read, int error); #endif glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/aio.h0000644000076200007630000000013112617742532022576 xustar000000000000000029 mtime=1447019866.03547157 30 atime=1447019866.371466515 30 ctime=1447019941.446337064 glusterfs-3.7.6/contrib/qemu/include/block/aio.h0000644000076200007630000001736712617742532023032 0ustar00jenkinsjenkins00000000000000/* * QEMU aio implementation * * Copyright IBM, Corp. 2008 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * */ #ifndef QEMU_AIO_H #define QEMU_AIO_H #include "qemu-common.h" #include "qemu/queue.h" #include "qemu/event_notifier.h" typedef struct BlockDriverAIOCB BlockDriverAIOCB; typedef void BlockDriverCompletionFunc(void *opaque, int ret); typedef struct AIOCBInfo { void (*cancel)(BlockDriverAIOCB *acb); size_t aiocb_size; } AIOCBInfo; struct BlockDriverAIOCB { const AIOCBInfo *aiocb_info; BlockDriverState *bs; BlockDriverCompletionFunc *cb; void *opaque; }; void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); void qemu_aio_release(void *p); typedef struct AioHandler AioHandler; typedef void QEMUBHFunc(void *opaque); typedef void IOHandler(void *opaque); typedef struct AioContext { GSource source; /* The list of registered AIO handlers */ QLIST_HEAD(, AioHandler) aio_handlers; /* This is a simple lock used to protect the aio_handlers list. * Specifically, it's used to ensure that no callbacks are removed while * we're walking and dispatching callbacks. */ int walking_handlers; /* Anchor of the list of Bottom Halves belonging to the context */ struct QEMUBH *first_bh; /* A simple lock used to protect the first_bh list, and ensure that * no callbacks are removed while we're walking and dispatching callbacks. */ int walking_bh; /* Used for aio_notify. */ EventNotifier notifier; /* GPollFDs for aio_poll() */ GArray *pollfds; /* Thread pool for performing work and receiving completion callbacks */ struct ThreadPool *thread_pool; } AioContext; /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */ typedef int (AioFlushEventNotifierHandler)(EventNotifier *e); /** * aio_context_new: Allocate a new AioContext. * * AioContext provide a mini event-loop that can be waited on synchronously. * They also provide bottom halves, a service to execute a piece of code * as soon as possible. */ AioContext *aio_context_new(void); /** * aio_context_ref: * @ctx: The AioContext to operate on. * * Add a reference to an AioContext. */ void aio_context_ref(AioContext *ctx); /** * aio_context_unref: * @ctx: The AioContext to operate on. * * Drop a reference to an AioContext. */ void aio_context_unref(AioContext *ctx); /** * aio_bh_new: Allocate a new bottom half structure. * * Bottom halves are lightweight callbacks whose invocation is guaranteed * to be wait-free, thread-safe and signal-safe. The #QEMUBH structure * is opaque and must be allocated prior to its use. */ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque); /** * aio_notify: Force processing of pending events. * * Similar to signaling a condition variable, aio_notify forces * aio_wait to exit, so that the next call will re-examine pending events. * The caller of aio_notify will usually call aio_wait again very soon, * or go through another iteration of the GLib main loop. Hence, aio_notify * also has the side effect of recalculating the sets of file descriptors * that the main loop waits for. * * Calling aio_notify is rarely necessary, because for example scheduling * a bottom half calls it already. */ void aio_notify(AioContext *ctx); /** * aio_bh_poll: Poll bottom halves for an AioContext. * * These are internal functions used by the QEMU main loop. */ int aio_bh_poll(AioContext *ctx); /** * qemu_bh_schedule: Schedule a bottom half. * * Scheduling a bottom half interrupts the main loop and causes the * execution of the callback that was passed to qemu_bh_new. * * Bottom halves that are scheduled from a bottom half handler are instantly * invoked. This can create an infinite loop if a bottom half handler * schedules itself. * * @bh: The bottom half to be scheduled. */ void qemu_bh_schedule(QEMUBH *bh); /** * qemu_bh_cancel: Cancel execution of a bottom half. * * Canceling execution of a bottom half undoes the effect of calls to * qemu_bh_schedule without freeing its resources yet. While cancellation * itself is also wait-free and thread-safe, it can of course race with the * loop that executes bottom halves unless you are holding the iothread * mutex. This makes it mostly useless if you are not holding the mutex. * * @bh: The bottom half to be canceled. */ void qemu_bh_cancel(QEMUBH *bh); /** *qemu_bh_delete: Cancel execution of a bottom half and free its resources. * * Deleting a bottom half frees the memory that was allocated for it by * qemu_bh_new. It also implies canceling the bottom half if it was * scheduled. * * @bh: The bottom half to be deleted. */ void qemu_bh_delete(QEMUBH *bh); /* Return whether there are any pending callbacks from the GSource * attached to the AioContext. * * This is used internally in the implementation of the GSource. */ bool aio_pending(AioContext *ctx); /* Progress in completing AIO work to occur. This can issue new pending * aio as a result of executing I/O completion or bh callbacks. * * If there is no pending AIO operation or completion (bottom half), * return false. If there are pending AIO operations of bottom halves, * return true. * * If there are no pending bottom halves, but there are pending AIO * operations, it may not be possible to make any progress without * blocking. If @blocking is true, this function will wait until one * or more AIO events have completed, to ensure something has moved * before returning. */ bool aio_poll(AioContext *ctx, bool blocking); #ifdef CONFIG_POSIX /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */ typedef int (AioFlushHandler)(void *opaque); /* Register a file descriptor and associated callbacks. Behaves very similarly * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will * be invoked when using qemu_aio_wait(). * * Code that invokes AIO completion functions should rely on this function * instead of qemu_set_fd_handler[2]. */ void aio_set_fd_handler(AioContext *ctx, int fd, IOHandler *io_read, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque); #endif /* Register an event notifier and associated callbacks. Behaves very similarly * to event_notifier_set_handler. Unlike event_notifier_set_handler, these callbacks * will be invoked when using qemu_aio_wait(). * * Code that invokes AIO completion functions should rely on this function * instead of event_notifier_set_handler. */ void aio_set_event_notifier(AioContext *ctx, EventNotifier *notifier, EventNotifierHandler *io_read, AioFlushEventNotifierHandler *io_flush); /* Return a GSource that lets the main loop poll the file descriptors attached * to this AioContext. */ GSource *aio_get_g_source(AioContext *ctx); /* Return the ThreadPool bound to this AioContext */ struct ThreadPool *aio_get_thread_pool(AioContext *ctx); /* Functions to operate on the main QEMU AioContext. */ bool qemu_aio_wait(void); void qemu_aio_set_event_notifier(EventNotifier *notifier, EventNotifierHandler *io_read, AioFlushEventNotifierHandler *io_flush); #ifdef CONFIG_POSIX void qemu_aio_set_fd_handler(int fd, IOHandler *io_read, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque); #endif #endif glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/block_int.h0000644000076200007630000000013212617742532023773 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.452336973 glusterfs-3.7.6/contrib/qemu/include/block/block_int.h0000644000076200007630000004054412617742532024217 0ustar00jenkinsjenkins00000000000000/* * QEMU System Emulator block driver * * Copyright (c) 2003 Fabrice Bellard * * 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. */ #ifndef BLOCK_INT_H #define BLOCK_INT_H #include "block/block.h" #include "qemu/option.h" #include "qemu/queue.h" #include "block/coroutine.h" #include "qemu/timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" #include "monitor/monitor.h" #include "qemu/hbitmap.h" #include "block/snapshot.h" #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 #define BLOCK_FLAG_LAZY_REFCOUNTS 8 #define BLOCK_IO_LIMIT_READ 0 #define BLOCK_IO_LIMIT_WRITE 1 #define BLOCK_IO_LIMIT_TOTAL 2 #define BLOCK_IO_SLICE_TIME 100000000 #define NANOSECONDS_PER_SECOND 1000000000.0 #define BLOCK_OPT_SIZE "size" #define BLOCK_OPT_ENCRYPT "encryption" #define BLOCK_OPT_COMPAT6 "compat6" #define BLOCK_OPT_BACKING_FILE "backing_file" #define BLOCK_OPT_BACKING_FMT "backing_fmt" #define BLOCK_OPT_CLUSTER_SIZE "cluster_size" #define BLOCK_OPT_TABLE_SIZE "table_size" #define BLOCK_OPT_PREALLOC "preallocation" #define BLOCK_OPT_SUBFMT "subformat" #define BLOCK_OPT_COMPAT_LEVEL "compat" #define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts" #define BLOCK_OPT_ADAPTER_TYPE "adapter_type" typedef struct BdrvTrackedRequest { BlockDriverState *bs; int64_t sector_num; int nb_sectors; bool is_write; QLIST_ENTRY(BdrvTrackedRequest) list; Coroutine *co; /* owner, used for deadlock detection */ CoQueue wait_queue; /* coroutines blocked on this request */ } BdrvTrackedRequest; typedef struct BlockIOLimit { int64_t bps[3]; int64_t iops[3]; } BlockIOLimit; typedef struct BlockIOBaseValue { uint64_t bytes[2]; uint64_t ios[2]; } BlockIOBaseValue; struct BlockDriver { const char *format_name; int instance_size; int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); int (*bdrv_probe_device)(const char *filename); /* Any driver implementing this callback is expected to be able to handle * NULL file names in its .bdrv_open() implementation */ void (*bdrv_parse_filename)(const char *filename, QDict *options, Error **errp); /* For handling image reopen for split or non-split files */ int (*bdrv_reopen_prepare)(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp); void (*bdrv_reopen_commit)(BDRVReopenState *reopen_state); void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state); int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags); int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags); int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); void (*bdrv_close)(BlockDriverState *bs); void (*bdrv_rebind)(BlockDriverState *bs); int (*bdrv_create)(const char *filename, QEMUOptionParameter *options); int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); /* aio */ BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); BlockDriverAIOCB *(*bdrv_aio_discard)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); /* * Efficiently zero a region of the disk image. Typically an image format * would use a compact metadata representation to implement this. This * function pointer may be NULL and .bdrv_co_writev() will be called * instead. */ int coroutine_fn (*bdrv_co_write_zeroes)(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); /* * Invalidate any cached meta-data. */ void (*bdrv_invalidate_cache)(BlockDriverState *bs); /* * Flushes all data that was already written to the OS all the way down to * the disk (for example raw-posix calls fsync()). */ int coroutine_fn (*bdrv_co_flush_to_disk)(BlockDriverState *bs); /* * Flushes all internal caches to the OS. The data may still sit in a * writeback cache of the host OS, but it will survive a crash of the qemu * process. */ int coroutine_fn (*bdrv_co_flush_to_os)(BlockDriverState *bs); const char *protocol_name; int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset); int64_t (*bdrv_getlength)(BlockDriverState *bs); int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); int (*bdrv_snapshot_create)(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); int (*bdrv_snapshot_goto)(BlockDriverState *bs, const char *snapshot_id); int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id); int (*bdrv_snapshot_list)(BlockDriverState *bs, QEMUSnapshotInfo **psn_info); int (*bdrv_snapshot_load_tmp)(BlockDriverState *bs, const char *snapshot_name); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size); int (*bdrv_change_backing_file)(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); /* removable device specific */ int (*bdrv_is_inserted)(BlockDriverState *bs); int (*bdrv_media_changed)(BlockDriverState *bs); void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); /* to control generic scsi devices */ int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf); BlockDriverAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque); /* List of options for creating images, terminated by name == NULL */ QEMUOptionParameter *create_options; /* * Returns 0 for completed check, -errno for internal errors. * The check results are stored in result. */ int (*bdrv_check)(BlockDriverState* bs, BdrvCheckResult *result, BdrvCheckMode fix); void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event); /* TODO Better pass a option string/QDict/QemuOpts to add any rule? */ int (*bdrv_debug_breakpoint)(BlockDriverState *bs, const char *event, const char *tag); int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag); bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); /* * Returns 1 if newly created images are guaranteed to contain only * zeros, 0 otherwise. */ int (*bdrv_has_zero_init)(BlockDriverState *bs); QLIST_ENTRY(BlockDriver) list; }; /* * Note: the function bdrv_append() copies and swaps contents of * BlockDriverStates, so if you add new fields to this struct, please * inspect bdrv_append() to determine if the new fields need to be * copied as well. */ struct BlockDriverState { int64_t total_sectors; /* if we are reading a disk image, give its size in sectors */ int read_only; /* if true, the media is read only */ int open_flags; /* flags used to open the file, re-used for re-open */ int encrypted; /* if true, the media is encrypted */ int valid_key; /* if true, a valid encryption key has been set */ int sg; /* if true, the device is a /dev/sg* */ int copy_on_read; /* if true, copy read backing sectors into image note this is a reference count */ BlockDriver *drv; /* NULL means no media */ void *opaque; void *dev; /* attached device model, if any */ /* TODO change to DeviceState when all users are qdevified */ const BlockDevOps *dev_ops; void *dev_opaque; char filename[1024]; char backing_file[1024]; /* if non zero, the image is a diff of this file image */ char backing_format[16]; /* if non-zero and backing_file exists */ int is_temporary; BlockDriverState *backing_hd; BlockDriverState *file; NotifierList close_notifiers; /* Callback before write request is processed */ NotifierWithReturnList before_write_notifiers; /* number of in-flight copy-on-read requests */ unsigned int copy_on_read_in_flight; /* the time for latest disk I/O */ int64_t slice_start; int64_t slice_end; BlockIOLimit io_limits; BlockIOBaseValue slice_submitted; CoQueue throttled_reqs; QEMUTimer *block_timer; bool io_limits_enabled; /* I/O stats (display with "info blockstats"). */ uint64_t nr_bytes[BDRV_MAX_IOTYPE]; uint64_t nr_ops[BDRV_MAX_IOTYPE]; uint64_t total_time_ns[BDRV_MAX_IOTYPE]; uint64_t wr_highest_sector; /* Whether the disk can expand beyond total_sectors */ int growable; /* the memory alignment required for the buffers handled by this driver */ int buffer_alignment; /* do we need to tell the quest if we have a volatile write cache? */ int enable_write_cache; /* NOTE: the following infos are only hints for real hardware drivers. They are not used by the block driver */ BlockdevOnError on_read_error, on_write_error; bool iostatus_enabled; BlockDeviceIoStatus iostatus; char device_name[32]; HBitmap *dirty_bitmap; int in_use; /* users other than guest access, eg. block migration */ QTAILQ_ENTRY(BlockDriverState) list; QLIST_HEAD(, BdrvTrackedRequest) tracked_requests; /* long-running background operation */ BlockJob *job; QDict *options; }; int get_tmp_filename(char *filename, int size); void bdrv_set_io_limits(BlockDriverState *bs, BlockIOLimit *io_limits); /** * bdrv_add_before_write_notifier: * * Register a callback that is invoked before write requests are processed but * after any throttling or waiting for overlapping requests. */ void bdrv_add_before_write_notifier(BlockDriverState *bs, NotifierWithReturn *notifier); /** * bdrv_get_aio_context: * * Returns: the currently bound #AioContext */ AioContext *bdrv_get_aio_context(BlockDriverState *bs); #ifdef _WIN32 int is_windows_drive(const char *filename); #endif void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, enum MonitorEvent ev, BlockErrorAction action, bool is_read); /** * stream_start: * @bs: Block device to operate on. * @base: Block device that will become the new base, or %NULL to * flatten the whole backing file chain onto @bs. * @base_id: The file name that will be written to @bs as the new * backing file if the job completes. Ignored if @base is %NULL. * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_error: The action to take upon error. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @errp: Error object. * * Start a streaming operation on @bs. Clusters that are unallocated * in @bs, but allocated in any image between @base and @bs (both * exclusive) will be written to @bs. At the end of a successful * streaming job, the backing file of @bs will be changed to * @base_id in the written image and to @base in the live BlockDriverState. */ void stream_start(BlockDriverState *bs, BlockDriverState *base, const char *base_id, int64_t speed, BlockdevOnError on_error, BlockDriverCompletionFunc *cb, void *opaque, Error **errp); /** * commit_start: * @bs: Top Block device * @base: Block device that will be written into, and become the new top * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_error: The action to take upon error. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @errp: Error object. * */ void commit_start(BlockDriverState *bs, BlockDriverState *base, BlockDriverState *top, int64_t speed, BlockdevOnError on_error, BlockDriverCompletionFunc *cb, void *opaque, Error **errp); /* * mirror_start: * @bs: Block device to operate on. * @target: Block device to write to. * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @granularity: The chosen granularity for the dirty bitmap. * @buf_size: The amount of data that can be in flight at one time. * @mode: Whether to collapse all images in the chain to the target. * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @errp: Error object. * * Start a mirroring operation on @bs. Clusters that are allocated * in @bs will be written to @bs until the job is cancelled or * manually completed. At the end of a successful mirroring job, * @bs will be switched to read from @target. */ void mirror_start(BlockDriverState *bs, BlockDriverState *target, int64_t speed, int64_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockDriverCompletionFunc *cb, void *opaque, Error **errp); /* * backup_start: * @bs: Block device to operate on. * @target: Block device to write to. * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * * Start a backup operation on @bs. Clusters in @bs are written to @target * until the job is cancelled or manually completed. */ void backup_start(BlockDriverState *bs, BlockDriverState *target, int64_t speed, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockDriverCompletionFunc *cb, void *opaque, Error **errp); #endif /* BLOCK_INT_H */ glusterfs-3.7.6/contrib/qemu/include/block/PaxHeaders.7244/coroutine_int.h0000644000076200007630000000013212617742532024710 xustar000000000000000030 mtime=1447019866.036471555 30 atime=1447019866.371466515 30 ctime=1447019941.459336868 glusterfs-3.7.6/contrib/qemu/include/block/coroutine_int.h0000644000076200007630000000362312617742532025131 0ustar00jenkinsjenkins00000000000000/* * Coroutine internals * * Copyright (c) 2011 Kevin Wolf * * 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. */ #ifndef QEMU_COROUTINE_INT_H #define QEMU_COROUTINE_INT_H #include "qemu/queue.h" #include "block/coroutine.h" typedef enum { COROUTINE_YIELD = 1, COROUTINE_TERMINATE = 2, } CoroutineAction; struct Coroutine { CoroutineEntry *entry; void *entry_arg; Coroutine *caller; QSLIST_ENTRY(Coroutine) pool_next; /* Coroutines that should be woken up when we yield or terminate */ QTAILQ_HEAD(, Coroutine) co_queue_wakeup; QTAILQ_ENTRY(Coroutine) co_queue_next; }; Coroutine *qemu_coroutine_new(void); void qemu_coroutine_delete(Coroutine *co); CoroutineAction qemu_coroutine_switch(Coroutine *from, Coroutine *to, CoroutineAction action); void coroutine_fn qemu_co_queue_run_restart(Coroutine *co); #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/glib-compat.h0000644000076200007630000000013112617742532023132 xustar000000000000000029 mtime=1447019866.03747154 30 atime=1447019866.371466515 30 ctime=1447019941.433337259 glusterfs-3.7.6/contrib/qemu/include/glib-compat.h0000644000076200007630000000111512617742532023346 0ustar00jenkinsjenkins00000000000000/* * GLIB Compatibility Functions * * Copyright IBM, Corp. 2013 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. * */ #ifndef QEMU_GLIB_COMPAT_H #define QEMU_GLIB_COMPAT_H #include #if !GLIB_CHECK_VERSION(2, 14, 0) static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) { return g_timeout_add(interval * 1000, function, data); } #endif #endif glusterfs-3.7.6/contrib/qemu/include/PaxHeaders.7244/trace.h0000644000076200007630000000013112617742532022032 xustar000000000000000029 mtime=1447019866.04147148 30 atime=1447019866.373466485 30 ctime=1447019941.439337167 glusterfs-3.7.6/contrib/qemu/include/trace.h0000644000076200007630000000013512617742532022247 0ustar00jenkinsjenkins00000000000000#ifndef TRACE_H #define TRACE_H #include "trace/generated-tracers.h" #endif /* TRACE_H */ glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qapi-types.h0000644000076200007630000000013212617742532021406 xustar000000000000000030 mtime=1447019866.042471464 30 atime=1447019866.373466485 30 ctime=1447019941.420337456 glusterfs-3.7.6/contrib/qemu/qapi-types.h0000644000076200007630000015554712617742532021644 0ustar00jenkinsjenkins00000000000000/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ /* * schema-defined QAPI types * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef QAPI_TYPES_H #define QAPI_TYPES_H #include #include #ifndef QAPI_TYPES_BUILTIN_STRUCT_DECL_H #define QAPI_TYPES_BUILTIN_STRUCT_DECL_H typedef struct strList { union { char * value; uint64_t padding; }; struct strList *next; } strList; typedef struct intList { union { int64_t value; uint64_t padding; }; struct intList *next; } intList; typedef struct numberList { union { double value; uint64_t padding; }; struct numberList *next; } numberList; typedef struct boolList { union { bool value; uint64_t padding; }; struct boolList *next; } boolList; typedef struct int8List { union { int8_t value; uint64_t padding; }; struct int8List *next; } int8List; typedef struct int16List { union { int16_t value; uint64_t padding; }; struct int16List *next; } int16List; typedef struct int32List { union { int32_t value; uint64_t padding; }; struct int32List *next; } int32List; typedef struct int64List { union { int64_t value; uint64_t padding; }; struct int64List *next; } int64List; typedef struct uint8List { union { uint8_t value; uint64_t padding; }; struct uint8List *next; } uint8List; typedef struct uint16List { union { uint16_t value; uint64_t padding; }; struct uint16List *next; } uint16List; typedef struct uint32List { union { uint32_t value; uint64_t padding; }; struct uint32List *next; } uint32List; typedef struct uint64List { union { uint64_t value; uint64_t padding; }; struct uint64List *next; } uint64List; #endif /* QAPI_TYPES_BUILTIN_STRUCT_DECL_H */ extern const char *ErrorClass_lookup[]; typedef enum ErrorClass { ERROR_CLASS_GENERIC_ERROR = 0, ERROR_CLASS_COMMAND_NOT_FOUND = 1, ERROR_CLASS_DEVICE_ENCRYPTED = 2, ERROR_CLASS_DEVICE_NOT_ACTIVE = 3, ERROR_CLASS_DEVICE_NOT_FOUND = 4, ERROR_CLASS_K_V_M_MISSING_CAP = 5, ERROR_CLASS_MAX = 6, } ErrorClass; typedef struct ErrorClassList { ErrorClass value; struct ErrorClassList *next; } ErrorClassList; typedef struct NameInfo NameInfo; typedef struct NameInfoList { union { NameInfo *value; uint64_t padding; }; struct NameInfoList *next; } NameInfoList; typedef struct VersionInfo VersionInfo; typedef struct VersionInfoList { union { VersionInfo *value; uint64_t padding; }; struct VersionInfoList *next; } VersionInfoList; typedef struct KvmInfo KvmInfo; typedef struct KvmInfoList { union { KvmInfo *value; uint64_t padding; }; struct KvmInfoList *next; } KvmInfoList; extern const char *RunState_lookup[]; typedef enum RunState { RUN_STATE_DEBUG = 0, RUN_STATE_INMIGRATE = 1, RUN_STATE_INTERNAL_ERROR = 2, RUN_STATE_IO_ERROR = 3, RUN_STATE_PAUSED = 4, RUN_STATE_POSTMIGRATE = 5, RUN_STATE_PRELAUNCH = 6, RUN_STATE_FINISH_MIGRATE = 7, RUN_STATE_RESTORE_VM = 8, RUN_STATE_RUNNING = 9, RUN_STATE_SAVE_VM = 10, RUN_STATE_SHUTDOWN = 11, RUN_STATE_SUSPENDED = 12, RUN_STATE_WATCHDOG = 13, RUN_STATE_GUEST_PANICKED = 14, RUN_STATE_MAX = 15, } RunState; typedef struct RunStateList { RunState value; struct RunStateList *next; } RunStateList; typedef struct SnapshotInfo SnapshotInfo; typedef struct SnapshotInfoList { union { SnapshotInfo *value; uint64_t padding; }; struct SnapshotInfoList *next; } SnapshotInfoList; typedef struct ImageInfo ImageInfo; typedef struct ImageInfoList { union { ImageInfo *value; uint64_t padding; }; struct ImageInfoList *next; } ImageInfoList; typedef struct ImageCheck ImageCheck; typedef struct ImageCheckList { union { ImageCheck *value; uint64_t padding; }; struct ImageCheckList *next; } ImageCheckList; typedef struct StatusInfo StatusInfo; typedef struct StatusInfoList { union { StatusInfo *value; uint64_t padding; }; struct StatusInfoList *next; } StatusInfoList; typedef struct UuidInfo UuidInfo; typedef struct UuidInfoList { union { UuidInfo *value; uint64_t padding; }; struct UuidInfoList *next; } UuidInfoList; typedef struct ChardevInfo ChardevInfo; typedef struct ChardevInfoList { union { ChardevInfo *value; uint64_t padding; }; struct ChardevInfoList *next; } ChardevInfoList; extern const char *DataFormat_lookup[]; typedef enum DataFormat { DATA_FORMAT_UTF8 = 0, DATA_FORMAT_BASE64 = 1, DATA_FORMAT_MAX = 2, } DataFormat; typedef struct DataFormatList { DataFormat value; struct DataFormatList *next; } DataFormatList; typedef struct CommandInfo CommandInfo; typedef struct CommandInfoList { union { CommandInfo *value; uint64_t padding; }; struct CommandInfoList *next; } CommandInfoList; typedef struct EventInfo EventInfo; typedef struct EventInfoList { union { EventInfo *value; uint64_t padding; }; struct EventInfoList *next; } EventInfoList; typedef struct MigrationStats MigrationStats; typedef struct MigrationStatsList { union { MigrationStats *value; uint64_t padding; }; struct MigrationStatsList *next; } MigrationStatsList; typedef struct XBZRLECacheStats XBZRLECacheStats; typedef struct XBZRLECacheStatsList { union { XBZRLECacheStats *value; uint64_t padding; }; struct XBZRLECacheStatsList *next; } XBZRLECacheStatsList; typedef struct MigrationInfo MigrationInfo; typedef struct MigrationInfoList { union { MigrationInfo *value; uint64_t padding; }; struct MigrationInfoList *next; } MigrationInfoList; extern const char *MigrationCapability_lookup[]; typedef enum MigrationCapability { MIGRATION_CAPABILITY_XBZRLE = 0, MIGRATION_CAPABILITY_X_RDMA_PIN_ALL = 1, MIGRATION_CAPABILITY_AUTO_CONVERGE = 2, MIGRATION_CAPABILITY_MAX = 3, } MigrationCapability; typedef struct MigrationCapabilityList { MigrationCapability value; struct MigrationCapabilityList *next; } MigrationCapabilityList; typedef struct MigrationCapabilityStatus MigrationCapabilityStatus; typedef struct MigrationCapabilityStatusList { union { MigrationCapabilityStatus *value; uint64_t padding; }; struct MigrationCapabilityStatusList *next; } MigrationCapabilityStatusList; typedef struct MouseInfo MouseInfo; typedef struct MouseInfoList { union { MouseInfo *value; uint64_t padding; }; struct MouseInfoList *next; } MouseInfoList; typedef struct CpuInfo CpuInfo; typedef struct CpuInfoList { union { CpuInfo *value; uint64_t padding; }; struct CpuInfoList *next; } CpuInfoList; typedef struct BlockDeviceInfo BlockDeviceInfo; typedef struct BlockDeviceInfoList { union { BlockDeviceInfo *value; uint64_t padding; }; struct BlockDeviceInfoList *next; } BlockDeviceInfoList; extern const char *BlockDeviceIoStatus_lookup[]; typedef enum BlockDeviceIoStatus { BLOCK_DEVICE_IO_STATUS_OK = 0, BLOCK_DEVICE_IO_STATUS_FAILED = 1, BLOCK_DEVICE_IO_STATUS_NOSPACE = 2, BLOCK_DEVICE_IO_STATUS_MAX = 3, } BlockDeviceIoStatus; typedef struct BlockDeviceIoStatusList { BlockDeviceIoStatus value; struct BlockDeviceIoStatusList *next; } BlockDeviceIoStatusList; typedef struct BlockDirtyInfo BlockDirtyInfo; typedef struct BlockDirtyInfoList { union { BlockDirtyInfo *value; uint64_t padding; }; struct BlockDirtyInfoList *next; } BlockDirtyInfoList; typedef struct BlockInfo BlockInfo; typedef struct BlockInfoList { union { BlockInfo *value; uint64_t padding; }; struct BlockInfoList *next; } BlockInfoList; typedef struct BlockDeviceStats BlockDeviceStats; typedef struct BlockDeviceStatsList { union { BlockDeviceStats *value; uint64_t padding; }; struct BlockDeviceStatsList *next; } BlockDeviceStatsList; typedef struct BlockStats BlockStats; typedef struct BlockStatsList { union { BlockStats *value; uint64_t padding; }; struct BlockStatsList *next; } BlockStatsList; typedef struct VncClientInfo VncClientInfo; typedef struct VncClientInfoList { union { VncClientInfo *value; uint64_t padding; }; struct VncClientInfoList *next; } VncClientInfoList; typedef struct VncInfo VncInfo; typedef struct VncInfoList { union { VncInfo *value; uint64_t padding; }; struct VncInfoList *next; } VncInfoList; typedef struct SpiceChannel SpiceChannel; typedef struct SpiceChannelList { union { SpiceChannel *value; uint64_t padding; }; struct SpiceChannelList *next; } SpiceChannelList; extern const char *SpiceQueryMouseMode_lookup[]; typedef enum SpiceQueryMouseMode { SPICE_QUERY_MOUSE_MODE_CLIENT = 0, SPICE_QUERY_MOUSE_MODE_SERVER = 1, SPICE_QUERY_MOUSE_MODE_UNKNOWN = 2, SPICE_QUERY_MOUSE_MODE_MAX = 3, } SpiceQueryMouseMode; typedef struct SpiceQueryMouseModeList { SpiceQueryMouseMode value; struct SpiceQueryMouseModeList *next; } SpiceQueryMouseModeList; typedef struct SpiceInfo SpiceInfo; typedef struct SpiceInfoList { union { SpiceInfo *value; uint64_t padding; }; struct SpiceInfoList *next; } SpiceInfoList; typedef struct BalloonInfo BalloonInfo; typedef struct BalloonInfoList { union { BalloonInfo *value; uint64_t padding; }; struct BalloonInfoList *next; } BalloonInfoList; typedef struct PciMemoryRange PciMemoryRange; typedef struct PciMemoryRangeList { union { PciMemoryRange *value; uint64_t padding; }; struct PciMemoryRangeList *next; } PciMemoryRangeList; typedef struct PciMemoryRegion PciMemoryRegion; typedef struct PciMemoryRegionList { union { PciMemoryRegion *value; uint64_t padding; }; struct PciMemoryRegionList *next; } PciMemoryRegionList; typedef struct PciBridgeInfo PciBridgeInfo; typedef struct PciBridgeInfoList { union { PciBridgeInfo *value; uint64_t padding; }; struct PciBridgeInfoList *next; } PciBridgeInfoList; typedef struct PciDeviceInfo PciDeviceInfo; typedef struct PciDeviceInfoList { union { PciDeviceInfo *value; uint64_t padding; }; struct PciDeviceInfoList *next; } PciDeviceInfoList; typedef struct PciInfo PciInfo; typedef struct PciInfoList { union { PciInfo *value; uint64_t padding; }; struct PciInfoList *next; } PciInfoList; extern const char *BlockdevOnError_lookup[]; typedef enum BlockdevOnError { BLOCKDEV_ON_ERROR_REPORT = 0, BLOCKDEV_ON_ERROR_IGNORE = 1, BLOCKDEV_ON_ERROR_ENOSPC = 2, BLOCKDEV_ON_ERROR_STOP = 3, BLOCKDEV_ON_ERROR_MAX = 4, } BlockdevOnError; typedef struct BlockdevOnErrorList { BlockdevOnError value; struct BlockdevOnErrorList *next; } BlockdevOnErrorList; extern const char *MirrorSyncMode_lookup[]; typedef enum MirrorSyncMode { MIRROR_SYNC_MODE_TOP = 0, MIRROR_SYNC_MODE_FULL = 1, MIRROR_SYNC_MODE_NONE = 2, MIRROR_SYNC_MODE_MAX = 3, } MirrorSyncMode; typedef struct MirrorSyncModeList { MirrorSyncMode value; struct MirrorSyncModeList *next; } MirrorSyncModeList; typedef struct BlockJobInfo BlockJobInfo; typedef struct BlockJobInfoList { union { BlockJobInfo *value; uint64_t padding; }; struct BlockJobInfoList *next; } BlockJobInfoList; extern const char *NewImageMode_lookup[]; typedef enum NewImageMode { NEW_IMAGE_MODE_EXISTING = 0, NEW_IMAGE_MODE_ABSOLUTE_PATHS = 1, NEW_IMAGE_MODE_MAX = 2, } NewImageMode; typedef struct NewImageModeList { NewImageMode value; struct NewImageModeList *next; } NewImageModeList; typedef struct BlockdevSnapshot BlockdevSnapshot; typedef struct BlockdevSnapshotList { union { BlockdevSnapshot *value; uint64_t padding; }; struct BlockdevSnapshotList *next; } BlockdevSnapshotList; typedef struct DriveBackup DriveBackup; typedef struct DriveBackupList { union { DriveBackup *value; uint64_t padding; }; struct DriveBackupList *next; } DriveBackupList; typedef struct Abort Abort; typedef struct AbortList { union { Abort *value; uint64_t padding; }; struct AbortList *next; } AbortList; typedef struct TransactionAction TransactionAction; typedef struct TransactionActionList { union { TransactionAction *value; uint64_t padding; }; struct TransactionActionList *next; } TransactionActionList; extern const char *TransactionActionKind_lookup[]; typedef enum TransactionActionKind { TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC = 0, TRANSACTION_ACTION_KIND_DRIVE_BACKUP = 1, TRANSACTION_ACTION_KIND_ABORT = 2, TRANSACTION_ACTION_KIND_MAX = 3, } TransactionActionKind; typedef struct ObjectPropertyInfo ObjectPropertyInfo; typedef struct ObjectPropertyInfoList { union { ObjectPropertyInfo *value; uint64_t padding; }; struct ObjectPropertyInfoList *next; } ObjectPropertyInfoList; typedef struct ObjectTypeInfo ObjectTypeInfo; typedef struct ObjectTypeInfoList { union { ObjectTypeInfo *value; uint64_t padding; }; struct ObjectTypeInfoList *next; } ObjectTypeInfoList; typedef struct DevicePropertyInfo DevicePropertyInfo; typedef struct DevicePropertyInfoList { union { DevicePropertyInfo *value; uint64_t padding; }; struct DevicePropertyInfoList *next; } DevicePropertyInfoList; typedef struct NetdevNoneOptions NetdevNoneOptions; typedef struct NetdevNoneOptionsList { union { NetdevNoneOptions *value; uint64_t padding; }; struct NetdevNoneOptionsList *next; } NetdevNoneOptionsList; typedef struct NetLegacyNicOptions NetLegacyNicOptions; typedef struct NetLegacyNicOptionsList { union { NetLegacyNicOptions *value; uint64_t padding; }; struct NetLegacyNicOptionsList *next; } NetLegacyNicOptionsList; typedef struct String String; typedef struct StringList { union { String *value; uint64_t padding; }; struct StringList *next; } StringList; typedef struct NetdevUserOptions NetdevUserOptions; typedef struct NetdevUserOptionsList { union { NetdevUserOptions *value; uint64_t padding; }; struct NetdevUserOptionsList *next; } NetdevUserOptionsList; typedef struct NetdevTapOptions NetdevTapOptions; typedef struct NetdevTapOptionsList { union { NetdevTapOptions *value; uint64_t padding; }; struct NetdevTapOptionsList *next; } NetdevTapOptionsList; typedef struct NetdevSocketOptions NetdevSocketOptions; typedef struct NetdevSocketOptionsList { union { NetdevSocketOptions *value; uint64_t padding; }; struct NetdevSocketOptionsList *next; } NetdevSocketOptionsList; typedef struct NetdevVdeOptions NetdevVdeOptions; typedef struct NetdevVdeOptionsList { union { NetdevVdeOptions *value; uint64_t padding; }; struct NetdevVdeOptionsList *next; } NetdevVdeOptionsList; typedef struct NetdevDumpOptions NetdevDumpOptions; typedef struct NetdevDumpOptionsList { union { NetdevDumpOptions *value; uint64_t padding; }; struct NetdevDumpOptionsList *next; } NetdevDumpOptionsList; typedef struct NetdevBridgeOptions NetdevBridgeOptions; typedef struct NetdevBridgeOptionsList { union { NetdevBridgeOptions *value; uint64_t padding; }; struct NetdevBridgeOptionsList *next; } NetdevBridgeOptionsList; typedef struct NetdevHubPortOptions NetdevHubPortOptions; typedef struct NetdevHubPortOptionsList { union { NetdevHubPortOptions *value; uint64_t padding; }; struct NetdevHubPortOptionsList *next; } NetdevHubPortOptionsList; typedef struct NetClientOptions NetClientOptions; typedef struct NetClientOptionsList { union { NetClientOptions *value; uint64_t padding; }; struct NetClientOptionsList *next; } NetClientOptionsList; extern const char *NetClientOptionsKind_lookup[]; typedef enum NetClientOptionsKind { NET_CLIENT_OPTIONS_KIND_NONE = 0, NET_CLIENT_OPTIONS_KIND_NIC = 1, NET_CLIENT_OPTIONS_KIND_USER = 2, NET_CLIENT_OPTIONS_KIND_TAP = 3, NET_CLIENT_OPTIONS_KIND_SOCKET = 4, NET_CLIENT_OPTIONS_KIND_VDE = 5, NET_CLIENT_OPTIONS_KIND_DUMP = 6, NET_CLIENT_OPTIONS_KIND_BRIDGE = 7, NET_CLIENT_OPTIONS_KIND_HUBPORT = 8, NET_CLIENT_OPTIONS_KIND_MAX = 9, } NetClientOptionsKind; typedef struct NetLegacy NetLegacy; typedef struct NetLegacyList { union { NetLegacy *value; uint64_t padding; }; struct NetLegacyList *next; } NetLegacyList; typedef struct Netdev Netdev; typedef struct NetdevList { union { Netdev *value; uint64_t padding; }; struct NetdevList *next; } NetdevList; typedef struct InetSocketAddress InetSocketAddress; typedef struct InetSocketAddressList { union { InetSocketAddress *value; uint64_t padding; }; struct InetSocketAddressList *next; } InetSocketAddressList; typedef struct UnixSocketAddress UnixSocketAddress; typedef struct UnixSocketAddressList { union { UnixSocketAddress *value; uint64_t padding; }; struct UnixSocketAddressList *next; } UnixSocketAddressList; typedef struct SocketAddress SocketAddress; typedef struct SocketAddressList { union { SocketAddress *value; uint64_t padding; }; struct SocketAddressList *next; } SocketAddressList; extern const char *SocketAddressKind_lookup[]; typedef enum SocketAddressKind { SOCKET_ADDRESS_KIND_INET = 0, SOCKET_ADDRESS_KIND_UNIX = 1, SOCKET_ADDRESS_KIND_FD = 2, SOCKET_ADDRESS_KIND_MAX = 3, } SocketAddressKind; typedef struct MachineInfo MachineInfo; typedef struct MachineInfoList { union { MachineInfo *value; uint64_t padding; }; struct MachineInfoList *next; } MachineInfoList; typedef struct CpuDefinitionInfo CpuDefinitionInfo; typedef struct CpuDefinitionInfoList { union { CpuDefinitionInfo *value; uint64_t padding; }; struct CpuDefinitionInfoList *next; } CpuDefinitionInfoList; typedef struct AddfdInfo AddfdInfo; typedef struct AddfdInfoList { union { AddfdInfo *value; uint64_t padding; }; struct AddfdInfoList *next; } AddfdInfoList; typedef struct FdsetFdInfo FdsetFdInfo; typedef struct FdsetFdInfoList { union { FdsetFdInfo *value; uint64_t padding; }; struct FdsetFdInfoList *next; } FdsetFdInfoList; typedef struct FdsetInfo FdsetInfo; typedef struct FdsetInfoList { union { FdsetInfo *value; uint64_t padding; }; struct FdsetInfoList *next; } FdsetInfoList; typedef struct TargetInfo TargetInfo; typedef struct TargetInfoList { union { TargetInfo *value; uint64_t padding; }; struct TargetInfoList *next; } TargetInfoList; extern const char *QKeyCode_lookup[]; typedef enum QKeyCode { Q_KEY_CODE_SHIFT = 0, Q_KEY_CODE_SHIFT_R = 1, Q_KEY_CODE_ALT = 2, Q_KEY_CODE_ALT_R = 3, Q_KEY_CODE_ALTGR = 4, Q_KEY_CODE_ALTGR_R = 5, Q_KEY_CODE_CTRL = 6, Q_KEY_CODE_CTRL_R = 7, Q_KEY_CODE_MENU = 8, Q_KEY_CODE_ESC = 9, Q_KEY_CODE_1 = 10, Q_KEY_CODE_2 = 11, Q_KEY_CODE_3 = 12, Q_KEY_CODE_4 = 13, Q_KEY_CODE_5 = 14, Q_KEY_CODE_6 = 15, Q_KEY_CODE_7 = 16, Q_KEY_CODE_8 = 17, Q_KEY_CODE_9 = 18, Q_KEY_CODE_0 = 19, Q_KEY_CODE_MINUS = 20, Q_KEY_CODE_EQUAL = 21, Q_KEY_CODE_BACKSPACE = 22, Q_KEY_CODE_TAB = 23, Q_KEY_CODE_Q = 24, Q_KEY_CODE_W = 25, Q_KEY_CODE_E = 26, Q_KEY_CODE_R = 27, Q_KEY_CODE_T = 28, Q_KEY_CODE_Y = 29, Q_KEY_CODE_U = 30, Q_KEY_CODE_I = 31, Q_KEY_CODE_O = 32, Q_KEY_CODE_P = 33, Q_KEY_CODE_BRACKET_LEFT = 34, Q_KEY_CODE_BRACKET_RIGHT = 35, Q_KEY_CODE_RET = 36, Q_KEY_CODE_A = 37, Q_KEY_CODE_S = 38, Q_KEY_CODE_D = 39, Q_KEY_CODE_F = 40, Q_KEY_CODE_G = 41, Q_KEY_CODE_H = 42, Q_KEY_CODE_J = 43, Q_KEY_CODE_K = 44, Q_KEY_CODE_L = 45, Q_KEY_CODE_SEMICOLON = 46, Q_KEY_CODE_APOSTROPHE = 47, Q_KEY_CODE_GRAVE_ACCENT = 48, Q_KEY_CODE_BACKSLASH = 49, Q_KEY_CODE_Z = 50, Q_KEY_CODE_X = 51, Q_KEY_CODE_C = 52, Q_KEY_CODE_V = 53, Q_KEY_CODE_B = 54, Q_KEY_CODE_N = 55, Q_KEY_CODE_M = 56, Q_KEY_CODE_COMMA = 57, Q_KEY_CODE_DOT = 58, Q_KEY_CODE_SLASH = 59, Q_KEY_CODE_ASTERISK = 60, Q_KEY_CODE_SPC = 61, Q_KEY_CODE_CAPS_LOCK = 62, Q_KEY_CODE_F1 = 63, Q_KEY_CODE_F2 = 64, Q_KEY_CODE_F3 = 65, Q_KEY_CODE_F4 = 66, Q_KEY_CODE_F5 = 67, Q_KEY_CODE_F6 = 68, Q_KEY_CODE_F7 = 69, Q_KEY_CODE_F8 = 70, Q_KEY_CODE_F9 = 71, Q_KEY_CODE_F10 = 72, Q_KEY_CODE_NUM_LOCK = 73, Q_KEY_CODE_SCROLL_LOCK = 74, Q_KEY_CODE_KP_DIVIDE = 75, Q_KEY_CODE_KP_MULTIPLY = 76, Q_KEY_CODE_KP_SUBTRACT = 77, Q_KEY_CODE_KP_ADD = 78, Q_KEY_CODE_KP_ENTER = 79, Q_KEY_CODE_KP_DECIMAL = 80, Q_KEY_CODE_SYSRQ = 81, Q_KEY_CODE_KP_0 = 82, Q_KEY_CODE_KP_1 = 83, Q_KEY_CODE_KP_2 = 84, Q_KEY_CODE_KP_3 = 85, Q_KEY_CODE_KP_4 = 86, Q_KEY_CODE_KP_5 = 87, Q_KEY_CODE_KP_6 = 88, Q_KEY_CODE_KP_7 = 89, Q_KEY_CODE_KP_8 = 90, Q_KEY_CODE_KP_9 = 91, Q_KEY_CODE_LESS = 92, Q_KEY_CODE_F11 = 93, Q_KEY_CODE_F12 = 94, Q_KEY_CODE_PRINT = 95, Q_KEY_CODE_HOME = 96, Q_KEY_CODE_PGUP = 97, Q_KEY_CODE_PGDN = 98, Q_KEY_CODE_END = 99, Q_KEY_CODE_LEFT = 100, Q_KEY_CODE_UP = 101, Q_KEY_CODE_DOWN = 102, Q_KEY_CODE_RIGHT = 103, Q_KEY_CODE_INSERT = 104, Q_KEY_CODE_DELETE = 105, Q_KEY_CODE_STOP = 106, Q_KEY_CODE_AGAIN = 107, Q_KEY_CODE_PROPS = 108, Q_KEY_CODE_UNDO = 109, Q_KEY_CODE_FRONT = 110, Q_KEY_CODE_COPY = 111, Q_KEY_CODE_OPEN = 112, Q_KEY_CODE_PASTE = 113, Q_KEY_CODE_FIND = 114, Q_KEY_CODE_CUT = 115, Q_KEY_CODE_LF = 116, Q_KEY_CODE_HELP = 117, Q_KEY_CODE_META_L = 118, Q_KEY_CODE_META_R = 119, Q_KEY_CODE_COMPOSE = 120, Q_KEY_CODE_MAX = 121, } QKeyCode; typedef struct QKeyCodeList { QKeyCode value; struct QKeyCodeList *next; } QKeyCodeList; typedef struct KeyValue KeyValue; typedef struct KeyValueList { union { KeyValue *value; uint64_t padding; }; struct KeyValueList *next; } KeyValueList; extern const char *KeyValueKind_lookup[]; typedef enum KeyValueKind { KEY_VALUE_KIND_NUMBER = 0, KEY_VALUE_KIND_QCODE = 1, KEY_VALUE_KIND_MAX = 2, } KeyValueKind; typedef struct ChardevFile ChardevFile; typedef struct ChardevFileList { union { ChardevFile *value; uint64_t padding; }; struct ChardevFileList *next; } ChardevFileList; typedef struct ChardevHostdev ChardevHostdev; typedef struct ChardevHostdevList { union { ChardevHostdev *value; uint64_t padding; }; struct ChardevHostdevList *next; } ChardevHostdevList; typedef struct ChardevSocket ChardevSocket; typedef struct ChardevSocketList { union { ChardevSocket *value; uint64_t padding; }; struct ChardevSocketList *next; } ChardevSocketList; typedef struct ChardevUdp ChardevUdp; typedef struct ChardevUdpList { union { ChardevUdp *value; uint64_t padding; }; struct ChardevUdpList *next; } ChardevUdpList; typedef struct ChardevMux ChardevMux; typedef struct ChardevMuxList { union { ChardevMux *value; uint64_t padding; }; struct ChardevMuxList *next; } ChardevMuxList; typedef struct ChardevStdio ChardevStdio; typedef struct ChardevStdioList { union { ChardevStdio *value; uint64_t padding; }; struct ChardevStdioList *next; } ChardevStdioList; typedef struct ChardevSpiceChannel ChardevSpiceChannel; typedef struct ChardevSpiceChannelList { union { ChardevSpiceChannel *value; uint64_t padding; }; struct ChardevSpiceChannelList *next; } ChardevSpiceChannelList; typedef struct ChardevSpicePort ChardevSpicePort; typedef struct ChardevSpicePortList { union { ChardevSpicePort *value; uint64_t padding; }; struct ChardevSpicePortList *next; } ChardevSpicePortList; typedef struct ChardevVC ChardevVC; typedef struct ChardevVCList { union { ChardevVC *value; uint64_t padding; }; struct ChardevVCList *next; } ChardevVCList; typedef struct ChardevMemory ChardevMemory; typedef struct ChardevMemoryList { union { ChardevMemory *value; uint64_t padding; }; struct ChardevMemoryList *next; } ChardevMemoryList; typedef struct ChardevDummy ChardevDummy; typedef struct ChardevDummyList { union { ChardevDummy *value; uint64_t padding; }; struct ChardevDummyList *next; } ChardevDummyList; typedef struct ChardevBackend ChardevBackend; typedef struct ChardevBackendList { union { ChardevBackend *value; uint64_t padding; }; struct ChardevBackendList *next; } ChardevBackendList; extern const char *ChardevBackendKind_lookup[]; typedef enum ChardevBackendKind { CHARDEV_BACKEND_KIND_FILE = 0, CHARDEV_BACKEND_KIND_SERIAL = 1, CHARDEV_BACKEND_KIND_PARALLEL = 2, CHARDEV_BACKEND_KIND_PIPE = 3, CHARDEV_BACKEND_KIND_SOCKET = 4, CHARDEV_BACKEND_KIND_UDP = 5, CHARDEV_BACKEND_KIND_PTY = 6, CHARDEV_BACKEND_KIND_NULL = 7, CHARDEV_BACKEND_KIND_MUX = 8, CHARDEV_BACKEND_KIND_MSMOUSE = 9, CHARDEV_BACKEND_KIND_BRAILLE = 10, CHARDEV_BACKEND_KIND_STDIO = 11, CHARDEV_BACKEND_KIND_CONSOLE = 12, CHARDEV_BACKEND_KIND_SPICEVMC = 13, CHARDEV_BACKEND_KIND_SPICEPORT = 14, CHARDEV_BACKEND_KIND_VC = 15, CHARDEV_BACKEND_KIND_MEMORY = 16, CHARDEV_BACKEND_KIND_MAX = 17, } ChardevBackendKind; typedef struct ChardevReturn ChardevReturn; typedef struct ChardevReturnList { union { ChardevReturn *value; uint64_t padding; }; struct ChardevReturnList *next; } ChardevReturnList; extern const char *TpmModel_lookup[]; typedef enum TpmModel { TPM_MODEL_TPM_TIS = 0, TPM_MODEL_MAX = 1, } TpmModel; typedef struct TpmModelList { TpmModel value; struct TpmModelList *next; } TpmModelList; extern const char *TpmType_lookup[]; typedef enum TpmType { TPM_TYPE_PASSTHROUGH = 0, TPM_TYPE_MAX = 1, } TpmType; typedef struct TpmTypeList { TpmType value; struct TpmTypeList *next; } TpmTypeList; typedef struct TPMPassthroughOptions TPMPassthroughOptions; typedef struct TPMPassthroughOptionsList { union { TPMPassthroughOptions *value; uint64_t padding; }; struct TPMPassthroughOptionsList *next; } TPMPassthroughOptionsList; typedef struct TpmTypeOptions TpmTypeOptions; typedef struct TpmTypeOptionsList { union { TpmTypeOptions *value; uint64_t padding; }; struct TpmTypeOptionsList *next; } TpmTypeOptionsList; extern const char *TpmTypeOptionsKind_lookup[]; typedef enum TpmTypeOptionsKind { TPM_TYPE_OPTIONS_KIND_PASSTHROUGH = 0, TPM_TYPE_OPTIONS_KIND_MAX = 1, } TpmTypeOptionsKind; typedef struct TPMInfo TPMInfo; typedef struct TPMInfoList { union { TPMInfo *value; uint64_t padding; }; struct TPMInfoList *next; } TPMInfoList; typedef struct AcpiTableOptions AcpiTableOptions; typedef struct AcpiTableOptionsList { union { AcpiTableOptions *value; uint64_t padding; }; struct AcpiTableOptionsList *next; } AcpiTableOptionsList; extern const char *CommandLineParameterType_lookup[]; typedef enum CommandLineParameterType { COMMAND_LINE_PARAMETER_TYPE_STRING = 0, COMMAND_LINE_PARAMETER_TYPE_BOOLEAN = 1, COMMAND_LINE_PARAMETER_TYPE_NUMBER = 2, COMMAND_LINE_PARAMETER_TYPE_SIZE = 3, COMMAND_LINE_PARAMETER_TYPE_MAX = 4, } CommandLineParameterType; typedef struct CommandLineParameterTypeList { CommandLineParameterType value; struct CommandLineParameterTypeList *next; } CommandLineParameterTypeList; typedef struct CommandLineParameterInfo CommandLineParameterInfo; typedef struct CommandLineParameterInfoList { union { CommandLineParameterInfo *value; uint64_t padding; }; struct CommandLineParameterInfoList *next; } CommandLineParameterInfoList; typedef struct CommandLineOptionInfo CommandLineOptionInfo; typedef struct CommandLineOptionInfoList { union { CommandLineOptionInfo *value; uint64_t padding; }; struct CommandLineOptionInfoList *next; } CommandLineOptionInfoList; extern const char *X86CPURegister32_lookup[]; typedef enum X86CPURegister32 { X86_C_P_U_REGISTER32_EAX = 0, X86_C_P_U_REGISTER32_EBX = 1, X86_C_P_U_REGISTER32_ECX = 2, X86_C_P_U_REGISTER32_EDX = 3, X86_C_P_U_REGISTER32_ESP = 4, X86_C_P_U_REGISTER32_EBP = 5, X86_C_P_U_REGISTER32_ESI = 6, X86_C_P_U_REGISTER32_EDI = 7, X86_C_P_U_REGISTER32_MAX = 8, } X86CPURegister32; typedef struct X86CPURegister32List { X86CPURegister32 value; struct X86CPURegister32List *next; } X86CPURegister32List; typedef struct X86CPUFeatureWordInfo X86CPUFeatureWordInfo; typedef struct X86CPUFeatureWordInfoList { union { X86CPUFeatureWordInfo *value; uint64_t padding; }; struct X86CPUFeatureWordInfoList *next; } X86CPUFeatureWordInfoList; extern const char *RxState_lookup[]; typedef enum RxState { RX_STATE_NORMAL = 0, RX_STATE_NONE = 1, RX_STATE_ALL = 2, RX_STATE_MAX = 3, } RxState; typedef struct RxStateList { RxState value; struct RxStateList *next; } RxStateList; typedef struct RxFilterInfo RxFilterInfo; typedef struct RxFilterInfoList { union { RxFilterInfo *value; uint64_t padding; }; struct RxFilterInfoList *next; } RxFilterInfoList; #ifndef QAPI_TYPES_BUILTIN_CLEANUP_DECL_H #define QAPI_TYPES_BUILTIN_CLEANUP_DECL_H void qapi_free_strList(strList * obj); void qapi_free_intList(intList * obj); void qapi_free_numberList(numberList * obj); void qapi_free_boolList(boolList * obj); void qapi_free_int8List(int8List * obj); void qapi_free_int16List(int16List * obj); void qapi_free_int32List(int32List * obj); void qapi_free_int64List(int64List * obj); void qapi_free_uint8List(uint8List * obj); void qapi_free_uint16List(uint16List * obj); void qapi_free_uint32List(uint32List * obj); void qapi_free_uint64List(uint64List * obj); #endif /* QAPI_TYPES_BUILTIN_CLEANUP_DECL_H */ void qapi_free_ErrorClassList(ErrorClassList * obj); struct NameInfo { bool has_name; char * name; }; void qapi_free_NameInfoList(NameInfoList * obj); void qapi_free_NameInfo(NameInfo * obj); struct VersionInfo { struct { int64_t major; int64_t minor; int64_t micro; } qemu; char * package; }; void qapi_free_VersionInfoList(VersionInfoList * obj); void qapi_free_VersionInfo(VersionInfo * obj); struct KvmInfo { bool enabled; bool present; }; void qapi_free_KvmInfoList(KvmInfoList * obj); void qapi_free_KvmInfo(KvmInfo * obj); void qapi_free_RunStateList(RunStateList * obj); struct SnapshotInfo { char * id; char * name; int64_t vm_state_size; int64_t date_sec; int64_t date_nsec; int64_t vm_clock_sec; int64_t vm_clock_nsec; }; void qapi_free_SnapshotInfoList(SnapshotInfoList * obj); void qapi_free_SnapshotInfo(SnapshotInfo * obj); struct ImageInfo { char * filename; char * format; bool has_dirty_flag; bool dirty_flag; bool has_actual_size; int64_t actual_size; int64_t virtual_size; bool has_cluster_size; int64_t cluster_size; bool has_encrypted; bool encrypted; bool has_backing_filename; char * backing_filename; bool has_full_backing_filename; char * full_backing_filename; bool has_backing_filename_format; char * backing_filename_format; bool has_snapshots; SnapshotInfoList * snapshots; bool has_backing_image; ImageInfo * backing_image; }; void qapi_free_ImageInfoList(ImageInfoList * obj); void qapi_free_ImageInfo(ImageInfo * obj); struct ImageCheck { char * filename; char * format; int64_t check_errors; bool has_image_end_offset; int64_t image_end_offset; bool has_corruptions; int64_t corruptions; bool has_leaks; int64_t leaks; bool has_corruptions_fixed; int64_t corruptions_fixed; bool has_leaks_fixed; int64_t leaks_fixed; bool has_total_clusters; int64_t total_clusters; bool has_allocated_clusters; int64_t allocated_clusters; bool has_fragmented_clusters; int64_t fragmented_clusters; bool has_compressed_clusters; int64_t compressed_clusters; }; void qapi_free_ImageCheckList(ImageCheckList * obj); void qapi_free_ImageCheck(ImageCheck * obj); struct StatusInfo { bool running; bool singlestep; RunState status; }; void qapi_free_StatusInfoList(StatusInfoList * obj); void qapi_free_StatusInfo(StatusInfo * obj); struct UuidInfo { char * UUID; }; void qapi_free_UuidInfoList(UuidInfoList * obj); void qapi_free_UuidInfo(UuidInfo * obj); struct ChardevInfo { char * label; char * filename; }; void qapi_free_ChardevInfoList(ChardevInfoList * obj); void qapi_free_ChardevInfo(ChardevInfo * obj); void qapi_free_DataFormatList(DataFormatList * obj); struct CommandInfo { char * name; }; void qapi_free_CommandInfoList(CommandInfoList * obj); void qapi_free_CommandInfo(CommandInfo * obj); struct EventInfo { char * name; }; void qapi_free_EventInfoList(EventInfoList * obj); void qapi_free_EventInfo(EventInfo * obj); struct MigrationStats { int64_t transferred; int64_t remaining; int64_t total; int64_t duplicate; int64_t skipped; int64_t normal; int64_t normal_bytes; int64_t dirty_pages_rate; double mbps; }; void qapi_free_MigrationStatsList(MigrationStatsList * obj); void qapi_free_MigrationStats(MigrationStats * obj); struct XBZRLECacheStats { int64_t cache_size; int64_t bytes; int64_t pages; int64_t cache_miss; int64_t overflow; }; void qapi_free_XBZRLECacheStatsList(XBZRLECacheStatsList * obj); void qapi_free_XBZRLECacheStats(XBZRLECacheStats * obj); struct MigrationInfo { bool has_status; char * status; bool has_ram; MigrationStats * ram; bool has_disk; MigrationStats * disk; bool has_xbzrle_cache; XBZRLECacheStats * xbzrle_cache; bool has_total_time; int64_t total_time; bool has_expected_downtime; int64_t expected_downtime; bool has_downtime; int64_t downtime; }; void qapi_free_MigrationInfoList(MigrationInfoList * obj); void qapi_free_MigrationInfo(MigrationInfo * obj); void qapi_free_MigrationCapabilityList(MigrationCapabilityList * obj); struct MigrationCapabilityStatus { MigrationCapability capability; bool state; }; void qapi_free_MigrationCapabilityStatusList(MigrationCapabilityStatusList * obj); void qapi_free_MigrationCapabilityStatus(MigrationCapabilityStatus * obj); struct MouseInfo { char * name; int64_t index; bool current; bool absolute; }; void qapi_free_MouseInfoList(MouseInfoList * obj); void qapi_free_MouseInfo(MouseInfo * obj); struct CpuInfo { int64_t CPU; bool current; bool halted; bool has_pc; int64_t pc; bool has_nip; int64_t nip; bool has_npc; int64_t npc; bool has_PC; int64_t PC; int64_t thread_id; }; void qapi_free_CpuInfoList(CpuInfoList * obj); void qapi_free_CpuInfo(CpuInfo * obj); struct BlockDeviceInfo { char * file; bool ro; char * drv; bool has_backing_file; char * backing_file; int64_t backing_file_depth; bool encrypted; bool encryption_key_missing; int64_t bps; int64_t bps_rd; int64_t bps_wr; int64_t iops; int64_t iops_rd; int64_t iops_wr; ImageInfo * image; }; void qapi_free_BlockDeviceInfoList(BlockDeviceInfoList * obj); void qapi_free_BlockDeviceInfo(BlockDeviceInfo * obj); void qapi_free_BlockDeviceIoStatusList(BlockDeviceIoStatusList * obj); struct BlockDirtyInfo { int64_t count; int64_t granularity; }; void qapi_free_BlockDirtyInfoList(BlockDirtyInfoList * obj); void qapi_free_BlockDirtyInfo(BlockDirtyInfo * obj); struct BlockInfo { char * device; char * type; bool removable; bool locked; bool has_inserted; BlockDeviceInfo * inserted; bool has_tray_open; bool tray_open; bool has_io_status; BlockDeviceIoStatus io_status; bool has_dirty; BlockDirtyInfo * dirty; }; void qapi_free_BlockInfoList(BlockInfoList * obj); void qapi_free_BlockInfo(BlockInfo * obj); struct BlockDeviceStats { int64_t rd_bytes; int64_t wr_bytes; int64_t rd_operations; int64_t wr_operations; int64_t flush_operations; int64_t flush_total_time_ns; int64_t wr_total_time_ns; int64_t rd_total_time_ns; int64_t wr_highest_offset; }; void qapi_free_BlockDeviceStatsList(BlockDeviceStatsList * obj); void qapi_free_BlockDeviceStats(BlockDeviceStats * obj); struct BlockStats { bool has_device; char * device; BlockDeviceStats * stats; bool has_parent; BlockStats * parent; }; void qapi_free_BlockStatsList(BlockStatsList * obj); void qapi_free_BlockStats(BlockStats * obj); struct VncClientInfo { char * host; char * family; char * service; bool has_x509_dname; char * x509_dname; bool has_sasl_username; char * sasl_username; }; void qapi_free_VncClientInfoList(VncClientInfoList * obj); void qapi_free_VncClientInfo(VncClientInfo * obj); struct VncInfo { bool enabled; bool has_host; char * host; bool has_family; char * family; bool has_service; char * service; bool has_auth; char * auth; bool has_clients; VncClientInfoList * clients; }; void qapi_free_VncInfoList(VncInfoList * obj); void qapi_free_VncInfo(VncInfo * obj); struct SpiceChannel { char * host; char * family; char * port; int64_t connection_id; int64_t channel_type; int64_t channel_id; bool tls; }; void qapi_free_SpiceChannelList(SpiceChannelList * obj); void qapi_free_SpiceChannel(SpiceChannel * obj); void qapi_free_SpiceQueryMouseModeList(SpiceQueryMouseModeList * obj); struct SpiceInfo { bool enabled; bool migrated; bool has_host; char * host; bool has_port; int64_t port; bool has_tls_port; int64_t tls_port; bool has_auth; char * auth; bool has_compiled_version; char * compiled_version; SpiceQueryMouseMode mouse_mode; bool has_channels; SpiceChannelList * channels; }; void qapi_free_SpiceInfoList(SpiceInfoList * obj); void qapi_free_SpiceInfo(SpiceInfo * obj); struct BalloonInfo { int64_t actual; }; void qapi_free_BalloonInfoList(BalloonInfoList * obj); void qapi_free_BalloonInfo(BalloonInfo * obj); struct PciMemoryRange { int64_t base; int64_t limit; }; void qapi_free_PciMemoryRangeList(PciMemoryRangeList * obj); void qapi_free_PciMemoryRange(PciMemoryRange * obj); struct PciMemoryRegion { int64_t bar; char * type; int64_t address; int64_t size; bool has_prefetch; bool prefetch; bool has_mem_type_64; bool mem_type_64; }; void qapi_free_PciMemoryRegionList(PciMemoryRegionList * obj); void qapi_free_PciMemoryRegion(PciMemoryRegion * obj); struct PciBridgeInfo { struct { int64_t number; int64_t secondary; int64_t subordinate; PciMemoryRange * io_range; PciMemoryRange * memory_range; PciMemoryRange * prefetchable_range; } bus; bool has_devices; PciDeviceInfoList * devices; }; void qapi_free_PciBridgeInfoList(PciBridgeInfoList * obj); void qapi_free_PciBridgeInfo(PciBridgeInfo * obj); struct PciDeviceInfo { int64_t bus; int64_t slot; int64_t function; struct { bool has_desc; char * desc; int64_t class; } class_info; struct { int64_t device; int64_t vendor; } id; bool has_irq; int64_t irq; char * qdev_id; bool has_pci_bridge; PciBridgeInfo * pci_bridge; PciMemoryRegionList * regions; }; void qapi_free_PciDeviceInfoList(PciDeviceInfoList * obj); void qapi_free_PciDeviceInfo(PciDeviceInfo * obj); struct PciInfo { int64_t bus; PciDeviceInfoList * devices; }; void qapi_free_PciInfoList(PciInfoList * obj); void qapi_free_PciInfo(PciInfo * obj); void qapi_free_BlockdevOnErrorList(BlockdevOnErrorList * obj); void qapi_free_MirrorSyncModeList(MirrorSyncModeList * obj); struct BlockJobInfo { char * type; char * device; int64_t len; int64_t offset; bool busy; bool paused; int64_t speed; BlockDeviceIoStatus io_status; }; void qapi_free_BlockJobInfoList(BlockJobInfoList * obj); void qapi_free_BlockJobInfo(BlockJobInfo * obj); void qapi_free_NewImageModeList(NewImageModeList * obj); struct BlockdevSnapshot { char * device; char * snapshot_file; bool has_format; char * format; bool has_mode; NewImageMode mode; }; void qapi_free_BlockdevSnapshotList(BlockdevSnapshotList * obj); void qapi_free_BlockdevSnapshot(BlockdevSnapshot * obj); struct DriveBackup { char * device; char * target; bool has_format; char * format; MirrorSyncMode sync; bool has_mode; NewImageMode mode; bool has_speed; int64_t speed; bool has_on_source_error; BlockdevOnError on_source_error; bool has_on_target_error; BlockdevOnError on_target_error; }; void qapi_free_DriveBackupList(DriveBackupList * obj); void qapi_free_DriveBackup(DriveBackup * obj); struct Abort { }; void qapi_free_AbortList(AbortList * obj); void qapi_free_Abort(Abort * obj); struct TransactionAction { TransactionActionKind kind; union { void *data; BlockdevSnapshot * blockdev_snapshot_sync; DriveBackup * drive_backup; Abort * abort; }; }; void qapi_free_TransactionActionList(TransactionActionList * obj); void qapi_free_TransactionAction(TransactionAction * obj); struct ObjectPropertyInfo { char * name; char * type; }; void qapi_free_ObjectPropertyInfoList(ObjectPropertyInfoList * obj); void qapi_free_ObjectPropertyInfo(ObjectPropertyInfo * obj); struct ObjectTypeInfo { char * name; }; void qapi_free_ObjectTypeInfoList(ObjectTypeInfoList * obj); void qapi_free_ObjectTypeInfo(ObjectTypeInfo * obj); struct DevicePropertyInfo { char * name; char * type; }; void qapi_free_DevicePropertyInfoList(DevicePropertyInfoList * obj); void qapi_free_DevicePropertyInfo(DevicePropertyInfo * obj); struct NetdevNoneOptions { }; void qapi_free_NetdevNoneOptionsList(NetdevNoneOptionsList * obj); void qapi_free_NetdevNoneOptions(NetdevNoneOptions * obj); struct NetLegacyNicOptions { bool has_netdev; char * netdev; bool has_macaddr; char * macaddr; bool has_model; char * model; bool has_addr; char * addr; bool has_vectors; uint32_t vectors; }; void qapi_free_NetLegacyNicOptionsList(NetLegacyNicOptionsList * obj); void qapi_free_NetLegacyNicOptions(NetLegacyNicOptions * obj); struct String { char * str; }; void qapi_free_StringList(StringList * obj); void qapi_free_String(String * obj); struct NetdevUserOptions { bool has_hostname; char * hostname; bool has_q_restrict; bool q_restrict; bool has_ip; char * ip; bool has_net; char * net; bool has_host; char * host; bool has_tftp; char * tftp; bool has_bootfile; char * bootfile; bool has_dhcpstart; char * dhcpstart; bool has_dns; char * dns; bool has_dnssearch; StringList * dnssearch; bool has_smb; char * smb; bool has_smbserver; char * smbserver; bool has_hostfwd; StringList * hostfwd; bool has_guestfwd; StringList * guestfwd; }; void qapi_free_NetdevUserOptionsList(NetdevUserOptionsList * obj); void qapi_free_NetdevUserOptions(NetdevUserOptions * obj); struct NetdevTapOptions { bool has_ifname; char * ifname; bool has_fd; char * fd; bool has_fds; char * fds; bool has_script; char * script; bool has_downscript; char * downscript; bool has_helper; char * helper; bool has_sndbuf; uint64_t sndbuf; bool has_vnet_hdr; bool vnet_hdr; bool has_vhost; bool vhost; bool has_vhostfd; char * vhostfd; bool has_vhostfds; char * vhostfds; bool has_vhostforce; bool vhostforce; bool has_queues; uint32_t queues; }; void qapi_free_NetdevTapOptionsList(NetdevTapOptionsList * obj); void qapi_free_NetdevTapOptions(NetdevTapOptions * obj); struct NetdevSocketOptions { bool has_fd; char * fd; bool has_listen; char * listen; bool has_connect; char * connect; bool has_mcast; char * mcast; bool has_localaddr; char * localaddr; bool has_udp; char * udp; }; void qapi_free_NetdevSocketOptionsList(NetdevSocketOptionsList * obj); void qapi_free_NetdevSocketOptions(NetdevSocketOptions * obj); struct NetdevVdeOptions { bool has_sock; char * sock; bool has_port; uint16_t port; bool has_group; char * group; bool has_mode; uint16_t mode; }; void qapi_free_NetdevVdeOptionsList(NetdevVdeOptionsList * obj); void qapi_free_NetdevVdeOptions(NetdevVdeOptions * obj); struct NetdevDumpOptions { bool has_len; uint64_t len; bool has_file; char * file; }; void qapi_free_NetdevDumpOptionsList(NetdevDumpOptionsList * obj); void qapi_free_NetdevDumpOptions(NetdevDumpOptions * obj); struct NetdevBridgeOptions { bool has_br; char * br; bool has_helper; char * helper; }; void qapi_free_NetdevBridgeOptionsList(NetdevBridgeOptionsList * obj); void qapi_free_NetdevBridgeOptions(NetdevBridgeOptions * obj); struct NetdevHubPortOptions { int32_t hubid; }; void qapi_free_NetdevHubPortOptionsList(NetdevHubPortOptionsList * obj); void qapi_free_NetdevHubPortOptions(NetdevHubPortOptions * obj); struct NetClientOptions { NetClientOptionsKind kind; union { void *data; NetdevNoneOptions * none; NetLegacyNicOptions * nic; NetdevUserOptions * user; NetdevTapOptions * tap; NetdevSocketOptions * socket; NetdevVdeOptions * vde; NetdevDumpOptions * dump; NetdevBridgeOptions * bridge; NetdevHubPortOptions * hubport; }; }; void qapi_free_NetClientOptionsList(NetClientOptionsList * obj); void qapi_free_NetClientOptions(NetClientOptions * obj); struct NetLegacy { bool has_vlan; int32_t vlan; bool has_id; char * id; bool has_name; char * name; NetClientOptions * opts; }; void qapi_free_NetLegacyList(NetLegacyList * obj); void qapi_free_NetLegacy(NetLegacy * obj); struct Netdev { char * id; NetClientOptions * opts; }; void qapi_free_NetdevList(NetdevList * obj); void qapi_free_Netdev(Netdev * obj); struct InetSocketAddress { char * host; char * port; bool has_to; uint16_t to; bool has_ipv4; bool ipv4; bool has_ipv6; bool ipv6; }; void qapi_free_InetSocketAddressList(InetSocketAddressList * obj); void qapi_free_InetSocketAddress(InetSocketAddress * obj); struct UnixSocketAddress { char * path; }; void qapi_free_UnixSocketAddressList(UnixSocketAddressList * obj); void qapi_free_UnixSocketAddress(UnixSocketAddress * obj); struct SocketAddress { SocketAddressKind kind; union { void *data; InetSocketAddress * inet; UnixSocketAddress * q_unix; String * fd; }; }; void qapi_free_SocketAddressList(SocketAddressList * obj); void qapi_free_SocketAddress(SocketAddress * obj); struct MachineInfo { char * name; bool has_alias; char * alias; bool has_is_default; bool is_default; int64_t cpu_max; }; void qapi_free_MachineInfoList(MachineInfoList * obj); void qapi_free_MachineInfo(MachineInfo * obj); struct CpuDefinitionInfo { char * name; }; void qapi_free_CpuDefinitionInfoList(CpuDefinitionInfoList * obj); void qapi_free_CpuDefinitionInfo(CpuDefinitionInfo * obj); struct AddfdInfo { int64_t fdset_id; int64_t fd; }; void qapi_free_AddfdInfoList(AddfdInfoList * obj); void qapi_free_AddfdInfo(AddfdInfo * obj); struct FdsetFdInfo { int64_t fd; bool has_opaque; char * opaque; }; void qapi_free_FdsetFdInfoList(FdsetFdInfoList * obj); void qapi_free_FdsetFdInfo(FdsetFdInfo * obj); struct FdsetInfo { int64_t fdset_id; FdsetFdInfoList * fds; }; void qapi_free_FdsetInfoList(FdsetInfoList * obj); void qapi_free_FdsetInfo(FdsetInfo * obj); struct TargetInfo { char * arch; }; void qapi_free_TargetInfoList(TargetInfoList * obj); void qapi_free_TargetInfo(TargetInfo * obj); void qapi_free_QKeyCodeList(QKeyCodeList * obj); struct KeyValue { KeyValueKind kind; union { void *data; int64_t number; QKeyCode qcode; }; }; void qapi_free_KeyValueList(KeyValueList * obj); void qapi_free_KeyValue(KeyValue * obj); struct ChardevFile { bool has_in; char * in; char * out; }; void qapi_free_ChardevFileList(ChardevFileList * obj); void qapi_free_ChardevFile(ChardevFile * obj); struct ChardevHostdev { char * device; }; void qapi_free_ChardevHostdevList(ChardevHostdevList * obj); void qapi_free_ChardevHostdev(ChardevHostdev * obj); struct ChardevSocket { SocketAddress * addr; bool has_server; bool server; bool has_wait; bool wait; bool has_nodelay; bool nodelay; bool has_telnet; bool telnet; }; void qapi_free_ChardevSocketList(ChardevSocketList * obj); void qapi_free_ChardevSocket(ChardevSocket * obj); struct ChardevUdp { SocketAddress * remote; bool has_local; SocketAddress * local; }; void qapi_free_ChardevUdpList(ChardevUdpList * obj); void qapi_free_ChardevUdp(ChardevUdp * obj); struct ChardevMux { char * chardev; }; void qapi_free_ChardevMuxList(ChardevMuxList * obj); void qapi_free_ChardevMux(ChardevMux * obj); struct ChardevStdio { bool has_signal; bool signal; }; void qapi_free_ChardevStdioList(ChardevStdioList * obj); void qapi_free_ChardevStdio(ChardevStdio * obj); struct ChardevSpiceChannel { char * type; }; void qapi_free_ChardevSpiceChannelList(ChardevSpiceChannelList * obj); void qapi_free_ChardevSpiceChannel(ChardevSpiceChannel * obj); struct ChardevSpicePort { char * fqdn; }; void qapi_free_ChardevSpicePortList(ChardevSpicePortList * obj); void qapi_free_ChardevSpicePort(ChardevSpicePort * obj); struct ChardevVC { bool has_width; int64_t width; bool has_height; int64_t height; bool has_cols; int64_t cols; bool has_rows; int64_t rows; }; void qapi_free_ChardevVCList(ChardevVCList * obj); void qapi_free_ChardevVC(ChardevVC * obj); struct ChardevMemory { bool has_size; int64_t size; }; void qapi_free_ChardevMemoryList(ChardevMemoryList * obj); void qapi_free_ChardevMemory(ChardevMemory * obj); struct ChardevDummy { }; void qapi_free_ChardevDummyList(ChardevDummyList * obj); void qapi_free_ChardevDummy(ChardevDummy * obj); struct ChardevBackend { ChardevBackendKind kind; union { void *data; ChardevFile * file; ChardevHostdev * serial; ChardevHostdev * parallel; ChardevHostdev * pipe; ChardevSocket * socket; ChardevUdp * udp; ChardevDummy * pty; ChardevDummy * null; ChardevMux * mux; ChardevDummy * msmouse; ChardevDummy * braille; ChardevStdio * stdio; ChardevDummy * console; ChardevSpiceChannel * spicevmc; ChardevSpicePort * spiceport; ChardevVC * vc; ChardevMemory * memory; }; }; void qapi_free_ChardevBackendList(ChardevBackendList * obj); void qapi_free_ChardevBackend(ChardevBackend * obj); struct ChardevReturn { bool has_pty; char * pty; }; void qapi_free_ChardevReturnList(ChardevReturnList * obj); void qapi_free_ChardevReturn(ChardevReturn * obj); void qapi_free_TpmModelList(TpmModelList * obj); void qapi_free_TpmTypeList(TpmTypeList * obj); struct TPMPassthroughOptions { bool has_path; char * path; bool has_cancel_path; char * cancel_path; }; void qapi_free_TPMPassthroughOptionsList(TPMPassthroughOptionsList * obj); void qapi_free_TPMPassthroughOptions(TPMPassthroughOptions * obj); struct TpmTypeOptions { TpmTypeOptionsKind kind; union { void *data; TPMPassthroughOptions * passthrough; }; }; void qapi_free_TpmTypeOptionsList(TpmTypeOptionsList * obj); void qapi_free_TpmTypeOptions(TpmTypeOptions * obj); struct TPMInfo { char * id; TpmModel model; TpmTypeOptions * options; }; void qapi_free_TPMInfoList(TPMInfoList * obj); void qapi_free_TPMInfo(TPMInfo * obj); struct AcpiTableOptions { bool has_sig; char * sig; bool has_rev; uint8_t rev; bool has_oem_id; char * oem_id; bool has_oem_table_id; char * oem_table_id; bool has_oem_rev; uint32_t oem_rev; bool has_asl_compiler_id; char * asl_compiler_id; bool has_asl_compiler_rev; uint32_t asl_compiler_rev; bool has_file; char * file; bool has_data; char * data; }; void qapi_free_AcpiTableOptionsList(AcpiTableOptionsList * obj); void qapi_free_AcpiTableOptions(AcpiTableOptions * obj); void qapi_free_CommandLineParameterTypeList(CommandLineParameterTypeList * obj); struct CommandLineParameterInfo { char * name; CommandLineParameterType type; bool has_help; char * help; }; void qapi_free_CommandLineParameterInfoList(CommandLineParameterInfoList * obj); void qapi_free_CommandLineParameterInfo(CommandLineParameterInfo * obj); struct CommandLineOptionInfo { char * option; CommandLineParameterInfoList * parameters; }; void qapi_free_CommandLineOptionInfoList(CommandLineOptionInfoList * obj); void qapi_free_CommandLineOptionInfo(CommandLineOptionInfo * obj); void qapi_free_X86CPURegister32List(X86CPURegister32List * obj); struct X86CPUFeatureWordInfo { int64_t cpuid_input_eax; bool has_cpuid_input_ecx; int64_t cpuid_input_ecx; X86CPURegister32 cpuid_register; int64_t features; }; void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList * obj); void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo * obj); void qapi_free_RxStateList(RxStateList * obj); struct RxFilterInfo { char * name; bool promiscuous; RxState multicast; RxState unicast; bool broadcast_allowed; bool multicast_overflow; bool unicast_overflow; char * main_mac; intList * vlan_table; strList * unicast_table; strList * multicast_table; }; void qapi_free_RxFilterInfoList(RxFilterInfoList * obj); void qapi_free_RxFilterInfo(RxFilterInfo * obj); #endif glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/trace0000644000076200007630000000013212617742645020167 xustar000000000000000030 mtime=1447019941.426337364 30 atime=1447019949.333218415 30 ctime=1447019941.426337364 glusterfs-3.7.6/contrib/qemu/trace/0000755000076200007630000000000012617742645020461 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/trace/PaxHeaders.7244/generated-tracers.h0000644000076200007630000000013112617742532024006 xustar000000000000000030 mtime=1447019866.044471434 29 atime=1447019866.37446647 30 ctime=1447019941.427337348 glusterfs-3.7.6/contrib/qemu/trace/generated-tracers.h0000644000076200007630000023220412617742532024227 0ustar00jenkinsjenkins00000000000000/* This file is autogenerated by tracetool, do not edit. */ #ifndef TRACE__GENERATED_TRACERS_H #define TRACE__GENERATED_TRACERS_H #include "qemu-common.h" static inline void trace_qxl_interface_set_mm_time(int qid, uint32_t mm_time) { } static inline void trace_qxl_io_write_vga(int qid, const char * mode, uint32_t addr, uint32_t val) { } static inline void trace_g_malloc(size_t size, void * ptr) { } static inline void trace_g_realloc(void * ptr, size_t size, void * newptr) { } static inline void trace_g_free(void * ptr) { } static inline void trace_qemu_memalign(size_t alignment, size_t size, void * ptr) { } static inline void trace_qemu_anon_ram_alloc(size_t size, void * ptr) { } static inline void trace_qemu_vfree(void * ptr) { } static inline void trace_qemu_anon_ram_free(void * ptr, size_t size) { } static inline void trace_virtqueue_fill(void * vq, const void * elem, unsigned int len, unsigned int idx) { } static inline void trace_virtqueue_flush(void * vq, unsigned int count) { } static inline void trace_virtqueue_pop(void * vq, void * elem, unsigned int in_num, unsigned int out_num) { } static inline void trace_virtio_queue_notify(void * vdev, int n, void * vq) { } static inline void trace_virtio_irq(void * vq) { } static inline void trace_virtio_notify(void * vdev, void * vq) { } static inline void trace_virtio_set_status(void * vdev, uint8_t val) { } static inline void trace_virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t value) { } static inline void trace_virtio_serial_throttle_port(unsigned int port, bool throttle) { } static inline void trace_virtio_serial_handle_control_message(uint16_t event, uint16_t value) { } static inline void trace_virtio_serial_handle_control_message_port(unsigned int port) { } static inline void trace_virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) { } static inline void trace_virtio_console_chr_read(unsigned int port, int size) { } static inline void trace_virtio_console_chr_event(unsigned int port, int event) { } static inline void trace_bdrv_open_common(void * bs, const char * filename, int flags, const char * format_name) { } static inline void trace_multiwrite_cb(void * mcb, int ret) { } static inline void trace_bdrv_aio_multiwrite(void * mcb, int num_callbacks, int num_reqs) { } static inline void trace_bdrv_aio_discard(void * bs, int64_t sector_num, int nb_sectors, void * opaque) { } static inline void trace_bdrv_aio_flush(void * bs, void * opaque) { } static inline void trace_bdrv_aio_readv(void * bs, int64_t sector_num, int nb_sectors, void * opaque) { } static inline void trace_bdrv_aio_writev(void * bs, int64_t sector_num, int nb_sectors, void * opaque) { } static inline void trace_bdrv_lock_medium(void * bs, bool locked) { } static inline void trace_bdrv_co_readv(void * bs, int64_t sector_num, int nb_sector) { } static inline void trace_bdrv_co_copy_on_readv(void * bs, int64_t sector_num, int nb_sector) { } static inline void trace_bdrv_co_writev(void * bs, int64_t sector_num, int nb_sector) { } static inline void trace_bdrv_co_write_zeroes(void * bs, int64_t sector_num, int nb_sector) { } static inline void trace_bdrv_co_io_em(void * bs, int64_t sector_num, int nb_sectors, int is_write, void * acb) { } static inline void trace_bdrv_co_do_copy_on_readv(void * bs, int64_t sector_num, int nb_sectors, int64_t cluster_sector_num, int cluster_nb_sectors) { } static inline void trace_stream_one_iteration(void * s, int64_t sector_num, int nb_sectors, int is_allocated) { } static inline void trace_stream_start(void * bs, void * base, void * s, void * co, void * opaque) { } static inline void trace_commit_one_iteration(void * s, int64_t sector_num, int nb_sectors, int is_allocated) { } static inline void trace_commit_start(void * bs, void * base, void * top, void * s, void * co, void * opaque) { } static inline void trace_mirror_start(void * bs, void * s, void * co, void * opaque) { } static inline void trace_mirror_restart_iter(void * s, int64_t cnt) { } static inline void trace_mirror_before_flush(void * s) { } static inline void trace_mirror_before_drain(void * s, int64_t cnt) { } static inline void trace_mirror_before_sleep(void * s, int64_t cnt, int synced) { } static inline void trace_mirror_one_iteration(void * s, int64_t sector_num, int nb_sectors) { } static inline void trace_mirror_cow(void * s, int64_t sector_num) { } static inline void trace_mirror_iteration_done(void * s, int64_t sector_num, int nb_sectors, int ret) { } static inline void trace_mirror_yield(void * s, int64_t cnt, int buf_free_count, int in_flight) { } static inline void trace_mirror_yield_in_flight(void * s, int64_t sector_num, int in_flight) { } static inline void trace_mirror_yield_buf_busy(void * s, int nb_chunks, int in_flight) { } static inline void trace_mirror_break_buf_busy(void * s, int nb_chunks, int in_flight) { } static inline void trace_backup_do_cow_enter(void * job, int64_t start, int64_t sector_num, int nb_sectors) { } static inline void trace_backup_do_cow_return(void * job, int64_t sector_num, int nb_sectors, int ret) { } static inline void trace_backup_do_cow_skip(void * job, int64_t start) { } static inline void trace_backup_do_cow_process(void * job, int64_t start) { } static inline void trace_backup_do_cow_read_fail(void * job, int64_t start, int ret) { } static inline void trace_backup_do_cow_write_fail(void * job, int64_t start, int ret) { } static inline void trace_qmp_block_job_cancel(void * job) { } static inline void trace_qmp_block_job_pause(void * job) { } static inline void trace_qmp_block_job_resume(void * job) { } static inline void trace_qmp_block_job_complete(void * job) { } static inline void trace_block_job_cb(void * bs, void * job, int ret) { } static inline void trace_qmp_block_stream(void * bs, void * job) { } static inline void trace_virtio_blk_req_complete(void * req, int status) { } static inline void trace_virtio_blk_rw_complete(void * req, int ret) { } static inline void trace_virtio_blk_handle_write(void * req, uint64_t sector, size_t nsectors) { } static inline void trace_virtio_blk_handle_read(void * req, uint64_t sector, size_t nsectors) { } static inline void trace_virtio_blk_data_plane_start(void * s) { } static inline void trace_virtio_blk_data_plane_stop(void * s) { } static inline void trace_virtio_blk_data_plane_process_request(void * s, unsigned int out_num, unsigned int in_num, unsigned int head) { } static inline void trace_virtio_blk_data_plane_complete_request(void * s, unsigned int head, int ret) { } static inline void trace_vring_setup(uint64_t physical, void * desc, void * avail, void * used) { } static inline void trace_thread_pool_submit(void * pool, void * req, void * opaque) { } static inline void trace_thread_pool_complete(void * pool, void * req, void * opaque, int ret) { } static inline void trace_thread_pool_cancel(void * req, void * opaque) { } static inline void trace_paio_submit(void * acb, void * opaque, int64_t sector_num, int nb_sectors, int type) { } static inline void trace_paio_complete(void * acb, void * opaque, int ret) { } static inline void trace_paio_cancel(void * acb, void * opaque) { } static inline void trace_cpu_in(unsigned int addr, unsigned int val) { } static inline void trace_cpu_out(unsigned int addr, unsigned int val) { } static inline void trace_balloon_event(void * opaque, unsigned long addr) { } static inline void trace_apic_local_deliver(int vector, uint32_t lvt) { } static inline void trace_apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode) { } static inline void trace_cpu_set_apic_base(uint64_t val) { } static inline void trace_cpu_get_apic_base(uint64_t val) { } static inline void trace_apic_mem_readl(uint64_t addr, uint32_t val) { } static inline void trace_apic_mem_writel(uint64_t addr, uint32_t val) { } static inline void trace_apic_report_irq_delivered(int apic_irq_delivered) { } static inline void trace_apic_reset_irq_delivered(int apic_irq_delivered) { } static inline void trace_apic_get_irq_delivered(int apic_irq_delivered) { } static inline void trace_cs4231_mem_readl_dreg(uint32_t reg, uint32_t ret) { } static inline void trace_cs4231_mem_readl_reg(uint32_t reg, uint32_t ret) { } static inline void trace_cs4231_mem_writel_reg(uint32_t reg, uint32_t old, uint32_t val) { } static inline void trace_cs4231_mem_writel_dreg(uint32_t reg, uint32_t old, uint32_t val) { } static inline void trace_nvram_read(uint32_t addr, uint32_t ret) { } static inline void trace_nvram_write(uint32_t addr, uint32_t old, uint32_t val) { } static inline void trace_ecc_mem_writel_mer(uint32_t val) { } static inline void trace_ecc_mem_writel_mdr(uint32_t val) { } static inline void trace_ecc_mem_writel_mfsr(uint32_t val) { } static inline void trace_ecc_mem_writel_vcr(uint32_t val) { } static inline void trace_ecc_mem_writel_dr(uint32_t val) { } static inline void trace_ecc_mem_writel_ecr0(uint32_t val) { } static inline void trace_ecc_mem_writel_ecr1(uint32_t val) { } static inline void trace_ecc_mem_readl_mer(uint32_t ret) { } static inline void trace_ecc_mem_readl_mdr(uint32_t ret) { } static inline void trace_ecc_mem_readl_mfsr(uint32_t ret) { } static inline void trace_ecc_mem_readl_vcr(uint32_t ret) { } static inline void trace_ecc_mem_readl_mfar0(uint32_t ret) { } static inline void trace_ecc_mem_readl_mfar1(uint32_t ret) { } static inline void trace_ecc_mem_readl_dr(uint32_t ret) { } static inline void trace_ecc_mem_readl_ecr0(uint32_t ret) { } static inline void trace_ecc_mem_readl_ecr1(uint32_t ret) { } static inline void trace_ecc_diag_mem_writeb(uint64_t addr, uint32_t val) { } static inline void trace_ecc_diag_mem_readb(uint64_t addr, uint32_t ret) { } static inline void trace_fw_cfg_write(void * s, uint8_t value) { } static inline void trace_fw_cfg_select(void * s, uint16_t key, int ret) { } static inline void trace_fw_cfg_read(void * s, uint8_t ret) { } static inline void trace_fw_cfg_add_file_dupe(void * s, char * name) { } static inline void trace_fw_cfg_add_file(void * s, int index, char * name, size_t len) { } static inline void trace_hd_geometry_lchs_guess(void * bs, int cyls, int heads, int secs) { } static inline void trace_hd_geometry_guess(void * bs, uint32_t cyls, uint32_t heads, uint32_t secs, int trans) { } static inline void trace_jazz_led_read(uint64_t addr, uint8_t val) { } static inline void trace_jazz_led_write(uint64_t addr, uint8_t new) { } static inline void trace_lance_mem_readw(uint64_t addr, uint32_t ret) { } static inline void trace_lance_mem_writew(uint64_t addr, uint32_t val) { } static inline void trace_slavio_intctl_mem_readl(uint32_t cpu, uint64_t addr, uint32_t ret) { } static inline void trace_slavio_intctl_mem_writel(uint32_t cpu, uint64_t addr, uint32_t val) { } static inline void trace_slavio_intctl_mem_writel_clear(uint32_t cpu, uint32_t val, uint32_t intreg_pending) { } static inline void trace_slavio_intctl_mem_writel_set(uint32_t cpu, uint32_t val, uint32_t intreg_pending) { } static inline void trace_slavio_intctlm_mem_readl(uint64_t addr, uint32_t ret) { } static inline void trace_slavio_intctlm_mem_writel(uint64_t addr, uint32_t val) { } static inline void trace_slavio_intctlm_mem_writel_enable(uint32_t val, uint32_t intregm_disabled) { } static inline void trace_slavio_intctlm_mem_writel_disable(uint32_t val, uint32_t intregm_disabled) { } static inline void trace_slavio_intctlm_mem_writel_target(uint32_t cpu) { } static inline void trace_slavio_check_interrupts(uint32_t pending, uint32_t intregm_disabled) { } static inline void trace_slavio_set_irq(uint32_t target_cpu, int irq, uint32_t pil, int level) { } static inline void trace_slavio_set_timer_irq_cpu(int cpu, int level) { } static inline void trace_slavio_misc_update_irq_raise(void) { } static inline void trace_slavio_misc_update_irq_lower(void) { } static inline void trace_slavio_set_power_fail(int power_failing, uint8_t config) { } static inline void trace_slavio_cfg_mem_writeb(uint32_t val) { } static inline void trace_slavio_cfg_mem_readb(uint32_t ret) { } static inline void trace_slavio_diag_mem_writeb(uint32_t val) { } static inline void trace_slavio_diag_mem_readb(uint32_t ret) { } static inline void trace_slavio_mdm_mem_writeb(uint32_t val) { } static inline void trace_slavio_mdm_mem_readb(uint32_t ret) { } static inline void trace_slavio_aux1_mem_writeb(uint32_t val) { } static inline void trace_slavio_aux1_mem_readb(uint32_t ret) { } static inline void trace_slavio_aux2_mem_writeb(uint32_t val) { } static inline void trace_slavio_aux2_mem_readb(uint32_t ret) { } static inline void trace_apc_mem_writeb(uint32_t val) { } static inline void trace_apc_mem_readb(uint32_t ret) { } static inline void trace_slavio_sysctrl_mem_writel(uint32_t val) { } static inline void trace_slavio_sysctrl_mem_readl(uint32_t ret) { } static inline void trace_slavio_led_mem_writew(uint32_t val) { } static inline void trace_slavio_led_mem_readw(uint32_t ret) { } static inline void trace_slavio_timer_get_out(uint64_t limit, uint32_t counthigh, uint32_t count) { } static inline void trace_slavio_timer_irq(uint32_t counthigh, uint32_t count) { } static inline void trace_slavio_timer_mem_readl_invalid(uint64_t addr) { } static inline void trace_slavio_timer_mem_readl(uint64_t addr, uint32_t ret) { } static inline void trace_slavio_timer_mem_writel(uint64_t addr, uint32_t val) { } static inline void trace_slavio_timer_mem_writel_limit(unsigned int timer_index, uint64_t count) { } static inline void trace_slavio_timer_mem_writel_counter_invalid(void) { } static inline void trace_slavio_timer_mem_writel_status_start(unsigned int timer_index) { } static inline void trace_slavio_timer_mem_writel_status_stop(unsigned int timer_index) { } static inline void trace_slavio_timer_mem_writel_mode_user(unsigned int timer_index) { } static inline void trace_slavio_timer_mem_writel_mode_counter(unsigned int timer_index) { } static inline void trace_slavio_timer_mem_writel_mode_invalid(void) { } static inline void trace_slavio_timer_mem_writel_invalid(uint64_t addr) { } static inline void trace_ledma_memory_read(uint64_t addr) { } static inline void trace_ledma_memory_write(uint64_t addr) { } static inline void trace_sparc32_dma_set_irq_raise(void) { } static inline void trace_sparc32_dma_set_irq_lower(void) { } static inline void trace_espdma_memory_read(uint32_t addr) { } static inline void trace_espdma_memory_write(uint32_t addr) { } static inline void trace_sparc32_dma_mem_readl(uint64_t addr, uint32_t ret) { } static inline void trace_sparc32_dma_mem_writel(uint64_t addr, uint32_t old, uint32_t val) { } static inline void trace_sparc32_dma_enable_raise(void) { } static inline void trace_sparc32_dma_enable_lower(void) { } static inline void trace_sun4m_cpu_interrupt(unsigned int level) { } static inline void trace_sun4m_cpu_reset_interrupt(unsigned int level) { } static inline void trace_sun4m_cpu_set_irq_raise(int level) { } static inline void trace_sun4m_cpu_set_irq_lower(int level) { } static inline void trace_sun4m_iommu_mem_readl(uint64_t addr, uint32_t ret) { } static inline void trace_sun4m_iommu_mem_writel(uint64_t addr, uint32_t val) { } static inline void trace_sun4m_iommu_mem_writel_ctrl(uint64_t iostart) { } static inline void trace_sun4m_iommu_mem_writel_tlbflush(uint32_t val) { } static inline void trace_sun4m_iommu_mem_writel_pgflush(uint32_t val) { } static inline void trace_sun4m_iommu_page_get_flags(uint64_t pa, uint64_t iopte, uint32_t ret) { } static inline void trace_sun4m_iommu_translate_pa(uint64_t addr, uint64_t pa, uint32_t iopte) { } static inline void trace_sun4m_iommu_bad_addr(uint64_t addr) { } static inline void trace_usb_packet_state_change(int bus, const char * port, int ep, void * p, const char * o, const char * n) { } static inline void trace_usb_packet_state_fault(int bus, const char * port, int ep, void * p, const char * o, const char * n) { } static inline void trace_usb_port_claim(int bus, const char * port) { } static inline void trace_usb_port_attach(int bus, const char * port, const char * devspeed, const char * portspeed) { } static inline void trace_usb_port_detach(int bus, const char * port) { } static inline void trace_usb_port_release(int bus, const char * port) { } static inline void trace_usb_ehci_reset(void) { } static inline void trace_usb_ehci_opreg_read(uint32_t addr, const char * str, uint32_t val) { } static inline void trace_usb_ehci_opreg_write(uint32_t addr, const char * str, uint32_t val) { } static inline void trace_usb_ehci_opreg_change(uint32_t addr, const char * str, uint32_t new, uint32_t old) { } static inline void trace_usb_ehci_portsc_read(uint32_t addr, uint32_t port, uint32_t val) { } static inline void trace_usb_ehci_portsc_write(uint32_t addr, uint32_t port, uint32_t val) { } static inline void trace_usb_ehci_portsc_change(uint32_t addr, uint32_t port, uint32_t new, uint32_t old) { } static inline void trace_usb_ehci_usbsts(const char * sts, int state) { } static inline void trace_usb_ehci_state(const char * schedule, const char * state) { } static inline void trace_usb_ehci_qh_ptrs(void * q, uint32_t addr, uint32_t nxt, uint32_t c_qtd, uint32_t n_qtd, uint32_t a_qtd) { } static inline void trace_usb_ehci_qh_fields(uint32_t addr, int rl, int mplen, int eps, int ep, int devaddr) { } static inline void trace_usb_ehci_qh_bits(uint32_t addr, int c, int h, int dtc, int i) { } static inline void trace_usb_ehci_qtd_ptrs(void * q, uint32_t addr, uint32_t nxt, uint32_t altnext) { } static inline void trace_usb_ehci_qtd_fields(uint32_t addr, int tbytes, int cpage, int cerr, int pid) { } static inline void trace_usb_ehci_qtd_bits(uint32_t addr, int ioc, int active, int halt, int babble, int xacterr) { } static inline void trace_usb_ehci_itd(uint32_t addr, uint32_t nxt, uint32_t mplen, uint32_t mult, uint32_t ep, uint32_t devaddr) { } static inline void trace_usb_ehci_sitd(uint32_t addr, uint32_t nxt, uint32_t active) { } static inline void trace_usb_ehci_port_attach(uint32_t port, const char * owner, const char * device) { } static inline void trace_usb_ehci_port_detach(uint32_t port, const char * owner) { } static inline void trace_usb_ehci_port_reset(uint32_t port, int enable) { } static inline void trace_usb_ehci_data(int rw, uint32_t cpage, uint32_t offset, uint32_t addr, uint32_t len, uint32_t bufpos) { } static inline void trace_usb_ehci_queue_action(void * q, const char * action) { } static inline void trace_usb_ehci_packet_action(void * q, void * p, const char * action) { } static inline void trace_usb_ehci_irq(uint32_t level, uint32_t frindex, uint32_t sts, uint32_t mask) { } static inline void trace_usb_ehci_guest_bug(const char * reason) { } static inline void trace_usb_ehci_doorbell_ring(void) { } static inline void trace_usb_ehci_doorbell_ack(void) { } static inline void trace_usb_ehci_dma_error(void) { } static inline void trace_usb_uhci_reset(void) { } static inline void trace_usb_uhci_schedule_start(void) { } static inline void trace_usb_uhci_schedule_stop(void) { } static inline void trace_usb_uhci_frame_start(uint32_t num) { } static inline void trace_usb_uhci_frame_stop_bandwidth(void) { } static inline void trace_usb_uhci_frame_loop_stop_idle(void) { } static inline void trace_usb_uhci_frame_loop_continue(void) { } static inline void trace_usb_uhci_mmio_readw(uint32_t addr, uint32_t val) { } static inline void trace_usb_uhci_mmio_writew(uint32_t addr, uint32_t val) { } static inline void trace_usb_uhci_queue_add(uint32_t token) { } static inline void trace_usb_uhci_queue_del(uint32_t token, const char * reason) { } static inline void trace_usb_uhci_packet_add(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_link_async(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_unlink_async(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_cancel(uint32_t token, uint32_t addr, int done) { } static inline void trace_usb_uhci_packet_complete_success(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_complete_shortxfer(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_complete_stall(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_complete_babble(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_complete_error(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_packet_del(uint32_t token, uint32_t addr) { } static inline void trace_usb_uhci_qh_load(uint32_t qh) { } static inline void trace_usb_uhci_td_load(uint32_t qh, uint32_t td, uint32_t ctrl, uint32_t token) { } static inline void trace_usb_uhci_td_queue(uint32_t td, uint32_t ctrl, uint32_t token) { } static inline void trace_usb_uhci_td_nextqh(uint32_t qh, uint32_t td) { } static inline void trace_usb_uhci_td_async(uint32_t qh, uint32_t td) { } static inline void trace_usb_uhci_td_complete(uint32_t qh, uint32_t td) { } static inline void trace_usb_xhci_reset(void) { } static inline void trace_usb_xhci_run(void) { } static inline void trace_usb_xhci_stop(void) { } static inline void trace_usb_xhci_cap_read(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_oper_read(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_port_read(uint32_t port, uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_runtime_read(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_doorbell_read(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_oper_write(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_port_write(uint32_t port, uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_runtime_write(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_doorbell_write(uint32_t off, uint32_t val) { } static inline void trace_usb_xhci_irq_intx(uint32_t level) { } static inline void trace_usb_xhci_irq_msi(uint32_t nr) { } static inline void trace_usb_xhci_irq_msix(uint32_t nr) { } static inline void trace_usb_xhci_irq_msix_use(uint32_t nr) { } static inline void trace_usb_xhci_irq_msix_unuse(uint32_t nr) { } static inline void trace_usb_xhci_queue_event(uint32_t vector, uint32_t idx, const char * trb, const char * evt, uint64_t param, uint32_t status, uint32_t control) { } static inline void trace_usb_xhci_fetch_trb(uint64_t addr, const char * name, uint64_t param, uint32_t status, uint32_t control) { } static inline void trace_usb_xhci_port_reset(uint32_t port) { } static inline void trace_usb_xhci_port_link(uint32_t port, uint32_t pls) { } static inline void trace_usb_xhci_port_notify(uint32_t port, uint32_t pls) { } static inline void trace_usb_xhci_slot_enable(uint32_t slotid) { } static inline void trace_usb_xhci_slot_disable(uint32_t slotid) { } static inline void trace_usb_xhci_slot_address(uint32_t slotid) { } static inline void trace_usb_xhci_slot_configure(uint32_t slotid) { } static inline void trace_usb_xhci_slot_evaluate(uint32_t slotid) { } static inline void trace_usb_xhci_slot_reset(uint32_t slotid) { } static inline void trace_usb_xhci_ep_enable(uint32_t slotid, uint32_t epid) { } static inline void trace_usb_xhci_ep_disable(uint32_t slotid, uint32_t epid) { } static inline void trace_usb_xhci_ep_set_dequeue(uint32_t slotid, uint32_t epid, uint32_t streamid, uint64_t param) { } static inline void trace_usb_xhci_ep_kick(uint32_t slotid, uint32_t epid, uint32_t streamid) { } static inline void trace_usb_xhci_ep_stop(uint32_t slotid, uint32_t epid) { } static inline void trace_usb_xhci_ep_reset(uint32_t slotid, uint32_t epid) { } static inline void trace_usb_xhci_xfer_start(void * xfer, uint32_t slotid, uint32_t epid, uint32_t streamid) { } static inline void trace_usb_xhci_xfer_async(void * xfer) { } static inline void trace_usb_xhci_xfer_nak(void * xfer) { } static inline void trace_usb_xhci_xfer_retry(void * xfer) { } static inline void trace_usb_xhci_xfer_success(void * xfer, uint32_t bytes) { } static inline void trace_usb_xhci_xfer_error(void * xfer, uint32_t ret) { } static inline void trace_usb_xhci_unimplemented(const char * item, int nr) { } static inline void trace_usb_desc_device(int addr, int len, int ret) { } static inline void trace_usb_desc_device_qualifier(int addr, int len, int ret) { } static inline void trace_usb_desc_config(int addr, int index, int len, int ret) { } static inline void trace_usb_desc_other_speed_config(int addr, int index, int len, int ret) { } static inline void trace_usb_desc_string(int addr, int index, int len, int ret) { } static inline void trace_usb_desc_bos(int addr, int len, int ret) { } static inline void trace_usb_set_addr(int addr) { } static inline void trace_usb_set_config(int addr, int config, int ret) { } static inline void trace_usb_set_interface(int addr, int iface, int alt, int ret) { } static inline void trace_usb_clear_device_feature(int addr, int feature, int ret) { } static inline void trace_usb_set_device_feature(int addr, int feature, int ret) { } static inline void trace_usb_hub_reset(int addr) { } static inline void trace_usb_hub_control(int addr, int request, int value, int index, int length) { } static inline void trace_usb_hub_get_port_status(int addr, int nr, int status, int changed) { } static inline void trace_usb_hub_set_port_feature(int addr, int nr, const char * f) { } static inline void trace_usb_hub_clear_port_feature(int addr, int nr, const char * f) { } static inline void trace_usb_hub_attach(int addr, int nr) { } static inline void trace_usb_hub_detach(int addr, int nr) { } static inline void trace_usb_uas_reset(int addr) { } static inline void trace_usb_uas_command(int addr, uint16_t tag, int lun, uint32_t lun64_1, uint32_t lun64_2) { } static inline void trace_usb_uas_response(int addr, uint16_t tag, uint8_t code) { } static inline void trace_usb_uas_sense(int addr, uint16_t tag, uint8_t status) { } static inline void trace_usb_uas_read_ready(int addr, uint16_t tag) { } static inline void trace_usb_uas_write_ready(int addr, uint16_t tag) { } static inline void trace_usb_uas_xfer_data(int addr, uint16_t tag, uint32_t copy, uint32_t uoff, uint32_t usize, uint32_t soff, uint32_t ssize) { } static inline void trace_usb_uas_scsi_data(int addr, uint16_t tag, uint32_t bytes) { } static inline void trace_usb_uas_scsi_complete(int addr, uint16_t tag, uint32_t status, uint32_t resid) { } static inline void trace_usb_uas_tmf_abort_task(int addr, uint16_t tag, uint16_t task_tag) { } static inline void trace_usb_uas_tmf_logical_unit_reset(int addr, uint16_t tag, int lun) { } static inline void trace_usb_uas_tmf_unsupported(int addr, uint16_t tag, uint32_t function) { } static inline void trace_usb_host_open_started(int bus, int addr) { } static inline void trace_usb_host_open_success(int bus, int addr) { } static inline void trace_usb_host_open_failure(int bus, int addr) { } static inline void trace_usb_host_disconnect(int bus, int addr) { } static inline void trace_usb_host_close(int bus, int addr) { } static inline void trace_usb_host_attach_kernel(int bus, int addr, int interface) { } static inline void trace_usb_host_detach_kernel(int bus, int addr, int interface) { } static inline void trace_usb_host_set_address(int bus, int addr, int config) { } static inline void trace_usb_host_set_config(int bus, int addr, int config) { } static inline void trace_usb_host_set_interface(int bus, int addr, int interface, int alt) { } static inline void trace_usb_host_claim_interfaces(int bus, int addr, int config, int nif) { } static inline void trace_usb_host_claim_interface(int bus, int addr, int config, int interface) { } static inline void trace_usb_host_release_interfaces(int bus, int addr) { } static inline void trace_usb_host_release_interface(int bus, int addr, int interface) { } static inline void trace_usb_host_req_control(int bus, int addr, void * p, int req, int value, int index) { } static inline void trace_usb_host_req_data(int bus, int addr, void * p, int in, int ep, int size) { } static inline void trace_usb_host_req_complete(int bus, int addr, void * p, int status, int length) { } static inline void trace_usb_host_req_emulated(int bus, int addr, void * p, int status) { } static inline void trace_usb_host_req_canceled(int bus, int addr, void * p) { } static inline void trace_usb_host_urb_submit(int bus, int addr, void * aurb, int length, int more) { } static inline void trace_usb_host_urb_complete(int bus, int addr, void * aurb, int status, int length, int more) { } static inline void trace_usb_host_urb_canceled(int bus, int addr, void * aurb) { } static inline void trace_usb_host_ep_set_halt(int bus, int addr, int ep) { } static inline void trace_usb_host_ep_clear_halt(int bus, int addr, int ep) { } static inline void trace_usb_host_iso_start(int bus, int addr, int ep) { } static inline void trace_usb_host_iso_stop(int bus, int addr, int ep) { } static inline void trace_usb_host_iso_out_of_bufs(int bus, int addr, int ep) { } static inline void trace_usb_host_iso_many_urbs(int bus, int addr, int count) { } static inline void trace_usb_host_reset(int bus, int addr) { } static inline void trace_usb_host_auto_scan_enabled(void) { } static inline void trace_usb_host_auto_scan_disabled(void) { } static inline void trace_usb_host_claim_port(int bus, int hub, int port) { } static inline void trace_usb_host_parse_device(int bus, int addr, int vendor, int product) { } static inline void trace_usb_host_parse_config(int bus, int addr, int value, int active) { } static inline void trace_usb_host_parse_interface(int bus, int addr, int num, int alt, int active) { } static inline void trace_usb_host_parse_endpoint(int bus, int addr, int ep, const char * dir, const char * type, int active) { } static inline void trace_usb_host_parse_unknown(int bus, int addr, int len, int type) { } static inline void trace_usb_host_parse_error(int bus, int addr, const char * errmsg) { } static inline void trace_scsi_req_alloc(int target, int lun, int tag) { } static inline void trace_scsi_req_cancel(int target, int lun, int tag) { } static inline void trace_scsi_req_data(int target, int lun, int tag, int len) { } static inline void trace_scsi_req_data_canceled(int target, int lun, int tag, int len) { } static inline void trace_scsi_req_dequeue(int target, int lun, int tag) { } static inline void trace_scsi_req_continue(int target, int lun, int tag) { } static inline void trace_scsi_req_continue_canceled(int target, int lun, int tag) { } static inline void trace_scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer) { } static inline void trace_scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) { } static inline void trace_scsi_req_parse_bad(int target, int lun, int tag, int cmd) { } static inline void trace_scsi_req_build_sense(int target, int lun, int tag, int key, int asc, int ascq) { } static inline void trace_scsi_device_set_ua(int target, int lun, int key, int asc, int ascq) { } static inline void trace_scsi_report_luns(int target, int lun, int tag) { } static inline void trace_scsi_inquiry(int target, int lun, int tag, int cdb1, int cdb2) { } static inline void trace_scsi_test_unit_ready(int target, int lun, int tag) { } static inline void trace_scsi_request_sense(int target, int lun, int tag) { } static inline void trace_vm_state_notify(int running, int reason) { } static inline void trace_load_file(const char * name, const char * path) { } static inline void trace_runstate_set(int new_state) { } static inline void trace_qcow2_writev_start_req(void * co, int64_t sector, int nb_sectors) { } static inline void trace_qcow2_writev_done_req(void * co, int ret) { } static inline void trace_qcow2_writev_start_part(void * co) { } static inline void trace_qcow2_writev_done_part(void * co, int cur_nr_sectors) { } static inline void trace_qcow2_writev_data(void * co, uint64_t offset) { } static inline void trace_qcow2_alloc_clusters_offset(void * co, uint64_t offset, int n_start, int n_end) { } static inline void trace_qcow2_handle_copied(void * co, uint64_t guest_offset, uint64_t host_offset, uint64_t bytes) { } static inline void trace_qcow2_handle_alloc(void * co, uint64_t guest_offset, uint64_t host_offset, uint64_t bytes) { } static inline void trace_qcow2_do_alloc_clusters_offset(void * co, uint64_t guest_offset, uint64_t host_offset, int nb_clusters) { } static inline void trace_qcow2_cluster_alloc_phys(void * co) { } static inline void trace_qcow2_cluster_link_l2(void * co, int nb_clusters) { } static inline void trace_qcow2_l2_allocate(void * bs, int l1_index) { } static inline void trace_qcow2_l2_allocate_get_empty(void * bs, int l1_index) { } static inline void trace_qcow2_l2_allocate_write_l2(void * bs, int l1_index) { } static inline void trace_qcow2_l2_allocate_write_l1(void * bs, int l1_index) { } static inline void trace_qcow2_l2_allocate_done(void * bs, int l1_index, int ret) { } static inline void trace_qcow2_cache_get(void * co, int c, uint64_t offset, bool read_from_disk) { } static inline void trace_qcow2_cache_get_replace_entry(void * co, int c, int i) { } static inline void trace_qcow2_cache_get_read(void * co, int c, int i) { } static inline void trace_qcow2_cache_get_done(void * co, int c, int i) { } static inline void trace_qcow2_cache_flush(void * co, int c) { } static inline void trace_qcow2_cache_entry_flush(void * co, int c, int i) { } static inline void trace_qed_alloc_l2_cache_entry(void * l2_cache, void * entry) { } static inline void trace_qed_unref_l2_cache_entry(void * entry, int ref) { } static inline void trace_qed_find_l2_cache_entry(void * l2_cache, void * entry, uint64_t offset, int ref) { } static inline void trace_qed_read_table(void * s, uint64_t offset, void * table) { } static inline void trace_qed_read_table_cb(void * s, void * table, int ret) { } static inline void trace_qed_write_table(void * s, uint64_t offset, void * table, unsigned int index, unsigned int n) { } static inline void trace_qed_write_table_cb(void * s, void * table, int flush, int ret) { } static inline void trace_qed_need_check_timer_cb(void * s) { } static inline void trace_qed_start_need_check_timer(void * s) { } static inline void trace_qed_cancel_need_check_timer(void * s) { } static inline void trace_qed_aio_complete(void * s, void * acb, int ret) { } static inline void trace_qed_aio_setup(void * s, void * acb, int64_t sector_num, int nb_sectors, void * opaque, int flags) { } static inline void trace_qed_aio_next_io(void * s, void * acb, int ret, uint64_t cur_pos) { } static inline void trace_qed_aio_read_data(void * s, void * acb, int ret, uint64_t offset, size_t len) { } static inline void trace_qed_aio_write_data(void * s, void * acb, int ret, uint64_t offset, size_t len) { } static inline void trace_qed_aio_write_prefill(void * s, void * acb, uint64_t start, size_t len, uint64_t offset) { } static inline void trace_qed_aio_write_postfill(void * s, void * acb, uint64_t start, size_t len, uint64_t offset) { } static inline void trace_qed_aio_write_main(void * s, void * acb, int ret, uint64_t offset, size_t len) { } static inline void trace_g364fb_read(uint64_t addr, uint32_t val) { } static inline void trace_g364fb_write(uint64_t addr, uint32_t new) { } static inline void trace_grlib_gptimer_enable(int id, uint32_t count) { } static inline void trace_grlib_gptimer_disabled(int id, uint32_t config) { } static inline void trace_grlib_gptimer_restart(int id, uint32_t reload) { } static inline void trace_grlib_gptimer_set_scaler(uint32_t scaler, uint32_t freq) { } static inline void trace_grlib_gptimer_hit(int id) { } static inline void trace_grlib_gptimer_readl(int id, uint64_t addr, uint32_t val) { } static inline void trace_grlib_gptimer_writel(int id, uint64_t addr, uint32_t val) { } static inline void trace_grlib_irqmp_check_irqs(uint32_t pend, uint32_t force, uint32_t mask, uint32_t lvl1, uint32_t lvl2) { } static inline void trace_grlib_irqmp_ack(int intno) { } static inline void trace_grlib_irqmp_set_irq(int irq) { } static inline void trace_grlib_irqmp_readl_unknown(uint64_t addr) { } static inline void trace_grlib_irqmp_writel_unknown(uint64_t addr, uint32_t value) { } static inline void trace_grlib_apbuart_event(int event) { } static inline void trace_grlib_apbuart_writel_unknown(uint64_t addr, uint32_t value) { } static inline void trace_grlib_apbuart_readl_unknown(uint64_t addr) { } static inline void trace_leon3_set_irq(int intno) { } static inline void trace_leon3_reset_irq(int intno) { } static inline void trace_spice_vmc_write(ssize_t out, int len) { } static inline void trace_spice_vmc_read(int bytes, int len) { } static inline void trace_spice_vmc_register_interface(void * scd) { } static inline void trace_spice_vmc_unregister_interface(void * scd) { } static inline void trace_spice_vmc_event(int event) { } static inline void trace_lm32_pic_raise_irq(void) { } static inline void trace_lm32_pic_lower_irq(void) { } static inline void trace_lm32_pic_interrupt(int irq, int level) { } static inline void trace_lm32_pic_set_im(uint32_t im) { } static inline void trace_lm32_pic_set_ip(uint32_t ip) { } static inline void trace_lm32_pic_get_im(uint32_t im) { } static inline void trace_lm32_pic_get_ip(uint32_t ip) { } static inline void trace_lm32_juart_get_jtx(uint32_t value) { } static inline void trace_lm32_juart_set_jtx(uint32_t value) { } static inline void trace_lm32_juart_get_jrx(uint32_t value) { } static inline void trace_lm32_juart_set_jrx(uint32_t value) { } static inline void trace_lm32_timer_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_lm32_timer_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_lm32_timer_hit(void) { } static inline void trace_lm32_timer_irq_state(int level) { } static inline void trace_lm32_uart_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_lm32_uart_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_lm32_uart_irq_state(int level) { } static inline void trace_lm32_sys_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_megasas_init_firmware(uint64_t pa) { } static inline void trace_megasas_init_queue(uint64_t queue_pa, int queue_len, uint64_t head, uint64_t tail, uint32_t flags) { } static inline void trace_megasas_initq_map_failed(int frame) { } static inline void trace_megasas_initq_mismatch(int queue_len, int fw_cmds) { } static inline void trace_megasas_qf_found(unsigned int index, uint64_t pa) { } static inline void trace_megasas_qf_new(unsigned int index, void * cmd) { } static inline void trace_megasas_qf_failed(unsigned long pa) { } static inline void trace_megasas_qf_enqueue(unsigned int index, unsigned int count, uint64_t context, unsigned int tail, int busy) { } static inline void trace_megasas_qf_update(unsigned int head, unsigned int busy) { } static inline void trace_megasas_qf_dequeue(unsigned int index) { } static inline void trace_megasas_qf_map_failed(int cmd, unsigned long frame) { } static inline void trace_megasas_qf_complete_noirq(uint64_t context) { } static inline void trace_megasas_qf_complete(uint64_t context, unsigned int tail, unsigned int offset, int busy, unsigned int doorbell) { } static inline void trace_megasas_handle_frame(const char * cmd, uint64_t addr, uint64_t context, uint32_t count) { } static inline void trace_megasas_frame_busy(uint64_t addr) { } static inline void trace_megasas_unhandled_frame_cmd(int cmd, uint8_t frame_cmd) { } static inline void trace_megasas_handle_scsi(const char * frame, int bus, int dev, int lun, void * sdev, unsigned long size) { } static inline void trace_megasas_scsi_target_not_present(const char * frame, int bus, int dev, int lun) { } static inline void trace_megasas_scsi_invalid_cdb_len(const char * frame, int bus, int dev, int lun, int len) { } static inline void trace_megasas_iov_read_overflow(int cmd, int bytes, int len) { } static inline void trace_megasas_iov_write_overflow(int cmd, int bytes, int len) { } static inline void trace_megasas_iov_read_underflow(int cmd, int bytes, int len) { } static inline void trace_megasas_iov_write_underflow(int cmd, int bytes, int len) { } static inline void trace_megasas_scsi_req_alloc_failed(const char * frame, int dev, int lun) { } static inline void trace_megasas_scsi_read_start(int cmd, int len) { } static inline void trace_megasas_scsi_write_start(int cmd, int len) { } static inline void trace_megasas_scsi_nodata(int cmd) { } static inline void trace_megasas_scsi_complete(int cmd, uint32_t status, int len, int xfer) { } static inline void trace_megasas_command_complete(int cmd, uint32_t status, uint32_t resid) { } static inline void trace_megasas_handle_io(int cmd, const char * frame, int dev, int lun, unsigned long lba, unsigned long count) { } static inline void trace_megasas_io_target_not_present(int cmd, const char * frame, int dev, int lun) { } static inline void trace_megasas_io_read_start(int cmd, unsigned long lba, unsigned long count, unsigned long len) { } static inline void trace_megasas_io_write_start(int cmd, unsigned long lba, unsigned long count, unsigned long len) { } static inline void trace_megasas_io_complete(int cmd, uint32_t len) { } static inline void trace_megasas_io_read(int cmd, int bytes, int len, unsigned long offset) { } static inline void trace_megasas_io_write(int cmd, int bytes, int len, unsigned long offset) { } static inline void trace_megasas_io_continue(int cmd, int bytes) { } static inline void trace_megasas_iovec_map_failed(int cmd, int index, unsigned long iov_size) { } static inline void trace_megasas_iovec_sgl_overflow(int cmd, int index, int limit) { } static inline void trace_megasas_iovec_sgl_underflow(int cmd, int index) { } static inline void trace_megasas_iovec_sgl_invalid(int cmd, int index, uint64_t pa, uint32_t len) { } static inline void trace_megasas_iovec_overflow(int cmd, int len, int limit) { } static inline void trace_megasas_iovec_underflow(int cmd, int len, int limit) { } static inline void trace_megasas_handle_dcmd(int cmd, int opcode) { } static inline void trace_megasas_finish_dcmd(int cmd, int size) { } static inline void trace_megasas_dcmd_req_alloc_failed(int cmd, const char * desc) { } static inline void trace_megasas_dcmd_internal_submit(int cmd, const char * desc, int dev) { } static inline void trace_megasas_dcmd_internal_finish(int cmd, int opcode, int lun) { } static inline void trace_megasas_dcmd_internal_invalid(int cmd, int opcode) { } static inline void trace_megasas_dcmd_unhandled(int cmd, int opcode, int len) { } static inline void trace_megasas_dcmd_zero_sge(int cmd) { } static inline void trace_megasas_dcmd_invalid_sge(int cmd, int count) { } static inline void trace_megasas_dcmd_map_failed(int cmd) { } static inline void trace_megasas_dcmd_invalid_xfer_len(int cmd, unsigned long size, unsigned long max) { } static inline void trace_megasas_dcmd_enter(int cmd, const char * dcmd, int len) { } static inline void trace_megasas_dcmd_dummy(int cmd, unsigned long size) { } static inline void trace_megasas_dcmd_set_fw_time(int cmd, unsigned long time) { } static inline void trace_megasas_dcmd_pd_get_list(int cmd, int num, int max, int offset) { } static inline void trace_megasas_dcmd_ld_get_list(int cmd, int num, int max) { } static inline void trace_megasas_dcmd_ld_get_info(int cmd, int ld_id) { } static inline void trace_megasas_dcmd_pd_get_info(int cmd, int pd_id) { } static inline void trace_megasas_dcmd_pd_list_query(int cmd, int flags) { } static inline void trace_megasas_dcmd_unsupported(int cmd, unsigned long size) { } static inline void trace_megasas_abort_frame(int cmd, int abort_cmd) { } static inline void trace_megasas_abort_no_cmd(int cmd, uint64_t context) { } static inline void trace_megasas_abort_invalid_context(int cmd, uint64_t context, int abort_cmd) { } static inline void trace_megasas_reset(void) { } static inline void trace_megasas_init(int sges, int cmds, const char * intr, const char * mode) { } static inline void trace_megasas_msix_raise(int vector) { } static inline void trace_megasas_irq_lower(void) { } static inline void trace_megasas_irq_raise(void) { } static inline void trace_megasas_intr_enabled(void) { } static inline void trace_megasas_intr_disabled(void) { } static inline void trace_megasas_mmio_readl(unsigned long addr, uint32_t val) { } static inline void trace_megasas_mmio_invalid_readl(unsigned long addr) { } static inline void trace_megasas_mmio_writel(uint32_t addr, uint32_t val) { } static inline void trace_megasas_mmio_invalid_writel(uint32_t addr, uint32_t val) { } static inline void trace_milkymist_ac97_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_ac97_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_ac97_pulse_irq_crrequest(void) { } static inline void trace_milkymist_ac97_pulse_irq_crreply(void) { } static inline void trace_milkymist_ac97_pulse_irq_dmaw(void) { } static inline void trace_milkymist_ac97_pulse_irq_dmar(void) { } static inline void trace_milkymist_ac97_in_cb(int avail, uint32_t remaining) { } static inline void trace_milkymist_ac97_in_cb_transferred(int transferred) { } static inline void trace_milkymist_ac97_out_cb(int free, uint32_t remaining) { } static inline void trace_milkymist_ac97_out_cb_transferred(int transferred) { } static inline void trace_milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_memcard_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_memcard_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_minimac2_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_minimac2_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_minimac2_mdio_write(uint8_t phy_addr, uint8_t addr, uint16_t value) { } static inline void trace_milkymist_minimac2_mdio_read(uint8_t phy_addr, uint8_t addr, uint16_t value) { } static inline void trace_milkymist_minimac2_tx_frame(uint32_t length) { } static inline void trace_milkymist_minimac2_rx_frame(const void * buf, uint32_t length) { } static inline void trace_milkymist_minimac2_drop_rx_frame(const void * buf) { } static inline void trace_milkymist_minimac2_rx_transfer(const void * buf, uint32_t length) { } static inline void trace_milkymist_minimac2_raise_irq_rx(void) { } static inline void trace_milkymist_minimac2_lower_irq_rx(void) { } static inline void trace_milkymist_minimac2_pulse_irq_tx(void) { } static inline void trace_milkymist_pfpu_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_pfpu_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_pfpu_vectout(uint32_t a, uint32_t b, uint32_t dma_ptr) { } static inline void trace_milkymist_pfpu_pulse_irq(void) { } static inline void trace_milkymist_softusb_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_softusb_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_softusb_mevt(uint8_t m) { } static inline void trace_milkymist_softusb_kevt(uint8_t m) { } static inline void trace_milkymist_softusb_mouse_event(int dx, int dy, int dz, int bs) { } static inline void trace_milkymist_softusb_pulse_irq(void) { } static inline void trace_milkymist_sysctl_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_sysctl_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_sysctl_icap_write(uint32_t value) { } static inline void trace_milkymist_sysctl_start_timer0(void) { } static inline void trace_milkymist_sysctl_stop_timer0(void) { } static inline void trace_milkymist_sysctl_start_timer1(void) { } static inline void trace_milkymist_sysctl_stop_timer1(void) { } static inline void trace_milkymist_sysctl_pulse_irq_timer0(void) { } static inline void trace_milkymist_sysctl_pulse_irq_timer1(void) { } static inline void trace_milkymist_tmu2_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_tmu2_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_tmu2_start(void) { } static inline void trace_milkymist_tmu2_pulse_irq(void) { } static inline void trace_milkymist_uart_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_uart_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_uart_raise_irq(void) { } static inline void trace_milkymist_uart_lower_irq(void) { } static inline void trace_milkymist_vgafb_memory_read(uint32_t addr, uint32_t value) { } static inline void trace_milkymist_vgafb_memory_write(uint32_t addr, uint32_t value) { } static inline void trace_mipsnet_send(uint32_t size) { } static inline void trace_mipsnet_receive(uint32_t size) { } static inline void trace_mipsnet_read(uint64_t addr, uint32_t val) { } static inline void trace_mipsnet_write(uint64_t addr, uint64_t val) { } static inline void trace_mipsnet_irq(uint32_t isr, uint32_t intctl) { } static inline void trace_pc87312_io_read(uint32_t addr, uint32_t val) { } static inline void trace_pc87312_io_write(uint32_t addr, uint32_t val) { } static inline void trace_pc87312_info_floppy(uint32_t base) { } static inline void trace_pc87312_info_ide(uint32_t base) { } static inline void trace_pc87312_info_parallel(uint32_t base, uint32_t irq) { } static inline void trace_pc87312_info_serial(int n, uint32_t base, uint32_t irq) { } static inline void trace_pvscsi_ring_init_data(uint32_t txr_len_log2, uint32_t rxr_len_log2) { } static inline void trace_pvscsi_ring_init_msg(uint32_t len_log2) { } static inline void trace_pvscsi_ring_flush_cmp(uint64_t filled_cmp_ptr) { } static inline void trace_pvscsi_ring_flush_msg(uint64_t filled_cmp_ptr) { } static inline void trace_pvscsi_update_irq_level(bool raise, uint64_t mask, uint64_t status) { } static inline void trace_pvscsi_update_irq_msi(void) { } static inline void trace_pvscsi_cmp_ring_put(unsigned long addr) { } static inline void trace_pvscsi_msg_ring_put(unsigned long addr) { } static inline void trace_pvscsi_complete_request(uint64_t context, uint64_t len, uint8_t sense_key) { } static inline void trace_pvscsi_get_sg_list(int nsg, size_t size) { } static inline void trace_pvscsi_get_next_sg_elem(uint32_t flags) { } static inline void trace_pvscsi_command_complete_not_found(uint32_t tag) { } static inline void trace_pvscsi_command_complete_data_run(void) { } static inline void trace_pvscsi_command_complete_sense_len(int len) { } static inline void trace_pvscsi_convert_sglist(uint64_t context, unsigned long addr, uint32_t resid) { } static inline void trace_pvscsi_process_req_descr(uint8_t cmd, uint64_t ctx) { } static inline void trace_pvscsi_process_req_descr_unknown_device(void) { } static inline void trace_pvscsi_process_req_descr_invalid_dir(void) { } static inline void trace_pvscsi_process_io(unsigned long addr) { } static inline void trace_pvscsi_on_cmd_noimpl(const char* cmd) { } static inline void trace_pvscsi_on_cmd_reset_dev(uint32_t tgt, int lun, void* dev) { } static inline void trace_pvscsi_on_cmd_arrived(const char* cmd) { } static inline void trace_pvscsi_on_cmd_abort(uint64_t ctx, uint32_t tgt) { } static inline void trace_pvscsi_on_cmd_unknown(uint64_t cmd_id) { } static inline void trace_pvscsi_on_cmd_unknown_data(uint32_t data) { } static inline void trace_pvscsi_io_write(const char* cmd, uint64_t val) { } static inline void trace_pvscsi_io_write_unknown(unsigned long addr, unsigned sz, uint64_t val) { } static inline void trace_pvscsi_io_read(const char* cmd, uint64_t status) { } static inline void trace_pvscsi_io_read_unknown(unsigned long addr, unsigned sz) { } static inline void trace_pvscsi_init_msi_fail(int res) { } static inline void trace_pvscsi_state(const char* state) { } static inline void trace_pvscsi_tx_rings_ppn(const char* label, uint64_t ppn) { } static inline void trace_pvscsi_tx_rings_num_pages(const char* label, uint32_t num) { } static inline void trace_xen_ram_alloc(unsigned long ram_addr, unsigned long size) { } static inline void trace_xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) { } static inline void trace_xen_map_cache(uint64_t phys_addr) { } static inline void trace_xen_remap_bucket(uint64_t index) { } static inline void trace_xen_map_cache_return(void* ptr) { } static inline void trace_xen_map_block(uint64_t phys_addr, uint64_t size) { } static inline void trace_xen_unmap_block(void* addr, unsigned long size) { } static inline void trace_xen_platform_log(char * s) { } static inline void trace_qemu_coroutine_enter(void * from, void * to, void * opaque) { } static inline void trace_qemu_coroutine_yield(void * from, void * to) { } static inline void trace_qemu_coroutine_terminate(void * co) { } static inline void trace_qemu_co_queue_run_restart(void * co) { } static inline void trace_qemu_co_queue_next(void * nxt) { } static inline void trace_qemu_co_mutex_lock_entry(void * mutex, void * self) { } static inline void trace_qemu_co_mutex_lock_return(void * mutex, void * self) { } static inline void trace_qemu_co_mutex_unlock_entry(void * mutex, void * self) { } static inline void trace_qemu_co_mutex_unlock_return(void * mutex, void * self) { } static inline void trace_escc_put_queue(char channel, int b) { } static inline void trace_escc_get_queue(char channel, int val) { } static inline void trace_escc_update_irq(int irq) { } static inline void trace_escc_update_parameters(char channel, int speed, int parity, int data_bits, int stop_bits) { } static inline void trace_escc_mem_writeb_ctrl(char channel, uint32_t reg, uint32_t val) { } static inline void trace_escc_mem_writeb_data(char channel, uint32_t val) { } static inline void trace_escc_mem_readb_ctrl(char channel, uint32_t reg, uint8_t val) { } static inline void trace_escc_mem_readb_data(char channel, uint32_t ret) { } static inline void trace_escc_serial_receive_byte(char channel, int ch) { } static inline void trace_escc_sunkbd_event_in(int ch) { } static inline void trace_escc_sunkbd_event_out(int ch) { } static inline void trace_escc_kbd_command(int val) { } static inline void trace_escc_sunmouse_event(int dx, int dy, int buttons_state) { } static inline void trace_iscsi_aio_write16_cb(void * iscsi, int status, void * acb, int canceled) { } static inline void trace_iscsi_aio_writev(void * iscsi, int64_t sector_num, int nb_sectors, void * opaque, void * acb) { } static inline void trace_iscsi_aio_read16_cb(void * iscsi, int status, void * acb, int canceled) { } static inline void trace_iscsi_aio_readv(void * iscsi, int64_t sector_num, int nb_sectors, void * opaque, void * acb) { } static inline void trace_esp_error_fifo_overrun(void) { } static inline void trace_esp_error_unhandled_command(uint32_t val) { } static inline void trace_esp_error_invalid_write(uint32_t val, uint32_t addr) { } static inline void trace_esp_raise_irq(void) { } static inline void trace_esp_lower_irq(void) { } static inline void trace_esp_dma_enable(void) { } static inline void trace_esp_dma_disable(void) { } static inline void trace_esp_get_cmd(uint32_t dmalen, int target) { } static inline void trace_esp_do_busid_cmd(uint8_t busid) { } static inline void trace_esp_handle_satn_stop(uint32_t cmdlen) { } static inline void trace_esp_write_response(uint32_t status) { } static inline void trace_esp_do_dma(uint32_t cmdlen, uint32_t len) { } static inline void trace_esp_command_complete(void) { } static inline void trace_esp_command_complete_unexpected(void) { } static inline void trace_esp_command_complete_fail(void) { } static inline void trace_esp_transfer_data(uint32_t dma_left, int32_t ti_size) { } static inline void trace_esp_handle_ti(uint32_t minlen) { } static inline void trace_esp_handle_ti_cmd(uint32_t cmdlen) { } static inline void trace_esp_mem_readb(uint32_t saddr, uint8_t reg) { } static inline void trace_esp_mem_writeb(uint32_t saddr, uint8_t reg, uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_nop(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_flush(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_reset(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_bus_reset(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_iccs(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_msgacc(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_pad(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_satn(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_rstatn(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_sel(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_selatn(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_selatns(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_ensel(uint32_t val) { } static inline void trace_esp_mem_writeb_cmd_dissel(uint32_t val) { } static inline void trace_esp_pci_error_invalid_dma_direction(void) { } static inline void trace_esp_pci_error_invalid_read(uint32_t reg) { } static inline void trace_esp_pci_error_invalid_write(uint32_t reg) { } static inline void trace_esp_pci_error_invalid_write_dma(uint32_t val, uint32_t addr) { } static inline void trace_esp_pci_dma_read(uint32_t saddr, uint32_t reg) { } static inline void trace_esp_pci_dma_write(uint32_t saddr, uint32_t reg, uint32_t val) { } static inline void trace_esp_pci_dma_idle(uint32_t val) { } static inline void trace_esp_pci_dma_blast(uint32_t val) { } static inline void trace_esp_pci_dma_abort(uint32_t val) { } static inline void trace_esp_pci_dma_start(uint32_t val) { } static inline void trace_esp_pci_sbac_read(uint32_t reg) { } static inline void trace_esp_pci_sbac_write(uint32_t reg, uint32_t val) { } static inline void trace_handle_qmp_command(void * mon, const char * cmd_name) { } static inline void trace_monitor_protocol_emitter(void * mon) { } static inline void trace_monitor_protocol_event(uint32_t event, const char * evname, void * data) { } static inline void trace_monitor_protocol_event_handler(uint32_t event, void * data, uint64_t last, uint64_t now) { } static inline void trace_monitor_protocol_event_emit(uint32_t event, void * data) { } static inline void trace_monitor_protocol_event_queue(uint32_t event, void * data, uint64_t rate, uint64_t last, uint64_t now) { } static inline void trace_monitor_protocol_event_throttle(uint32_t event, uint64_t rate) { } static inline void trace_open_eth_mii_write(unsigned idx, uint16_t v) { } static inline void trace_open_eth_mii_read(unsigned idx, uint16_t v) { } static inline void trace_open_eth_update_irq(uint32_t v) { } static inline void trace_open_eth_receive(unsigned len) { } static inline void trace_open_eth_receive_mcast(unsigned idx, uint32_t h0, uint32_t h1) { } static inline void trace_open_eth_receive_reject(void) { } static inline void trace_open_eth_receive_desc(uint32_t addr, uint32_t len_flags) { } static inline void trace_open_eth_start_xmit(uint32_t addr, unsigned len, unsigned tx_len) { } static inline void trace_open_eth_reg_read(uint32_t addr, uint32_t v) { } static inline void trace_open_eth_reg_write(uint32_t addr, uint32_t v) { } static inline void trace_open_eth_desc_read(uint32_t addr, uint32_t v) { } static inline void trace_open_eth_desc_write(uint32_t addr, uint32_t v) { } static inline void trace_v9fs_rerror(uint16_t tag, uint8_t id, int err) { } static inline void trace_v9fs_version(uint16_t tag, uint8_t id, int32_t msize, char* version) { } static inline void trace_v9fs_version_return(uint16_t tag, uint8_t id, int32_t msize, char* version) { } static inline void trace_v9fs_attach(uint16_t tag, uint8_t id, int32_t fid, int32_t afid, char* uname, char* aname) { } static inline void trace_v9fs_attach_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path) { } static inline void trace_v9fs_stat(uint16_t tag, uint8_t id, int32_t fid) { } static inline void trace_v9fs_stat_return(uint16_t tag, uint8_t id, int32_t mode, int32_t atime, int32_t mtime, int64_t length) { } static inline void trace_v9fs_getattr(uint16_t tag, uint8_t id, int32_t fid, uint64_t request_mask) { } static inline void trace_v9fs_getattr_return(uint16_t tag, uint8_t id, uint64_t result_mask, uint32_t mode, uint32_t uid, uint32_t gid) { } static inline void trace_v9fs_walk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, uint16_t nwnames) { } static inline void trace_v9fs_walk_return(uint16_t tag, uint8_t id, uint16_t nwnames, void* qids) { } static inline void trace_v9fs_open(uint16_t tag, uint8_t id, int32_t fid, int32_t mode) { } static inline void trace_v9fs_open_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path, int iounit) { } static inline void trace_v9fs_lcreate(uint16_t tag, uint8_t id, int32_t dfid, int32_t flags, int32_t mode, uint32_t gid) { } static inline void trace_v9fs_lcreate_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path, int32_t iounit) { } static inline void trace_v9fs_fsync(uint16_t tag, uint8_t id, int32_t fid, int datasync) { } static inline void trace_v9fs_clunk(uint16_t tag, uint8_t id, int32_t fid) { } static inline void trace_v9fs_read(uint16_t tag, uint8_t id, int32_t fid, uint64_t off, uint32_t max_count) { } static inline void trace_v9fs_read_return(uint16_t tag, uint8_t id, int32_t count, ssize_t err) { } static inline void trace_v9fs_readdir(uint16_t tag, uint8_t id, int32_t fid, uint64_t offset, uint32_t max_count) { } static inline void trace_v9fs_readdir_return(uint16_t tag, uint8_t id, uint32_t count, ssize_t retval) { } static inline void trace_v9fs_write(uint16_t tag, uint8_t id, int32_t fid, uint64_t off, uint32_t count, int cnt) { } static inline void trace_v9fs_write_return(uint16_t tag, uint8_t id, int32_t total, ssize_t err) { } static inline void trace_v9fs_create(uint16_t tag, uint8_t id, int32_t fid, char* name, int32_t perm, int8_t mode) { } static inline void trace_v9fs_create_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path, int iounit) { } static inline void trace_v9fs_symlink(uint16_t tag, uint8_t id, int32_t fid, char* name, char* symname, uint32_t gid) { } static inline void trace_v9fs_symlink_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path) { } static inline void trace_v9fs_flush(uint16_t tag, uint8_t id, int16_t flush_tag) { } static inline void trace_v9fs_link(uint16_t tag, uint8_t id, int32_t dfid, int32_t oldfid, char* name) { } static inline void trace_v9fs_remove(uint16_t tag, uint8_t id, int32_t fid) { } static inline void trace_v9fs_wstat(uint16_t tag, uint8_t id, int32_t fid, int32_t mode, int32_t atime, int32_t mtime) { } static inline void trace_v9fs_mknod(uint16_t tag, uint8_t id, int32_t fid, int mode, int major, int minor) { } static inline void trace_v9fs_mknod_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path) { } static inline void trace_v9fs_lock(uint16_t tag, uint8_t id, int32_t fid, uint8_t type, uint64_t start, uint64_t length) { } static inline void trace_v9fs_lock_return(uint16_t tag, uint8_t id, int8_t status) { } static inline void trace_v9fs_getlock(uint16_t tag, uint8_t id, int32_t fid, uint8_t type, uint64_t start, uint64_t length) { } static inline void trace_v9fs_getlock_return(uint16_t tag, uint8_t id, uint8_t type, uint64_t start, uint64_t length, uint32_t proc_id) { } static inline void trace_v9fs_mkdir(uint16_t tag, uint8_t id, int32_t fid, char* name, int mode, uint32_t gid) { } static inline void trace_v9fs_mkdir_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, int64_t path, int err) { } static inline void trace_v9fs_xattrwalk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, char* name) { } static inline void trace_v9fs_xattrwalk_return(uint16_t tag, uint8_t id, int64_t size) { } static inline void trace_v9fs_xattrcreate(uint16_t tag, uint8_t id, int32_t fid, char* name, int64_t size, int flags) { } static inline void trace_v9fs_readlink(uint16_t tag, uint8_t id, int32_t fid) { } static inline void trace_v9fs_readlink_return(uint16_t tag, uint8_t id, char* target) { } static inline void trace_mmu_helper_dfault(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) { } static inline void trace_mmu_helper_dprot(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) { } static inline void trace_mmu_helper_dmiss(uint64_t address, uint64_t context) { } static inline void trace_mmu_helper_tfault(uint64_t address, uint64_t context) { } static inline void trace_mmu_helper_tmiss(uint64_t address, uint64_t context) { } static inline void trace_mmu_helper_get_phys_addr_code(uint32_t tl, int mmu_idx, uint64_t prim_context, uint64_t sec_context, uint64_t address) { } static inline void trace_mmu_helper_get_phys_addr_data(uint32_t tl, int mmu_idx, uint64_t prim_context, uint64_t sec_context, uint64_t address) { } static inline void trace_mmu_helper_mmu_fault(uint64_t address, uint64_t paddr, int mmu_idx, uint32_t tl, uint64_t prim_context, uint64_t sec_context) { } static inline void trace_int_helper_set_softint(uint32_t softint) { } static inline void trace_int_helper_clear_softint(uint32_t softint) { } static inline void trace_int_helper_write_softint(uint32_t softint) { } static inline void trace_int_helper_icache_freeze(void) { } static inline void trace_int_helper_dcache_freeze(void) { } static inline void trace_win_helper_gregset_error(uint32_t pstate) { } static inline void trace_win_helper_switch_pstate(uint32_t pstate_regs, uint32_t new_pstate_regs) { } static inline void trace_win_helper_no_switch_pstate(uint32_t new_pstate_regs) { } static inline void trace_win_helper_wrpil(uint32_t psrpil, uint32_t new_pil) { } static inline void trace_win_helper_done(uint32_t tl) { } static inline void trace_win_helper_retry(uint32_t tl) { } static inline void trace_dma_bdrv_io(void * dbs, void * bs, int64_t sector_num, bool to_dev) { } static inline void trace_dma_aio_cancel(void * dbs) { } static inline void trace_dma_complete(void * dbs, int ret, void * cb) { } static inline void trace_dma_bdrv_cb(void * dbs, int ret) { } static inline void trace_dma_map_wait(void * dbs) { } static inline void trace_console_gfx_new(void) { } static inline void trace_console_txt_new(int w, int h) { } static inline void trace_console_select(int nr) { } static inline void trace_console_refresh(int interval) { } static inline void trace_displaysurface_create(void * display_surface, int w, int h) { } static inline void trace_displaysurface_create_from(void * display_surface, int w, int h, int bpp, int swap) { } static inline void trace_displaysurface_free(void * display_surface) { } static inline void trace_displaychangelistener_register(void * dcl, const char * name) { } static inline void trace_displaychangelistener_unregister(void * dcl, const char * name) { } static inline void trace_ppm_save(const char * filename, void * display_surface) { } static inline void trace_vmware_value_read(uint32_t index, uint32_t value) { } static inline void trace_vmware_value_write(uint32_t index, uint32_t value) { } static inline void trace_vmware_palette_read(uint32_t index, uint32_t value) { } static inline void trace_vmware_palette_write(uint32_t index, uint32_t value) { } static inline void trace_vmware_scratch_read(uint32_t index, uint32_t value) { } static inline void trace_vmware_scratch_write(uint32_t index, uint32_t value) { } static inline void trace_vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) { } static inline void trace_savevm_section_start(void) { } static inline void trace_savevm_section_end(unsigned int section_id) { } static inline void trace_migration_bitmap_sync_start(void) { } static inline void trace_migration_bitmap_sync_end(uint64_t dirty_pages) { } static inline void trace_migration_throttle(void) { } static inline void trace_qxl_create_guest_primary(int qid, uint32_t width, uint32_t height, uint64_t mem, uint32_t format, uint32_t position) { } static inline void trace_qxl_create_guest_primary_rest(int qid, int32_t stride, uint32_t type, uint32_t flags) { } static inline void trace_qxl_destroy_primary(int qid) { } static inline void trace_qxl_enter_vga_mode(int qid) { } static inline void trace_qxl_exit_vga_mode(int qid) { } static inline void trace_qxl_hard_reset(int qid, int64_t loadvm) { } static inline void trace_qxl_interface_async_complete_io(int qid, uint32_t current_async, void * cookie) { } static inline void trace_qxl_interface_attach_worker(int qid) { } static inline void trace_qxl_interface_get_init_info(int qid) { } static inline void trace_qxl_interface_set_compression_level(int qid, int64_t level) { } static inline void trace_qxl_interface_update_area_complete(int qid, uint32_t surface_id, uint32_t dirty_left, uint32_t dirty_right, uint32_t dirty_top, uint32_t dirty_bottom) { } static inline void trace_qxl_interface_update_area_complete_rest(int qid, uint32_t num_updated_rects) { } static inline void trace_qxl_interface_update_area_complete_overflow(int qid, int max) { } static inline void trace_qxl_interface_update_area_complete_schedule_bh(int qid, uint32_t num_dirty) { } static inline void trace_qxl_io_destroy_primary_ignored(int qid, const char * mode) { } static inline void trace_qxl_io_log(int qid, const uint8_t * log_buf) { } static inline void trace_qxl_io_read_unexpected(int qid) { } static inline void trace_qxl_io_unexpected_vga_mode(int qid, uint64_t addr, uint64_t val, const char * desc) { } static inline void trace_qxl_io_write(int qid, const char * mode, uint64_t addr, uint64_t val, unsigned size, int async) { } static inline void trace_qxl_memslot_add_guest(int qid, uint32_t slot_id, uint64_t guest_start, uint64_t guest_end) { } static inline void trace_qxl_post_load(int qid, const char * mode) { } static inline void trace_qxl_pre_load(int qid) { } static inline void trace_qxl_pre_save(int qid) { } static inline void trace_qxl_reset_surfaces(int qid) { } static inline void trace_qxl_ring_command_check(int qid, const char * mode) { } static inline void trace_qxl_ring_command_get(int qid, const char * mode) { } static inline void trace_qxl_ring_command_req_notification(int qid) { } static inline void trace_qxl_ring_cursor_check(int qid, const char * mode) { } static inline void trace_qxl_ring_cursor_get(int qid, const char * mode) { } static inline void trace_qxl_ring_cursor_req_notification(int qid) { } static inline void trace_qxl_ring_res_push(int qid, const char * mode, uint32_t surface_count, uint32_t free_res, void * last_release, const char * notify) { } static inline void trace_qxl_ring_res_push_rest(int qid, uint32_t ring_has, uint32_t ring_size, uint32_t prod, uint32_t cons) { } static inline void trace_qxl_ring_res_put(int qid, uint32_t free_res) { } static inline void trace_qxl_set_mode(int qid, int modenr, uint32_t x_res, uint32_t y_res, uint32_t bits, uint64_t devmem) { } static inline void trace_qxl_soft_reset(int qid) { } static inline void trace_qemu_spice_add_memslot(int qid, uint32_t slot_id, unsigned long virt_start, unsigned long virt_end, int async) { } static inline void trace_qemu_spice_del_memslot(int qid, uint32_t gid, uint32_t slot_id) { } static inline void trace_qemu_spice_create_primary_surface(int qid, uint32_t sid, void * surface, int async) { } static inline void trace_qemu_spice_destroy_primary_surface(int qid, uint32_t sid, int async) { } static inline void trace_qemu_spice_wakeup(uint32_t qid) { } static inline void trace_qemu_spice_start(uint32_t qid) { } static inline void trace_qemu_spice_stop(uint32_t qid) { } static inline void trace_qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom) { } static inline void trace_qxl_spice_destroy_surfaces_complete(int qid) { } static inline void trace_qxl_spice_destroy_surfaces(int qid, int async) { } static inline void trace_qxl_spice_destroy_surface_wait_complete(int qid, uint32_t id) { } static inline void trace_qxl_spice_destroy_surface_wait(int qid, uint32_t id, int async) { } static inline void trace_qxl_spice_flush_surfaces_async(int qid, uint32_t surface_count, uint32_t num_free_res) { } static inline void trace_qxl_spice_monitors_config(int qid) { } static inline void trace_qxl_spice_loadvm_commands(int qid, void * ext, uint32_t count) { } static inline void trace_qxl_spice_oom(int qid) { } static inline void trace_qxl_spice_reset_cursor(int qid) { } static inline void trace_qxl_spice_reset_image_cache(int qid) { } static inline void trace_qxl_spice_reset_memslots(int qid) { } static inline void trace_qxl_spice_update_area(int qid, uint32_t surface_id, uint32_t left, uint32_t right, uint32_t top, uint32_t bottom) { } static inline void trace_qxl_spice_update_area_rest(int qid, uint32_t num_dirty_rects, uint32_t clear_dirty_region) { } static inline void trace_qxl_surfaces_dirty(int qid, int surface, int offset, int size) { } static inline void trace_qxl_send_events(int qid, uint32_t events) { } static inline void trace_qxl_send_events_vm_stopped(int qid, uint32_t events) { } static inline void trace_qxl_set_guest_bug(int qid) { } static inline void trace_qxl_interrupt_client_monitors_config(int qid, int num_heads, void * heads) { } static inline void trace_qxl_client_monitors_config_unsupported_by_guest(int qid, uint32_t int_mask, void * client_monitors_config) { } static inline void trace_qxl_client_monitors_config_unsupported_by_device(int qid, int revision) { } static inline void trace_qxl_client_monitors_config_capped(int qid, int requested, int limit) { } static inline void trace_qxl_client_monitors_config_crc(int qid, unsigned size, uint32_t crc32) { } static inline void trace_qxl_set_client_capabilities_unsupported_by_revision(int qid, int revision) { } static inline void trace_qxl_render_blit_guest_primary_initialized(void) { } static inline void trace_qxl_render_blit(int32_t stride, int32_t left, int32_t right, int32_t top, int32_t bottom) { } static inline void trace_qxl_render_guest_primary_resized(int32_t width, int32_t height, int32_t stride, int32_t bytes_pp, int32_t bits_pp) { } static inline void trace_qxl_render_update_area_done(void * cookie) { } static inline void trace_spapr_pci_msi(const char * msg, uint32_t n, uint32_t ca) { } static inline void trace_spapr_pci_msi_setup(const char * name, unsigned vector, uint64_t addr) { } static inline void trace_spapr_pci_rtas_ibm_change_msi(unsigned func, unsigned req) { } static inline void trace_spapr_pci_rtas_ibm_query_interrupt_source_number(unsigned ioa, unsigned intr) { } static inline void trace_spapr_pci_msi_write(uint64_t addr, uint64_t data, uint32_t dt_irq) { } static inline void trace_spapr_pci_lsi_set(const char * busname, int pin, uint32_t irq) { } static inline void trace_xics_icp_check_ipi(int server, uint8_t mfrr) { } static inline void trace_xics_icp_accept(uint32_t old_xirr, uint32_t new_xirr) { } static inline void trace_xics_icp_eoi(int server, uint32_t xirr, uint32_t new_xirr) { } static inline void trace_xics_icp_irq(int server, int nr, uint8_t priority) { } static inline void trace_xics_icp_raise(uint32_t xirr, uint8_t pending_priority) { } static inline void trace_xics_set_irq_msi(int srcno, int nr) { } static inline void trace_xics_masked_pending(void) { } static inline void trace_xics_set_irq_lsi(int srcno, int nr) { } static inline void trace_xics_ics_write_xive(int nr, int srcno, int server, uint8_t priority) { } static inline void trace_xics_ics_reject(int nr, int srcno) { } static inline void trace_xics_ics_eoi(int nr) { } static inline void trace_hbitmap_iter_skip_words(const void * hb, void * hbi, uint64_t pos, unsigned long cur) { } static inline void trace_hbitmap_reset(void * hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) { } static inline void trace_hbitmap_set(void * hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) { } static inline void trace_ioinst(const char * insn) { } static inline void trace_ioinst_sch_id(const char * insn, int cssid, int ssid, int schid) { } static inline void trace_ioinst_chp_id(const char * insn, int cssid, int chpid) { } static inline void trace_ioinst_chsc_cmd(uint16_t cmd, uint16_t len) { } static inline void trace_css_enable_facility(const char * facility) { } static inline void trace_css_crw(uint8_t rsc, uint8_t erc, uint16_t rsid, const char * chained) { } static inline void trace_css_chpid_add(uint8_t cssid, uint8_t chpid, uint8_t type) { } static inline void trace_css_new_image(uint8_t cssid, const char * default_cssid) { } static inline void trace_css_assign_subch(const char * do_assign, uint8_t cssid, uint8_t ssid, uint16_t schid, uint16_t devno) { } static inline void trace_css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t isc, const char * conditional) { } static inline void trace_virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) { } static inline void trace_virtio_ccw_new_device(int cssid, int ssid, int schid, int devno, const char * devno_mode) { } static inline void trace_migrate_set_state(int new_state) { } static inline void trace_kvm_ioctl(int type, void * arg) { } static inline void trace_kvm_vm_ioctl(int type, void * arg) { } static inline void trace_kvm_vcpu_ioctl(int cpu_index, int type, void * arg) { } static inline void trace_kvm_run_exit(int cpu_index, uint32_t reason) { } static inline void trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func) { } static inline void trace_object_class_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func) { } #endif /* TRACE__GENERATED_TRACERS_H */ glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/config-host.h0000644000076200007630000000013112617742532021531 xustar000000000000000029 mtime=1447019866.03547157 30 atime=1447019866.371466515 30 ctime=1447019941.417337498 glusterfs-3.7.6/contrib/qemu/config-host.h0000644000076200007630000000413312617742532021750 0ustar00jenkinsjenkins00000000000000/* Automatically generated by create_config - do not modify */ #define CONFIG_QEMU_CONFDIR "/usr/local/etc/qemu" #define CONFIG_QEMU_DATADIR "/usr/local/share/qemu" #define CONFIG_QEMU_DOCDIR "/usr/local/share/doc/qemu" #define CONFIG_QEMU_LOCALSTATEDIR "/usr/local/var" #define CONFIG_QEMU_HELPERDIR "/usr/local/libexec" #define CONFIG_QEMU_LOCALEDIR "/usr/local/share/locale" #define HOST_X86_64 1 #define CONFIG_QEMU_LDST_OPTIMIZATION 1 #define CONFIG_POSIX 1 #define CONFIG_LINUX 1 #define CONFIG_SLIRP 1 #define CONFIG_SMBD_COMMAND "/usr/sbin/smbd" #define CONFIG_AUDIO_DRIVERS \ &oss_audio_driver,\ #define CONFIG_OSS 1 #define CONFIG_BDRV_RW_WHITELIST\ NULL #define CONFIG_BDRV_RO_WHITELIST\ NULL #define CONFIG_VNC 1 #define CONFIG_VNC_TLS 1 #define CONFIG_VNC_SASL 1 #define CONFIG_VNC_WS 1 #define CONFIG_FNMATCH 1 #define CONFIG_UUID 1 #define CONFIG_XFS 1 #define QEMU_VERSION "1.5.50" #define QEMU_PKGVERSION "" #define CONFIG_CURSES 1 #define CONFIG_UTIMENSAT 1 #define CONFIG_PIPE2 1 #define CONFIG_ACCEPT4 1 #define CONFIG_SPLICE 1 #define CONFIG_EVENTFD 1 #define CONFIG_FALLOCATE 1 #define CONFIG_FALLOCATE_PUNCH_HOLE 1 #define CONFIG_SYNC_FILE_RANGE 1 #define CONFIG_FIEMAP 1 #define CONFIG_DUP3 1 #define CONFIG_EPOLL 1 #define CONFIG_EPOLL_CREATE1 1 #define CONFIG_EPOLL_PWAIT 1 #define CONFIG_SENDFILE 1 #define CONFIG_INOTIFY 1 #define CONFIG_INOTIFY1 1 #define CONFIG_BYTESWAP_H 1 #define CONFIG_CURL 1 #define CONFIG_LINUX_AIO 1 #define CONFIG_ATTR 1 #define CONFIG_VHOST_SCSI 1 #define CONFIG_IOVEC 1 #define CONFIG_PREADV 1 #define CONFIG_FDT 1 #define CONFIG_SIGNALFD 1 #define CONFIG_FDATASYNC 1 #define CONFIG_MADVISE 1 #define CONFIG_POSIX_MADVISE 1 #define CONFIG_SIGEV_THREAD_ID 1 #define CONFIG_UNAME_RELEASE "" #define CONFIG_QOM_CAST_DEBUG 1 #define CONFIG_COROUTINE_BACKEND ucontext #define CONFIG_OPEN_BY_HANDLE 1 #define CONFIG_LINUX_MAGIC_H 1 #define CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE 1 #define CONFIG_HAS_ENVIRON 1 #define CONFIG_CPUID_H 1 #define CONFIG_VIRTIO_BLK_DATA_PLANE $(CONFIG_VIRTIO) #define CONFIG_TRACE_NOP 1 #define CONFIG_TRACE_FILE trace #define CONFIG_TRACE_DEFAULT 1 glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/block0000644000076200007630000000013212617742645020163 xustar000000000000000030 mtime=1447019941.747332535 30 atime=1447019949.333218415 30 ctime=1447019941.747332535 glusterfs-3.7.6/contrib/qemu/block/0000755000076200007630000000000012617742645020455 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2.h0000644000076200007630000000013112617742532021436 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 30 ctime=1447019941.620334446 glusterfs-3.7.6/contrib/qemu/block/qcow2.h0000644000076200007630000003203012617742532021652 0ustar00jenkinsjenkins00000000000000/* * Block driver for the QCOW version 2 format * * Copyright (c) 2004-2006 Fabrice Bellard * * 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. */ #ifndef BLOCK_QCOW2_H #define BLOCK_QCOW2_H #include "qemu/aes.h" #include "block/coroutine.h" //#define DEBUG_ALLOC //#define DEBUG_ALLOC2 //#define DEBUG_EXT #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb) #define QCOW_CRYPT_NONE 0 #define QCOW_CRYPT_AES 1 #define QCOW_MAX_CRYPT_CLUSTERS 32 /* indicate that the refcount of the referenced cluster is exactly one. */ #define QCOW_OFLAG_COPIED (1LL << 63) /* indicate that the cluster is compressed (they never have the copied flag) */ #define QCOW_OFLAG_COMPRESSED (1LL << 62) /* The cluster reads as all zeros */ #define QCOW_OFLAG_ZERO (1LL << 0) #define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */ #define MIN_CLUSTER_BITS 9 #define MAX_CLUSTER_BITS 21 #define L2_CACHE_SIZE 16 /* Must be at least 4 to cover all cases of refcount table growth */ #define REFCOUNT_CACHE_SIZE 4 #define DEFAULT_CLUSTER_SIZE 65536 #define QCOW2_OPT_LAZY_REFCOUNTS "lazy_refcounts" #define QCOW2_OPT_DISCARD_REQUEST "pass_discard_request" #define QCOW2_OPT_DISCARD_SNAPSHOT "pass_discard_snapshot" #define QCOW2_OPT_DISCARD_OTHER "pass_discard_other" typedef struct QCowHeader { uint32_t magic; uint32_t version; uint64_t backing_file_offset; uint32_t backing_file_size; uint32_t cluster_bits; uint64_t size; /* in bytes */ uint32_t crypt_method; uint32_t l1_size; /* XXX: save number of clusters instead ? */ uint64_t l1_table_offset; uint64_t refcount_table_offset; uint32_t refcount_table_clusters; uint32_t nb_snapshots; uint64_t snapshots_offset; /* The following fields are only valid for version >= 3 */ uint64_t incompatible_features; uint64_t compatible_features; uint64_t autoclear_features; uint32_t refcount_order; uint32_t header_length; } QCowHeader; typedef struct QCowSnapshot { uint64_t l1_table_offset; uint32_t l1_size; char *id_str; char *name; uint64_t disk_size; uint64_t vm_state_size; uint32_t date_sec; uint32_t date_nsec; uint64_t vm_clock_nsec; } QCowSnapshot; struct Qcow2Cache; typedef struct Qcow2Cache Qcow2Cache; typedef struct Qcow2UnknownHeaderExtension { uint32_t magic; uint32_t len; QLIST_ENTRY(Qcow2UnknownHeaderExtension) next; uint8_t data[]; } Qcow2UnknownHeaderExtension; enum { QCOW2_FEAT_TYPE_INCOMPATIBLE = 0, QCOW2_FEAT_TYPE_COMPATIBLE = 1, QCOW2_FEAT_TYPE_AUTOCLEAR = 2, }; /* Incompatible feature bits */ enum { QCOW2_INCOMPAT_DIRTY_BITNR = 0, QCOW2_INCOMPAT_DIRTY = 1 << QCOW2_INCOMPAT_DIRTY_BITNR, QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY, }; /* Compatible feature bits */ enum { QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR = 0, QCOW2_COMPAT_LAZY_REFCOUNTS = 1 << QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, QCOW2_COMPAT_FEAT_MASK = QCOW2_COMPAT_LAZY_REFCOUNTS, }; enum qcow2_discard_type { QCOW2_DISCARD_NEVER = 0, QCOW2_DISCARD_ALWAYS, QCOW2_DISCARD_REQUEST, QCOW2_DISCARD_SNAPSHOT, QCOW2_DISCARD_OTHER, QCOW2_DISCARD_MAX }; typedef struct Qcow2Feature { uint8_t type; uint8_t bit; char name[46]; } QEMU_PACKED Qcow2Feature; typedef struct Qcow2DiscardRegion { BlockDriverState *bs; uint64_t offset; uint64_t bytes; QTAILQ_ENTRY(Qcow2DiscardRegion) next; } Qcow2DiscardRegion; typedef struct BDRVQcowState { int cluster_bits; int cluster_size; int cluster_sectors; int l2_bits; int l2_size; int l1_size; int l1_vm_state_index; int csize_shift; int csize_mask; uint64_t cluster_offset_mask; uint64_t l1_table_offset; uint64_t *l1_table; Qcow2Cache* l2_table_cache; Qcow2Cache* refcount_block_cache; uint8_t *cluster_cache; uint8_t *cluster_data; uint64_t cluster_cache_offset; QLIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs; uint64_t *refcount_table; uint64_t refcount_table_offset; uint32_t refcount_table_size; int64_t free_cluster_index; int64_t free_byte_offset; CoMutex lock; uint32_t crypt_method; /* current crypt method, 0 if no key yet */ uint32_t crypt_method_header; AES_KEY aes_encrypt_key; AES_KEY aes_decrypt_key; uint64_t snapshots_offset; int snapshots_size; int nb_snapshots; QCowSnapshot *snapshots; int flags; int qcow_version; bool use_lazy_refcounts; bool discard_passthrough[QCOW2_DISCARD_MAX]; uint64_t incompatible_features; uint64_t compatible_features; uint64_t autoclear_features; size_t unknown_header_fields_size; void* unknown_header_fields; QLIST_HEAD(, Qcow2UnknownHeaderExtension) unknown_header_ext; QTAILQ_HEAD (, Qcow2DiscardRegion) discards; bool cache_discards; } BDRVQcowState; /* XXX: use std qcow open function ? */ typedef struct QCowCreateState { int cluster_size; int cluster_bits; uint16_t *refcount_block; uint64_t *refcount_table; int64_t l1_table_offset; int64_t refcount_table_offset; int64_t refcount_block_offset; } QCowCreateState; struct QCowAIOCB; typedef struct Qcow2COWRegion { /** * Offset of the COW region in bytes from the start of the first cluster * touched by the request. */ uint64_t offset; /** Number of sectors to copy */ int nb_sectors; } Qcow2COWRegion; /** * Describes an in-flight (part of a) write request that writes to clusters * that are not referenced in their L2 table yet. */ typedef struct QCowL2Meta { /** Guest offset of the first newly allocated cluster */ uint64_t offset; /** Host offset of the first newly allocated cluster */ uint64_t alloc_offset; /** * Number of sectors from the start of the first allocated cluster to * the end of the (possibly shortened) request */ int nb_available; /** Number of newly allocated clusters */ int nb_clusters; /** * Requests that overlap with this allocation and wait to be restarted * when the allocating request has completed. */ CoQueue dependent_requests; /** * The COW Region between the start of the first allocated cluster and the * area the guest actually writes to. */ Qcow2COWRegion cow_start; /** * The COW Region between the area the guest actually writes to and the * end of the last allocated cluster. */ Qcow2COWRegion cow_end; /** Pointer to next L2Meta of the same write request */ struct QCowL2Meta *next; QLIST_ENTRY(QCowL2Meta) next_in_flight; } QCowL2Meta; enum { QCOW2_CLUSTER_UNALLOCATED, QCOW2_CLUSTER_NORMAL, QCOW2_CLUSTER_COMPRESSED, QCOW2_CLUSTER_ZERO }; #define L1E_OFFSET_MASK 0x00ffffffffffff00ULL #define L2E_OFFSET_MASK 0x00ffffffffffff00ULL #define L2E_COMPRESSED_OFFSET_SIZE_MASK 0x3fffffffffffffffULL #define REFT_OFFSET_MASK 0xffffffffffffff00ULL static inline int64_t start_of_cluster(BDRVQcowState *s, int64_t offset) { return offset & ~(s->cluster_size - 1); } static inline int64_t offset_into_cluster(BDRVQcowState *s, int64_t offset) { return offset & (s->cluster_size - 1); } static inline int size_to_clusters(BDRVQcowState *s, int64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } static inline int64_t size_to_l1(BDRVQcowState *s, int64_t size) { int shift = s->cluster_bits + s->l2_bits; return (size + (1ULL << shift) - 1) >> shift; } static inline int offset_to_l2_index(BDRVQcowState *s, int64_t offset) { return (offset >> s->cluster_bits) & (s->l2_size - 1); } static inline int64_t align_offset(int64_t offset, int n) { offset = (offset + n - 1) & ~(n - 1); return offset; } static inline int qcow2_get_cluster_type(uint64_t l2_entry) { if (l2_entry & QCOW_OFLAG_COMPRESSED) { return QCOW2_CLUSTER_COMPRESSED; } else if (l2_entry & QCOW_OFLAG_ZERO) { return QCOW2_CLUSTER_ZERO; } else if (!(l2_entry & L2E_OFFSET_MASK)) { return QCOW2_CLUSTER_UNALLOCATED; } else { return QCOW2_CLUSTER_NORMAL; } } /* Check whether refcounts are eager or lazy */ static inline bool qcow2_need_accurate_refcounts(BDRVQcowState *s) { return !(s->incompatible_features & QCOW2_INCOMPAT_DIRTY); } static inline uint64_t l2meta_cow_start(QCowL2Meta *m) { return m->offset + m->cow_start.offset; } static inline uint64_t l2meta_cow_end(QCowL2Meta *m) { return m->offset + m->cow_end.offset + (m->cow_end.nb_sectors << BDRV_SECTOR_BITS); } // FIXME Need qcow2_ prefix to global functions /* qcow2.c functions */ int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, int64_t sector_num, int nb_sectors); int qcow2_mark_dirty(BlockDriverState *bs); int qcow2_update_header(BlockDriverState *bs); /* qcow2-refcount.c functions */ int qcow2_refcount_init(BlockDriverState *bs); void qcow2_refcount_close(BlockDriverState *bs); int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size); int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, enum qcow2_discard_type type); void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int nb_clusters, enum qcow2_discard_type type); int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); void qcow2_process_discards(BlockDriverState *bs, int ret); /* qcow2-cluster.c functions */ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size); void qcow2_l2_cache_reset(BlockDriverState *bs); int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset); void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, int enc, const AES_KEY *key); int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset); int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, uint64_t *host_offset, QCowL2Meta **m); uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size); int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m); int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors); int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors); /* qcow2-snapshot.c functions */ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info); int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id); int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id); int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab); int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name); void qcow2_free_snapshots(BlockDriverState *bs); int qcow2_read_snapshots(BlockDriverState *bs); /* qcow2-cache.c functions */ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, Qcow2Cache *dependency); void qcow2_cache_depends_on_flush(Qcow2Cache *c); int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table); int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table); int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table); #endif glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed.h0000644000076200007630000000013012617742532021153 xustar000000000000000029 mtime=1447019866.03547157 30 atime=1447019866.371466515 29 ctime=1447019941.62533437 glusterfs-3.7.6/contrib/qemu/block/qed.h0000644000076200007630000002552312617742532021401 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #ifndef BLOCK_QED_H #define BLOCK_QED_H #include "block/block_int.h" /* The layout of a QED file is as follows: * * +--------+----------+----------+----------+-----+ * | header | L1 table | cluster0 | cluster1 | ... | * +--------+----------+----------+----------+-----+ * * There is a 2-level pagetable for cluster allocation: * * +----------+ * | L1 table | * +----------+ * ,------' | '------. * +----------+ | +----------+ * | L2 table | ... | L2 table | * +----------+ +----------+ * ,------' | '------. * +----------+ | +----------+ * | Data | ... | Data | * +----------+ +----------+ * * The L1 table is fixed size and always present. L2 tables are allocated on * demand. The L1 table size determines the maximum possible image size; it * can be influenced using the cluster_size and table_size values. * * All fields are little-endian on disk. */ enum { QED_MAGIC = 'Q' | 'E' << 8 | 'D' << 16 | '\0' << 24, /* The image supports a backing file */ QED_F_BACKING_FILE = 0x01, /* The image needs a consistency check before use */ QED_F_NEED_CHECK = 0x02, /* The backing file format must not be probed, treat as raw image */ QED_F_BACKING_FORMAT_NO_PROBE = 0x04, /* Feature bits must be used when the on-disk format changes */ QED_FEATURE_MASK = QED_F_BACKING_FILE | /* supported feature bits */ QED_F_NEED_CHECK | QED_F_BACKING_FORMAT_NO_PROBE, QED_COMPAT_FEATURE_MASK = 0, /* supported compat feature bits */ QED_AUTOCLEAR_FEATURE_MASK = 0, /* supported autoclear feature bits */ /* Data is stored in groups of sectors called clusters. Cluster size must * be large to avoid keeping too much metadata. I/O requests that have * sub-cluster size will require read-modify-write. */ QED_MIN_CLUSTER_SIZE = 4 * 1024, /* in bytes */ QED_MAX_CLUSTER_SIZE = 64 * 1024 * 1024, QED_DEFAULT_CLUSTER_SIZE = 64 * 1024, /* Allocated clusters are tracked using a 2-level pagetable. Table size is * a multiple of clusters so large maximum image sizes can be supported * without jacking up the cluster size too much. */ QED_MIN_TABLE_SIZE = 1, /* in clusters */ QED_MAX_TABLE_SIZE = 16, QED_DEFAULT_TABLE_SIZE = 4, /* Delay to flush and clean image after last allocating write completes */ QED_NEED_CHECK_TIMEOUT = 5, /* in seconds */ }; typedef struct { uint32_t magic; /* QED\0 */ uint32_t cluster_size; /* in bytes */ uint32_t table_size; /* for L1 and L2 tables, in clusters */ uint32_t header_size; /* in clusters */ uint64_t features; /* format feature bits */ uint64_t compat_features; /* compatible feature bits */ uint64_t autoclear_features; /* self-resetting feature bits */ uint64_t l1_table_offset; /* in bytes */ uint64_t image_size; /* total logical image size, in bytes */ /* if (features & QED_F_BACKING_FILE) */ uint32_t backing_filename_offset; /* in bytes from start of header */ uint32_t backing_filename_size; /* in bytes */ } QEDHeader; typedef struct { uint64_t offsets[0]; /* in bytes */ } QEDTable; /* The L2 cache is a simple write-through cache for L2 structures */ typedef struct CachedL2Table { QEDTable *table; uint64_t offset; /* offset=0 indicates an invalidate entry */ QTAILQ_ENTRY(CachedL2Table) node; int ref; } CachedL2Table; typedef struct { QTAILQ_HEAD(, CachedL2Table) entries; unsigned int n_entries; } L2TableCache; typedef struct QEDRequest { CachedL2Table *l2_table; } QEDRequest; enum { QED_AIOCB_WRITE = 0x0001, /* read or write? */ QED_AIOCB_ZERO = 0x0002, /* zero write, used with QED_AIOCB_WRITE */ }; typedef struct QEDAIOCB { BlockDriverAIOCB common; QEMUBH *bh; int bh_ret; /* final return status for completion bh */ QSIMPLEQ_ENTRY(QEDAIOCB) next; /* next request */ int flags; /* QED_AIOCB_* bits ORed together */ bool *finished; /* signal for cancel completion */ uint64_t end_pos; /* request end on block device, in bytes */ /* User scatter-gather list */ QEMUIOVector *qiov; size_t qiov_offset; /* byte count already processed */ /* Current cluster scatter-gather list */ QEMUIOVector cur_qiov; uint64_t cur_pos; /* position on block device, in bytes */ uint64_t cur_cluster; /* cluster offset in image file */ unsigned int cur_nclusters; /* number of clusters being accessed */ int find_cluster_ret; /* used for L1/L2 update */ QEDRequest request; } QEDAIOCB; typedef struct { BlockDriverState *bs; /* device */ uint64_t file_size; /* length of image file, in bytes */ QEDHeader header; /* always cpu-endian */ QEDTable *l1_table; L2TableCache l2_cache; /* l2 table cache */ uint32_t table_nelems; uint32_t l1_shift; uint32_t l2_shift; uint32_t l2_mask; /* Allocating write request queue */ QSIMPLEQ_HEAD(, QEDAIOCB) allocating_write_reqs; bool allocating_write_reqs_plugged; /* Periodic flush and clear need check flag */ QEMUTimer *need_check_timer; } BDRVQEDState; enum { QED_CLUSTER_FOUND, /* cluster found */ QED_CLUSTER_ZERO, /* zero cluster found */ QED_CLUSTER_L2, /* cluster missing in L2 */ QED_CLUSTER_L1, /* cluster missing in L1 */ }; /** * qed_find_cluster() completion callback * * @opaque: User data for completion callback * @ret: QED_CLUSTER_FOUND Success * QED_CLUSTER_L2 Data cluster unallocated in L2 * QED_CLUSTER_L1 L2 unallocated in L1 * -errno POSIX error occurred * @offset: Data cluster offset * @len: Contiguous bytes starting from cluster offset * * This function is invoked when qed_find_cluster() completes. * * On success ret is QED_CLUSTER_FOUND and offset/len are a contiguous range * in the image file. * * On failure ret is QED_CLUSTER_L2 or QED_CLUSTER_L1 for missing L2 or L1 * table offset, respectively. len is number of contiguous unallocated bytes. */ typedef void QEDFindClusterFunc(void *opaque, int ret, uint64_t offset, size_t len); /** * Generic callback for chaining async callbacks */ typedef struct { BlockDriverCompletionFunc *cb; void *opaque; } GenericCB; void *gencb_alloc(size_t len, BlockDriverCompletionFunc *cb, void *opaque); void gencb_complete(void *opaque, int ret); /** * Header functions */ int qed_write_header_sync(BDRVQEDState *s); /** * L2 cache functions */ void qed_init_l2_cache(L2TableCache *l2_cache); void qed_free_l2_cache(L2TableCache *l2_cache); CachedL2Table *qed_alloc_l2_cache_entry(L2TableCache *l2_cache); void qed_unref_l2_cache_entry(CachedL2Table *entry); CachedL2Table *qed_find_l2_cache_entry(L2TableCache *l2_cache, uint64_t offset); void qed_commit_l2_cache_entry(L2TableCache *l2_cache, CachedL2Table *l2_table); /** * Table I/O functions */ int qed_read_l1_table_sync(BDRVQEDState *s); void qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int n, BlockDriverCompletionFunc *cb, void *opaque); int qed_write_l1_table_sync(BDRVQEDState *s, unsigned int index, unsigned int n); int qed_read_l2_table_sync(BDRVQEDState *s, QEDRequest *request, uint64_t offset); void qed_read_l2_table(BDRVQEDState *s, QEDRequest *request, uint64_t offset, BlockDriverCompletionFunc *cb, void *opaque); void qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush, BlockDriverCompletionFunc *cb, void *opaque); int qed_write_l2_table_sync(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush); /** * Cluster functions */ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos, size_t len, QEDFindClusterFunc *cb, void *opaque); /** * Consistency check */ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix); QEDTable *qed_alloc_table(BDRVQEDState *s); /** * Round down to the start of a cluster */ static inline uint64_t qed_start_of_cluster(BDRVQEDState *s, uint64_t offset) { return offset & ~(uint64_t)(s->header.cluster_size - 1); } static inline uint64_t qed_offset_into_cluster(BDRVQEDState *s, uint64_t offset) { return offset & (s->header.cluster_size - 1); } static inline uint64_t qed_bytes_to_clusters(BDRVQEDState *s, uint64_t bytes) { return qed_start_of_cluster(s, bytes + (s->header.cluster_size - 1)) / (s->header.cluster_size - 1); } static inline unsigned int qed_l1_index(BDRVQEDState *s, uint64_t pos) { return pos >> s->l1_shift; } static inline unsigned int qed_l2_index(BDRVQEDState *s, uint64_t pos) { return (pos >> s->l2_shift) & s->l2_mask; } /** * Test if a cluster offset is valid */ static inline bool qed_check_cluster_offset(BDRVQEDState *s, uint64_t offset) { uint64_t header_size = (uint64_t)s->header.header_size * s->header.cluster_size; if (offset & (s->header.cluster_size - 1)) { return false; } return offset >= header_size && offset < s->file_size; } /** * Test if a table offset is valid */ static inline bool qed_check_table_offset(BDRVQEDState *s, uint64_t offset) { uint64_t end_offset = offset + (s->header.table_size - 1) * s->header.cluster_size; /* Overflow check */ if (end_offset <= offset) { return false; } return qed_check_cluster_offset(s, offset) && qed_check_cluster_offset(s, end_offset); } static inline bool qed_offset_is_cluster_aligned(BDRVQEDState *s, uint64_t offset) { if (qed_offset_into_cluster(s, offset)) { return false; } return true; } static inline bool qed_offset_is_unalloc_cluster(uint64_t offset) { if (offset == 0) { return true; } return false; } static inline bool qed_offset_is_zero_cluster(uint64_t offset) { if (offset == 1) { return true; } return false; } #endif /* BLOCK_QED_H */ glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2-cache.c0000644000076200007630000000013112617742532022472 xustar000000000000000030 mtime=1447019866.032471615 30 atime=1447019866.369466545 29 ctime=1447019941.71433303 glusterfs-3.7.6/contrib/qemu/block/qcow2-cache.c0000644000076200007630000001750712617742532022722 0ustar00jenkinsjenkins00000000000000/* * L2/refcount table cache for the QCOW2 format * * Copyright (c) 2010 Kevin Wolf * * 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. */ #include "block/block_int.h" #include "qemu-common.h" #include "qcow2.h" #include "trace.h" typedef struct Qcow2CachedTable { void* table; int64_t offset; bool dirty; int cache_hits; int ref; } Qcow2CachedTable; struct Qcow2Cache { Qcow2CachedTable* entries; struct Qcow2Cache* depends; int size; bool depends_on_flush; }; Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) { BDRVQcowState *s = bs->opaque; Qcow2Cache *c; int i; c = g_malloc0(sizeof(*c)); c->size = num_tables; c->entries = g_malloc0(sizeof(*c->entries) * num_tables); for (i = 0; i < c->size; i++) { c->entries[i].table = qemu_blockalign(bs, s->cluster_size); } return c; } int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c) { int i; for (i = 0; i < c->size; i++) { assert(c->entries[i].ref == 0); qemu_vfree(c->entries[i].table); } g_free(c->entries); g_free(c); return 0; } static int qcow2_cache_flush_dependency(BlockDriverState *bs, Qcow2Cache *c) { int ret; ret = qcow2_cache_flush(bs, c->depends); if (ret < 0) { return ret; } c->depends = NULL; c->depends_on_flush = false; return 0; } static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) { BDRVQcowState *s = bs->opaque; int ret = 0; if (!c->entries[i].dirty || !c->entries[i].offset) { return 0; } trace_qcow2_cache_entry_flush(qemu_coroutine_self(), c == s->l2_table_cache, i); if (c->depends) { ret = qcow2_cache_flush_dependency(bs, c); } else if (c->depends_on_flush) { ret = bdrv_flush(bs->file); if (ret >= 0) { c->depends_on_flush = false; } } if (ret < 0) { return ret; } if (c == s->refcount_block_cache) { BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART); } else if (c == s->l2_table_cache) { BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); } ret = bdrv_pwrite(bs->file, c->entries[i].offset, c->entries[i].table, s->cluster_size); if (ret < 0) { return ret; } c->entries[i].dirty = false; return 0; } int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c) { BDRVQcowState *s = bs->opaque; int result = 0; int ret; int i; trace_qcow2_cache_flush(qemu_coroutine_self(), c == s->l2_table_cache); for (i = 0; i < c->size; i++) { ret = qcow2_cache_entry_flush(bs, c, i); if (ret < 0 && result != -ENOSPC) { result = ret; } } if (result == 0) { ret = bdrv_flush(bs->file); if (ret < 0) { result = ret; } } return result; } int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, Qcow2Cache *dependency) { int ret; if (dependency->depends) { ret = qcow2_cache_flush_dependency(bs, dependency); if (ret < 0) { return ret; } } if (c->depends && (c->depends != dependency)) { ret = qcow2_cache_flush_dependency(bs, c); if (ret < 0) { return ret; } } c->depends = dependency; return 0; } void qcow2_cache_depends_on_flush(Qcow2Cache *c) { c->depends_on_flush = true; } static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c) { int i; int min_count = INT_MAX; int min_index = -1; for (i = 0; i < c->size; i++) { if (c->entries[i].ref) { continue; } if (c->entries[i].cache_hits < min_count) { min_index = i; min_count = c->entries[i].cache_hits; } /* Give newer hits priority */ /* TODO Check how to optimize the replacement strategy */ c->entries[i].cache_hits /= 2; } if (min_index == -1) { /* This can't happen in current synchronous code, but leave the check * here as a reminder for whoever starts using AIO with the cache */ abort(); } return min_index; } static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table, bool read_from_disk) { BDRVQcowState *s = bs->opaque; int i; int ret; trace_qcow2_cache_get(qemu_coroutine_self(), c == s->l2_table_cache, offset, read_from_disk); /* Check if the table is already cached */ for (i = 0; i < c->size; i++) { if (c->entries[i].offset == offset) { goto found; } } /* If not, write a table back and replace it */ i = qcow2_cache_find_entry_to_replace(c); trace_qcow2_cache_get_replace_entry(qemu_coroutine_self(), c == s->l2_table_cache, i); if (i < 0) { return i; } ret = qcow2_cache_entry_flush(bs, c, i); if (ret < 0) { return ret; } trace_qcow2_cache_get_read(qemu_coroutine_self(), c == s->l2_table_cache, i); c->entries[i].offset = 0; if (read_from_disk) { if (c == s->l2_table_cache) { BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); } ret = bdrv_pread(bs->file, offset, c->entries[i].table, s->cluster_size); if (ret < 0) { return ret; } } /* Give the table some hits for the start so that it won't be replaced * immediately. The number 32 is completely arbitrary. */ c->entries[i].cache_hits = 32; c->entries[i].offset = offset; /* And return the right table */ found: c->entries[i].cache_hits++; c->entries[i].ref++; *table = c->entries[i].table; trace_qcow2_cache_get_done(qemu_coroutine_self(), c == s->l2_table_cache, i); return 0; } int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table) { return qcow2_cache_do_get(bs, c, offset, table, true); } int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table) { return qcow2_cache_do_get(bs, c, offset, table, false); } int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { int i; for (i = 0; i < c->size; i++) { if (c->entries[i].table == *table) { goto found; } } return -ENOENT; found: c->entries[i].ref--; *table = NULL; assert(c->entries[i].ref >= 0); return 0; } void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table) { int i; for (i = 0; i < c->size; i++) { if (c->entries[i].table == table) { goto found; } } abort(); found: c->entries[i].dirty = true; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed-cluster.c0000644000076200007630000000013112617742532022626 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 30 ctime=1447019941.735332716 glusterfs-3.7.6/contrib/qemu/block/qed-cluster.c0000644000076200007630000001217412617742532023051 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format Cluster functions * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qed.h" /** * Count the number of contiguous data clusters * * @s: QED state * @table: L2 table * @index: First cluster index * @n: Maximum number of clusters * @offset: Set to first cluster offset * * This function scans tables for contiguous clusters. A contiguous run of * clusters may be allocated, unallocated, or zero. */ static unsigned int qed_count_contiguous_clusters(BDRVQEDState *s, QEDTable *table, unsigned int index, unsigned int n, uint64_t *offset) { unsigned int end = MIN(index + n, s->table_nelems); uint64_t last = table->offsets[index]; unsigned int i; *offset = last; for (i = index + 1; i < end; i++) { if (qed_offset_is_unalloc_cluster(last)) { /* Counting unallocated clusters */ if (!qed_offset_is_unalloc_cluster(table->offsets[i])) { break; } } else if (qed_offset_is_zero_cluster(last)) { /* Counting zero clusters */ if (!qed_offset_is_zero_cluster(table->offsets[i])) { break; } } else { /* Counting allocated clusters */ if (table->offsets[i] != last + s->header.cluster_size) { break; } last = table->offsets[i]; } } return i - index; } typedef struct { BDRVQEDState *s; uint64_t pos; size_t len; QEDRequest *request; /* User callback */ QEDFindClusterFunc *cb; void *opaque; } QEDFindClusterCB; static void qed_find_cluster_cb(void *opaque, int ret) { QEDFindClusterCB *find_cluster_cb = opaque; BDRVQEDState *s = find_cluster_cb->s; QEDRequest *request = find_cluster_cb->request; uint64_t offset = 0; size_t len = 0; unsigned int index; unsigned int n; if (ret) { goto out; } index = qed_l2_index(s, find_cluster_cb->pos); n = qed_bytes_to_clusters(s, qed_offset_into_cluster(s, find_cluster_cb->pos) + find_cluster_cb->len); n = qed_count_contiguous_clusters(s, request->l2_table->table, index, n, &offset); if (qed_offset_is_unalloc_cluster(offset)) { ret = QED_CLUSTER_L2; } else if (qed_offset_is_zero_cluster(offset)) { ret = QED_CLUSTER_ZERO; } else if (qed_check_cluster_offset(s, offset)) { ret = QED_CLUSTER_FOUND; } else { ret = -EINVAL; } len = MIN(find_cluster_cb->len, n * s->header.cluster_size - qed_offset_into_cluster(s, find_cluster_cb->pos)); out: find_cluster_cb->cb(find_cluster_cb->opaque, ret, offset, len); g_free(find_cluster_cb); } /** * Find the offset of a data cluster * * @s: QED state * @request: L2 cache entry * @pos: Byte position in device * @len: Number of bytes * @cb: Completion function * @opaque: User data for completion function * * This function translates a position in the block device to an offset in the * image file. It invokes the cb completion callback to report back the * translated offset or unallocated range in the image file. * * If the L2 table exists, request->l2_table points to the L2 table cache entry * and the caller must free the reference when they are finished. The cache * entry is exposed in this way to avoid callers having to read the L2 table * again later during request processing. If request->l2_table is non-NULL it * will be unreferenced before taking on the new cache entry. */ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos, size_t len, QEDFindClusterFunc *cb, void *opaque) { QEDFindClusterCB *find_cluster_cb; uint64_t l2_offset; /* Limit length to L2 boundary. Requests are broken up at the L2 boundary * so that a request acts on one L2 table at a time. */ len = MIN(len, (((pos >> s->l1_shift) + 1) << s->l1_shift) - pos); l2_offset = s->l1_table->offsets[qed_l1_index(s, pos)]; if (qed_offset_is_unalloc_cluster(l2_offset)) { cb(opaque, QED_CLUSTER_L1, 0, len); return; } if (!qed_check_table_offset(s, l2_offset)) { cb(opaque, -EINVAL, 0, 0); return; } find_cluster_cb = g_malloc(sizeof(*find_cluster_cb)); find_cluster_cb->s = s; find_cluster_cb->pos = pos; find_cluster_cb->len = len; find_cluster_cb->cb = cb; find_cluster_cb->opaque = opaque; find_cluster_cb->request = request; qed_read_l2_table(s, request, l2_offset, qed_find_cluster_cb, find_cluster_cb); } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed-l2-cache.c0000644000076200007630000000013112617742532022523 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 30 ctime=1447019941.741332625 glusterfs-3.7.6/contrib/qemu/block/qed-l2-cache.c0000644000076200007630000001355112617742532022746 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format L2 Cache * * Copyright IBM, Corp. 2010 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ /* * L2 table cache usage is as follows: * * An open image has one L2 table cache that is used to avoid accessing the * image file for recently referenced L2 tables. * * Cluster offset lookup translates the logical offset within the block device * to a cluster offset within the image file. This is done by indexing into * the L1 and L2 tables which store cluster offsets. It is here where the L2 * table cache serves up recently referenced L2 tables. * * If there is a cache miss, that L2 table is read from the image file and * committed to the cache. Subsequent accesses to that L2 table will be served * from the cache until the table is evicted from the cache. * * L2 tables are also committed to the cache when new L2 tables are allocated * in the image file. Since the L2 table cache is write-through, the new L2 * table is first written out to the image file and then committed to the * cache. * * Multiple I/O requests may be using an L2 table cache entry at any given * time. That means an entry may be in use across several requests and * reference counting is needed to free the entry at the correct time. In * particular, an entry evicted from the cache will only be freed once all * references are dropped. * * An in-flight I/O request will hold a reference to a L2 table cache entry for * the period during which it needs to access the L2 table. This includes * cluster offset lookup, L2 table allocation, and L2 table update when a new * data cluster has been allocated. * * An interesting case occurs when two requests need to access an L2 table that * is not in the cache. Since the operation to read the table from the image * file takes some time to complete, both requests may see a cache miss and * start reading the L2 table from the image file. The first to finish will * commit its L2 table into the cache. When the second tries to commit its * table will be deleted in favor of the existing cache entry. */ #include "trace.h" #include "qed.h" /* Each L2 holds 2GB so this let's us fully cache a 100GB disk */ #define MAX_L2_CACHE_SIZE 50 /** * Initialize the L2 cache */ void qed_init_l2_cache(L2TableCache *l2_cache) { QTAILQ_INIT(&l2_cache->entries); l2_cache->n_entries = 0; } /** * Free the L2 cache */ void qed_free_l2_cache(L2TableCache *l2_cache) { CachedL2Table *entry, *next_entry; QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next_entry) { qemu_vfree(entry->table); g_free(entry); } } /** * Allocate an uninitialized entry from the cache * * The returned entry has a reference count of 1 and is owned by the caller. * The caller must allocate the actual table field for this entry and it must * be freeable using qemu_vfree(). */ CachedL2Table *qed_alloc_l2_cache_entry(L2TableCache *l2_cache) { CachedL2Table *entry; entry = g_malloc0(sizeof(*entry)); entry->ref++; trace_qed_alloc_l2_cache_entry(l2_cache, entry); return entry; } /** * Decrease an entry's reference count and free if necessary when the reference * count drops to zero. */ void qed_unref_l2_cache_entry(CachedL2Table *entry) { if (!entry) { return; } entry->ref--; trace_qed_unref_l2_cache_entry(entry, entry->ref); if (entry->ref == 0) { qemu_vfree(entry->table); g_free(entry); } } /** * Find an entry in the L2 cache. This may return NULL and it's up to the * caller to satisfy the cache miss. * * For a cached entry, this function increases the reference count and returns * the entry. */ CachedL2Table *qed_find_l2_cache_entry(L2TableCache *l2_cache, uint64_t offset) { CachedL2Table *entry; QTAILQ_FOREACH(entry, &l2_cache->entries, node) { if (entry->offset == offset) { trace_qed_find_l2_cache_entry(l2_cache, entry, offset, entry->ref); entry->ref++; return entry; } } return NULL; } /** * Commit an L2 cache entry into the cache. This is meant to be used as part of * the process to satisfy a cache miss. A caller would allocate an entry which * is not actually in the L2 cache and then once the entry was valid and * present on disk, the entry can be committed into the cache. * * Since the cache is write-through, it's important that this function is not * called until the entry is present on disk and the L1 has been updated to * point to the entry. * * N.B. This function steals a reference to the l2_table from the caller so the * caller must obtain a new reference by issuing a call to * qed_find_l2_cache_entry(). */ void qed_commit_l2_cache_entry(L2TableCache *l2_cache, CachedL2Table *l2_table) { CachedL2Table *entry; entry = qed_find_l2_cache_entry(l2_cache, l2_table->offset); if (entry) { qed_unref_l2_cache_entry(entry); qed_unref_l2_cache_entry(l2_table); return; } /* Evict an unused cache entry so we have space. If all entries are in use * we can grow the cache temporarily and we try to shrink back down later. */ if (l2_cache->n_entries >= MAX_L2_CACHE_SIZE) { CachedL2Table *next; QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next) { if (entry->ref > 1) { continue; } QTAILQ_REMOVE(&l2_cache->entries, entry, node); l2_cache->n_entries--; qed_unref_l2_cache_entry(entry); /* Stop evicting when we've shrunk back to max size */ if (l2_cache->n_entries < MAX_L2_CACHE_SIZE) { break; } } } l2_cache->n_entries++; QTAILQ_INSERT_TAIL(&l2_cache->entries, l2_table, node); } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed.c0000644000076200007630000000012712617742532021154 xustar000000000000000029 mtime=1447019866.03547157 29 atime=1447019866.37046653 29 ctime=1447019941.74833252 glusterfs-3.7.6/contrib/qemu/block/qed.c0000644000076200007630000013404512617742532021374 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qemu/timer.h" #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" #include "migration/migration.h" static void qed_aio_cancel(BlockDriverAIOCB *blockacb) { QEDAIOCB *acb = (QEDAIOCB *)blockacb; bool finished = false; /* Wait for the request to finish */ acb->finished = &finished; while (!finished) { qemu_aio_wait(); } } static const AIOCBInfo qed_aiocb_info = { .aiocb_size = sizeof(QEDAIOCB), .cancel = qed_aio_cancel, }; static int bdrv_qed_probe(const uint8_t *buf, int buf_size, const char *filename) { const QEDHeader *header = (const QEDHeader *)buf; if (buf_size < sizeof(*header)) { return 0; } if (le32_to_cpu(header->magic) != QED_MAGIC) { return 0; } return 100; } /** * Check whether an image format is raw * * @fmt: Backing file format, may be NULL */ static bool qed_fmt_is_raw(const char *fmt) { return fmt && strcmp(fmt, "raw") == 0; } static void qed_header_le_to_cpu(const QEDHeader *le, QEDHeader *cpu) { cpu->magic = le32_to_cpu(le->magic); cpu->cluster_size = le32_to_cpu(le->cluster_size); cpu->table_size = le32_to_cpu(le->table_size); cpu->header_size = le32_to_cpu(le->header_size); cpu->features = le64_to_cpu(le->features); cpu->compat_features = le64_to_cpu(le->compat_features); cpu->autoclear_features = le64_to_cpu(le->autoclear_features); cpu->l1_table_offset = le64_to_cpu(le->l1_table_offset); cpu->image_size = le64_to_cpu(le->image_size); cpu->backing_filename_offset = le32_to_cpu(le->backing_filename_offset); cpu->backing_filename_size = le32_to_cpu(le->backing_filename_size); } static void qed_header_cpu_to_le(const QEDHeader *cpu, QEDHeader *le) { le->magic = cpu_to_le32(cpu->magic); le->cluster_size = cpu_to_le32(cpu->cluster_size); le->table_size = cpu_to_le32(cpu->table_size); le->header_size = cpu_to_le32(cpu->header_size); le->features = cpu_to_le64(cpu->features); le->compat_features = cpu_to_le64(cpu->compat_features); le->autoclear_features = cpu_to_le64(cpu->autoclear_features); le->l1_table_offset = cpu_to_le64(cpu->l1_table_offset); le->image_size = cpu_to_le64(cpu->image_size); le->backing_filename_offset = cpu_to_le32(cpu->backing_filename_offset); le->backing_filename_size = cpu_to_le32(cpu->backing_filename_size); } int qed_write_header_sync(BDRVQEDState *s) { QEDHeader le; int ret; qed_header_cpu_to_le(&s->header, &le); ret = bdrv_pwrite(s->bs->file, 0, &le, sizeof(le)); if (ret != sizeof(le)) { return ret; } return 0; } typedef struct { GenericCB gencb; BDRVQEDState *s; struct iovec iov; QEMUIOVector qiov; int nsectors; uint8_t *buf; } QEDWriteHeaderCB; static void qed_write_header_cb(void *opaque, int ret) { QEDWriteHeaderCB *write_header_cb = opaque; qemu_vfree(write_header_cb->buf); gencb_complete(write_header_cb, ret); } static void qed_write_header_read_cb(void *opaque, int ret) { QEDWriteHeaderCB *write_header_cb = opaque; BDRVQEDState *s = write_header_cb->s; if (ret) { qed_write_header_cb(write_header_cb, ret); return; } /* Update header */ qed_header_cpu_to_le(&s->header, (QEDHeader *)write_header_cb->buf); bdrv_aio_writev(s->bs->file, 0, &write_header_cb->qiov, write_header_cb->nsectors, qed_write_header_cb, write_header_cb); } /** * Update header in-place (does not rewrite backing filename or other strings) * * This function only updates known header fields in-place and does not affect * extra data after the QED header. */ static void qed_write_header(BDRVQEDState *s, BlockDriverCompletionFunc cb, void *opaque) { /* We must write full sectors for O_DIRECT but cannot necessarily generate * the data following the header if an unrecognized compat feature is * active. Therefore, first read the sectors containing the header, update * them, and write back. */ int nsectors = (sizeof(QEDHeader) + BDRV_SECTOR_SIZE - 1) / BDRV_SECTOR_SIZE; size_t len = nsectors * BDRV_SECTOR_SIZE; QEDWriteHeaderCB *write_header_cb = gencb_alloc(sizeof(*write_header_cb), cb, opaque); write_header_cb->s = s; write_header_cb->nsectors = nsectors; write_header_cb->buf = qemu_blockalign(s->bs, len); write_header_cb->iov.iov_base = write_header_cb->buf; write_header_cb->iov.iov_len = len; qemu_iovec_init_external(&write_header_cb->qiov, &write_header_cb->iov, 1); bdrv_aio_readv(s->bs->file, 0, &write_header_cb->qiov, nsectors, qed_write_header_read_cb, write_header_cb); } static uint64_t qed_max_image_size(uint32_t cluster_size, uint32_t table_size) { uint64_t table_entries; uint64_t l2_size; table_entries = (table_size * cluster_size) / sizeof(uint64_t); l2_size = table_entries * cluster_size; return l2_size * table_entries; } static bool qed_is_cluster_size_valid(uint32_t cluster_size) { if (cluster_size < QED_MIN_CLUSTER_SIZE || cluster_size > QED_MAX_CLUSTER_SIZE) { return false; } if (cluster_size & (cluster_size - 1)) { return false; /* not power of 2 */ } return true; } static bool qed_is_table_size_valid(uint32_t table_size) { if (table_size < QED_MIN_TABLE_SIZE || table_size > QED_MAX_TABLE_SIZE) { return false; } if (table_size & (table_size - 1)) { return false; /* not power of 2 */ } return true; } static bool qed_is_image_size_valid(uint64_t image_size, uint32_t cluster_size, uint32_t table_size) { if (image_size % BDRV_SECTOR_SIZE != 0) { return false; /* not multiple of sector size */ } if (image_size > qed_max_image_size(cluster_size, table_size)) { return false; /* image is too large */ } return true; } /** * Read a string of known length from the image file * * @file: Image file * @offset: File offset to start of string, in bytes * @n: String length in bytes * @buf: Destination buffer * @buflen: Destination buffer length in bytes * @ret: 0 on success, -errno on failure * * The string is NUL-terminated. */ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, char *buf, size_t buflen) { int ret; if (n >= buflen) { return -EINVAL; } ret = bdrv_pread(file, offset, buf, n); if (ret < 0) { return ret; } buf[n] = '\0'; return 0; } /** * Allocate new clusters * * @s: QED state * @n: Number of contiguous clusters to allocate * @ret: Offset of first allocated cluster * * This function only produces the offset where the new clusters should be * written. It updates BDRVQEDState but does not make any changes to the image * file. */ static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n) { uint64_t offset = s->file_size; s->file_size += n * s->header.cluster_size; return offset; } QEDTable *qed_alloc_table(BDRVQEDState *s) { /* Honor O_DIRECT memory alignment requirements */ return qemu_blockalign(s->bs, s->header.cluster_size * s->header.table_size); } /** * Allocate a new zeroed L2 table */ static CachedL2Table *qed_new_l2_table(BDRVQEDState *s) { CachedL2Table *l2_table = qed_alloc_l2_cache_entry(&s->l2_cache); l2_table->table = qed_alloc_table(s); l2_table->offset = qed_alloc_clusters(s, s->header.table_size); memset(l2_table->table->offsets, 0, s->header.cluster_size * s->header.table_size); return l2_table; } static void qed_aio_next_io(void *opaque, int ret); static void qed_plug_allocating_write_reqs(BDRVQEDState *s) { assert(!s->allocating_write_reqs_plugged); s->allocating_write_reqs_plugged = true; } static void qed_unplug_allocating_write_reqs(BDRVQEDState *s) { QEDAIOCB *acb; assert(s->allocating_write_reqs_plugged); s->allocating_write_reqs_plugged = false; acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs); if (acb) { qed_aio_next_io(acb, 0); } } static void qed_finish_clear_need_check(void *opaque, int ret) { /* Do nothing */ } static void qed_flush_after_clear_need_check(void *opaque, int ret) { BDRVQEDState *s = opaque; bdrv_aio_flush(s->bs, qed_finish_clear_need_check, s); /* No need to wait until flush completes */ qed_unplug_allocating_write_reqs(s); } static void qed_clear_need_check(void *opaque, int ret) { BDRVQEDState *s = opaque; if (ret) { qed_unplug_allocating_write_reqs(s); return; } s->header.features &= ~QED_F_NEED_CHECK; qed_write_header(s, qed_flush_after_clear_need_check, s); } static void qed_need_check_timer_cb(void *opaque) { BDRVQEDState *s = opaque; /* The timer should only fire when allocating writes have drained */ assert(!QSIMPLEQ_FIRST(&s->allocating_write_reqs)); trace_qed_need_check_timer_cb(s); qed_plug_allocating_write_reqs(s); /* Ensure writes are on disk before clearing flag */ bdrv_aio_flush(s->bs, qed_clear_need_check, s); } static void qed_start_need_check_timer(BDRVQEDState *s) { trace_qed_start_need_check_timer(s); /* Use vm_clock so we don't alter the image file while suspended for * migration. */ qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(vm_clock) + get_ticks_per_sec() * QED_NEED_CHECK_TIMEOUT); } /* It's okay to call this multiple times or when no timer is started */ static void qed_cancel_need_check_timer(BDRVQEDState *s) { trace_qed_cancel_need_check_timer(s); qemu_del_timer(s->need_check_timer); } static void bdrv_qed_rebind(BlockDriverState *bs) { BDRVQEDState *s = bs->opaque; s->bs = bs; } static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags) { BDRVQEDState *s = bs->opaque; QEDHeader le_header; int64_t file_size; int ret; s->bs = bs; QSIMPLEQ_INIT(&s->allocating_write_reqs); ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { return ret; } qed_header_le_to_cpu(&le_header, &s->header); if (s->header.magic != QED_MAGIC) { return -EMEDIUMTYPE; } if (s->header.features & ~QED_FEATURE_MASK) { /* image uses unsupported feature bits */ char buf[64]; snprintf(buf, sizeof(buf), "%" PRIx64, s->header.features & ~QED_FEATURE_MASK); qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "QED", buf); return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { return -EINVAL; } /* Round down file size to the last cluster */ file_size = bdrv_getlength(bs->file); if (file_size < 0) { return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { return -EINVAL; } s->table_nelems = (s->header.cluster_size * s->header.table_size) / sizeof(uint64_t); s->l2_shift = ffs(s->header.cluster_size) - 1; s->l2_mask = s->table_nelems - 1; s->l1_shift = s->l2_shift + ffs(s->table_nelems) - 1; if ((s->header.features & QED_F_BACKING_FILE)) { if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { return -EINVAL; } ret = qed_read_string(bs->file, s->header.backing_filename_offset, s->header.backing_filename_size, bs->backing_file, sizeof(bs->backing_file)); if (ret < 0) { return ret; } if (s->header.features & QED_F_BACKING_FORMAT_NO_PROBE) { pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw"); } } /* Reset unknown autoclear feature bits. This is a backwards * compatibility mechanism that allows images to be opened by older * programs, which "knock out" unknown feature bits. When an image is * opened by a newer program again it can detect that the autoclear * feature is no longer valid. */ if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && !bdrv_is_read_only(bs->file) && !(flags & BDRV_O_INCOMING)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); if (ret) { return ret; } /* From here on only known autoclear feature bits are valid */ bdrv_flush(bs->file); } s->l1_table = qed_alloc_table(s); qed_init_l2_cache(&s->l2_cache); ret = qed_read_l1_table_sync(s); if (ret) { goto out; } /* If image was not closed cleanly, check consistency */ if (!(flags & BDRV_O_CHECK) && (s->header.features & QED_F_NEED_CHECK)) { /* Read-only images cannot be fixed. There is no risk of corruption * since write operations are not possible. Therefore, allow * potentially inconsistent images to be opened read-only. This can * aid data recovery from an otherwise inconsistent image. */ if (!bdrv_is_read_only(bs->file) && !(flags & BDRV_O_INCOMING)) { BdrvCheckResult result = {0}; ret = qed_check(s, &result, true); if (ret) { goto out; } } } s->need_check_timer = qemu_new_timer_ns(vm_clock, qed_need_check_timer_cb, s); out: if (ret) { qed_free_l2_cache(&s->l2_cache); qemu_vfree(s->l1_table); } return ret; } /* We have nothing to do for QED reopen, stubs just return * success */ static int bdrv_qed_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { return 0; } static void bdrv_qed_close(BlockDriverState *bs) { BDRVQEDState *s = bs->opaque; qed_cancel_need_check_timer(s); qemu_free_timer(s->need_check_timer); /* Ensure writes reach stable storage */ bdrv_flush(bs->file); /* Clean shutdown, no check required on next open */ if (s->header.features & QED_F_NEED_CHECK) { s->header.features &= ~QED_F_NEED_CHECK; qed_write_header_sync(s); } qed_free_l2_cache(&s->l2_cache); qemu_vfree(s->l1_table); } static int qed_create(const char *filename, uint32_t cluster_size, uint64_t image_size, uint32_t table_size, const char *backing_file, const char *backing_fmt) { QEDHeader header = { .magic = QED_MAGIC, .cluster_size = cluster_size, .table_size = table_size, .header_size = 1, .features = 0, .compat_features = 0, .l1_table_offset = cluster_size, .image_size = image_size, }; QEDHeader le_header; uint8_t *l1_table = NULL; size_t l1_size = header.cluster_size * header.table_size; int ret = 0; BlockDriverState *bs = NULL; ret = bdrv_create_file(filename, NULL); if (ret < 0) { return ret; } ret = bdrv_file_open(&bs, filename, NULL, BDRV_O_RDWR | BDRV_O_CACHE_WB); if (ret < 0) { return ret; } /* File must start empty and grow, check truncate is supported */ ret = bdrv_truncate(bs, 0); if (ret < 0) { goto out; } if (backing_file) { header.features |= QED_F_BACKING_FILE; header.backing_filename_offset = sizeof(le_header); header.backing_filename_size = strlen(backing_file); if (qed_fmt_is_raw(backing_fmt)) { header.features |= QED_F_BACKING_FORMAT_NO_PROBE; } } qed_header_cpu_to_le(&header, &le_header); ret = bdrv_pwrite(bs, 0, &le_header, sizeof(le_header)); if (ret < 0) { goto out; } ret = bdrv_pwrite(bs, sizeof(le_header), backing_file, header.backing_filename_size); if (ret < 0) { goto out; } l1_table = g_malloc0(l1_size); ret = bdrv_pwrite(bs, header.l1_table_offset, l1_table, l1_size); if (ret < 0) { goto out; } ret = 0; /* success */ out: g_free(l1_table); bdrv_delete(bs); return ret; } static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options) { uint64_t image_size = 0; uint32_t cluster_size = QED_DEFAULT_CLUSTER_SIZE; uint32_t table_size = QED_DEFAULT_TABLE_SIZE; const char *backing_file = NULL; const char *backing_fmt = NULL; while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { image_size = options->value.n; } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { backing_file = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) { backing_fmt = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) { if (options->value.n) { cluster_size = options->value.n; } } else if (!strcmp(options->name, BLOCK_OPT_TABLE_SIZE)) { if (options->value.n) { table_size = options->value.n; } } options++; } if (!qed_is_cluster_size_valid(cluster_size)) { fprintf(stderr, "QED cluster size must be within range [%u, %u] and power of 2\n", QED_MIN_CLUSTER_SIZE, QED_MAX_CLUSTER_SIZE); return -EINVAL; } if (!qed_is_table_size_valid(table_size)) { fprintf(stderr, "QED table size must be within range [%u, %u] and power of 2\n", QED_MIN_TABLE_SIZE, QED_MAX_TABLE_SIZE); return -EINVAL; } if (!qed_is_image_size_valid(image_size, cluster_size, table_size)) { fprintf(stderr, "QED image size must be a non-zero multiple of " "cluster size and less than %" PRIu64 " bytes\n", qed_max_image_size(cluster_size, table_size)); return -EINVAL; } return qed_create(filename, cluster_size, image_size, table_size, backing_file, backing_fmt); } typedef struct { Coroutine *co; int is_allocated; int *pnum; } QEDIsAllocatedCB; static void qed_is_allocated_cb(void *opaque, int ret, uint64_t offset, size_t len) { QEDIsAllocatedCB *cb = opaque; *cb->pnum = len / BDRV_SECTOR_SIZE; cb->is_allocated = (ret == QED_CLUSTER_FOUND || ret == QED_CLUSTER_ZERO); if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } } static int coroutine_fn bdrv_qed_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVQEDState *s = bs->opaque; uint64_t pos = (uint64_t)sector_num * BDRV_SECTOR_SIZE; size_t len = (size_t)nb_sectors * BDRV_SECTOR_SIZE; QEDIsAllocatedCB cb = { .is_allocated = -1, .pnum = pnum, }; QEDRequest request = { .l2_table = NULL }; qed_find_cluster(s, &request, pos, len, qed_is_allocated_cb, &cb); /* Now sleep if the callback wasn't invoked immediately */ while (cb.is_allocated == -1) { cb.co = qemu_coroutine_self(); qemu_coroutine_yield(); } qed_unref_l2_cache_entry(request.l2_table); return cb.is_allocated; } static int bdrv_qed_make_empty(BlockDriverState *bs) { return -ENOTSUP; } static BDRVQEDState *acb_to_s(QEDAIOCB *acb) { return acb->common.bs->opaque; } /** * Read from the backing file or zero-fill if no backing file * * @s: QED state * @pos: Byte position in device * @qiov: Destination I/O vector * @cb: Completion function * @opaque: User data for completion function * * This function reads qiov->size bytes starting at pos from the backing file. * If there is no backing file then zeroes are read. */ static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov, BlockDriverCompletionFunc *cb, void *opaque) { uint64_t backing_length = 0; size_t size; /* If there is a backing file, get its length. Treat the absence of a * backing file like a zero length backing file. */ if (s->bs->backing_hd) { int64_t l = bdrv_getlength(s->bs->backing_hd); if (l < 0) { cb(opaque, l); return; } backing_length = l; } /* Zero all sectors if reading beyond the end of the backing file */ if (pos >= backing_length || pos + qiov->size > backing_length) { qemu_iovec_memset(qiov, 0, 0, qiov->size); } /* Complete now if there are no backing file sectors to read */ if (pos >= backing_length) { cb(opaque, 0); return; } /* If the read straddles the end of the backing file, shorten it */ size = MIN((uint64_t)backing_length - pos, qiov->size); BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE, qiov, size / BDRV_SECTOR_SIZE, cb, opaque); } typedef struct { GenericCB gencb; BDRVQEDState *s; QEMUIOVector qiov; struct iovec iov; uint64_t offset; } CopyFromBackingFileCB; static void qed_copy_from_backing_file_cb(void *opaque, int ret) { CopyFromBackingFileCB *copy_cb = opaque; qemu_vfree(copy_cb->iov.iov_base); gencb_complete(©_cb->gencb, ret); } static void qed_copy_from_backing_file_write(void *opaque, int ret) { CopyFromBackingFileCB *copy_cb = opaque; BDRVQEDState *s = copy_cb->s; if (ret) { qed_copy_from_backing_file_cb(copy_cb, ret); return; } BLKDBG_EVENT(s->bs->file, BLKDBG_COW_WRITE); bdrv_aio_writev(s->bs->file, copy_cb->offset / BDRV_SECTOR_SIZE, ©_cb->qiov, copy_cb->qiov.size / BDRV_SECTOR_SIZE, qed_copy_from_backing_file_cb, copy_cb); } /** * Copy data from backing file into the image * * @s: QED state * @pos: Byte position in device * @len: Number of bytes * @offset: Byte offset in image file * @cb: Completion function * @opaque: User data for completion function */ static void qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos, uint64_t len, uint64_t offset, BlockDriverCompletionFunc *cb, void *opaque) { CopyFromBackingFileCB *copy_cb; /* Skip copy entirely if there is no work to do */ if (len == 0) { cb(opaque, 0); return; } copy_cb = gencb_alloc(sizeof(*copy_cb), cb, opaque); copy_cb->s = s; copy_cb->offset = offset; copy_cb->iov.iov_base = qemu_blockalign(s->bs, len); copy_cb->iov.iov_len = len; qemu_iovec_init_external(©_cb->qiov, ©_cb->iov, 1); qed_read_backing_file(s, pos, ©_cb->qiov, qed_copy_from_backing_file_write, copy_cb); } /** * Link one or more contiguous clusters into a table * * @s: QED state * @table: L2 table * @index: First cluster index * @n: Number of contiguous clusters * @cluster: First cluster offset * * The cluster offset may be an allocated byte offset in the image file, the * zero cluster marker, or the unallocated cluster marker. */ static void qed_update_l2_table(BDRVQEDState *s, QEDTable *table, int index, unsigned int n, uint64_t cluster) { int i; for (i = index; i < index + n; i++) { table->offsets[i] = cluster; if (!qed_offset_is_unalloc_cluster(cluster) && !qed_offset_is_zero_cluster(cluster)) { cluster += s->header.cluster_size; } } } static void qed_aio_complete_bh(void *opaque) { QEDAIOCB *acb = opaque; BlockDriverCompletionFunc *cb = acb->common.cb; void *user_opaque = acb->common.opaque; int ret = acb->bh_ret; bool *finished = acb->finished; qemu_bh_delete(acb->bh); qemu_aio_release(acb); /* Invoke callback */ cb(user_opaque, ret); /* Signal cancel completion */ if (finished) { *finished = true; } } static void qed_aio_complete(QEDAIOCB *acb, int ret) { BDRVQEDState *s = acb_to_s(acb); trace_qed_aio_complete(s, acb, ret); /* Free resources */ qemu_iovec_destroy(&acb->cur_qiov); qed_unref_l2_cache_entry(acb->request.l2_table); /* Free the buffer we may have allocated for zero writes */ if (acb->flags & QED_AIOCB_ZERO) { qemu_vfree(acb->qiov->iov[0].iov_base); acb->qiov->iov[0].iov_base = NULL; } /* Arrange for a bh to invoke the completion function */ acb->bh_ret = ret; acb->bh = qemu_bh_new(qed_aio_complete_bh, acb); qemu_bh_schedule(acb->bh); /* Start next allocating write request waiting behind this one. Note that * requests enqueue themselves when they first hit an unallocated cluster * but they wait until the entire request is finished before waking up the * next request in the queue. This ensures that we don't cycle through * requests multiple times but rather finish one at a time completely. */ if (acb == QSIMPLEQ_FIRST(&s->allocating_write_reqs)) { QSIMPLEQ_REMOVE_HEAD(&s->allocating_write_reqs, next); acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs); if (acb) { qed_aio_next_io(acb, 0); } else if (s->header.features & QED_F_NEED_CHECK) { qed_start_need_check_timer(s); } } } /** * Commit the current L2 table to the cache */ static void qed_commit_l2_update(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); CachedL2Table *l2_table = acb->request.l2_table; uint64_t l2_offset = l2_table->offset; qed_commit_l2_cache_entry(&s->l2_cache, l2_table); /* This is guaranteed to succeed because we just committed the entry to the * cache. */ acb->request.l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_offset); assert(acb->request.l2_table != NULL); qed_aio_next_io(opaque, ret); } /** * Update L1 table with new L2 table offset and write it out */ static void qed_aio_write_l1_update(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); int index; if (ret) { qed_aio_complete(acb, ret); return; } index = qed_l1_index(s, acb->cur_pos); s->l1_table->offsets[index] = acb->request.l2_table->offset; qed_write_l1_table(s, index, 1, qed_commit_l2_update, acb); } /** * Update L2 table with new cluster offsets and write them out */ static void qed_aio_write_l2_update(QEDAIOCB *acb, int ret, uint64_t offset) { BDRVQEDState *s = acb_to_s(acb); bool need_alloc = acb->find_cluster_ret == QED_CLUSTER_L1; int index; if (ret) { goto err; } if (need_alloc) { qed_unref_l2_cache_entry(acb->request.l2_table); acb->request.l2_table = qed_new_l2_table(s); } index = qed_l2_index(s, acb->cur_pos); qed_update_l2_table(s, acb->request.l2_table->table, index, acb->cur_nclusters, offset); if (need_alloc) { /* Write out the whole new L2 table */ qed_write_l2_table(s, &acb->request, 0, s->table_nelems, true, qed_aio_write_l1_update, acb); } else { /* Write out only the updated part of the L2 table */ qed_write_l2_table(s, &acb->request, index, acb->cur_nclusters, false, qed_aio_next_io, acb); } return; err: qed_aio_complete(acb, ret); } static void qed_aio_write_l2_update_cb(void *opaque, int ret) { QEDAIOCB *acb = opaque; qed_aio_write_l2_update(acb, ret, acb->cur_cluster); } /** * Flush new data clusters before updating the L2 table * * This flush is necessary when a backing file is in use. A crash during an * allocating write could result in empty clusters in the image. If the write * only touched a subregion of the cluster, then backing image sectors have * been lost in the untouched region. The solution is to flush after writing a * new data cluster and before updating the L2 table. */ static void qed_aio_write_flush_before_l2_update(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); if (!bdrv_aio_flush(s->bs->file, qed_aio_write_l2_update_cb, opaque)) { qed_aio_complete(acb, -EIO); } } /** * Write data to the image file */ static void qed_aio_write_main(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); uint64_t offset = acb->cur_cluster + qed_offset_into_cluster(s, acb->cur_pos); BlockDriverCompletionFunc *next_fn; trace_qed_aio_write_main(s, acb, ret, offset, acb->cur_qiov.size); if (ret) { qed_aio_complete(acb, ret); return; } if (acb->find_cluster_ret == QED_CLUSTER_FOUND) { next_fn = qed_aio_next_io; } else { if (s->bs->backing_hd) { next_fn = qed_aio_write_flush_before_l2_update; } else { next_fn = qed_aio_write_l2_update_cb; } } BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO); bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, next_fn, acb); } /** * Populate back untouched region of new data cluster */ static void qed_aio_write_postfill(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); uint64_t start = acb->cur_pos + acb->cur_qiov.size; uint64_t len = qed_start_of_cluster(s, start + s->header.cluster_size - 1) - start; uint64_t offset = acb->cur_cluster + qed_offset_into_cluster(s, acb->cur_pos) + acb->cur_qiov.size; if (ret) { qed_aio_complete(acb, ret); return; } trace_qed_aio_write_postfill(s, acb, start, len, offset); qed_copy_from_backing_file(s, start, len, offset, qed_aio_write_main, acb); } /** * Populate front untouched region of new data cluster */ static void qed_aio_write_prefill(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); uint64_t start = qed_start_of_cluster(s, acb->cur_pos); uint64_t len = qed_offset_into_cluster(s, acb->cur_pos); trace_qed_aio_write_prefill(s, acb, start, len, acb->cur_cluster); qed_copy_from_backing_file(s, start, len, acb->cur_cluster, qed_aio_write_postfill, acb); } /** * Check if the QED_F_NEED_CHECK bit should be set during allocating write */ static bool qed_should_set_need_check(BDRVQEDState *s) { /* The flush before L2 update path ensures consistency */ if (s->bs->backing_hd) { return false; } return !(s->header.features & QED_F_NEED_CHECK); } static void qed_aio_write_zero_cluster(void *opaque, int ret) { QEDAIOCB *acb = opaque; if (ret) { qed_aio_complete(acb, ret); return; } qed_aio_write_l2_update(acb, 0, 1); } /** * Write new data cluster * * @acb: Write request * @len: Length in bytes * * This path is taken when writing to previously unallocated clusters. */ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len) { BDRVQEDState *s = acb_to_s(acb); BlockDriverCompletionFunc *cb; /* Cancel timer when the first allocating request comes in */ if (QSIMPLEQ_EMPTY(&s->allocating_write_reqs)) { qed_cancel_need_check_timer(s); } /* Freeze this request if another allocating write is in progress */ if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) { QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next); } if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs) || s->allocating_write_reqs_plugged) { return; /* wait for existing request to finish */ } acb->cur_nclusters = qed_bytes_to_clusters(s, qed_offset_into_cluster(s, acb->cur_pos) + len); qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len); if (acb->flags & QED_AIOCB_ZERO) { /* Skip ahead if the clusters are already zero */ if (acb->find_cluster_ret == QED_CLUSTER_ZERO) { qed_aio_next_io(acb, 0); return; } cb = qed_aio_write_zero_cluster; } else { cb = qed_aio_write_prefill; acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters); } if (qed_should_set_need_check(s)) { s->header.features |= QED_F_NEED_CHECK; qed_write_header(s, cb, acb); } else { cb(acb, 0); } } /** * Write data cluster in place * * @acb: Write request * @offset: Cluster offset in bytes * @len: Length in bytes * * This path is taken when writing to already allocated clusters. */ static void qed_aio_write_inplace(QEDAIOCB *acb, uint64_t offset, size_t len) { /* Allocate buffer for zero writes */ if (acb->flags & QED_AIOCB_ZERO) { struct iovec *iov = acb->qiov->iov; if (!iov->iov_base) { iov->iov_base = qemu_blockalign(acb->common.bs, iov->iov_len); memset(iov->iov_base, 0, iov->iov_len); } } /* Calculate the I/O vector */ acb->cur_cluster = offset; qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len); /* Do the actual write */ qed_aio_write_main(acb, 0); } /** * Write data cluster * * @opaque: Write request * @ret: QED_CLUSTER_FOUND, QED_CLUSTER_L2, QED_CLUSTER_L1, * or -errno * @offset: Cluster offset in bytes * @len: Length in bytes * * Callback from qed_find_cluster(). */ static void qed_aio_write_data(void *opaque, int ret, uint64_t offset, size_t len) { QEDAIOCB *acb = opaque; trace_qed_aio_write_data(acb_to_s(acb), acb, ret, offset, len); acb->find_cluster_ret = ret; switch (ret) { case QED_CLUSTER_FOUND: qed_aio_write_inplace(acb, offset, len); break; case QED_CLUSTER_L2: case QED_CLUSTER_L1: case QED_CLUSTER_ZERO: qed_aio_write_alloc(acb, len); break; default: qed_aio_complete(acb, ret); break; } } /** * Read data cluster * * @opaque: Read request * @ret: QED_CLUSTER_FOUND, QED_CLUSTER_L2, QED_CLUSTER_L1, * or -errno * @offset: Cluster offset in bytes * @len: Length in bytes * * Callback from qed_find_cluster(). */ static void qed_aio_read_data(void *opaque, int ret, uint64_t offset, size_t len) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); BlockDriverState *bs = acb->common.bs; /* Adjust offset into cluster */ offset += qed_offset_into_cluster(s, acb->cur_pos); trace_qed_aio_read_data(s, acb, ret, offset, len); if (ret < 0) { goto err; } qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len); /* Handle zero cluster and backing file reads */ if (ret == QED_CLUSTER_ZERO) { qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size); qed_aio_next_io(acb, 0); return; } else if (ret != QED_CLUSTER_FOUND) { qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov, qed_aio_next_io, acb); return; } BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); bdrv_aio_readv(bs->file, offset / BDRV_SECTOR_SIZE, &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, qed_aio_next_io, acb); return; err: qed_aio_complete(acb, ret); } /** * Begin next I/O or complete the request */ static void qed_aio_next_io(void *opaque, int ret) { QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); QEDFindClusterFunc *io_fn = (acb->flags & QED_AIOCB_WRITE) ? qed_aio_write_data : qed_aio_read_data; trace_qed_aio_next_io(s, acb, ret, acb->cur_pos + acb->cur_qiov.size); /* Handle I/O error */ if (ret) { qed_aio_complete(acb, ret); return; } acb->qiov_offset += acb->cur_qiov.size; acb->cur_pos += acb->cur_qiov.size; qemu_iovec_reset(&acb->cur_qiov); /* Complete request */ if (acb->cur_pos >= acb->end_pos) { qed_aio_complete(acb, 0); return; } /* Find next cluster and start I/O */ qed_find_cluster(s, &acb->request, acb->cur_pos, acb->end_pos - acb->cur_pos, io_fn, acb); } static BlockDriverAIOCB *qed_aio_setup(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int flags) { QEDAIOCB *acb = qemu_aio_get(&qed_aiocb_info, bs, cb, opaque); trace_qed_aio_setup(bs->opaque, acb, sector_num, nb_sectors, opaque, flags); acb->flags = flags; acb->finished = NULL; acb->qiov = qiov; acb->qiov_offset = 0; acb->cur_pos = (uint64_t)sector_num * BDRV_SECTOR_SIZE; acb->end_pos = acb->cur_pos + nb_sectors * BDRV_SECTOR_SIZE; acb->request.l2_table = NULL; qemu_iovec_init(&acb->cur_qiov, qiov->niov); /* Start request */ qed_aio_next_io(acb, 0); return &acb->common; } static BlockDriverAIOCB *bdrv_qed_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { return qed_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); } static BlockDriverAIOCB *bdrv_qed_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { return qed_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, QED_AIOCB_WRITE); } typedef struct { Coroutine *co; int ret; bool done; } QEDWriteZeroesCB; static void coroutine_fn qed_co_write_zeroes_cb(void *opaque, int ret) { QEDWriteZeroesCB *cb = opaque; cb->done = true; cb->ret = ret; if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } } static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BlockDriverAIOCB *blockacb; BDRVQEDState *s = bs->opaque; QEDWriteZeroesCB cb = { .done = false }; QEMUIOVector qiov; struct iovec iov; /* Refuse if there are untouched backing file sectors */ if (bs->backing_hd) { if (qed_offset_into_cluster(s, sector_num * BDRV_SECTOR_SIZE) != 0) { return -ENOTSUP; } if (qed_offset_into_cluster(s, nb_sectors * BDRV_SECTOR_SIZE) != 0) { return -ENOTSUP; } } /* Zero writes start without an I/O buffer. If a buffer becomes necessary * then it will be allocated during request processing. */ iov.iov_base = NULL, iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE, qemu_iovec_init_external(&qiov, &iov, 1); blockacb = qed_aio_setup(bs, sector_num, &qiov, nb_sectors, qed_co_write_zeroes_cb, &cb, QED_AIOCB_WRITE | QED_AIOCB_ZERO); if (!blockacb) { return -EIO; } if (!cb.done) { cb.co = qemu_coroutine_self(); qemu_coroutine_yield(); } assert(cb.done); return cb.ret; } static int bdrv_qed_truncate(BlockDriverState *bs, int64_t offset) { BDRVQEDState *s = bs->opaque; uint64_t old_image_size; int ret; if (!qed_is_image_size_valid(offset, s->header.cluster_size, s->header.table_size)) { return -EINVAL; } /* Shrinking is currently not supported */ if ((uint64_t)offset < s->header.image_size) { return -ENOTSUP; } old_image_size = s->header.image_size; s->header.image_size = offset; ret = qed_write_header_sync(s); if (ret < 0) { s->header.image_size = old_image_size; } return ret; } static int64_t bdrv_qed_getlength(BlockDriverState *bs) { BDRVQEDState *s = bs->opaque; return s->header.image_size; } static int bdrv_qed_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQEDState *s = bs->opaque; memset(bdi, 0, sizeof(*bdi)); bdi->cluster_size = s->header.cluster_size; bdi->is_dirty = s->header.features & QED_F_NEED_CHECK; return 0; } static int bdrv_qed_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { BDRVQEDState *s = bs->opaque; QEDHeader new_header, le_header; void *buffer; size_t buffer_len, backing_file_len; int ret; /* Refuse to set backing filename if unknown compat feature bits are * active. If the image uses an unknown compat feature then we may not * know the layout of data following the header structure and cannot safely * add a new string. */ if (backing_file && (s->header.compat_features & ~QED_COMPAT_FEATURE_MASK)) { return -ENOTSUP; } memcpy(&new_header, &s->header, sizeof(new_header)); new_header.features &= ~(QED_F_BACKING_FILE | QED_F_BACKING_FORMAT_NO_PROBE); /* Adjust feature flags */ if (backing_file) { new_header.features |= QED_F_BACKING_FILE; if (qed_fmt_is_raw(backing_fmt)) { new_header.features |= QED_F_BACKING_FORMAT_NO_PROBE; } } /* Calculate new header size */ backing_file_len = 0; if (backing_file) { backing_file_len = strlen(backing_file); } buffer_len = sizeof(new_header); new_header.backing_filename_offset = buffer_len; new_header.backing_filename_size = backing_file_len; buffer_len += backing_file_len; /* Make sure we can rewrite header without failing */ if (buffer_len > new_header.header_size * new_header.cluster_size) { return -ENOSPC; } /* Prepare new header */ buffer = g_malloc(buffer_len); qed_header_cpu_to_le(&new_header, &le_header); memcpy(buffer, &le_header, sizeof(le_header)); buffer_len = sizeof(le_header); if (backing_file) { memcpy(buffer + buffer_len, backing_file, backing_file_len); buffer_len += backing_file_len; } /* Write new header */ ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len); g_free(buffer); if (ret == 0) { memcpy(&s->header, &new_header, sizeof(new_header)); } return ret; } static void bdrv_qed_invalidate_cache(BlockDriverState *bs) { BDRVQEDState *s = bs->opaque; bdrv_qed_close(bs); memset(s, 0, sizeof(BDRVQEDState)); bdrv_qed_open(bs, NULL, bs->open_flags); } static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) { BDRVQEDState *s = bs->opaque; return qed_check(s, result, !!fix); } static QEMUOptionParameter qed_create_options[] = { { .name = BLOCK_OPT_SIZE, .type = OPT_SIZE, .help = "Virtual disk size (in bytes)" }, { .name = BLOCK_OPT_BACKING_FILE, .type = OPT_STRING, .help = "File name of a base image" }, { .name = BLOCK_OPT_BACKING_FMT, .type = OPT_STRING, .help = "Image format of the base image" }, { .name = BLOCK_OPT_CLUSTER_SIZE, .type = OPT_SIZE, .help = "Cluster size (in bytes)", .value = { .n = QED_DEFAULT_CLUSTER_SIZE }, }, { .name = BLOCK_OPT_TABLE_SIZE, .type = OPT_SIZE, .help = "L1/L2 table size (in clusters)" }, { /* end of list */ } }; static BlockDriver bdrv_qed = { .format_name = "qed", .instance_size = sizeof(BDRVQEDState), .create_options = qed_create_options, .bdrv_probe = bdrv_qed_probe, .bdrv_rebind = bdrv_qed_rebind, .bdrv_open = bdrv_qed_open, .bdrv_close = bdrv_qed_close, .bdrv_reopen_prepare = bdrv_qed_reopen_prepare, .bdrv_create = bdrv_qed_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_is_allocated = bdrv_qed_co_is_allocated, .bdrv_make_empty = bdrv_qed_make_empty, .bdrv_aio_readv = bdrv_qed_aio_readv, .bdrv_aio_writev = bdrv_qed_aio_writev, .bdrv_co_write_zeroes = bdrv_qed_co_write_zeroes, .bdrv_truncate = bdrv_qed_truncate, .bdrv_getlength = bdrv_qed_getlength, .bdrv_get_info = bdrv_qed_get_info, .bdrv_change_backing_file = bdrv_qed_change_backing_file, .bdrv_invalidate_cache = bdrv_qed_invalidate_cache, .bdrv_check = bdrv_qed_check, }; static void bdrv_qed_init(void) { bdrv_register(&bdrv_qed); } block_init(bdrv_qed_init); glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed-check.c0000644000076200007630000000013112617742532022222 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 30 ctime=1447019941.732332761 glusterfs-3.7.6/contrib/qemu/block/qed-check.c0000644000076200007630000001503612617742532022445 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format Consistency Check * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qed.h" typedef struct { BDRVQEDState *s; BdrvCheckResult *result; bool fix; /* whether to fix invalid offsets */ uint64_t nclusters; uint32_t *used_clusters; /* referenced cluster bitmap */ QEDRequest request; } QEDCheck; static bool qed_test_bit(uint32_t *bitmap, uint64_t n) { return !!(bitmap[n / 32] & (1 << (n % 32))); } static void qed_set_bit(uint32_t *bitmap, uint64_t n) { bitmap[n / 32] |= 1 << (n % 32); } /** * Set bitmap bits for clusters * * @check: Check structure * @offset: Starting offset in bytes * @n: Number of clusters */ static bool qed_set_used_clusters(QEDCheck *check, uint64_t offset, unsigned int n) { uint64_t cluster = qed_bytes_to_clusters(check->s, offset); unsigned int corruptions = 0; while (n-- != 0) { /* Clusters should only be referenced once */ if (qed_test_bit(check->used_clusters, cluster)) { corruptions++; } qed_set_bit(check->used_clusters, cluster); cluster++; } check->result->corruptions += corruptions; return corruptions == 0; } /** * Check an L2 table * * @ret: Number of invalid cluster offsets */ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) { BDRVQEDState *s = check->s; unsigned int i, num_invalid = 0; uint64_t last_offset = 0; for (i = 0; i < s->table_nelems; i++) { uint64_t offset = table->offsets[i]; if (qed_offset_is_unalloc_cluster(offset) || qed_offset_is_zero_cluster(offset)) { continue; } check->result->bfi.allocated_clusters++; if (last_offset && (last_offset + s->header.cluster_size != offset)) { check->result->bfi.fragmented_clusters++; } last_offset = offset; /* Detect invalid cluster offset */ if (!qed_check_cluster_offset(s, offset)) { if (check->fix) { table->offsets[i] = 0; check->result->corruptions_fixed++; } else { check->result->corruptions++; } num_invalid++; continue; } qed_set_used_clusters(check, offset, 1); } return num_invalid; } /** * Descend tables and check each cluster is referenced once only */ static int qed_check_l1_table(QEDCheck *check, QEDTable *table) { BDRVQEDState *s = check->s; unsigned int i, num_invalid_l1 = 0; int ret, last_error = 0; /* Mark L1 table clusters used */ qed_set_used_clusters(check, s->header.l1_table_offset, s->header.table_size); for (i = 0; i < s->table_nelems; i++) { unsigned int num_invalid_l2; uint64_t offset = table->offsets[i]; if (qed_offset_is_unalloc_cluster(offset)) { continue; } /* Detect invalid L2 offset */ if (!qed_check_table_offset(s, offset)) { /* Clear invalid offset */ if (check->fix) { table->offsets[i] = 0; check->result->corruptions_fixed++; } else { check->result->corruptions++; } num_invalid_l1++; continue; } if (!qed_set_used_clusters(check, offset, s->header.table_size)) { continue; /* skip an invalid table */ } ret = qed_read_l2_table_sync(s, &check->request, offset); if (ret) { check->result->check_errors++; last_error = ret; continue; } num_invalid_l2 = qed_check_l2_table(check, check->request.l2_table->table); /* Write out fixed L2 table */ if (num_invalid_l2 > 0 && check->fix) { ret = qed_write_l2_table_sync(s, &check->request, 0, s->table_nelems, false); if (ret) { check->result->check_errors++; last_error = ret; continue; } } } /* Drop reference to final table */ qed_unref_l2_cache_entry(check->request.l2_table); check->request.l2_table = NULL; /* Write out fixed L1 table */ if (num_invalid_l1 > 0 && check->fix) { ret = qed_write_l1_table_sync(s, 0, s->table_nelems); if (ret) { check->result->check_errors++; last_error = ret; } } return last_error; } /** * Check for unreferenced (leaked) clusters */ static void qed_check_for_leaks(QEDCheck *check) { BDRVQEDState *s = check->s; uint64_t i; for (i = s->header.header_size; i < check->nclusters; i++) { if (!qed_test_bit(check->used_clusters, i)) { check->result->leaks++; } } } /** * Mark an image clean once it passes check or has been repaired */ static void qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result) { /* Skip if there were unfixable corruptions or I/O errors */ if (result->corruptions > 0 || result->check_errors > 0) { return; } /* Skip if image is already marked clean */ if (!(s->header.features & QED_F_NEED_CHECK)) { return; } /* Ensure fixes reach storage before clearing check bit */ bdrv_flush(s->bs); s->header.features &= ~QED_F_NEED_CHECK; qed_write_header_sync(s); } int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix) { QEDCheck check = { .s = s, .result = result, .nclusters = qed_bytes_to_clusters(s, s->file_size), .request = { .l2_table = NULL }, .fix = fix, }; int ret; check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) * sizeof(check.used_clusters[0])); check.result->bfi.total_clusters = (s->header.image_size + s->header.cluster_size - 1) / s->header.cluster_size; ret = qed_check_l1_table(&check, s->l1_table); if (ret == 0) { /* Only check for leaks if entire image was scanned successfully */ qed_check_for_leaks(&check); if (fix) { qed_check_mark_clean(s, result); } } g_free(check.used_clusters); return ret; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2-snapshot.c0000644000076200007630000000012712617742532023273 xustar000000000000000028 mtime=1447019866.0334716 29 atime=1447019866.37046653 30 ctime=1447019941.725332865 glusterfs-3.7.6/contrib/qemu/block/qcow2-snapshot.c0000644000076200007630000004526712617742532023522 0ustar00jenkinsjenkins00000000000000/* * Block driver for the QCOW version 2 format * * Copyright (c) 2004-2006 Fabrice Bellard * * 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. */ #include "qemu-common.h" #include "block/block_int.h" #include "block/qcow2.h" typedef struct QEMU_PACKED QCowSnapshotHeader { /* header is 8 byte aligned */ uint64_t l1_table_offset; uint32_t l1_size; uint16_t id_str_size; uint16_t name_size; uint32_t date_sec; uint32_t date_nsec; uint64_t vm_clock_nsec; uint32_t vm_state_size; uint32_t extra_data_size; /* for extension */ /* extra data follows */ /* id_str follows */ /* name follows */ } QCowSnapshotHeader; typedef struct QEMU_PACKED QCowSnapshotExtraData { uint64_t vm_state_size_large; uint64_t disk_size; } QCowSnapshotExtraData; void qcow2_free_snapshots(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int i; for(i = 0; i < s->nb_snapshots; i++) { g_free(s->snapshots[i].name); g_free(s->snapshots[i].id_str); } g_free(s->snapshots); s->snapshots = NULL; s->nb_snapshots = 0; } int qcow2_read_snapshots(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowSnapshotHeader h; QCowSnapshotExtraData extra; QCowSnapshot *sn; int i, id_str_size, name_size; int64_t offset; uint32_t extra_data_size; int ret; if (!s->nb_snapshots) { s->snapshots = NULL; s->snapshots_size = 0; return 0; } offset = s->snapshots_offset; s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot)); for(i = 0; i < s->nb_snapshots; i++) { /* Read statically sized part of the snapshot header */ offset = align_offset(offset, 8); ret = bdrv_pread(bs->file, offset, &h, sizeof(h)); if (ret < 0) { goto fail; } offset += sizeof(h); sn = s->snapshots + i; sn->l1_table_offset = be64_to_cpu(h.l1_table_offset); sn->l1_size = be32_to_cpu(h.l1_size); sn->vm_state_size = be32_to_cpu(h.vm_state_size); sn->date_sec = be32_to_cpu(h.date_sec); sn->date_nsec = be32_to_cpu(h.date_nsec); sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec); extra_data_size = be32_to_cpu(h.extra_data_size); id_str_size = be16_to_cpu(h.id_str_size); name_size = be16_to_cpu(h.name_size); /* Read extra data */ ret = bdrv_pread(bs->file, offset, &extra, MIN(sizeof(extra), extra_data_size)); if (ret < 0) { goto fail; } offset += extra_data_size; if (extra_data_size >= 8) { sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large); } if (extra_data_size >= 16) { sn->disk_size = be64_to_cpu(extra.disk_size); } else { sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; } /* Read snapshot ID */ sn->id_str = g_malloc(id_str_size + 1); ret = bdrv_pread(bs->file, offset, sn->id_str, id_str_size); if (ret < 0) { goto fail; } offset += id_str_size; sn->id_str[id_str_size] = '\0'; /* Read snapshot name */ sn->name = g_malloc(name_size + 1); ret = bdrv_pread(bs->file, offset, sn->name, name_size); if (ret < 0) { goto fail; } offset += name_size; sn->name[name_size] = '\0'; } s->snapshots_size = offset - s->snapshots_offset; return 0; fail: qcow2_free_snapshots(bs); return ret; } /* add at the end of the file a new list of snapshots */ static int qcow2_write_snapshots(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; QCowSnapshotHeader h; QCowSnapshotExtraData extra; int i, name_size, id_str_size, snapshots_size; struct { uint32_t nb_snapshots; uint64_t snapshots_offset; } QEMU_PACKED header_data; int64_t offset, snapshots_offset; int ret; /* compute the size of the snapshots */ offset = 0; for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; offset = align_offset(offset, 8); offset += sizeof(h); offset += sizeof(extra); offset += strlen(sn->id_str); offset += strlen(sn->name); } snapshots_size = offset; /* Allocate space for the new snapshot list */ snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { return offset; } ret = bdrv_flush(bs); if (ret < 0) { return ret; } /* Write all snapshots to the new list */ for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; memset(&h, 0, sizeof(h)); h.l1_table_offset = cpu_to_be64(sn->l1_table_offset); h.l1_size = cpu_to_be32(sn->l1_size); /* If it doesn't fit in 32 bit, older implementations should treat it * as a disk-only snapshot rather than truncate the VM state */ if (sn->vm_state_size <= 0xffffffff) { h.vm_state_size = cpu_to_be32(sn->vm_state_size); } h.date_sec = cpu_to_be32(sn->date_sec); h.date_nsec = cpu_to_be32(sn->date_nsec); h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec); h.extra_data_size = cpu_to_be32(sizeof(extra)); memset(&extra, 0, sizeof(extra)); extra.vm_state_size_large = cpu_to_be64(sn->vm_state_size); extra.disk_size = cpu_to_be64(sn->disk_size); id_str_size = strlen(sn->id_str); name_size = strlen(sn->name); h.id_str_size = cpu_to_be16(id_str_size); h.name_size = cpu_to_be16(name_size); offset = align_offset(offset, 8); ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h)); if (ret < 0) { goto fail; } offset += sizeof(h); ret = bdrv_pwrite(bs->file, offset, &extra, sizeof(extra)); if (ret < 0) { goto fail; } offset += sizeof(extra); ret = bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size); if (ret < 0) { goto fail; } offset += id_str_size; ret = bdrv_pwrite(bs->file, offset, sn->name, name_size); if (ret < 0) { goto fail; } offset += name_size; } /* * Update the header to point to the new snapshot table. This requires the * new table and its refcounts to be stable on disk. */ ret = bdrv_flush(bs); if (ret < 0) { goto fail; } QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) != offsetof(QCowHeader, nb_snapshots) + sizeof(header_data.nb_snapshots)); header_data.nb_snapshots = cpu_to_be32(s->nb_snapshots); header_data.snapshots_offset = cpu_to_be64(snapshots_offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), &header_data, sizeof(header_data)); if (ret < 0) { goto fail; } /* free the old snapshot table */ qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size, QCOW2_DISCARD_SNAPSHOT); s->snapshots_offset = snapshots_offset; s->snapshots_size = snapshots_size; return 0; fail: return ret; } static void find_new_snapshot_id(BlockDriverState *bs, char *id_str, int id_str_size) { BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; int i, id, id_max = 0; for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; id = strtoul(sn->id_str, NULL, 10); if (id > id_max) id_max = id; } snprintf(id_str, id_str_size, "%d", id_max + 1); } static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str) { BDRVQcowState *s = bs->opaque; int i; for(i = 0; i < s->nb_snapshots; i++) { if (!strcmp(s->snapshots[i].id_str, id_str)) return i; } return -1; } static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name) { BDRVQcowState *s = bs->opaque; int i, ret; ret = find_snapshot_by_id(bs, name); if (ret >= 0) return ret; for(i = 0; i < s->nb_snapshots; i++) { if (!strcmp(s->snapshots[i].name, name)) return i; } return -1; } /* if no id is provided, a new one is constructed */ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { BDRVQcowState *s = bs->opaque; QCowSnapshot *new_snapshot_list = NULL; QCowSnapshot *old_snapshot_list = NULL; QCowSnapshot sn1, *sn = &sn1; int i, ret; uint64_t *l1_table = NULL; int64_t l1_table_offset; memset(sn, 0, sizeof(*sn)); /* Generate an ID if it wasn't passed */ if (sn_info->id_str[0] == '\0') { find_new_snapshot_id(bs, sn_info->id_str, sizeof(sn_info->id_str)); } /* Check that the ID is unique */ if (find_snapshot_by_id(bs, sn_info->id_str) >= 0) { return -EEXIST; } /* Populate sn with passed data */ sn->id_str = g_strdup(sn_info->id_str); sn->name = g_strdup(sn_info->name); sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; sn->vm_state_size = sn_info->vm_state_size; sn->date_sec = sn_info->date_sec; sn->date_nsec = sn_info->date_nsec; sn->vm_clock_nsec = sn_info->vm_clock_nsec; /* Allocate the L1 table of the snapshot and copy the current one there. */ l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t)); if (l1_table_offset < 0) { ret = l1_table_offset; goto fail; } sn->l1_table_offset = l1_table_offset; sn->l1_size = s->l1_size; l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); for(i = 0; i < s->l1_size; i++) { l1_table[i] = cpu_to_be64(s->l1_table[i]); } ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; } g_free(l1_table); l1_table = NULL; /* * Increase the refcounts of all clusters and make sure everything is * stable on disk before updating the snapshot table to contain a pointer * to the new L1 table. */ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1); if (ret < 0) { goto fail; } /* Append the new snapshot to the snapshot list */ new_snapshot_list = g_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot)); if (s->snapshots) { memcpy(new_snapshot_list, s->snapshots, s->nb_snapshots * sizeof(QCowSnapshot)); old_snapshot_list = s->snapshots; } s->snapshots = new_snapshot_list; s->snapshots[s->nb_snapshots++] = *sn; ret = qcow2_write_snapshots(bs); if (ret < 0) { g_free(s->snapshots); s->snapshots = old_snapshot_list; goto fail; } g_free(old_snapshot_list); #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); } #endif return 0; fail: g_free(sn->id_str); g_free(sn->name); g_free(l1_table); return ret; } /* copy the snapshot 'snapshot_name' into the current disk image */ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; int i, snapshot_index; int cur_l1_bytes, sn_l1_bytes; int ret; uint64_t *sn_l1_table = NULL; /* Search the snapshot */ snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); if (snapshot_index < 0) { return -ENOENT; } sn = &s->snapshots[snapshot_index]; if (sn->disk_size != bs->total_sectors * BDRV_SECTOR_SIZE) { error_report("qcow2: Loading snapshots with different disk " "size is not implemented"); ret = -ENOTSUP; goto fail; } /* * Make sure that the current L1 table is big enough to contain the whole * L1 table of the snapshot. If the snapshot L1 table is smaller, the * current one must be padded with zeros. */ ret = qcow2_grow_l1_table(bs, sn->l1_size, true); if (ret < 0) { goto fail; } cur_l1_bytes = s->l1_size * sizeof(uint64_t); sn_l1_bytes = sn->l1_size * sizeof(uint64_t); /* * Copy the snapshot L1 table to the current L1 table. * * Before overwriting the old current L1 table on disk, make sure to * increase all refcounts for the clusters referenced by the new one. * Decrease the refcount referenced by the old one only when the L1 * table is overwritten. */ sn_l1_table = g_malloc0(cur_l1_bytes); ret = bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_bytes); if (ret < 0) { goto fail; } ret = qcow2_update_snapshot_refcount(bs, sn->l1_table_offset, sn->l1_size, 1); if (ret < 0) { goto fail; } ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, cur_l1_bytes); if (ret < 0) { goto fail; } /* * Decrease refcount of clusters of current L1 table. * * At this point, the in-memory s->l1_table points to the old L1 table, * whereas on disk we already have the new one. * * qcow2_update_snapshot_refcount special cases the current L1 table to use * the in-memory data instead of really using the offset to load a new one, * which is why this works. */ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, -1); /* * Now update the in-memory L1 table to be in sync with the on-disk one. We * need to do this even if updating refcounts failed. */ for(i = 0;i < s->l1_size; i++) { s->l1_table[i] = be64_to_cpu(sn_l1_table[i]); } if (ret < 0) { goto fail; } g_free(sn_l1_table); sn_l1_table = NULL; /* * Update QCOW_OFLAG_COPIED in the active L1 table (it may have changed * when we decreased the refcount of the old snapshot. */ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0); if (ret < 0) { goto fail; } #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); } #endif return 0; fail: g_free(sn_l1_table); return ret; } int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) { BDRVQcowState *s = bs->opaque; QCowSnapshot sn; int snapshot_index, ret; /* Search the snapshot */ snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); if (snapshot_index < 0) { return -ENOENT; } sn = s->snapshots[snapshot_index]; /* Remove it from the snapshot list */ memmove(s->snapshots + snapshot_index, s->snapshots + snapshot_index + 1, (s->nb_snapshots - snapshot_index - 1) * sizeof(sn)); s->nb_snapshots--; ret = qcow2_write_snapshots(bs); if (ret < 0) { return ret; } /* * The snapshot is now unused, clean up. If we fail after this point, we * won't recover but just leak clusters. */ g_free(sn.id_str); g_free(sn.name); /* * Now decrease the refcounts of clusters referenced by the snapshot and * free the L1 table. */ ret = qcow2_update_snapshot_refcount(bs, sn.l1_table_offset, sn.l1_size, -1); if (ret < 0) { return ret; } qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * sizeof(uint64_t), QCOW2_DISCARD_SNAPSHOT); /* must update the copied flag on the current cluster offsets */ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0); if (ret < 0) { return ret; } #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); } #endif return 0; } int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) { BDRVQcowState *s = bs->opaque; QEMUSnapshotInfo *sn_tab, *sn_info; QCowSnapshot *sn; int i; if (!s->nb_snapshots) { *psn_tab = NULL; return s->nb_snapshots; } sn_tab = g_malloc0(s->nb_snapshots * sizeof(QEMUSnapshotInfo)); for(i = 0; i < s->nb_snapshots; i++) { sn_info = sn_tab + i; sn = s->snapshots + i; pstrcpy(sn_info->id_str, sizeof(sn_info->id_str), sn->id_str); pstrcpy(sn_info->name, sizeof(sn_info->name), sn->name); sn_info->vm_state_size = sn->vm_state_size; sn_info->date_sec = sn->date_sec; sn_info->date_nsec = sn->date_nsec; sn_info->vm_clock_nsec = sn->vm_clock_nsec; } *psn_tab = sn_tab; return s->nb_snapshots; } int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name) { int i, snapshot_index; BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; uint64_t *new_l1_table; int new_l1_bytes; int ret; assert(bs->read_only); /* Search the snapshot */ snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_name); if (snapshot_index < 0) { return -ENOENT; } sn = &s->snapshots[snapshot_index]; /* Allocate and read in the snapshot's L1 table */ new_l1_bytes = s->l1_size * sizeof(uint64_t); new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512)); ret = bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, new_l1_bytes); if (ret < 0) { g_free(new_l1_table); return ret; } /* Switch the L1 table */ g_free(s->l1_table); s->l1_size = sn->l1_size; s->l1_table_offset = sn->l1_table_offset; s->l1_table = new_l1_table; for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } return 0; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2-cluster.c0000644000076200007630000000013012617742532023107 xustar000000000000000028 mtime=1447019866.0334716 30 atime=1447019866.369466545 30 ctime=1447019941.718332973 glusterfs-3.7.6/contrib/qemu/block/qcow2-cluster.c0000644000076200007630000012777012617742532023344 0ustar00jenkinsjenkins00000000000000/* * Block driver for the QCOW version 2 format * * Copyright (c) 2004-2006 Fabrice Bellard * * 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. */ #include #include "qemu-common.h" #include "block/block_int.h" #include "block/qcow2.h" #include "trace.h" int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size) { BDRVQcowState *s = bs->opaque; int new_l1_size2, ret, i; uint64_t *new_l1_table; int64_t new_l1_table_offset, new_l1_size; uint8_t data[12]; if (min_size <= s->l1_size) return 0; if (exact_size) { new_l1_size = min_size; } else { /* Bump size up to reduce the number of times we have to grow */ new_l1_size = s->l1_size; if (new_l1_size == 0) { new_l1_size = 1; } while (min_size > new_l1_size) { new_l1_size = (new_l1_size * 3 + 1) / 2; } } if (new_l1_size > INT_MAX) { return -EFBIG; } #ifdef DEBUG_ALLOC2 fprintf(stderr, "grow l1_table from %d to %" PRId64 "\n", s->l1_size, new_l1_size); #endif new_l1_size2 = sizeof(uint64_t) * new_l1_size; new_l1_table = g_malloc0(align_offset(new_l1_size2, 512)); memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); /* write new table (align to cluster) */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE); new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2); if (new_l1_table_offset < 0) { g_free(new_l1_table); return new_l1_table_offset; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; } BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i = 0; i < s->l1_size; i++) new_l1_table[i] = cpu_to_be64(new_l1_table[i]); ret = bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2); if (ret < 0) goto fail; for(i = 0; i < s->l1_size; i++) new_l1_table[i] = be64_to_cpu(new_l1_table[i]); /* set new table */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); cpu_to_be32w((uint32_t*)data, new_l1_size); cpu_to_be64wu((uint64_t*)(data + 4), new_l1_table_offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data)); if (ret < 0) { goto fail; } g_free(s->l1_table); qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t), QCOW2_DISCARD_OTHER); s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; s->l1_size = new_l1_size; return 0; fail: g_free(new_l1_table); qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2, QCOW2_DISCARD_OTHER); return ret; } /* * l2_load * * Loads a L2 table into memory. If the table is in the cache, the cache * is used; otherwise the L2 table is loaded from the image file. * * Returns a pointer to the L2 table on success, or NULL if the read from * the image file failed. */ static int l2_load(BlockDriverState *bs, uint64_t l2_offset, uint64_t **l2_table) { BDRVQcowState *s = bs->opaque; int ret; ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table); return ret; } /* * Writes one sector of the L1 table to the disk (can't update single entries * and we really don't want bdrv_pread to perform a read-modify-write) */ #define L1_ENTRIES_PER_SECTOR (512 / 8) static int write_l1_entry(BlockDriverState *bs, int l1_index) { BDRVQcowState *s = bs->opaque; uint64_t buf[L1_ENTRIES_PER_SECTOR]; int l1_start_index; int i, ret; l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1); for (i = 0; i < L1_ENTRIES_PER_SECTOR; i++) { buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]); } BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset + 8 * l1_start_index, buf, sizeof(buf)); if (ret < 0) { return ret; } return 0; } /* * l2_allocate * * Allocate a new l2 entry in the file. If l1_index points to an already * used entry in the L2 table (i.e. we are doing a copy on write for the L2 * table) copy the contents of the old L2 table into the newly allocated one. * Otherwise the new table is initialized with zeros. * */ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) { BDRVQcowState *s = bs->opaque; uint64_t old_l2_offset; uint64_t *l2_table; int64_t l2_offset; int ret; old_l2_offset = s->l1_table[l1_index]; trace_qcow2_l2_allocate(bs, l1_index); /* allocate a new l2 entry */ l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t)); if (l2_offset < 0) { return l2_offset; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; } /* allocate a new entry in the l2 cache */ trace_qcow2_l2_allocate_get_empty(bs, l1_index); ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) table); if (ret < 0) { return ret; } l2_table = *table; if ((old_l2_offset & L1E_OFFSET_MASK) == 0) { /* if there was no old l2 table, clear the new table */ memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); } else { uint64_t* old_table; /* if there was an old l2 table, read it from the disk */ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); ret = qcow2_cache_get(bs, s->l2_table_cache, old_l2_offset & L1E_OFFSET_MASK, (void**) &old_table); if (ret < 0) { goto fail; } memcpy(l2_table, old_table, s->cluster_size); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &old_table); if (ret < 0) { goto fail; } } /* write the l2 table to the file */ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); trace_qcow2_l2_allocate_write_l2(bs, l1_index); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; } /* update the L1 entry */ trace_qcow2_l2_allocate_write_l1(bs, l1_index); s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED; ret = write_l1_entry(bs, l1_index); if (ret < 0) { goto fail; } *table = l2_table; trace_qcow2_l2_allocate_done(bs, l1_index, 0); return 0; fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); qcow2_cache_put(bs, s->l2_table_cache, (void**) table); s->l1_table[l1_index] = old_l2_offset; return ret; } /* * Checks how many clusters in a given L2 table are contiguous in the image * file. As soon as one of the flags in the bitmask stop_flags changes compared * to the first cluster, the search is stopped and the cluster is not counted * as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t start, uint64_t stop_flags) { int i; uint64_t mask = stop_flags | L2E_OFFSET_MASK; uint64_t offset = be64_to_cpu(l2_table[0]) & mask; if (!offset) return 0; for (i = start; i < start + nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[i]) & mask; if (offset + (uint64_t) i * cluster_size != l2_entry) { break; } } return (i - start); } static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) { int i; for (i = 0; i < nb_clusters; i++) { int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i])); if (type != QCOW2_CLUSTER_UNALLOCATED) { break; } } return i; } /* The crypt function is compatible with the linux cryptoloop algorithm for < 4 GB images. NOTE: out_buf == in_buf is supported */ void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, int enc, const AES_KEY *key) { union { uint64_t ll[2]; uint8_t b[16]; } ivec; int i; for(i = 0; i < nb_sectors; i++) { ivec.ll[0] = cpu_to_le64(sector_num); ivec.ll[1] = 0; AES_cbc_encrypt(in_buf, out_buf, 512, key, ivec.b, enc); sector_num++; in_buf += 512; out_buf += 512; } } static int coroutine_fn copy_sectors(BlockDriverState *bs, uint64_t start_sect, uint64_t cluster_offset, int n_start, int n_end) { BDRVQcowState *s = bs->opaque; QEMUIOVector qiov; struct iovec iov; int n, ret; /* * If this is the last cluster and it is only partially used, we must only * copy until the end of the image, or bdrv_check_request will fail for the * bdrv_read/write calls below. */ if (start_sect + n_end > bs->total_sectors) { n_end = bs->total_sectors - start_sect; } n = n_end - n_start; if (n <= 0) { return 0; } iov.iov_len = n * BDRV_SECTOR_SIZE; iov.iov_base = qemu_blockalign(bs, iov.iov_len); qemu_iovec_init_external(&qiov, &iov, 1); BLKDBG_EVENT(bs->file, BLKDBG_COW_READ); /* Call .bdrv_co_readv() directly instead of using the public block-layer * interface. This avoids double I/O throttling and request tracking, * which can lead to deadlock when block layer copy-on-read is enabled. */ ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov); if (ret < 0) { goto out; } if (s->crypt_method) { qcow2_encrypt_sectors(s, start_sect + n_start, iov.iov_base, iov.iov_base, n, 1, &s->aes_encrypt_key); } BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE); ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov); if (ret < 0) { goto out; } ret = 0; out: qemu_vfree(iov.iov_base); return ret; } /* * get_cluster_offset * * For a given offset of the disk image, find the cluster offset in * qcow2 file. The offset is stored in *cluster_offset. * * on entry, *num is the number of contiguous sectors we'd like to * access following offset. * * on exit, *num is the number of contiguous sectors we can read. * * Returns the cluster type (QCOW2_CLUSTER_*) on success, -errno in error * cases. */ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { BDRVQcowState *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; unsigned int index_in_cluster, nb_clusters; uint64_t nb_available, nb_needed; int ret; index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); nb_needed = *num + index_in_cluster; l1_bits = s->l2_bits + s->cluster_bits; /* compute how many bytes there are between the offset and * the end of the l1 entry */ nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); /* compute the number of available sectors */ nb_available = (nb_available >> 9) + index_in_cluster; if (nb_needed > nb_available) { nb_needed = nb_available; } *cluster_offset = 0; /* seek the the l2 offset in the l1 table */ l1_index = offset >> l1_bits; if (l1_index >= s->l1_size) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; if (!l2_offset) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } /* load the l2 table in memory */ ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } /* find the cluster offset for the given disk offset */ l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); switch (ret) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters can only be processed one by one */ c = 1; *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; break; case QCOW2_CLUSTER_ZERO: if (s->qcow_version < 3) { return -EIO; } c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, QCOW_OFLAG_COMPRESSED | QCOW_OFLAG_ZERO); *cluster_offset = 0; break; case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); *cluster_offset = 0; break; case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, QCOW_OFLAG_COMPRESSED | QCOW_OFLAG_ZERO); *cluster_offset &= L2E_OFFSET_MASK; break; default: abort(); } qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); nb_available = (c * s->cluster_sectors); out: if (nb_available > nb_needed) nb_available = nb_needed; *num = nb_available - index_in_cluster; return ret; } /* * get_cluster_table * * for a given disk offset, load (and allocate if needed) * the l2 table. * * the l2 table offset in the qcow2 file and the cluster index * in the l2 table are given to the caller. * * Returns 0 on success, -errno in failure case */ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, uint64_t **new_l2_table, int *new_l2_index) { BDRVQcowState *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; uint64_t *l2_table = NULL; int ret; /* seek the the l2 offset in the l1 table */ l1_index = offset >> (s->l2_bits + s->cluster_bits); if (l1_index >= s->l1_size) { ret = qcow2_grow_l1_table(bs, l1_index + 1, false); if (ret < 0) { return ret; } } assert(l1_index < s->l1_size); l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; /* seek the l2 table of the given l2 offset */ if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { /* load the l2 table in memory */ ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } } else { /* First allocate a new L2 table (and do COW if needed) */ ret = l2_allocate(bs, l1_index, &l2_table); if (ret < 0) { return ret; } /* Then decrease the refcount of the old table */ if (l2_offset) { qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t), QCOW2_DISCARD_OTHER); } } /* find the cluster offset for the given disk offset */ l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *new_l2_table = l2_table; *new_l2_index = l2_index; return 0; } /* * alloc_compressed_cluster_offset * * For a given offset of the disk image, return cluster offset in * qcow2 file. * * If the offset is not found, allocate a new compressed cluster. * * Return the cluster offset if successful, * Return 0, otherwise. * */ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t *l2_table; int64_t cluster_offset; int nb_csectors; ret = get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { return 0; } /* Compression can't overwrite anything. Fail if the cluster was already * allocated. */ cluster_offset = be64_to_cpu(l2_table[l2_index]); if (cluster_offset & L2E_OFFSET_MASK) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); return 0; } cluster_offset = qcow2_alloc_bytes(bs, compressed_size); if (cluster_offset < 0) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); return 0; } nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) - (cluster_offset >> 9); cluster_offset |= QCOW_OFLAG_COMPRESSED | ((uint64_t)nb_csectors << s->csize_shift); /* update L2 table */ /* compressed clusters never have the copied flag */ BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index] = cpu_to_be64(cluster_offset); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return 0; } return cluster_offset; } static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r) { BDRVQcowState *s = bs->opaque; int ret; if (r->nb_sectors == 0) { return 0; } qemu_co_mutex_unlock(&s->lock); ret = copy_sectors(bs, m->offset / BDRV_SECTOR_SIZE, m->alloc_offset, r->offset / BDRV_SECTOR_SIZE, r->offset / BDRV_SECTOR_SIZE + r->nb_sectors); qemu_co_mutex_lock(&s->lock); if (ret < 0) { return ret; } /* * Before we update the L2 table to actually point to the new cluster, we * need to be sure that the refcounts have been increased and COW was * handled. */ qcow2_cache_depends_on_flush(s->l2_table_cache); return 0; } int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int i, j = 0, l2_index, ret; uint64_t *old_cluster, *l2_table; uint64_t cluster_offset = m->alloc_offset; trace_qcow2_cluster_link_l2(qemu_coroutine_self(), m->nb_clusters); assert(m->nb_clusters > 0); old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t)); /* copy content of unmodified sectors */ ret = perform_cow(bs, m, &m->cow_start); if (ret < 0) { goto err; } ret = perform_cow(bs, m, &m->cow_end); if (ret < 0) { goto err; } /* Update L2 table. */ if (s->use_lazy_refcounts) { qcow2_mark_dirty(bs); } if (qcow2_need_accurate_refcounts(s)) { qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); } ret = get_cluster_table(bs, m->offset, &l2_table, &l2_index); if (ret < 0) { goto err; } qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); for (i = 0; i < m->nb_clusters; i++) { /* if two concurrent writes happen to the same unallocated cluster * each write allocates separate cluster and writes data concurrently. * The first one to complete updates l2 table with pointer to its * cluster the second one has to do RMW (which is done above by * copy_sectors()), update l2 table with its cluster pointer and free * old cluster. This is what this loop does */ if(l2_table[l2_index + i] != 0) old_cluster[j++] = l2_table[l2_index + i]; l2_table[l2_index + i] = cpu_to_be64((cluster_offset + (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); } ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { goto err; } /* * If this was a COW, we need to decrease the refcount of the old cluster. * Also flush bs->file to get the right order for L2 and refcount update. * * Don't discard clusters that reach a refcount of 0 (e.g. compressed * clusters), the next write will reuse them anyway. */ if (j != 0) { for (i = 0; i < j; i++) { qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1, QCOW2_DISCARD_NEVER); } } ret = 0; err: g_free(old_cluster); return ret; } /* * Returns the number of contiguous clusters that can be used for an allocating * write, but require COW to be performed (this includes yet unallocated space, * which must copy from the backing file) */ static int count_cow_clusters(BDRVQcowState *s, int nb_clusters, uint64_t *l2_table, int l2_index) { int i; for (i = 0; i < nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); int cluster_type = qcow2_get_cluster_type(l2_entry); switch(cluster_type) { case QCOW2_CLUSTER_NORMAL: if (l2_entry & QCOW_OFLAG_COPIED) { goto out; } break; case QCOW2_CLUSTER_UNALLOCATED: case QCOW2_CLUSTER_COMPRESSED: case QCOW2_CLUSTER_ZERO: break; default: abort(); } } out: assert(i <= nb_clusters); return i; } /* * Check if there already is an AIO write request in flight which allocates * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. * * Returns: * 0 if there was no dependency. *cur_bytes indicates the number of * bytes from guest_offset that can be read before the next * dependency must be processed (or the request is complete) * * -EAGAIN if we had to wait for another request, previously gathered * information on cluster allocation may be invalid now. The caller * must start over anyway, so consider *cur_bytes undefined. */ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, uint64_t *cur_bytes, QCowL2Meta **m) { BDRVQcowState *s = bs->opaque; QCowL2Meta *old_alloc; uint64_t bytes = *cur_bytes; QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t start = guest_offset; uint64_t end = start + bytes; uint64_t old_start = l2meta_cow_start(old_alloc); uint64_t old_end = l2meta_cow_end(old_alloc); if (end <= old_start || start >= old_end) { /* No intersection */ } else { if (start < old_start) { /* Stop at the start of a running allocation */ bytes = old_start - start; } else { bytes = 0; } /* Stop if already an l2meta exists. After yielding, it wouldn't * be valid any more, so we'd have to clean up the old L2Metas * and deal with requests depending on them before starting to * gather new ones. Not worth the trouble. */ if (bytes == 0 && *m) { *cur_bytes = 0; return 0; } if (bytes == 0) { /* Wait for the dependency to complete. We need to recheck * the free/allocated clusters when we continue. */ qemu_co_mutex_unlock(&s->lock); qemu_co_queue_wait(&old_alloc->dependent_requests); qemu_co_mutex_lock(&s->lock); return -EAGAIN; } } } /* Make sure that existing clusters and new allocations are only used up to * the next dependency if we shortened the request above */ *cur_bytes = bytes; return 0; } /* * Checks how many already allocated clusters that don't require a copy on * write there are at the given guest_offset (up to *bytes). If * *host_offset is not zero, only physically contiguous clusters beginning at * this host offset are counted. * * Note that guest_offset may not be cluster aligned. In this case, the * returned *host_offset points to exact byte referenced by guest_offset and * therefore isn't cluster aligned as well. * * Returns: * 0: if no allocated clusters are available at the given offset. * *bytes is normally unchanged. It is set to 0 if the cluster * is allocated and doesn't need COW, but doesn't have the right * physical offset. * * 1: if allocated clusters that don't require a COW are available at * the requested offset. *bytes may have decreased and describes * the length of the area that can be written to. * * -errno: in error cases */ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcowState *s = bs->opaque; int l2_index; uint64_t cluster_offset; uint64_t *l2_table; unsigned int nb_clusters; unsigned int keep_clusters; int ret, pret; trace_qcow2_handle_copied(qemu_coroutine_self(), guest_offset, *host_offset, *bytes); assert(*host_offset == 0 || offset_into_cluster(s, guest_offset) == offset_into_cluster(s, *host_offset)); /* * Calculate the number of clusters to look for. We stop at L2 table * boundaries to keep things simple. */ nb_clusters = size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); if (ret < 0) { return ret; } cluster_offset = be64_to_cpu(l2_table[l2_index]); /* Check how many clusters are already allocated and don't need COW */ if (qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL && (cluster_offset & QCOW_OFLAG_COPIED)) { /* If a specific host_offset is required, check it */ bool offset_matches = (cluster_offset & L2E_OFFSET_MASK) == *host_offset; if (*host_offset != 0 && !offset_matches) { *bytes = 0; ret = 0; goto out; } /* We keep all QCOW_OFLAG_COPIED clusters */ keep_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO); assert(keep_clusters <= nb_clusters); *bytes = MIN(*bytes, keep_clusters * s->cluster_size - offset_into_cluster(s, guest_offset)); ret = 1; } else { ret = 0; } /* Cleanup */ out: pret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (pret < 0) { return pret; } /* Only return a host offset if we actually made progress. Otherwise we * would make requirements for handle_alloc() that it can't fulfill */ if (ret) { *host_offset = (cluster_offset & L2E_OFFSET_MASK) + offset_into_cluster(s, guest_offset); } return ret; } /* * Allocates new clusters for the given guest_offset. * * At most *nb_clusters are allocated, and on return *nb_clusters is updated to * contain the number of clusters that have been allocated and are contiguous * in the image file. * * If *host_offset is non-zero, it specifies the offset in the image file at * which the new clusters must start. *nb_clusters can be 0 on return in this * case if the cluster at host_offset is already in use. If *host_offset is * zero, the clusters can be allocated anywhere in the image file. * * *host_offset is updated to contain the offset into the image file at which * the first allocated cluster starts. * * Return 0 on success and -errno in error cases. -EAGAIN means that the * function has been waiting for another request and the allocation must be * restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters) { BDRVQcowState *s = bs->opaque; trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset, *host_offset, *nb_clusters); /* Allocate new clusters */ trace_qcow2_cluster_alloc_phys(qemu_coroutine_self()); if (*host_offset == 0) { int64_t cluster_offset = qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size); if (cluster_offset < 0) { return cluster_offset; } *host_offset = cluster_offset; return 0; } else { int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); if (ret < 0) { return ret; } *nb_clusters = ret; return 0; } } /* * Allocates new clusters for an area that either is yet unallocated or needs a * copy on write. If *host_offset is non-zero, clusters are only allocated if * the new allocation can match the specified host offset. * * Note that guest_offset may not be cluster aligned. In this case, the * returned *host_offset points to exact byte referenced by guest_offset and * therefore isn't cluster aligned as well. * * Returns: * 0: if no clusters could be allocated. *bytes is set to 0, * *host_offset is left unchanged. * * 1: if new clusters were allocated. *bytes may be decreased if the * new allocation doesn't cover all of the requested area. * *host_offset is updated to contain the host offset of the first * newly allocated cluster. * * -errno: in error cases */ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcowState *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; unsigned int nb_clusters; int ret; uint64_t alloc_cluster_offset; trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset, *bytes); assert(*bytes > 0); /* * Calculate the number of clusters to look for. We stop at L2 table * boundaries to keep things simple. */ nb_clusters = size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); if (ret < 0) { return ret; } entry = be64_to_cpu(l2_table[l2_index]); /* For the moment, overwrite compressed clusters one by one */ if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters = 1; } else { nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index); } /* This function is only called when there were no non-COW clusters, so if * we can't find any unallocated or COW clusters either, something is * wrong with our code. */ assert(nb_clusters > 0); ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return ret; } /* Allocate, if necessary at a given offset in the image file */ alloc_cluster_offset = start_of_cluster(s, *host_offset); ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset, &nb_clusters); if (ret < 0) { goto fail; } /* Can't extend contiguous allocation */ if (nb_clusters == 0) { *bytes = 0; return 0; } /* * Save info needed for meta data update. * * requested_sectors: Number of sectors from the start of the first * newly allocated cluster to the end of the (possibly shortened * before) write request. * * avail_sectors: Number of sectors from the start of the first * newly allocated to the end of the last newly allocated cluster. * * nb_sectors: The number of sectors from the start of the first * newly allocated cluster to the end of the area that the write * request actually writes to (excluding COW at the end) */ int requested_sectors = (*bytes + offset_into_cluster(s, guest_offset)) >> BDRV_SECTOR_BITS; int avail_sectors = nb_clusters << (s->cluster_bits - BDRV_SECTOR_BITS); int alloc_n_start = offset_into_cluster(s, guest_offset) >> BDRV_SECTOR_BITS; int nb_sectors = MIN(requested_sectors, avail_sectors); QCowL2Meta *old_m = *m; *m = g_malloc0(sizeof(**m)); **m = (QCowL2Meta) { .next = old_m, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, guest_offset), .nb_clusters = nb_clusters, .nb_available = nb_sectors, .cow_start = { .offset = 0, .nb_sectors = alloc_n_start, }, .cow_end = { .offset = nb_sectors * BDRV_SECTOR_SIZE, .nb_sectors = avail_sectors - nb_sectors, }, }; qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); *host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset); *bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE) - offset_into_cluster(s, guest_offset)); assert(*bytes != 0); return 1; fail: if (*m && (*m)->nb_clusters > 0) { QLIST_REMOVE(*m, next_in_flight); } return ret; } /* * alloc_cluster_offset * * For a given offset on the virtual disk, find the cluster offset in qcow2 * file. If the offset is not found, allocate a new cluster. * * If the cluster was already allocated, m->nb_clusters is set to 0 and * other fields in m are meaningless. * * If the cluster is newly allocated, m->nb_clusters is set to the number of * contiguous clusters that have been allocated. In this case, the other * fields of m are valid and contain information about the first allocated * cluster. * * If the request conflicts with another write request in flight, the coroutine * is queued and will be reentered when the dependency has completed. * * Return 0 on success and -errno in error cases */ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, uint64_t *host_offset, QCowL2Meta **m) { BDRVQcowState *s = bs->opaque; uint64_t start, remaining; uint64_t cluster_offset; uint64_t cur_bytes; int ret; trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, n_start, n_end); assert(n_start * BDRV_SECTOR_SIZE == offset_into_cluster(s, offset)); offset = start_of_cluster(s, offset); again: start = offset + (n_start << BDRV_SECTOR_BITS); remaining = (n_end - n_start) << BDRV_SECTOR_BITS; cluster_offset = 0; *host_offset = 0; cur_bytes = 0; *m = NULL; while (true) { if (!*host_offset) { *host_offset = start_of_cluster(s, cluster_offset); } assert(remaining >= cur_bytes); start += cur_bytes; remaining -= cur_bytes; cluster_offset += cur_bytes; if (remaining == 0) { break; } cur_bytes = remaining; /* * Now start gathering as many contiguous clusters as possible: * * 1. Check for overlaps with in-flight allocations * * a) Overlap not in the first cluster -> shorten this request and * let the caller handle the rest in its next loop iteration. * * b) Real overlaps of two requests. Yield and restart the search * for contiguous clusters (the situation could have changed * while we were sleeping) * * c) TODO: Request starts in the same cluster as the in-flight * allocation ends. Shorten the COW of the in-fight allocation, * set cluster_offset to write to the same cluster and set up * the right synchronisation between the in-flight request and * the new one. */ ret = handle_dependencies(bs, start, &cur_bytes, m); if (ret == -EAGAIN) { /* Currently handle_dependencies() doesn't yield if we already had * an allocation. If it did, we would have to clean up the L2Meta * structs before starting over. */ assert(*m == NULL); goto again; } else if (ret < 0) { return ret; } else if (cur_bytes == 0) { break; } else { /* handle_dependencies() may have decreased cur_bytes (shortened * the allocations below) so that the next dependency is processed * correctly during the next loop iteration. */ } /* * 2. Count contiguous COPIED clusters. */ ret = handle_copied(bs, start, &cluster_offset, &cur_bytes, m); if (ret < 0) { return ret; } else if (ret) { continue; } else if (cur_bytes == 0) { break; } /* * 3. If the request still hasn't completed, allocate new clusters, * considering any cluster_offset of steps 1c or 2. */ ret = handle_alloc(bs, start, &cluster_offset, &cur_bytes, m); if (ret < 0) { return ret; } else if (ret) { continue; } else { assert(cur_bytes == 0); break; } } *num = (n_end - n_start) - (remaining >> BDRV_SECTOR_BITS); assert(*num > 0); assert(*host_offset != 0); return 0; } static int decompress_buffer(uint8_t *out_buf, int out_buf_size, const uint8_t *buf, int buf_size) { z_stream strm1, *strm = &strm1; int ret, out_len; memset(strm, 0, sizeof(*strm)); strm->next_in = (uint8_t *)buf; strm->avail_in = buf_size; strm->next_out = out_buf; strm->avail_out = out_buf_size; ret = inflateInit2(strm, -12); if (ret != Z_OK) return -1; ret = inflate(strm, Z_FINISH); out_len = strm->next_out - out_buf; if ((ret != Z_STREAM_END && ret != Z_BUF_ERROR) || out_len != out_buf_size) { inflateEnd(strm); return -1; } inflateEnd(strm); return 0; } int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) { BDRVQcowState *s = bs->opaque; int ret, csize, nb_csectors, sector_offset; uint64_t coffset; coffset = cluster_offset & s->cluster_offset_mask; if (s->cluster_cache_offset != coffset) { nb_csectors = ((cluster_offset >> s->csize_shift) & s->csize_mask) + 1; sector_offset = coffset & 511; csize = nb_csectors * 512 - sector_offset; BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); ret = bdrv_read(bs->file, coffset >> 9, s->cluster_data, nb_csectors); if (ret < 0) { return ret; } if (decompress_buffer(s->cluster_cache, s->cluster_size, s->cluster_data + sector_offset, csize) < 0) { return -EIO; } s->cluster_cache_offset = coffset; } return 0; } /* * This discards as many clusters of nb_clusters as possible at once (i.e. * all clusters in the same L2 table) and returns the number of discarded * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; int i; ret = get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { return ret; } /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; old_offset = be64_to_cpu(l2_table[l2_index + i]); if ((old_offset & L2E_OFFSET_MASK) == 0) { continue; } /* First remove L2 entries */ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index + i] = cpu_to_be64(0); /* Then decrease the refcount */ qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST); } ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return ret; } return nb_clusters; } int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcowState *s = bs->opaque; uint64_t end_offset; unsigned int nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); /* Round start up and end down */ offset = align_offset(offset, s->cluster_size); end_offset &= ~(s->cluster_size - 1); if (offset > end_offset) { return 0; } nb_clusters = size_to_clusters(s, end_offset - offset); s->cache_discards = true; /* Each L2 table is handled by its own loop iteration */ while (nb_clusters > 0) { ret = discard_single_l2(bs, offset, nb_clusters); if (ret < 0) { goto fail; } nb_clusters -= ret; offset += (ret * s->cluster_size); } ret = 0; fail: s->cache_discards = false; qcow2_process_discards(bs, ret); return ret; } /* * This zeroes as many clusters of nb_clusters as possible at once (i.e. * all clusters in the same L2 table) and returns the number of zeroed * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; int i; ret = get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { return ret; } /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; old_offset = be64_to_cpu(l2_table[l2_index + i]); /* Update L2 entries */ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); if (old_offset & QCOW_OFLAG_COMPRESSED) { l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST); } else { l2_table[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO); } } ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return ret; } return nb_clusters; } int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcowState *s = bs->opaque; unsigned int nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ if (s->qcow_version < 3) { return -ENOTSUP; } /* Each L2 table is handled by its own loop iteration */ nb_clusters = size_to_clusters(s, nb_sectors << BDRV_SECTOR_BITS); s->cache_discards = true; while (nb_clusters > 0) { ret = zero_single_l2(bs, offset, nb_clusters); if (ret < 0) { goto fail; } nb_clusters -= ret; offset += (ret * s->cluster_size); } ret = 0; fail: s->cache_discards = false; qcow2_process_discards(bs, ret); return ret; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed-gencb.c0000644000076200007630000000013012617742532022222 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 29 ctime=1447019941.73833267 glusterfs-3.7.6/contrib/qemu/block/qed-gencb.c0000644000076200007630000000126012617742532022440 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qed.h" void *gencb_alloc(size_t len, BlockDriverCompletionFunc *cb, void *opaque) { GenericCB *gencb = g_malloc(len); gencb->cb = cb; gencb->opaque = opaque; return gencb; } void gencb_complete(void *opaque, int ret) { GenericCB *gencb = opaque; BlockDriverCompletionFunc *cb = gencb->cb; void *user_opaque = gencb->opaque; g_free(gencb); cb(user_opaque, ret); } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2-refcount.c0000644000076200007630000000013012617742532023253 xustar000000000000000028 mtime=1447019866.0334716 30 atime=1447019866.369466545 30 ctime=1447019941.722332912 glusterfs-3.7.6/contrib/qemu/block/qcow2-refcount.c0000644000076200007630000013100712617742532023474 0ustar00jenkinsjenkins00000000000000/* * Block driver for the QCOW version 2 format * * Copyright (c) 2004-2006 Fabrice Bellard * * 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. */ #include "qemu-common.h" #include "block/block_int.h" #include "block/qcow2.h" static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size); static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, int64_t offset, int64_t length, int addend, enum qcow2_discard_type type); /*********************************************************/ /* refcount handling */ int qcow2_refcount_init(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int ret, refcount_table_size2, i; refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t); s->refcount_table = g_malloc(refcount_table_size2); if (s->refcount_table_size > 0) { BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); ret = bdrv_pread(bs->file, s->refcount_table_offset, s->refcount_table, refcount_table_size2); if (ret != refcount_table_size2) goto fail; for(i = 0; i < s->refcount_table_size; i++) be64_to_cpus(&s->refcount_table[i]); } return 0; fail: return -ENOMEM; } void qcow2_refcount_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; g_free(s->refcount_table); } static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { BDRVQcowState *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, refcount_block); return ret; } /* * Returns the refcount of the cluster given by its index. Any non-negative * return value is the refcount of the cluster, negative values are -errno * and indicate an error. */ static int get_refcount(BlockDriverState *bs, int64_t cluster_index) { BDRVQcowState *s = bs->opaque; int refcount_table_index, block_index; int64_t refcount_block_offset; int ret; uint16_t *refcount_block; uint16_t refcount; refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if (refcount_table_index >= s->refcount_table_size) return 0; refcount_block_offset = s->refcount_table[refcount_table_index]; if (!refcount_block_offset) return 0; ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, (void**) &refcount_block); if (ret < 0) { return ret; } block_index = cluster_index & ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); refcount = be16_to_cpu(refcount_block[block_index]); ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (ret < 0) { return ret; } return refcount; } /* * Rounds the refcount table size up to avoid growing the table for each single * refcount block that is allocated. */ static unsigned int next_refcount_table_size(BDRVQcowState *s, unsigned int min_size) { unsigned int min_clusters = (min_size >> (s->cluster_bits - 3)) + 1; unsigned int refcount_table_clusters = MAX(1, s->refcount_table_size >> (s->cluster_bits - 3)); while (min_clusters > refcount_table_clusters) { refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2; } return refcount_table_clusters << (s->cluster_bits - 3); } /* Checks if two offsets are described by the same refcount block */ static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, uint64_t offset_b) { uint64_t block_a = offset_a >> (2 * s->cluster_bits - REFCOUNT_SHIFT); uint64_t block_b = offset_b >> (2 * s->cluster_bits - REFCOUNT_SHIFT); return (block_a == block_b); } /* * Loads a refcount block. If it doesn't exist yet, it is allocated first * (including growing the refcount table if needed). * * Returns 0 on success or -errno in error case */ static int alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index, uint16_t **refcount_block) { BDRVQcowState *s = bs->opaque; unsigned int refcount_table_index; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC); /* Find the refcount block for the given cluster */ refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if (refcount_table_index < s->refcount_table_size) { uint64_t refcount_block_offset = s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK; /* If it's already there, we're done */ if (refcount_block_offset) { return load_refcount_block(bs, refcount_block_offset, (void**) refcount_block); } } /* * If we came here, we need to allocate something. Something is at least * a cluster for the new refcount block. It may also include a new refcount * table if the old refcount table is too small. * * Note that allocating clusters here needs some special care: * * - We can't use the normal qcow2_alloc_clusters(), it would try to * increase the refcount and very likely we would end up with an endless * recursion. Instead we must place the refcount blocks in a way that * they can describe them themselves. * * - We need to consider that at this point we are inside update_refcounts * and doing the initial refcount increase. This means that some clusters * have already been allocated by the caller, but their refcount isn't * accurate yet. free_cluster_index tells us where this allocation ends * as long as we don't overwrite it by freeing clusters. * * - alloc_clusters_noref and qcow2_free_clusters may load a different * refcount block into the cache */ *refcount_block = NULL; /* We write to the refcount table, so we might depend on L2 tables */ ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { return ret; } /* Allocate the refcount block itself and mark it as used */ int64_t new_block = alloc_clusters_noref(bs, s->cluster_size); if (new_block < 0) { return new_block; } #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64 " at %" PRIx64 "\n", refcount_table_index, cluster_index << s->cluster_bits, new_block); #endif if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) { /* Zero the new refcount block before updating it */ ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block, (void**) refcount_block); if (ret < 0) { goto fail_block; } memset(*refcount_block, 0, s->cluster_size); /* The block describes itself, need to update the cache */ int block_index = (new_block >> s->cluster_bits) & ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); (*refcount_block)[block_index] = cpu_to_be16(1); } else { /* Described somewhere else. This can recurse at most twice before we * arrive at a block that describes itself. */ ret = update_refcount(bs, new_block, s->cluster_size, 1, QCOW2_DISCARD_NEVER); if (ret < 0) { goto fail_block; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail_block; } /* Initialize the new refcount block only after updating its refcount, * update_refcount uses the refcount cache itself */ ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block, (void**) refcount_block); if (ret < 0) { goto fail_block; } memset(*refcount_block, 0, s->cluster_size); } /* Now the new refcount block needs to be written to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block); ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail_block; } /* If the refcount table is big enough, just hook the block up there */ if (refcount_table_index < s->refcount_table_size) { uint64_t data64 = cpu_to_be64(new_block); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset + refcount_table_index * sizeof(uint64_t), &data64, sizeof(data64)); if (ret < 0) { goto fail_block; } s->refcount_table[refcount_table_index] = new_block; return 0; } ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block); if (ret < 0) { goto fail_block; } /* * If we come here, we need to grow the refcount table. Again, a new * refcount table needs some space and we can't simply allocate to avoid * endless recursion. * * Therefore let's grab new refcount blocks at the end of the image, which * will describe themselves and the new refcount table. This way we can * reference them only in the new table and do the switch to the new * refcount table at once without producing an inconsistent state in * between. */ BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW); /* Calculate the number of refcount blocks needed so far */ uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT); uint64_t blocks_used = (s->free_cluster_index + refcount_block_clusters - 1) / refcount_block_clusters; /* And now we need at least one block more for the new metadata */ uint64_t table_size = next_refcount_table_size(s, blocks_used + 1); uint64_t last_table_size; uint64_t blocks_clusters; do { uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t)); blocks_clusters = 1 + ((table_clusters + refcount_block_clusters - 1) / refcount_block_clusters); uint64_t meta_clusters = table_clusters + blocks_clusters; last_table_size = table_size; table_size = next_refcount_table_size(s, blocks_used + ((meta_clusters + refcount_block_clusters - 1) / refcount_block_clusters)); } while (last_table_size != table_size); #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n", s->refcount_table_size, table_size); #endif /* Create the new refcount table and blocks */ uint64_t meta_offset = (blocks_used * refcount_block_clusters) * s->cluster_size; uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size; uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size); uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t)); assert(meta_offset >= (s->free_cluster_index * s->cluster_size)); /* Fill the new refcount table */ memcpy(new_table, s->refcount_table, s->refcount_table_size * sizeof(uint64_t)); new_table[refcount_table_index] = new_block; int i; for (i = 0; i < blocks_clusters; i++) { new_table[blocks_used + i] = meta_offset + (i * s->cluster_size); } /* Fill the refcount blocks */ uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t)); int block = 0; for (i = 0; i < table_clusters + blocks_clusters; i++) { new_blocks[block++] = cpu_to_be16(1); } /* Write refcount blocks to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks, blocks_clusters * s->cluster_size); g_free(new_blocks); if (ret < 0) { goto fail_table; } /* Write refcount table to disk */ for(i = 0; i < table_size; i++) { cpu_to_be64s(&new_table[i]); } BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); ret = bdrv_pwrite_sync(bs->file, table_offset, new_table, table_size * sizeof(uint64_t)); if (ret < 0) { goto fail_table; } for(i = 0; i < table_size; i++) { be64_to_cpus(&new_table[i]); } /* Hook up the new refcount table in the qcow2 header */ uint8_t data[12]; cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), data, sizeof(data)); if (ret < 0) { goto fail_table; } /* And switch it in memory */ uint64_t old_table_offset = s->refcount_table_offset; uint64_t old_table_size = s->refcount_table_size; g_free(s->refcount_table); s->refcount_table = new_table; s->refcount_table_size = table_size; s->refcount_table_offset = table_offset; /* Free old table. Remember, we must not change free_cluster_index */ uint64_t old_free_cluster_index = s->free_cluster_index; qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t), QCOW2_DISCARD_OTHER); s->free_cluster_index = old_free_cluster_index; ret = load_refcount_block(bs, new_block, (void**) refcount_block); if (ret < 0) { return ret; } return 0; fail_table: g_free(new_table); fail_block: if (*refcount_block != NULL) { qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block); } return ret; } void qcow2_process_discards(BlockDriverState *bs, int ret) { BDRVQcowState *s = bs->opaque; Qcow2DiscardRegion *d, *next; QTAILQ_FOREACH_SAFE(d, &s->discards, next, next) { QTAILQ_REMOVE(&s->discards, d, next); /* Discard is optional, ignore the return value */ if (ret >= 0) { bdrv_discard(bs->file, d->offset >> BDRV_SECTOR_BITS, d->bytes >> BDRV_SECTOR_BITS); } g_free(d); } } static void update_refcount_discard(BlockDriverState *bs, uint64_t offset, uint64_t length) { BDRVQcowState *s = bs->opaque; Qcow2DiscardRegion *d, *p, *next; QTAILQ_FOREACH(d, &s->discards, next) { uint64_t new_start = MIN(offset, d->offset); uint64_t new_end = MAX(offset + length, d->offset + d->bytes); if (new_end - new_start <= length + d->bytes) { /* There can't be any overlap, areas ending up here have no * references any more and therefore shouldn't get freed another * time. */ assert(d->bytes + length == new_end - new_start); d->offset = new_start; d->bytes = new_end - new_start; goto found; } } d = g_malloc(sizeof(*d)); *d = (Qcow2DiscardRegion) { .bs = bs, .offset = offset, .bytes = length, }; QTAILQ_INSERT_TAIL(&s->discards, d, next); found: /* Merge discard requests if they are adjacent now */ QTAILQ_FOREACH_SAFE(p, &s->discards, next, next) { if (p == d || p->offset > d->offset + d->bytes || d->offset > p->offset + p->bytes) { continue; } /* Still no overlap possible */ assert(p->offset == d->offset + d->bytes || d->offset == p->offset + p->bytes); QTAILQ_REMOVE(&s->discards, p, next); d->offset = MIN(d->offset, p->offset); d->bytes += p->bytes; } } /* XXX: cache several refcount block clusters ? */ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, int64_t offset, int64_t length, int addend, enum qcow2_discard_type type) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; uint16_t *refcount_block = NULL; int64_t old_table_index = -1; int ret; #ifdef DEBUG_ALLOC2 fprintf(stderr, "update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n", offset, length, addend); #endif if (length < 0) { return -EINVAL; } else if (length == 0) { return 0; } if (addend < 0) { qcow2_cache_set_dependency(bs, s->refcount_block_cache, s->l2_table_cache); } start = offset & ~(s->cluster_size - 1); last = (offset + length - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { int block_index, refcount; int64_t cluster_index = cluster_offset >> s->cluster_bits; int64_t table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); /* Load the refcount block and allocate it if needed */ if (table_index != old_table_index) { if (refcount_block) { ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (ret < 0) { goto fail; } } ret = alloc_refcount_block(bs, cluster_index, &refcount_block); if (ret < 0) { goto fail; } } old_table_index = table_index; qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block); /* we can update the count and save it */ block_index = cluster_index & ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); refcount = be16_to_cpu(refcount_block[block_index]); refcount += addend; if (refcount < 0 || refcount > 0xffff) { ret = -EINVAL; goto fail; } if (refcount == 0 && cluster_index < s->free_cluster_index) { s->free_cluster_index = cluster_index; } refcount_block[block_index] = cpu_to_be16(refcount); if (refcount == 0 && s->discard_passthrough[type]) { update_refcount_discard(bs, cluster_offset, s->cluster_size); } } ret = 0; fail: if (!s->cache_discards) { qcow2_process_discards(bs, ret); } /* Write last changed block to disk */ if (refcount_block) { int wret; wret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (wret < 0) { return ret < 0 ? ret : wret; } } /* * Try do undo any updates if an error is returned (This may succeed in * some cases like ENOSPC for allocating a new refcount block) */ if (ret < 0) { int dummy; dummy = update_refcount(bs, offset, cluster_offset - offset, -addend, QCOW2_DISCARD_NEVER); (void)dummy; } return ret; } /* * Increases or decreases the refcount of a given cluster by one. * addend must be 1 or -1. * * If the return value is non-negative, it is the new refcount of the cluster. * If it is negative, it is -errno and indicates an error. */ static int update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, int addend, enum qcow2_discard_type type) { BDRVQcowState *s = bs->opaque; int ret; ret = update_refcount(bs, cluster_index << s->cluster_bits, 1, addend, type); if (ret < 0) { return ret; } return get_refcount(bs, cluster_index); } /*********************************************************/ /* cluster allocation functions */ /* return < 0 if error */ static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size) { BDRVQcowState *s = bs->opaque; int i, nb_clusters, refcount; nb_clusters = size_to_clusters(s, size); retry: for(i = 0; i < nb_clusters; i++) { int64_t next_cluster_index = s->free_cluster_index++; refcount = get_refcount(bs, next_cluster_index); if (refcount < 0) { return refcount; } else if (refcount != 0) { goto retry; } } #ifdef DEBUG_ALLOC2 fprintf(stderr, "alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n", size, (s->free_cluster_index - nb_clusters) << s->cluster_bits); #endif return (s->free_cluster_index - nb_clusters) << s->cluster_bits; } int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size) { int64_t offset; int ret; BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC); offset = alloc_clusters_noref(bs, size); if (offset < 0) { return offset; } ret = update_refcount(bs, offset, size, 1, QCOW2_DISCARD_NEVER); if (ret < 0) { return ret; } return offset; } int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters) { BDRVQcowState *s = bs->opaque; uint64_t cluster_index; uint64_t old_free_cluster_index; int i, refcount, ret; /* Check how many clusters there are free */ cluster_index = offset >> s->cluster_bits; for(i = 0; i < nb_clusters; i++) { refcount = get_refcount(bs, cluster_index++); if (refcount < 0) { return refcount; } else if (refcount != 0) { break; } } /* And then allocate them */ old_free_cluster_index = s->free_cluster_index; s->free_cluster_index = cluster_index + i; ret = update_refcount(bs, offset, i << s->cluster_bits, 1, QCOW2_DISCARD_NEVER); if (ret < 0) { return ret; } s->free_cluster_index = old_free_cluster_index; return i; } /* only used to allocate compressed sectors. We try to allocate contiguous sectors. size must be <= cluster_size */ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) { BDRVQcowState *s = bs->opaque; int64_t offset, cluster_offset; int free_in_cluster; BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES); assert(size > 0 && size <= s->cluster_size); if (s->free_byte_offset == 0) { offset = qcow2_alloc_clusters(bs, s->cluster_size); if (offset < 0) { return offset; } s->free_byte_offset = offset; } redo: free_in_cluster = s->cluster_size - (s->free_byte_offset & (s->cluster_size - 1)); if (size <= free_in_cluster) { /* enough space in current cluster */ offset = s->free_byte_offset; s->free_byte_offset += size; free_in_cluster -= size; if (free_in_cluster == 0) s->free_byte_offset = 0; if ((offset & (s->cluster_size - 1)) != 0) update_cluster_refcount(bs, offset >> s->cluster_bits, 1, QCOW2_DISCARD_NEVER); } else { offset = qcow2_alloc_clusters(bs, s->cluster_size); if (offset < 0) { return offset; } cluster_offset = s->free_byte_offset & ~(s->cluster_size - 1); if ((cluster_offset + s->cluster_size) == offset) { /* we are lucky: contiguous data */ offset = s->free_byte_offset; update_cluster_refcount(bs, offset >> s->cluster_bits, 1, QCOW2_DISCARD_NEVER); s->free_byte_offset += size; } else { s->free_byte_offset = offset; goto redo; } } /* The cluster refcount was incremented, either by qcow2_alloc_clusters() * or explicitly by update_cluster_refcount(). Refcount blocks must be * flushed before the caller's L2 table updates. */ qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); return offset; } void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, enum qcow2_discard_type type) { int ret; BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_FREE); ret = update_refcount(bs, offset, size, -1, type); if (ret < 0) { fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret)); /* TODO Remember the clusters to free them later and avoid leaking */ } } /* * Free a cluster using its L2 entry (handles clusters of all types, e.g. * normal cluster, compressed cluster, etc.) */ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int nb_clusters, enum qcow2_discard_type type) { BDRVQcowState *s = bs->opaque; switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: { int nb_csectors; nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; qcow2_free_clusters(bs, (l2_entry & s->cluster_offset_mask) & ~511, nb_csectors * 512, type); } break; case QCOW2_CLUSTER_NORMAL: qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, nb_clusters << s->cluster_bits, type); break; case QCOW2_CLUSTER_UNALLOCATED: case QCOW2_CLUSTER_ZERO: break; default: abort(); } } /*********************************************************/ /* snapshots and image creation */ /* update the refcounts of snapshots and the copied flag */ int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcowState *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated; int64_t old_offset, old_l2_offset; int i, j, l1_modified = 0, nb_csectors, refcount; int ret; l2_table = NULL; l1_table = NULL; l1_size2 = l1_size * sizeof(uint64_t); s->cache_discards = true; /* WARNING: qcow2_snapshot_goto relies on this function not using the * l1_table_offset when it is the current s->l1_table_offset! Be careful * when changing this! */ if (l1_table_offset != s->l1_table_offset) { l1_table = g_malloc0(align_offset(l1_size2, 512)); l1_allocated = 1; ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2); if (ret < 0) { goto fail; } for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); } else { assert(l1_size == s->l1_size); l1_table = s->l1_table; l1_allocated = 0; } for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { old_l2_offset = l2_offset; l2_offset &= L1E_OFFSET_MASK; ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) &l2_table); if (ret < 0) { goto fail; } for(j = 0; j < s->l2_size; j++) { offset = be64_to_cpu(l2_table[j]); if (offset != 0) { old_offset = offset; offset &= ~QCOW_OFLAG_COPIED; if (offset & QCOW_OFLAG_COMPRESSED) { nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; if (addend != 0) { int ret; ret = update_refcount(bs, (offset & s->cluster_offset_mask) & ~511, nb_csectors * 512, addend, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { goto fail; } } /* compressed clusters are never modified */ refcount = 2; } else { uint64_t cluster_index = (offset & L2E_OFFSET_MASK) >> s->cluster_bits; if (addend != 0) { refcount = update_cluster_refcount(bs, cluster_index, addend, QCOW2_DISCARD_SNAPSHOT); } else { refcount = get_refcount(bs, cluster_index); } if (refcount < 0) { ret = refcount; goto fail; } } if (refcount == 1) { offset |= QCOW_OFLAG_COPIED; } if (offset != old_offset) { if (addend > 0) { qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); } l2_table[j] = cpu_to_be64(offset); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); } } } ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { goto fail; } if (addend != 0) { refcount = update_cluster_refcount(bs, l2_offset >> s->cluster_bits, addend, QCOW2_DISCARD_SNAPSHOT); } else { refcount = get_refcount(bs, l2_offset >> s->cluster_bits); } if (refcount < 0) { ret = refcount; goto fail; } else if (refcount == 1) { l2_offset |= QCOW_OFLAG_COPIED; } if (l2_offset != old_l2_offset) { l1_table[i] = l2_offset; l1_modified = 1; } } } ret = bdrv_flush(bs); fail: if (l2_table) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); } s->cache_discards = false; qcow2_process_discards(bs, ret); /* Update L1 only if it isn't deleted anyway (addend = -1) */ if (ret == 0 && addend >= 0 && l1_modified) { for (i = 0; i < l1_size; i++) { cpu_to_be64s(&l1_table[i]); } ret = bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table, l1_size2); for (i = 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); } } if (l1_allocated) g_free(l1_table); return ret; } /*********************************************************/ /* refcount checking functions */ /* * Increases the refcount for a range of clusters in a given refcount table. * This is used to construct a temporary refcount table out of L1 and L2 tables * which can be compared the the refcount table saved in the image. * * Modifies the number of errors in res. */ static void inc_refcounts(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int k; if (size <= 0) return; start = offset & ~(s->cluster_size - 1); last = (offset + size - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { k = cluster_offset >> s->cluster_bits; if (k < 0) { fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } else if (k >= refcount_table_size) { fprintf(stderr, "Warning: cluster offset=0x%" PRIx64 " is after " "the end of the image file, can't properly check refcounts.\n", cluster_offset); res->check_errors++; } else { if (++refcount_table[k] == 0) { fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } } } } /* Flags for check_refcounts_l1() and check_refcounts_l2() */ enum { CHECK_OFLAG_COPIED = 0x1, /* check QCOW_OFLAG_COPIED matches refcount */ CHECK_FRAG_INFO = 0x2, /* update BlockFragInfo counters */ }; /* * Increases the refcount in the given refcount table for the all clusters * referenced in the L2 table. While doing so, performs some checks on L2 * entries. * * Returns the number of errors found by the checks or -errno if an internal * error occurred. */ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors, refcount; /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size) goto fail; /* Do the actual checks */ for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters don't have QCOW_OFLAG_COPIED */ if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } /* Mark cluster as used */ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; res->bfi.compressed_clusters++; /* Compressed clusters are fragmented by nature. Since they * take up sub-sector space but we only have sector granularity * I/O we need to re-read the same sectors even for adjacent * compressed clusters. */ res->bfi.fragmented_clusters++; } break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } /* fall through */ case QCOW2_CLUSTER_NORMAL: { /* QCOW_OFLAG_COPIED must be set iff refcount == 1 */ uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (flags & CHECK_OFLAG_COPIED) { refcount = get_refcount(bs, offset >> s->cluster_bits); if (refcount < 0) { fprintf(stderr, "Can't get refcount for offset %" PRIx64 ": %s\n", l2_entry, strerror(-refcount)); goto fail; } if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" PRIx64 " refcount=%d\n", l2_entry, refcount); res->corruptions++; } } if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; if (next_contiguous_offset && offset != next_contiguous_offset) { res->bfi.fragmented_clusters++; } next_contiguous_offset = offset + s->cluster_size; } /* Mark cluster as used */ inc_refcounts(bs, res, refcount_table,refcount_table_size, offset, s->cluster_size); /* Correct offsets are cluster aligned */ if (offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); g_free(l2_table); return -EIO; } /* * Increases the refcount for the L1 table, its L2 tables and all referenced * clusters in the given refcount table. While doing so, performs some checks * on L1 and L2 entries. * * Returns the number of errors found by the checks or -errno if an internal * error occurred. */ static int check_refcounts_l1(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l1_table_offset, int l1_size, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l1_table, l2_offset, l1_size2; int i, refcount, ret; l1_size2 = l1_size * sizeof(uint64_t); /* Mark L1 table as used */ inc_refcounts(bs, res, refcount_table, refcount_table_size, l1_table_offset, l1_size2); /* Read L1 table entries from disk */ if (l1_size2 == 0) { l1_table = NULL; } else { l1_table = g_malloc(l1_size2); if (bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2) != l1_size2) goto fail; for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); } /* Do the actual checks */ for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { /* QCOW_OFLAG_COPIED must be set iff refcount == 1 */ if (flags & CHECK_OFLAG_COPIED) { refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if (refcount < 0) { fprintf(stderr, "Can't get refcount for l2_offset %" PRIx64 ": %s\n", l2_offset, strerror(-refcount)); goto fail; } if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: l2_offset=%" PRIx64 " refcount=%d\n", l2_offset, refcount); res->corruptions++; } } /* Mark L2 table as used */ l2_offset &= L1E_OFFSET_MASK; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_offset, s->cluster_size); /* L2 tables are cluster aligned */ if (l2_offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not " "cluster aligned; L1 entry corrupted\n", l2_offset); res->corruptions++; } /* Process and check L2 entries */ ret = check_refcounts_l2(bs, res, refcount_table, refcount_table_size, l2_offset, flags); if (ret < 0) { goto fail; } } } g_free(l1_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; g_free(l1_table); return -EIO; } /* * Checks an image for refcount consistency. * * Returns 0 if no errors are found, the number of errors in case the image is * detected as corrupted, and -errno when an internal error occurred. */ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVQcowState *s = bs->opaque; int64_t size, i, highest_cluster; int nb_clusters, refcount1, refcount2; QCowSnapshot *sn; uint16_t *refcount_table; int ret; size = bdrv_getlength(bs->file); nb_clusters = size_to_clusters(s, size); refcount_table = g_malloc0(nb_clusters * sizeof(uint16_t)); res->bfi.total_clusters = size_to_clusters(s, bs->total_sectors * BDRV_SECTOR_SIZE); /* header */ inc_refcounts(bs, res, refcount_table, nb_clusters, 0, s->cluster_size); /* current L1 table */ ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, s->l1_table_offset, s->l1_size, CHECK_OFLAG_COPIED | CHECK_FRAG_INFO); if (ret < 0) { goto fail; } /* snapshots */ for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, sn->l1_table_offset, sn->l1_size, 0); if (ret < 0) { goto fail; } } inc_refcounts(bs, res, refcount_table, nb_clusters, s->snapshots_offset, s->snapshots_size); /* refcount data */ inc_refcounts(bs, res, refcount_table, nb_clusters, s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t)); for(i = 0; i < s->refcount_table_size; i++) { uint64_t offset, cluster; offset = s->refcount_table[i]; cluster = offset >> s->cluster_bits; /* Refcount blocks are cluster aligned */ if (offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR refcount block %" PRId64 " is not " "cluster aligned; refcount table entry corrupted\n", i); res->corruptions++; continue; } if (cluster >= nb_clusters) { fprintf(stderr, "ERROR refcount block %" PRId64 " is outside image\n", i); res->corruptions++; continue; } if (offset != 0) { inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (refcount_table[cluster] != 1) { fprintf(stderr, "ERROR refcount block %" PRId64 " refcount=%d\n", i, refcount_table[cluster]); res->corruptions++; } } } /* compare ref counts */ for (i = 0, highest_cluster = 0; i < nb_clusters; i++) { refcount1 = get_refcount(bs, i); if (refcount1 < 0) { fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n", i, strerror(-refcount1)); res->check_errors++; continue; } refcount2 = refcount_table[i]; if (refcount1 > 0 || refcount2 > 0) { highest_cluster = i; } if (refcount1 != refcount2) { /* Check if we're allowed to fix the mismatch */ int *num_fixed = NULL; if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) { num_fixed = &res->leaks_fixed; } else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) { num_fixed = &res->corruptions_fixed; } fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n", num_fixed != NULL ? "Repairing" : refcount1 < refcount2 ? "ERROR" : "Leaked", i, refcount1, refcount2); if (num_fixed) { ret = update_refcount(bs, i << s->cluster_bits, 1, refcount2 - refcount1, QCOW2_DISCARD_ALWAYS); if (ret >= 0) { (*num_fixed)++; continue; } } /* And if we couldn't, print an error */ if (refcount1 < refcount2) { res->corruptions++; } else { res->leaks++; } } } res->image_end_offset = (highest_cluster + 1) * s->cluster_size; ret = 0; fail: g_free(refcount_table); return ret; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qcow2.c0000644000076200007630000000013112617742532021431 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 30 ctime=1447019941.728332821 glusterfs-3.7.6/contrib/qemu/block/qcow2.c0000644000076200007630000015347712617742532021670 0ustar00jenkinsjenkins00000000000000/* * Block driver for the QCOW version 2 format * * Copyright (c) 2004-2006 Fabrice Bellard * * 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. */ #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" #include #include "qemu/aes.h" #include "block/qcow2.h" #include "qemu/error-report.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qbool.h" #include "trace.h" /* Differences with QCOW: - Support for multiple incremental snapshots. - Memory management by reference counts. - Clusters which have a reference count of one have the bit QCOW_OFLAG_COPIED to optimize write performance. - Size of compressed clusters is stored in sectors to reduce bit usage in the cluster offsets. - Support for storing additional data (such as the VM state) in the snapshots. - If a backing store is used, the cluster size is not constrained (could be backported to QCOW). - L2 tables have always a size of one cluster. */ typedef struct { uint32_t magic; uint32_t len; } QCowExtension; #define QCOW2_EXT_MAGIC_END 0 #define QCOW2_EXT_MAGIC_BACKING_FORMAT 0xE2792ACA #define QCOW2_EXT_MAGIC_FEATURE_TABLE 0x6803f857 static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename) { const QCowHeader *cow_header = (const void *)buf; if (buf_size >= sizeof(QCowHeader) && be32_to_cpu(cow_header->magic) == QCOW_MAGIC && be32_to_cpu(cow_header->version) >= 2) return 100; else return 0; } /* * read qcow2 extension and fill bs * start reading from start_offset * finish reading upon magic of value 0 or when end_offset reached * unknown magic is skipped (future extension this version knows nothing about) * return 0 upon success, non-0 otherwise */ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uint64_t end_offset, void **p_feature_table) { BDRVQcowState *s = bs->opaque; QCowExtension ext; uint64_t offset; int ret; #ifdef DEBUG_EXT printf("qcow2_read_extensions: start=%ld end=%ld\n", start_offset, end_offset); #endif offset = start_offset; while (offset < end_offset) { #ifdef DEBUG_EXT /* Sanity check */ if (offset > s->cluster_size) printf("qcow2_read_extension: suspicious offset %lu\n", offset); printf("attempting to read extended header in offset %lu\n", offset); #endif if (bdrv_pread(bs->file, offset, &ext, sizeof(ext)) != sizeof(ext)) { fprintf(stderr, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64 "\n", offset); return 1; } be32_to_cpus(&ext.magic); be32_to_cpus(&ext.len); offset += sizeof(ext); #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); #endif if (ext.len > end_offset - offset) { error_report("Header extension too large"); return -EINVAL; } switch (ext.magic) { case QCOW2_EXT_MAGIC_END: return 0; case QCOW2_EXT_MAGIC_BACKING_FORMAT: if (ext.len >= sizeof(bs->backing_format)) { fprintf(stderr, "ERROR: ext_backing_format: len=%u too large" " (>=%zu)\n", ext.len, sizeof(bs->backing_format)); return 2; } if (bdrv_pread(bs->file, offset , bs->backing_format, ext.len) != ext.len) return 3; bs->backing_format[ext.len] = '\0'; #ifdef DEBUG_EXT printf("Qcow2: Got format extension %s\n", bs->backing_format); #endif break; case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table != NULL) { void* feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature)); ret = bdrv_pread(bs->file, offset , feature_table, ext.len); if (ret < 0) { return ret; } *p_feature_table = feature_table; } break; default: /* unknown magic - save it in case we need to rewrite the header */ { Qcow2UnknownHeaderExtension *uext; uext = g_malloc0(sizeof(*uext) + ext.len); uext->magic = ext.magic; uext->len = ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); ret = bdrv_pread(bs->file, offset , uext->data, uext->len); if (ret < 0) { return ret; } } break; } offset += ((ext.len + 7) & ~7); } return 0; } static void cleanup_unknown_header_ext(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; Qcow2UnknownHeaderExtension *uext, *next; QLIST_FOREACH_SAFE(uext, &s->unknown_header_ext, next, next) { QLIST_REMOVE(uext, next); g_free(uext); } } static void GCC_FMT_ATTR(2, 3) report_unsupported(BlockDriverState *bs, const char *fmt, ...) { char msg[64]; va_list ap; va_start(ap, fmt); vsnprintf(msg, sizeof(msg), fmt, ap); va_end(ap); qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "qcow2", msg); } static void report_unsupported_feature(BlockDriverState *bs, Qcow2Feature *table, uint64_t mask) { while (table && table->name[0] != '\0') { if (table->type == QCOW2_FEAT_TYPE_INCOMPATIBLE) { if (mask & (1 << table->bit)) { report_unsupported(bs, "%.46s",table->name); mask &= ~(1 << table->bit); } } table++; } if (mask) { report_unsupported(bs, "Unknown incompatible feature: %" PRIx64, mask); } } /* * Sets the dirty bit and flushes afterwards if necessary. * * The incompatible_features bit is only set if the image file header was * updated successfully. Therefore it is not required to check the return * value of this function. */ int qcow2_mark_dirty(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; uint64_t val; int ret; assert(s->qcow_version >= 3); if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) { return 0; /* already dirty */ } val = cpu_to_be64(s->incompatible_features | QCOW2_INCOMPAT_DIRTY); ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, incompatible_features), &val, sizeof(val)); if (ret < 0) { return ret; } ret = bdrv_flush(bs->file); if (ret < 0) { return ret; } /* Only treat image as dirty if the header was updated successfully */ s->incompatible_features |= QCOW2_INCOMPAT_DIRTY; return 0; } /* * Clears the dirty bit and flushes before if necessary. Only call this * function when there are no pending requests, it does not guard against * concurrent requests dirtying the image. */ static int qcow2_mark_clean(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) { int ret = bdrv_flush(bs); if (ret < 0) { return ret; } s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY; return qcow2_update_header(bs); } return 0; } static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) { int ret = qcow2_check_refcounts(bs, result, fix); if (ret < 0) { return ret; } if (fix && result->check_errors == 0 && result->corruptions == 0) { return qcow2_mark_clean(bs); } return ret; } static QemuOptsList qcow2_runtime_opts = { .name = "qcow2", .head = QTAILQ_HEAD_INITIALIZER(qcow2_runtime_opts.head), .desc = { { .name = "lazy_refcounts", .type = QEMU_OPT_BOOL, .help = "Postpone refcount updates", }, { .name = QCOW2_OPT_DISCARD_REQUEST, .type = QEMU_OPT_BOOL, .help = "Pass guest discard requests to the layer below", }, { .name = QCOW2_OPT_DISCARD_SNAPSHOT, .type = QEMU_OPT_BOOL, .help = "Generate discard requests when snapshot related space " "is freed", }, { .name = QCOW2_OPT_DISCARD_OTHER, .type = QEMU_OPT_BOOL, .help = "Generate discard requests when other clusters are freed", }, { /* end of list */ } }, }; static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) { BDRVQcowState *s = bs->opaque; int len, i, ret = 0; QCowHeader header; QemuOpts *opts; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be64_to_cpus(&header.size); be32_to_cpus(&header.cluster_bits); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); be32_to_cpus(&header.l1_size); be64_to_cpus(&header.refcount_table_offset); be32_to_cpus(&header.refcount_table_clusters); be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); if (header.magic != QCOW_MAGIC) { ret = -EMEDIUMTYPE; goto fail; } if (header.version < 2 || header.version > 3) { report_unsupported(bs, "QCOW version %d", header.version); ret = -ENOTSUP; goto fail; } s->qcow_version = header.version; /* Initialise version 3 header fields */ if (header.version == 2) { header.incompatible_features = 0; header.compatible_features = 0; header.autoclear_features = 0; header.refcount_order = 4; header.header_length = 72; } else { be64_to_cpus(&header.incompatible_features); be64_to_cpus(&header.compatible_features); be64_to_cpus(&header.autoclear_features); be32_to_cpus(&header.refcount_order); be32_to_cpus(&header.header_length); } if (header.header_length > sizeof(header)) { s->unknown_header_fields_size = header.header_length - sizeof(header); s->unknown_header_fields = g_malloc(s->unknown_header_fields_size); ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields, s->unknown_header_fields_size); if (ret < 0) { goto fail; } } if (header.backing_file_offset) { ext_end = header.backing_file_offset; } else { ext_end = 1 << header.cluster_bits; } /* Handle feature bits */ s->incompatible_features = header.incompatible_features; s->compatible_features = header.compatible_features; s->autoclear_features = header.autoclear_features; if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) { void *feature_table = NULL; qcow2_read_extensions(bs, header.header_length, ext_end, &feature_table); report_unsupported_feature(bs, feature_table, s->incompatible_features & ~QCOW2_INCOMPAT_MASK); ret = -ENOTSUP; goto fail; } /* Check support for various header values */ if (header.refcount_order != 4) { report_unsupported(bs, "%d bit reference counts", 1 << header.refcount_order); ret = -ENOTSUP; goto fail; } if (header.cluster_bits < MIN_CLUSTER_BITS || header.cluster_bits > MAX_CLUSTER_BITS) { ret = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { ret = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */ s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; s->refcount_table_offset = header.refcount_table_offset; s->refcount_table_size = header.refcount_table_clusters << (s->cluster_bits - 3); s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; /* read the level 1 table */ s->l1_size = header.l1_size; l1_vm_state_index = size_to_l1(s, header.size); if (l1_vm_state_index > INT_MAX) { ret = -EFBIG; goto fail; } s->l1_vm_state_index = l1_vm_state_index; /* the L1 table must contain at least enough entries to put header.size bytes */ if (s->l1_size < s->l1_vm_state_index) { ret = -EINVAL; goto fail; } s->l1_table_offset = header.l1_table_offset; if (s->l1_size > 0) { s->l1_table = g_malloc0( align_offset(s->l1_size * sizeof(uint64_t), 512)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; } for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } } /* alloc L2 table/refcount block cache */ s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE); s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE); s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); s->cluster_cache_offset = -1; s->flags = flags; ret = qcow2_refcount_init(bs); if (ret != 0) { goto fail; } QLIST_INIT(&s->cluster_allocs); QTAILQ_INIT(&s->discards); /* read qcow2 extensions */ if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL)) { ret = -EINVAL; goto fail; } /* read the backing file name */ if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; } ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { goto fail; } bs->backing_file[len] = '\0'; } ret = qcow2_read_snapshots(bs); if (ret < 0) { goto fail; } /* Clear unknown autoclear feature bits */ if (!bs->read_only && s->autoclear_features != 0) { s->autoclear_features = 0; ret = qcow2_update_header(bs); if (ret < 0) { goto fail; } } /* Initialise locks */ qemu_co_mutex_init(&s->lock); /* Repair image if dirty */ if (!(flags & BDRV_O_CHECK) && !bs->read_only && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result = {0}; ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS); if (ret < 0) { goto fail; } } /* Enable lazy_refcounts according to image and command line options */ opts = qemu_opts_create_nofail(&qcow2_runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); ret = -EINVAL; goto fail; } s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); qemu_opts_del(opts); if (s->use_lazy_refcounts && s->qcow_version < 3) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Lazy refcounts require " "a qcow2 image with at least qemu 1.1 compatibility level"); ret = -EINVAL; goto fail; } #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); } #endif return ret; fail: g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); qcow2_refcount_close(bs); g_free(s->l1_table); if (s->l2_table_cache) { qcow2_cache_destroy(bs, s->l2_table_cache); } g_free(s->cluster_cache); qemu_vfree(s->cluster_data); return ret; } static int qcow2_set_key(BlockDriverState *bs, const char *key) { BDRVQcowState *s = bs->opaque; uint8_t keybuf[16]; int len, i; memset(keybuf, 0, 16); len = strlen(key); if (len > 16) len = 16; /* XXX: we could compress the chars to 7 bits to increase entropy */ for(i = 0;i < len;i++) { keybuf[i] = key[i]; } s->crypt_method = s->crypt_method_header; if (AES_set_encrypt_key(keybuf, 128, &s->aes_encrypt_key) != 0) return -1; if (AES_set_decrypt_key(keybuf, 128, &s->aes_decrypt_key) != 0) return -1; #if 0 /* test */ { uint8_t in[16]; uint8_t out[16]; uint8_t tmp[16]; for(i=0;i<16;i++) in[i] = i; AES_encrypt(in, tmp, &s->aes_encrypt_key); AES_decrypt(tmp, out, &s->aes_decrypt_key); for(i = 0; i < 16; i++) printf(" %02x", tmp[i]); printf("\n"); for(i = 0; i < 16; i++) printf(" %02x", out[i]); printf("\n"); } #endif return 0; } /* We have nothing to do for QCOW2 reopen, stubs just return * success */ static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { return 0; } static int coroutine_fn qcow2_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVQcowState *s = bs->opaque; uint64_t cluster_offset; int ret; *pnum = nb_sectors; /* FIXME We can get errors here, but the bdrv_co_is_allocated interface * can't pass them on today */ qemu_co_mutex_lock(&s->lock); ret = qcow2_get_cluster_offset(bs, sector_num << 9, pnum, &cluster_offset); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { *pnum = 0; } return (cluster_offset != 0) || (ret == QCOW2_CLUSTER_ZERO); } /* handle reading after the end of the backing file */ int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, int64_t sector_num, int nb_sectors) { int n1; if ((sector_num + nb_sectors) <= bs->total_sectors) return nb_sectors; if (sector_num >= bs->total_sectors) n1 = 0; else n1 = bs->total_sectors - sector_num; qemu_iovec_memset(qiov, 512 * n1, 0, 512 * (nb_sectors - n1)); return n1; } static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, int remaining_sectors, QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; int index_in_cluster, n1; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ uint64_t cluster_offset = 0; uint64_t bytes_done = 0; QEMUIOVector hd_qiov; uint8_t *cluster_data = NULL; qemu_iovec_init(&hd_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); while (remaining_sectors != 0) { /* prepare next request */ cur_nr_sectors = remaining_sectors; if (s->crypt_method) { cur_nr_sectors = MIN(cur_nr_sectors, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors); } ret = qcow2_get_cluster_offset(bs, sector_num << 9, &cur_nr_sectors, &cluster_offset); if (ret < 0) { goto fail; } index_in_cluster = sector_num & (s->cluster_sectors - 1); qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_nr_sectors * 512); switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: if (bs->backing_hd) { /* read from the base image */ n1 = qcow2_backing_read1(bs->backing_hd, &hd_qiov, sector_num, cur_nr_sectors); if (n1 > 0) { BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_readv(bs->backing_hd, sector_num, n1, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } } } else { /* Note: in this case, no need to wait */ qemu_iovec_memset(&hd_qiov, 0, 0, 512 * cur_nr_sectors); } break; case QCOW2_CLUSTER_ZERO: qemu_iovec_memset(&hd_qiov, 0, 0, 512 * cur_nr_sectors); break; case QCOW2_CLUSTER_COMPRESSED: /* add AIO support for compressed blocks ? */ ret = qcow2_decompress_cluster(bs, cluster_offset); if (ret < 0) { goto fail; } qemu_iovec_from_buf(&hd_qiov, 0, s->cluster_cache + index_in_cluster * 512, 512 * cur_nr_sectors); break; case QCOW2_CLUSTER_NORMAL: if ((cluster_offset & 511) != 0) { ret = -EIO; goto fail; } if (s->crypt_method) { /* * For encrypted images, read everything into a temporary * contiguous buffer on which the AES functions can work. */ if (!cluster_data) { cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } assert(cur_nr_sectors <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors); qemu_iovec_reset(&hd_qiov); qemu_iovec_add(&hd_qiov, cluster_data, 512 * cur_nr_sectors); } BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_readv(bs->file, (cluster_offset >> 9) + index_in_cluster, cur_nr_sectors, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } if (s->crypt_method) { qcow2_encrypt_sectors(s, sector_num, cluster_data, cluster_data, cur_nr_sectors, 0, &s->aes_decrypt_key); qemu_iovec_from_buf(qiov, bytes_done, cluster_data, 512 * cur_nr_sectors); } break; default: g_assert_not_reached(); ret = -EIO; goto fail; } remaining_sectors -= cur_nr_sectors; sector_num += cur_nr_sectors; bytes_done += cur_nr_sectors * 512; } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); qemu_iovec_destroy(&hd_qiov); qemu_vfree(cluster_data); return ret; } static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, int64_t sector_num, int remaining_sectors, QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; int index_in_cluster; int n_end; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ uint64_t cluster_offset; QEMUIOVector hd_qiov; uint64_t bytes_done = 0; uint8_t *cluster_data = NULL; QCowL2Meta *l2meta = NULL; trace_qcow2_writev_start_req(qemu_coroutine_self(), sector_num, remaining_sectors); qemu_iovec_init(&hd_qiov, qiov->niov); s->cluster_cache_offset = -1; /* disable compressed cache */ qemu_co_mutex_lock(&s->lock); while (remaining_sectors != 0) { l2meta = NULL; trace_qcow2_writev_start_part(qemu_coroutine_self()); index_in_cluster = sector_num & (s->cluster_sectors - 1); n_end = index_in_cluster + remaining_sectors; if (s->crypt_method && n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors) { n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors; } ret = qcow2_alloc_cluster_offset(bs, sector_num << 9, index_in_cluster, n_end, &cur_nr_sectors, &cluster_offset, &l2meta); if (ret < 0) { goto fail; } assert((cluster_offset & 511) == 0); qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_nr_sectors * 512); if (s->crypt_method) { if (!cluster_data) { cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } assert(hd_qiov.size <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); qcow2_encrypt_sectors(s, sector_num, cluster_data, cluster_data, cur_nr_sectors, 1, &s->aes_encrypt_key); qemu_iovec_reset(&hd_qiov); qemu_iovec_add(&hd_qiov, cluster_data, cur_nr_sectors * 512); } qemu_co_mutex_unlock(&s->lock); BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), (cluster_offset >> 9) + index_in_cluster); ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + index_in_cluster, cur_nr_sectors, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } while (l2meta != NULL) { QCowL2Meta *next; ret = qcow2_alloc_cluster_link_l2(bs, l2meta); if (ret < 0) { goto fail; } /* Take the request off the list of running requests */ if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } remaining_sectors -= cur_nr_sectors; sector_num += cur_nr_sectors; bytes_done += cur_nr_sectors * 512; trace_qcow2_writev_done_part(qemu_coroutine_self(), cur_nr_sectors); } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); while (l2meta != NULL) { QCowL2Meta *next; if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } qemu_iovec_destroy(&hd_qiov); qemu_vfree(cluster_data); trace_qcow2_writev_done_req(qemu_coroutine_self(), ret); return ret; } static void qcow2_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; g_free(s->l1_table); qcow2_cache_flush(bs, s->l2_table_cache); qcow2_cache_flush(bs, s->refcount_block_cache); qcow2_mark_clean(bs); qcow2_cache_destroy(bs, s->l2_table_cache); qcow2_cache_destroy(bs, s->refcount_block_cache); g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); g_free(s->cluster_cache); qemu_vfree(s->cluster_data); qcow2_refcount_close(bs); qcow2_free_snapshots(bs); } static void qcow2_invalidate_cache(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int flags = s->flags; AES_KEY aes_encrypt_key; AES_KEY aes_decrypt_key; uint32_t crypt_method = 0; QDict *options; /* * Backing files are read-only which makes all of their metadata immutable, * that means we don't have to worry about reopening them here. */ if (s->crypt_method) { crypt_method = s->crypt_method; memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key)); memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key)); } qcow2_close(bs); options = qdict_new(); qdict_put(options, QCOW2_OPT_LAZY_REFCOUNTS, qbool_from_int(s->use_lazy_refcounts)); memset(s, 0, sizeof(BDRVQcowState)); qcow2_open(bs, options, flags); QDECREF(options); if (crypt_method) { s->crypt_method = crypt_method; memcpy(&s->aes_encrypt_key, &aes_encrypt_key, sizeof(aes_encrypt_key)); memcpy(&s->aes_decrypt_key, &aes_decrypt_key, sizeof(aes_decrypt_key)); } } static size_t header_ext_add(char *buf, uint32_t magic, const void *s, size_t len, size_t buflen) { QCowExtension *ext_backing_fmt = (QCowExtension*) buf; size_t ext_len = sizeof(QCowExtension) + ((len + 7) & ~7); if (buflen < ext_len) { return -ENOSPC; } *ext_backing_fmt = (QCowExtension) { .magic = cpu_to_be32(magic), .len = cpu_to_be32(len), }; memcpy(buf + sizeof(QCowExtension), s, len); return ext_len; } /* * Updates the qcow2 header, including the variable length parts of it, i.e. * the backing file name and all extensions. qcow2 was not designed to allow * such changes, so if we run out of space (we can only use the first cluster) * this function may fail. * * Returns 0 on success, -errno in error cases. */ int qcow2_update_header(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; int ret; uint64_t total_size; uint32_t refcount_table_clusters; size_t header_length; Qcow2UnknownHeaderExtension *uext; buf = qemu_blockalign(bs, buflen); /* Header structure */ header = (QCowHeader*) buf; if (buflen < sizeof(*header)) { ret = -ENOSPC; goto fail; } header_length = sizeof(*header) + s->unknown_header_fields_size; total_size = bs->total_sectors * BDRV_SECTOR_SIZE; refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3); *header = (QCowHeader) { /* Version 2 fields */ .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(total_size), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .refcount_table_clusters = cpu_to_be32(refcount_table_clusters), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), /* Version 3 fields */ .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT), .header_length = cpu_to_be32(header_length), }; /* For older versions, write a shorter header */ switch (s->qcow_version) { case 2: ret = offsetof(QCowHeader, incompatible_features); break; case 3: ret = sizeof(*header); break; default: ret = -EINVAL; goto fail; } buf += ret; buflen -= ret; memset(buf, 0, buflen); /* Preserve any unknown field in the header */ if (s->unknown_header_fields_size) { if (buflen < s->unknown_header_fields_size) { ret = -ENOSPC; goto fail; } memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size); buf += s->unknown_header_fields_size; buflen -= s->unknown_header_fields_size; } /* Backing file format header extension */ if (*bs->backing_format) { ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } /* Feature table */ Qcow2Feature features[] = { { .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", }, { .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }, }; ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, features, sizeof(features), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; /* Keep unknown header extensions */ QLIST_FOREACH(uext, &s->unknown_header_ext, next) { ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } /* End of header extensions */ ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; /* Backing file name */ if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; } /* Using strncpy is ok here, since buf is not NUL-terminated. */ strncpy(buf, bs->backing_file, buflen); header->backing_file_offset = cpu_to_be64(buf - ((char*) header)); header->backing_file_size = cpu_to_be32(backing_file_len); } /* Write the new header */ ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); if (ret < 0) { goto fail; } ret = 0; fail: qemu_vfree(header); return ret; } static int qcow2_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); return qcow2_update_header(bs); } static int preallocate(BlockDriverState *bs) { uint64_t nb_sectors; uint64_t offset; uint64_t host_offset = 0; int num; int ret; QCowL2Meta *meta; nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &host_offset, &meta); if (ret < 0) { return ret; } ret = qcow2_alloc_cluster_link_l2(bs, meta); if (ret < 0) { qcow2_free_any_clusters(bs, meta->alloc_offset, meta->nb_clusters, QCOW2_DISCARD_NEVER); return ret; } /* There are no dependent requests, but we need to remove our request * from the list of in-flight requests */ if (meta != NULL) { QLIST_REMOVE(meta, next_in_flight); } /* TODO Preallocate data if requested */ nb_sectors -= num; offset += num << 9; } /* * It is expected that the image file is large enough to actually contain * all of the allocated clusters (otherwise we get failing reads after * EOF). Extend the image to the last allocated sector. */ if (host_offset != 0) { uint8_t buf[512]; memset(buf, 0, 512); ret = bdrv_write(bs->file, (host_offset >> 9) + num - 1, buf, 1); if (ret < 0) { return ret; } } return 0; } static int qcow2_create2(const char *filename, int64_t total_size, const char *backing_file, const char *backing_format, int flags, size_t cluster_size, int prealloc, QEMUOptionParameter *options, int version) { /* Calculate cluster_bits */ int cluster_bits; cluster_bits = ffs(cluster_size) - 1; if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS || (1 << cluster_bits) != cluster_size) { error_report( "Cluster size must be a power of two between %d and %dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10)); return -EINVAL; } /* * Open the image file and write a minimal qcow2 header. * * We keep things simple and start with a zero-sized image. We also * do without refcount blocks or a L1 table for now. We'll fix the * inconsistency later. * * We do need a refcount table because growing the refcount table means * allocating two new refcount blocks - the seconds of which would be at * 2 GB for 64k clusters, and we don't want to have a 2 GB initial file * size for any qcow2 image. */ BlockDriverState* bs; QCowHeader header; uint8_t* refcount_table; int ret; ret = bdrv_create_file(filename, options); if (ret < 0) { return ret; } ret = bdrv_file_open(&bs, filename, NULL, BDRV_O_RDWR); if (ret < 0) { return ret; } /* Write the header */ memset(&header, 0, sizeof(header)); header.magic = cpu_to_be32(QCOW_MAGIC); header.version = cpu_to_be32(version); header.cluster_bits = cpu_to_be32(cluster_bits); header.size = cpu_to_be64(0); header.l1_table_offset = cpu_to_be64(0); header.l1_size = cpu_to_be32(0); header.refcount_table_offset = cpu_to_be64(cluster_size); header.refcount_table_clusters = cpu_to_be32(1); header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT); header.header_length = cpu_to_be32(sizeof(header)); if (flags & BLOCK_FLAG_ENCRYPT) { header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES); } else { header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE); } if (flags & BLOCK_FLAG_LAZY_REFCOUNTS) { header.compatible_features |= cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS); } ret = bdrv_pwrite(bs, 0, &header, sizeof(header)); if (ret < 0) { goto out; } /* Write an empty refcount table */ refcount_table = g_malloc0(cluster_size); ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size); g_free(refcount_table); if (ret < 0) { goto out; } bdrv_close(bs); /* * And now open the image and make it consistent first (i.e. increase the * refcount of the cluster that is occupied by the header and the refcount * table) */ BlockDriver* drv = bdrv_find_format("qcow2"); assert(drv != NULL); ret = bdrv_open(bs, filename, NULL, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv); if (ret < 0) { goto out; } ret = qcow2_alloc_clusters(bs, 2 * cluster_size); if (ret < 0) { goto out; } else if (ret != 0) { error_report("Huh, first cluster in empty image is already in use?"); abort(); } /* Okay, now that we have a valid image, let's give it the right size */ ret = bdrv_truncate(bs, total_size * BDRV_SECTOR_SIZE); if (ret < 0) { goto out; } /* Want a backing file? There you go.*/ if (backing_file) { ret = bdrv_change_backing_file(bs, backing_file, backing_format); if (ret < 0) { goto out; } } /* And if we're supposed to preallocate metadata, do that now */ if (prealloc) { BDRVQcowState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = preallocate(bs); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { goto out; } } ret = 0; out: bdrv_delete(bs); return ret; } static int qcow2_create(const char *filename, QEMUOptionParameter *options) { const char *backing_file = NULL; const char *backing_fmt = NULL; uint64_t sectors = 0; int flags = 0; size_t cluster_size = DEFAULT_CLUSTER_SIZE; int prealloc = 0; int version = 2; /* Read out options */ while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { sectors = options->value.n / 512; } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { backing_file = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) { backing_fmt = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) { flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0; } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) { if (options->value.n) { cluster_size = options->value.n; } } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) { if (!options->value.s || !strcmp(options->value.s, "off")) { prealloc = 0; } else if (!strcmp(options->value.s, "metadata")) { prealloc = 1; } else { fprintf(stderr, "Invalid preallocation mode: '%s'\n", options->value.s); return -EINVAL; } } else if (!strcmp(options->name, BLOCK_OPT_COMPAT_LEVEL)) { if (!options->value.s || !strcmp(options->value.s, "0.10")) { version = 2; } else if (!strcmp(options->value.s, "1.1")) { version = 3; } else { fprintf(stderr, "Invalid compatibility level: '%s'\n", options->value.s); return -EINVAL; } } else if (!strcmp(options->name, BLOCK_OPT_LAZY_REFCOUNTS)) { flags |= options->value.n ? BLOCK_FLAG_LAZY_REFCOUNTS : 0; } options++; } if (backing_file && prealloc) { fprintf(stderr, "Backing file and preallocation cannot be used at " "the same time\n"); return -EINVAL; } if (version < 3 && (flags & BLOCK_FLAG_LAZY_REFCOUNTS)) { fprintf(stderr, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)\n"); return -EINVAL; } return qcow2_create2(filename, sectors, backing_file, backing_fmt, flags, cluster_size, prealloc, options, version); } static int qcow2_make_empty(BlockDriverState *bs) { #if 0 /* XXX: not correct */ BDRVQcowState *s = bs->opaque; uint32_t l1_length = s->l1_size * sizeof(uint64_t); int ret; memset(s->l1_table, 0, l1_length); if (bdrv_pwrite(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0) return -1; ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length); if (ret < 0) return ret; l2_cache_reset(bs); #endif return 0; } static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { int ret; BDRVQcowState *s = bs->opaque; /* Emulate misaligned zero writes */ if (sector_num % s->cluster_sectors || nb_sectors % s->cluster_sectors) { return -ENOTSUP; } /* Whatever is left can use real zero clusters */ qemu_co_mutex_lock(&s->lock); ret = qcow2_zero_clusters(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; } static coroutine_fn int qcow2_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { int ret; BDRVQcowState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = qcow2_discard_clusters(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; } static int qcow2_truncate(BlockDriverState *bs, int64_t offset) { BDRVQcowState *s = bs->opaque; int64_t new_l1_size; int ret; if (offset & 511) { error_report("The new size must be a multiple of 512"); return -EINVAL; } /* cannot proceed if image has snapshots */ if (s->nb_snapshots) { error_report("Can't resize an image which has snapshots"); return -ENOTSUP; } /* shrinking is currently not supported */ if (offset < bs->total_sectors * 512) { error_report("qcow2 doesn't support shrinking images yet"); return -ENOTSUP; } new_l1_size = size_to_l1(s, offset); ret = qcow2_grow_l1_table(bs, new_l1_size, true); if (ret < 0) { return ret; } /* write updated header.size */ offset = cpu_to_be64(offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), &offset, sizeof(uint64_t)); if (ret < 0) { return ret; } s->l1_vm_state_index = new_l1_size; return 0; } /* XXX: put compressed sectors first, then all the cluster aligned tables to avoid losing bytes in alignment */ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BDRVQcowState *s = bs->opaque; z_stream strm; int ret, out_len; uint8_t *out_buf; uint64_t cluster_offset; if (nb_sectors == 0) { /* align end of file to a sector boundary to ease reading with sector based I/Os */ cluster_offset = bdrv_getlength(bs->file); cluster_offset = (cluster_offset + 511) & ~511; bdrv_truncate(bs->file, cluster_offset); return 0; } if (nb_sectors != s->cluster_sectors) { ret = -EINVAL; /* Zero-pad last write if image size is not cluster aligned */ if (sector_num + nb_sectors == bs->total_sectors && nb_sectors < s->cluster_sectors) { uint8_t *pad_buf = qemu_blockalign(bs, s->cluster_size); memset(pad_buf, 0, s->cluster_size); memcpy(pad_buf, buf, nb_sectors * BDRV_SECTOR_SIZE); ret = qcow2_write_compressed(bs, sector_num, pad_buf, s->cluster_sectors); qemu_vfree(pad_buf); } return ret; } out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); /* best compression, small window, no zlib header */ memset(&strm, 0, sizeof(strm)); ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -12, 9, Z_DEFAULT_STRATEGY); if (ret != 0) { ret = -EINVAL; goto fail; } strm.avail_in = s->cluster_size; strm.next_in = (uint8_t *)buf; strm.avail_out = s->cluster_size; strm.next_out = out_buf; ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK) { deflateEnd(&strm); ret = -EINVAL; goto fail; } out_len = strm.next_out - out_buf; deflateEnd(&strm); if (ret != Z_STREAM_END || out_len >= s->cluster_size) { /* could not compress: write normal cluster */ ret = bdrv_write(bs, sector_num, buf, s->cluster_sectors); if (ret < 0) { goto fail; } } else { cluster_offset = qcow2_alloc_compressed_cluster_offset(bs, sector_num << 9, out_len); if (!cluster_offset) { ret = -EIO; goto fail; } cluster_offset &= s->cluster_offset_mask; BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); ret = bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len); if (ret < 0) { goto fail; } } ret = 0; fail: g_free(out_buf); return ret; } static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int ret; qemu_co_mutex_lock(&s->lock); ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; } if (qcow2_need_accurate_refcounts(s)) { ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; } } qemu_co_mutex_unlock(&s->lock); return 0; } static int64_t qcow2_vm_state_offset(BDRVQcowState *s) { return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits); } static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQcowState *s = bs->opaque; bdi->cluster_size = s->cluster_size; bdi->vm_state_offset = qcow2_vm_state_offset(s); return 0; } #if 0 static void dump_refcounts(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int64_t nb_clusters, k, k1, size; int refcount; size = bdrv_getlength(bs->file); nb_clusters = size_to_clusters(s, size); for(k = 0; k < nb_clusters;) { k1 = k; refcount = get_refcount(bs, k); k++; while (k < nb_clusters && get_refcount(bs, k) == refcount) k++; printf("%" PRId64 ": refcount=%d nb=%" PRId64 "\n", k, refcount, k - k1); } } #endif static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BDRVQcowState *s = bs->opaque; int growable = bs->growable; int ret; BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); bs->growable = 1; ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov); bs->growable = growable; return ret; } static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size) { BDRVQcowState *s = bs->opaque; int growable = bs->growable; int ret; BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); bs->growable = 1; ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size); bs->growable = growable; return ret; } static QEMUOptionParameter qcow2_create_options[] = { { .name = BLOCK_OPT_SIZE, .type = OPT_SIZE, .help = "Virtual disk size" }, { .name = BLOCK_OPT_COMPAT_LEVEL, .type = OPT_STRING, .help = "Compatibility level (0.10 or 1.1)" }, { .name = BLOCK_OPT_BACKING_FILE, .type = OPT_STRING, .help = "File name of a base image" }, { .name = BLOCK_OPT_BACKING_FMT, .type = OPT_STRING, .help = "Image format of the base image" }, { .name = BLOCK_OPT_ENCRYPT, .type = OPT_FLAG, .help = "Encrypt the image" }, { .name = BLOCK_OPT_CLUSTER_SIZE, .type = OPT_SIZE, .help = "qcow2 cluster size", .value = { .n = DEFAULT_CLUSTER_SIZE }, }, { .name = BLOCK_OPT_PREALLOC, .type = OPT_STRING, .help = "Preallocation mode (allowed values: off, metadata)" }, { .name = BLOCK_OPT_LAZY_REFCOUNTS, .type = OPT_FLAG, .help = "Postpone refcount updates", }, { NULL } }; static BlockDriver bdrv_qcow2 = { .format_name = "qcow2", .instance_size = sizeof(BDRVQcowState), .bdrv_probe = qcow2_probe, .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, .bdrv_create = qcow2_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_is_allocated = qcow2_co_is_allocated, .bdrv_set_key = qcow2_set_key, .bdrv_make_empty = qcow2_make_empty, .bdrv_co_readv = qcow2_co_readv, .bdrv_co_writev = qcow2_co_writev, .bdrv_co_flush_to_os = qcow2_co_flush_to_os, .bdrv_co_write_zeroes = qcow2_co_write_zeroes, .bdrv_co_discard = qcow2_co_discard, .bdrv_truncate = qcow2_truncate, .bdrv_write_compressed = qcow2_write_compressed, .bdrv_snapshot_create = qcow2_snapshot_create, .bdrv_snapshot_goto = qcow2_snapshot_goto, .bdrv_snapshot_delete = qcow2_snapshot_delete, .bdrv_snapshot_list = qcow2_snapshot_list, .bdrv_snapshot_load_tmp = qcow2_snapshot_load_tmp, .bdrv_get_info = qcow2_get_info, .bdrv_save_vmstate = qcow2_save_vmstate, .bdrv_load_vmstate = qcow2_load_vmstate, .bdrv_change_backing_file = qcow2_change_backing_file, .bdrv_invalidate_cache = qcow2_invalidate_cache, .create_options = qcow2_create_options, .bdrv_check = qcow2_check, }; static void bdrv_qcow2_init(void) { bdrv_register(&bdrv_qcow2); } block_init(bdrv_qcow2_init); glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/qed-table.c0000644000076200007630000000013012617742532022233 xustar000000000000000030 mtime=1447019866.034471585 29 atime=1447019866.37046653 29 ctime=1447019941.74433258 glusterfs-3.7.6/contrib/qemu/block/qed-table.c0000644000076200007630000002066712617742532022465 0ustar00jenkinsjenkins00000000000000/* * QEMU Enhanced Disk Format Table I/O * * Copyright IBM, Corp. 2010 * * Authors: * Stefan Hajnoczi * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "trace.h" #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" typedef struct { GenericCB gencb; BDRVQEDState *s; QEDTable *table; struct iovec iov; QEMUIOVector qiov; } QEDReadTableCB; static void qed_read_table_cb(void *opaque, int ret) { QEDReadTableCB *read_table_cb = opaque; QEDTable *table = read_table_cb->table; int noffsets = read_table_cb->qiov.size / sizeof(uint64_t); int i; /* Handle I/O error */ if (ret) { goto out; } /* Byteswap offsets */ for (i = 0; i < noffsets; i++) { table->offsets[i] = le64_to_cpu(table->offsets[i]); } out: /* Completion */ trace_qed_read_table_cb(read_table_cb->s, read_table_cb->table, ret); gencb_complete(&read_table_cb->gencb, ret); } static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, BlockDriverCompletionFunc *cb, void *opaque) { QEDReadTableCB *read_table_cb = gencb_alloc(sizeof(*read_table_cb), cb, opaque); QEMUIOVector *qiov = &read_table_cb->qiov; trace_qed_read_table(s, offset, table); read_table_cb->s = s; read_table_cb->table = table; read_table_cb->iov.iov_base = table->offsets, read_table_cb->iov.iov_len = s->header.cluster_size * s->header.table_size, qemu_iovec_init_external(qiov, &read_table_cb->iov, 1); bdrv_aio_readv(s->bs->file, offset / BDRV_SECTOR_SIZE, qiov, qiov->size / BDRV_SECTOR_SIZE, qed_read_table_cb, read_table_cb); } typedef struct { GenericCB gencb; BDRVQEDState *s; QEDTable *orig_table; QEDTable *table; bool flush; /* flush after write? */ struct iovec iov; QEMUIOVector qiov; } QEDWriteTableCB; static void qed_write_table_cb(void *opaque, int ret) { QEDWriteTableCB *write_table_cb = opaque; trace_qed_write_table_cb(write_table_cb->s, write_table_cb->orig_table, write_table_cb->flush, ret); if (ret) { goto out; } if (write_table_cb->flush) { /* We still need to flush first */ write_table_cb->flush = false; bdrv_aio_flush(write_table_cb->s->bs, qed_write_table_cb, write_table_cb); return; } out: qemu_vfree(write_table_cb->table); gencb_complete(&write_table_cb->gencb, ret); } /** * Write out an updated part or all of a table * * @s: QED state * @offset: Offset of table in image file, in bytes * @table: Table * @index: Index of first element * @n: Number of elements * @flush: Whether or not to sync to disk * @cb: Completion function * @opaque: Argument for completion function */ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, unsigned int index, unsigned int n, bool flush, BlockDriverCompletionFunc *cb, void *opaque) { QEDWriteTableCB *write_table_cb; unsigned int sector_mask = BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1; unsigned int start, end, i; size_t len_bytes; trace_qed_write_table(s, offset, table, index, n); /* Calculate indices of the first and one after last elements */ start = index & ~sector_mask; end = (index + n + sector_mask) & ~sector_mask; len_bytes = (end - start) * sizeof(uint64_t); write_table_cb = gencb_alloc(sizeof(*write_table_cb), cb, opaque); write_table_cb->s = s; write_table_cb->orig_table = table; write_table_cb->flush = flush; write_table_cb->table = qemu_blockalign(s->bs, len_bytes); write_table_cb->iov.iov_base = write_table_cb->table->offsets; write_table_cb->iov.iov_len = len_bytes; qemu_iovec_init_external(&write_table_cb->qiov, &write_table_cb->iov, 1); /* Byteswap table */ for (i = start; i < end; i++) { uint64_t le_offset = cpu_to_le64(table->offsets[i]); write_table_cb->table->offsets[i - start] = le_offset; } /* Adjust for offset into table */ offset += start * sizeof(uint64_t); bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, &write_table_cb->qiov, write_table_cb->qiov.size / BDRV_SECTOR_SIZE, qed_write_table_cb, write_table_cb); } /** * Propagate return value from async callback */ static void qed_sync_cb(void *opaque, int ret) { *(int *)opaque = ret; } int qed_read_l1_table_sync(BDRVQEDState *s) { int ret = -EINPROGRESS; qed_read_table(s, s->header.l1_table_offset, s->l1_table, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { qemu_aio_wait(); } return ret; } void qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int n, BlockDriverCompletionFunc *cb, void *opaque) { BLKDBG_EVENT(s->bs->file, BLKDBG_L1_UPDATE); qed_write_table(s, s->header.l1_table_offset, s->l1_table, index, n, false, cb, opaque); } int qed_write_l1_table_sync(BDRVQEDState *s, unsigned int index, unsigned int n) { int ret = -EINPROGRESS; qed_write_l1_table(s, index, n, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { qemu_aio_wait(); } return ret; } typedef struct { GenericCB gencb; BDRVQEDState *s; uint64_t l2_offset; QEDRequest *request; } QEDReadL2TableCB; static void qed_read_l2_table_cb(void *opaque, int ret) { QEDReadL2TableCB *read_l2_table_cb = opaque; QEDRequest *request = read_l2_table_cb->request; BDRVQEDState *s = read_l2_table_cb->s; CachedL2Table *l2_table = request->l2_table; uint64_t l2_offset = read_l2_table_cb->l2_offset; if (ret) { /* can't trust loaded L2 table anymore */ qed_unref_l2_cache_entry(l2_table); request->l2_table = NULL; } else { l2_table->offset = l2_offset; qed_commit_l2_cache_entry(&s->l2_cache, l2_table); /* This is guaranteed to succeed because we just committed the entry * to the cache. */ request->l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_offset); assert(request->l2_table != NULL); } gencb_complete(&read_l2_table_cb->gencb, ret); } void qed_read_l2_table(BDRVQEDState *s, QEDRequest *request, uint64_t offset, BlockDriverCompletionFunc *cb, void *opaque) { QEDReadL2TableCB *read_l2_table_cb; qed_unref_l2_cache_entry(request->l2_table); /* Check for cached L2 entry */ request->l2_table = qed_find_l2_cache_entry(&s->l2_cache, offset); if (request->l2_table) { cb(opaque, 0); return; } request->l2_table = qed_alloc_l2_cache_entry(&s->l2_cache); request->l2_table->table = qed_alloc_table(s); read_l2_table_cb = gencb_alloc(sizeof(*read_l2_table_cb), cb, opaque); read_l2_table_cb->s = s; read_l2_table_cb->l2_offset = offset; read_l2_table_cb->request = request; BLKDBG_EVENT(s->bs->file, BLKDBG_L2_LOAD); qed_read_table(s, offset, request->l2_table->table, qed_read_l2_table_cb, read_l2_table_cb); } int qed_read_l2_table_sync(BDRVQEDState *s, QEDRequest *request, uint64_t offset) { int ret = -EINPROGRESS; qed_read_l2_table(s, request, offset, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { qemu_aio_wait(); } return ret; } void qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush, BlockDriverCompletionFunc *cb, void *opaque) { BLKDBG_EVENT(s->bs->file, BLKDBG_L2_UPDATE); qed_write_table(s, request->l2_table->offset, request->l2_table->table, index, n, flush, cb, opaque); } int qed_write_l2_table_sync(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush) { int ret = -EINPROGRESS; qed_write_l2_table(s, request, index, n, flush, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { qemu_aio_wait(); } return ret; } glusterfs-3.7.6/contrib/qemu/block/PaxHeaders.7244/snapshot.c0000644000076200007630000000013112617742532022235 xustar000000000000000029 mtime=1447019866.03547157 30 atime=1447019866.371466515 30 ctime=1447019941.711333077 glusterfs-3.7.6/contrib/qemu/block/snapshot.c0000644000076200007630000001022112617742532022447 0ustar00jenkinsjenkins00000000000000/* * Block layer snapshot related functions * * Copyright (c) 2003-2008 Fabrice Bellard * * 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. */ #include "block/snapshot.h" #include "block/block_int.h" int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, const char *name) { QEMUSnapshotInfo *sn_tab, *sn; int nb_sns, i, ret; ret = -ENOENT; nb_sns = bdrv_snapshot_list(bs, &sn_tab); if (nb_sns < 0) { return ret; } for (i = 0; i < nb_sns; i++) { sn = &sn_tab[i]; if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) { *sn_info = *sn; ret = 0; break; } } g_free(sn_tab); return ret; } int bdrv_can_snapshot(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) { return 0; } if (!drv->bdrv_snapshot_create) { if (bs->file != NULL) { return bdrv_can_snapshot(bs->file); } return 0; } return 1; } int bdrv_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (drv->bdrv_snapshot_create) { return drv->bdrv_snapshot_create(bs, sn_info); } if (bs->file) { return bdrv_snapshot_create(bs->file, sn_info); } return -ENOTSUP; } int bdrv_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { BlockDriver *drv = bs->drv; int ret, open_ret; if (!drv) { return -ENOMEDIUM; } if (drv->bdrv_snapshot_goto) { return drv->bdrv_snapshot_goto(bs, snapshot_id); } if (bs->file) { drv->bdrv_close(bs); ret = bdrv_snapshot_goto(bs->file, snapshot_id); open_ret = drv->bdrv_open(bs, NULL, bs->open_flags); if (open_ret < 0) { bdrv_delete(bs->file); bs->drv = NULL; return open_ret; } return ret; } return -ENOTSUP; } int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (drv->bdrv_snapshot_delete) { return drv->bdrv_snapshot_delete(bs, snapshot_id); } if (bs->file) { return bdrv_snapshot_delete(bs->file, snapshot_id); } return -ENOTSUP; } int bdrv_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_info) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (drv->bdrv_snapshot_list) { return drv->bdrv_snapshot_list(bs, psn_info); } if (bs->file) { return bdrv_snapshot_list(bs->file, psn_info); } return -ENOTSUP; } int bdrv_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (!bs->read_only) { return -EINVAL; } if (drv->bdrv_snapshot_load_tmp) { return drv->bdrv_snapshot_load_tmp(bs, snapshot_name); } return -ENOTSUP; } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/block.c0000644000076200007630000000013112617742532020376 xustar000000000000000030 mtime=1447019866.032471615 29 atime=1447019866.36846656 30 ctime=1447019941.657333888 glusterfs-3.7.6/contrib/qemu/block.c0000644000076200007630000037421512617742532020630 0ustar00jenkinsjenkins00000000000000/* * QEMU System Emulator block driver * * Copyright (c) 2003 Fabrice Bellard * * 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. */ #include "config-host.h" #include "qemu-common.h" #include "trace.h" #include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "qemu/module.h" #include "qapi/qmp/qjson.h" #include "sysemu/sysemu.h" #include "qemu/notify.h" #include "block/coroutine.h" #include "qmp-commands.h" #include "qemu/timer.h" #ifdef CONFIG_BSD #include #include #include #include #ifndef __DragonFly__ #include #endif #endif #ifdef _WIN32 #include #endif #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */ typedef enum { BDRV_REQ_COPY_ON_READ = 0x1, BDRV_REQ_ZERO_WRITE = 0x2, } BdrvRequestFlags; static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load); static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); static BlockDriverAIOCB *bdrv_aio_writev_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque); static int coroutine_fn bdrv_co_readv_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov); static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov); static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, BdrvRequestFlags flags); static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, BdrvRequestFlags flags); static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, bool is_write); static void coroutine_fn bdrv_co_do_rw(void *opaque); static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors); static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, bool is_write, double elapsed_time, uint64_t *wait); static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, double elapsed_time, uint64_t *wait); static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors, bool is_write, int64_t *wait); static QTAILQ_HEAD(, BlockDriverState) bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); static QLIST_HEAD(, BlockDriver) bdrv_drivers = QLIST_HEAD_INITIALIZER(bdrv_drivers); /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; #ifdef _WIN32 static int is_windows_drive_prefix(const char *filename) { return (((filename[0] >= 'a' && filename[0] <= 'z') || (filename[0] >= 'A' && filename[0] <= 'Z')) && filename[1] == ':'); } int is_windows_drive(const char *filename) { if (is_windows_drive_prefix(filename) && filename[2] == '\0') return 1; if (strstart(filename, "\\\\.\\", NULL) || strstart(filename, "//./", NULL)) return 1; return 0; } #endif /* throttling disk I/O limits */ void bdrv_io_limits_disable(BlockDriverState *bs) { bs->io_limits_enabled = false; while (qemu_co_queue_next(&bs->throttled_reqs)); if (bs->block_timer) { qemu_del_timer(bs->block_timer); qemu_free_timer(bs->block_timer); bs->block_timer = NULL; } bs->slice_start = 0; bs->slice_end = 0; } static void bdrv_block_timer(void *opaque) { BlockDriverState *bs = opaque; qemu_co_queue_next(&bs->throttled_reqs); } void bdrv_io_limits_enable(BlockDriverState *bs) { qemu_co_queue_init(&bs->throttled_reqs); bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs); bs->io_limits_enabled = true; } bool bdrv_io_limits_enabled(BlockDriverState *bs) { BlockIOLimit *io_limits = &bs->io_limits; return io_limits->bps[BLOCK_IO_LIMIT_READ] || io_limits->bps[BLOCK_IO_LIMIT_WRITE] || io_limits->bps[BLOCK_IO_LIMIT_TOTAL] || io_limits->iops[BLOCK_IO_LIMIT_READ] || io_limits->iops[BLOCK_IO_LIMIT_WRITE] || io_limits->iops[BLOCK_IO_LIMIT_TOTAL]; } static void bdrv_io_limits_intercept(BlockDriverState *bs, bool is_write, int nb_sectors) { int64_t wait_time = -1; if (!qemu_co_queue_empty(&bs->throttled_reqs)) { qemu_co_queue_wait(&bs->throttled_reqs); } /* In fact, we hope to keep each request's timing, in FIFO mode. The next * throttled requests will not be dequeued until the current request is * allowed to be serviced. So if the current request still exceeds the * limits, it will be inserted to the head. All requests followed it will * be still in throttled_reqs queue. */ while (bdrv_exceed_io_limits(bs, nb_sectors, is_write, &wait_time)) { qemu_mod_timer(bs->block_timer, wait_time + qemu_get_clock_ns(vm_clock)); qemu_co_queue_wait_insert_head(&bs->throttled_reqs); } qemu_co_queue_next(&bs->throttled_reqs); } /* check if the path starts with ":" */ static int path_has_protocol(const char *path) { const char *p; #ifdef _WIN32 if (is_windows_drive(path) || is_windows_drive_prefix(path)) { return 0; } p = path + strcspn(path, ":/\\"); #else p = path + strcspn(path, ":/"); #endif return *p == ':'; } int path_is_absolute(const char *path) { #ifdef _WIN32 /* specific case for names like: "\\.\d:" */ if (is_windows_drive(path) || is_windows_drive_prefix(path)) { return 1; } return (*path == '/' || *path == '\\'); #else return (*path == '/'); #endif } /* if filename is absolute, just copy it to dest. Otherwise, build a path to it by considering it is relative to base_path. URL are supported. */ void path_combine(char *dest, int dest_size, const char *base_path, const char *filename) { const char *p, *p1; int len; if (dest_size <= 0) return; if (path_is_absolute(filename)) { pstrcpy(dest, dest_size, filename); } else { p = strchr(base_path, ':'); if (p) p++; else p = base_path; p1 = strrchr(base_path, '/'); #ifdef _WIN32 { const char *p2; p2 = strrchr(base_path, '\\'); if (!p1 || p2 > p1) p1 = p2; } #endif if (p1) p1++; else p1 = base_path; if (p1 > p) p = p1; len = p - base_path; if (len > dest_size - 1) len = dest_size - 1; memcpy(dest, base_path, len); dest[len] = '\0'; pstrcat(dest, dest_size, filename); } } void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size_t sz) { if (bs->backing_file[0] == '\0' || path_has_protocol(bs->backing_file)) { pstrcpy(dest, sz, bs->backing_file); } else { path_combine(dest, sz, bs->filename, bs->backing_file); } } void bdrv_register(BlockDriver *bdrv) { /* Block drivers without coroutine functions need emulation */ if (!bdrv->bdrv_co_readv) { bdrv->bdrv_co_readv = bdrv_co_readv_em; bdrv->bdrv_co_writev = bdrv_co_writev_em; /* bdrv_co_readv_em()/brdv_co_writev_em() work in terms of aio, so if * the block driver lacks aio we need to emulate that too. */ if (!bdrv->bdrv_aio_readv) { /* add AIO emulation layer */ bdrv->bdrv_aio_readv = bdrv_aio_readv_em; bdrv->bdrv_aio_writev = bdrv_aio_writev_em; } } QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); } /* create a new block device (by default it is empty) */ BlockDriverState *bdrv_new(const char *device_name) { BlockDriverState *bs; bs = g_malloc0(sizeof(BlockDriverState)); pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); if (device_name[0] != '\0') { QTAILQ_INSERT_TAIL(&bdrv_states, bs, list); } bdrv_iostatus_disable(bs); notifier_list_init(&bs->close_notifiers); notifier_with_return_list_init(&bs->before_write_notifiers); return bs; } void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify) { notifier_list_add(&bs->close_notifiers, notify); } BlockDriver *bdrv_find_format(const char *format_name) { BlockDriver *drv1; QLIST_FOREACH(drv1, &bdrv_drivers, list) { if (!strcmp(drv1->format_name, format_name)) { return drv1; } } return NULL; } static int bdrv_is_whitelisted(BlockDriver *drv, bool read_only) { static const char *whitelist_rw[] = { CONFIG_BDRV_RW_WHITELIST }; static const char *whitelist_ro[] = { CONFIG_BDRV_RO_WHITELIST }; const char **p; if (!whitelist_rw[0] && !whitelist_ro[0]) { return 1; /* no whitelist, anything goes */ } for (p = whitelist_rw; *p; p++) { if (!strcmp(drv->format_name, *p)) { return 1; } } if (read_only) { for (p = whitelist_ro; *p; p++) { if (!strcmp(drv->format_name, *p)) { return 1; } } } return 0; } BlockDriver *bdrv_find_whitelisted_format(const char *format_name, bool read_only) { BlockDriver *drv = bdrv_find_format(format_name); return drv && bdrv_is_whitelisted(drv, read_only) ? drv : NULL; } typedef struct CreateCo { BlockDriver *drv; char *filename; QEMUOptionParameter *options; int ret; } CreateCo; static void coroutine_fn bdrv_create_co_entry(void *opaque) { CreateCo *cco = opaque; assert(cco->drv); cco->ret = cco->drv->bdrv_create(cco->filename, cco->options); } int bdrv_create(BlockDriver *drv, const char* filename, QEMUOptionParameter *options) { int ret; Coroutine *co; CreateCo cco = { .drv = drv, .filename = g_strdup(filename), .options = options, .ret = NOT_DONE, }; if (!drv->bdrv_create) { ret = -ENOTSUP; goto out; } if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_create_co_entry(&cco); } else { co = qemu_coroutine_create(bdrv_create_co_entry); qemu_coroutine_enter(co, &cco); while (cco.ret == NOT_DONE) { qemu_aio_wait(); } } ret = cco.ret; out: g_free(cco.filename); return ret; } int bdrv_create_file(const char* filename, QEMUOptionParameter *options) { BlockDriver *drv; drv = bdrv_find_protocol(filename, true); if (drv == NULL) { return -ENOENT; } return bdrv_create(drv, filename, options); } /* * Create a uniquely-named empty temporary file. * Return 0 upon success, otherwise a negative errno value. */ int get_tmp_filename(char *filename, int size) { #ifdef _WIN32 char temp_dir[MAX_PATH]; /* GetTempFileName requires that its output buffer (4th param) have length MAX_PATH or greater. */ assert(size >= MAX_PATH); return (GetTempPath(MAX_PATH, temp_dir) && GetTempFileName(temp_dir, "qem", 0, filename) ? 0 : -GetLastError()); #else int fd; const char *tmpdir; tmpdir = getenv("TMPDIR"); if (!tmpdir) tmpdir = "/tmp"; if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) { return -EOVERFLOW; } fd = mkstemp(filename); if (fd < 0) { return -errno; } if (close(fd) != 0) { unlink(filename); return -errno; } return 0; #endif } /* * Detect host devices. By convention, /dev/cdrom[N] is always * recognized as a host CDROM. */ static BlockDriver *find_hdev_driver(const char *filename) { int score_max = 0, score; BlockDriver *drv = NULL, *d; QLIST_FOREACH(d, &bdrv_drivers, list) { if (d->bdrv_probe_device) { score = d->bdrv_probe_device(filename); if (score > score_max) { score_max = score; drv = d; } } } return drv; } BlockDriver *bdrv_find_protocol(const char *filename, bool allow_protocol_prefix) { BlockDriver *drv1; char protocol[128]; int len; const char *p; /* TODO Drivers without bdrv_file_open must be specified explicitly */ /* * XXX(hch): we really should not let host device detection * override an explicit protocol specification, but moving this * later breaks access to device names with colons in them. * Thanks to the brain-dead persistent naming schemes on udev- * based Linux systems those actually are quite common. */ drv1 = find_hdev_driver(filename); if (drv1) { return drv1; } if (!path_has_protocol(filename) || !allow_protocol_prefix) { return bdrv_find_format("file"); } p = strchr(filename, ':'); assert(p != NULL); len = p - filename; if (len > sizeof(protocol) - 1) len = sizeof(protocol) - 1; memcpy(protocol, filename, len); protocol[len] = '\0'; QLIST_FOREACH(drv1, &bdrv_drivers, list) { if (drv1->protocol_name && !strcmp(drv1->protocol_name, protocol)) { return drv1; } } return NULL; } static int find_image_format(BlockDriverState *bs, const char *filename, BlockDriver **pdrv) { int score, score_max; BlockDriver *drv1, *drv; uint8_t buf[2048]; int ret = 0; /* Return the raw BlockDriver * to scsi-generic devices or empty drives */ if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) { drv = bdrv_find_format("raw"); if (!drv) { ret = -ENOENT; } *pdrv = drv; return ret; } ret = bdrv_pread(bs, 0, buf, sizeof(buf)); if (ret < 0) { *pdrv = NULL; return ret; } score_max = 0; drv = NULL; QLIST_FOREACH(drv1, &bdrv_drivers, list) { if (drv1->bdrv_probe) { score = drv1->bdrv_probe(buf, ret, filename); if (score > score_max) { score_max = score; drv = drv1; } } } if (!drv) { ret = -ENOENT; } *pdrv = drv; return ret; } /** * Set the current 'total_sectors' value */ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint) { BlockDriver *drv = bs->drv; /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */ if (bs->sg) return 0; /* query actual device if possible, otherwise just trust the hint */ if (drv->bdrv_getlength) { int64_t length = drv->bdrv_getlength(bs); if (length < 0) { return length; } hint = length >> BDRV_SECTOR_BITS; } bs->total_sectors = hint; return 0; } /** * Set open flags for a given discard mode * * Return 0 on success, -1 if the discard mode was invalid. */ int bdrv_parse_discard_flags(const char *mode, int *flags) { *flags &= ~BDRV_O_UNMAP; if (!strcmp(mode, "off") || !strcmp(mode, "ignore")) { /* do nothing */ } else if (!strcmp(mode, "on") || !strcmp(mode, "unmap")) { *flags |= BDRV_O_UNMAP; } else { return -1; } return 0; } /** * Set open flags for a given cache mode * * Return 0 on success, -1 if the cache mode was invalid. */ int bdrv_parse_cache_flags(const char *mode, int *flags) { *flags &= ~BDRV_O_CACHE_MASK; if (!strcmp(mode, "off") || !strcmp(mode, "none")) { *flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB; } else if (!strcmp(mode, "directsync")) { *flags |= BDRV_O_NOCACHE; } else if (!strcmp(mode, "writeback")) { *flags |= BDRV_O_CACHE_WB; } else if (!strcmp(mode, "unsafe")) { *flags |= BDRV_O_CACHE_WB; *flags |= BDRV_O_NO_FLUSH; } else if (!strcmp(mode, "writethrough")) { /* this is the default */ } else { return -1; } return 0; } /** * The copy-on-read flag is actually a reference count so multiple users may * use the feature without worrying about clobbering its previous state. * Copy-on-read stays enabled until all users have called to disable it. */ void bdrv_enable_copy_on_read(BlockDriverState *bs) { bs->copy_on_read++; } void bdrv_disable_copy_on_read(BlockDriverState *bs) { assert(bs->copy_on_read > 0); bs->copy_on_read--; } static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags = flags | BDRV_O_CACHE_WB; /* * Clear flags that are internal to the block layer before opening the * image. */ open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); /* * Snapshots should be writable. */ if (bs->is_temporary) { open_flags |= BDRV_O_RDWR; } return open_flags; } /* * Common part for opening disk images and files * * Removes all processed options from *options. */ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, QDict *options, int flags, BlockDriver *drv) { int ret, open_flags; const char *filename; assert(drv != NULL); assert(bs->file == NULL); assert(options != NULL && bs->options != options); if (file != NULL) { filename = file->filename; } else { filename = qdict_get_try_str(options, "filename"); } trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name); /* bdrv_open() with directly using a protocol as drv. This layer is already * opened, so assign it to bs (while file becomes a closed BlockDriverState) * and return immediately. */ if (file != NULL && drv->bdrv_file_open) { bdrv_swap(file, bs); return 0; } bs->open_flags = flags; bs->buffer_alignment = 512; open_flags = bdrv_open_flags(bs, flags); bs->read_only = !(open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { return -ENOTSUP; } assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */ if (!bs->read_only && (flags & BDRV_O_COPY_ON_READ)) { bdrv_enable_copy_on_read(bs); } if (filename != NULL) { pstrcpy(bs->filename, sizeof(bs->filename), filename); } else { bs->filename[0] = '\0'; } bs->drv = drv; bs->opaque = g_malloc0(drv->instance_size); bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB); /* Open the image, either directly or using a protocol */ if (drv->bdrv_file_open) { assert(file == NULL); assert(drv->bdrv_parse_filename || filename != NULL); ret = drv->bdrv_file_open(bs, options, open_flags); } else { if (file == NULL) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Can't use '%s' as a " "block driver for the protocol level", drv->format_name); ret = -EINVAL; goto free_and_fail; } assert(file != NULL); bs->file = file; ret = drv->bdrv_open(bs, options, open_flags); } if (ret < 0) { goto free_and_fail; } ret = refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { goto free_and_fail; } #ifndef _WIN32 if (bs->is_temporary) { assert(filename != NULL); unlink(filename); } #endif return 0; free_and_fail: bs->file = NULL; g_free(bs->opaque); bs->opaque = NULL; bs->drv = NULL; return ret; } /* * Opens a file using a protocol (file, host_device, nbd, ...) * * options is a QDict of options to pass to the block drivers, or NULL for an * empty set of options. The reference to the QDict belongs to the block layer * after the call (even on failure), so if the caller intends to reuse the * dictionary, it needs to use QINCREF() before calling bdrv_file_open. */ int bdrv_file_open(BlockDriverState **pbs, const char *filename, QDict *options, int flags) { BlockDriverState *bs; BlockDriver *drv; const char *drvname; bool allow_protocol_prefix = false; int ret; /* NULL means an empty set of options */ if (options == NULL) { options = qdict_new(); } bs = bdrv_new(""); bs->options = options; options = qdict_clone_shallow(options); /* Fetch the file name from the options QDict if necessary */ if (!filename) { filename = qdict_get_try_str(options, "filename"); } else if (filename && !qdict_haskey(options, "filename")) { qdict_put(options, "filename", qstring_from_str(filename)); allow_protocol_prefix = true; } else { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Can't specify 'file' and " "'filename' options at the same time"); ret = -EINVAL; goto fail; } /* Find the right block driver */ drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR)); qdict_del(options, "driver"); } else if (filename) { drv = bdrv_find_protocol(filename, allow_protocol_prefix); if (!drv) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Unknown protocol"); } } else { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Must specify either driver or file"); drv = NULL; } if (!drv) { ret = -ENOENT; goto fail; } /* Parse the filename and open it */ if (drv->bdrv_parse_filename && filename) { Error *local_err = NULL; drv->bdrv_parse_filename(filename, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); ret = -EINVAL; goto fail; } qdict_del(options, "filename"); } else if (!drv->bdrv_parse_filename && !filename) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; goto fail; } ret = bdrv_open_common(bs, NULL, options, flags, drv); if (ret < 0) { goto fail; } /* Check if any unknown options were used */ if (qdict_size(options) != 0) { const QDictEntry *entry = qdict_first(options); qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block protocol '%s' doesn't " "support the option '%s'", drv->format_name, entry->key); ret = -EINVAL; goto fail; } QDECREF(options); bs->growable = 1; *pbs = bs; return 0; fail: QDECREF(options); if (!bs->drv) { QDECREF(bs->options); } bdrv_delete(bs); return ret; } /* * Opens the backing file for a BlockDriverState if not yet open * * options is a QDict of options to pass to the block drivers, or NULL for an * empty set of options. The reference to the QDict is transferred to this * function (even on failure), so if the caller intends to reuse the dictionary, * it needs to use QINCREF() before calling bdrv_file_open. */ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options) { char backing_filename[PATH_MAX]; int back_flags, ret; BlockDriver *back_drv = NULL; if (bs->backing_hd != NULL) { QDECREF(options); return 0; } /* NULL means an empty set of options */ if (options == NULL) { options = qdict_new(); } bs->open_flags &= ~BDRV_O_NO_BACKING; if (qdict_haskey(options, "file.filename")) { backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { QDECREF(options); return 0; } bs->backing_hd = bdrv_new(""); bdrv_get_full_backing_filename(bs, backing_filename, sizeof(backing_filename)); if (bs->backing_format[0] != '\0') { back_drv = bdrv_find_format(bs->backing_format); } /* backing files always opened read-only */ back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT); ret = bdrv_open(bs->backing_hd, *backing_filename ? backing_filename : NULL, options, back_flags, back_drv); if (ret < 0) { bdrv_delete(bs->backing_hd); bs->backing_hd = NULL; bs->open_flags |= BDRV_O_NO_BACKING; return ret; } return 0; } static void extract_subqdict(QDict *src, QDict **dst, const char *start) { const QDictEntry *entry, *next; const char *p; *dst = qdict_new(); entry = qdict_first(src); while (entry != NULL) { next = qdict_next(src, entry); if (strstart(entry->key, start, &p)) { qobject_incref(entry->value); qdict_put_obj(*dst, p, entry->value); qdict_del(src, entry->key); } entry = next; } } /* * Opens a disk image (raw, qcow2, vmdk, ...) * * options is a QDict of options to pass to the block drivers, or NULL for an * empty set of options. The reference to the QDict belongs to the block layer * after the call (even on failure), so if the caller intends to reuse the * dictionary, it needs to use QINCREF() before calling bdrv_open. */ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, int flags, BlockDriver *drv) { int ret; /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ char tmp_filename[PATH_MAX + 1]; BlockDriverState *file = NULL; QDict *file_options = NULL; /* NULL means an empty set of options */ if (options == NULL) { options = qdict_new(); } bs->options = options; options = qdict_clone_shallow(options); /* For snapshot=on, create a temporary qcow2 overlay */ if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; BlockDriver *bdrv_qcow2; QEMUOptionParameter *create_options; char backing_filename[PATH_MAX]; if (qdict_size(options) != 0) { error_report("Can't use snapshot=on with driver-specific options"); ret = -EINVAL; goto fail; } assert(filename != NULL); /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ /* if there is a backing file, use it */ bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, NULL, 0, drv); if (ret < 0) { bdrv_delete(bs1); goto fail; } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; bdrv_delete(bs1); ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (ret < 0) { goto fail; } /* Real path is meaningless for protocols */ if (path_has_protocol(filename)) { snprintf(backing_filename, sizeof(backing_filename), "%s", filename); } else if (!realpath(filename, backing_filename)) { ret = -errno; goto fail; } bdrv_qcow2 = bdrv_find_format("qcow2"); create_options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size); set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options); free_option_parameters(create_options); if (ret < 0) { goto fail; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } /* Open image file without format layer */ if (flags & BDRV_O_RDWR) { flags |= BDRV_O_ALLOW_RDWR; } extract_subqdict(options, &file_options, "file."); ret = bdrv_file_open(&file, filename, file_options, bdrv_open_flags(bs, flags | BDRV_O_UNMAP)); if (ret < 0) { goto fail; } /* Find the right image format driver */ if (!drv) { ret = find_image_format(file, filename, &drv); } if (!drv) { goto unlink_and_fail; } /* Open the image */ ret = bdrv_open_common(bs, file, options, flags, drv); if (ret < 0) { goto unlink_and_fail; } if (bs->file != file) { bdrv_delete(file); file = NULL; } /* If there is a backing file, use it */ if ((flags & BDRV_O_NO_BACKING) == 0) { QDict *backing_options; extract_subqdict(options, &backing_options, "backing."); ret = bdrv_open_backing_file(bs, backing_options); if (ret < 0) { goto close_and_fail; } } /* Check if any unknown options were used */ if (qdict_size(options) != 0) { const QDictEntry *entry = qdict_first(options); qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by " "device '%s' doesn't support the option '%s'", drv->format_name, bs->device_name, entry->key); ret = -EINVAL; goto close_and_fail; } QDECREF(options); if (!bdrv_key_required(bs)) { bdrv_dev_change_media_cb(bs, true); } /* throttling disk I/O limits */ if (bs->io_limits_enabled) { bdrv_io_limits_enable(bs); } return 0; unlink_and_fail: if (file != NULL) { bdrv_delete(file); } if (bs->is_temporary) { unlink(filename); } fail: QDECREF(bs->options); QDECREF(options); bs->options = NULL; return ret; close_and_fail: bdrv_close(bs); QDECREF(options); return ret; } typedef struct BlockReopenQueueEntry { bool prepared; BDRVReopenState state; QSIMPLEQ_ENTRY(BlockReopenQueueEntry) entry; } BlockReopenQueueEntry; /* * Adds a BlockDriverState to a simple queue for an atomic, transactional * reopen of multiple devices. * * bs_queue can either be an existing BlockReopenQueue that has had QSIMPLE_INIT * already performed, or alternatively may be NULL a new BlockReopenQueue will * be created and initialized. This newly created BlockReopenQueue should be * passed back in for subsequent calls that are intended to be of the same * atomic 'set'. * * bs is the BlockDriverState to add to the reopen queue. * * flags contains the open flags for the associated bs * * returns a pointer to bs_queue, which is either the newly allocated * bs_queue, or the existing bs_queue being used. * */ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, int flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } if (bs->file) { bdrv_reopen_queue(bs_queue, bs->file, flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; bs_entry->state.flags = flags; return bs_queue; } /* * Reopen multiple BlockDriverStates atomically & transactionally. * * The queue passed in (bs_queue) must have been built up previous * via bdrv_reopen_queue(). * * Reopens all BDS specified in the queue, with the appropriate * flags. All devices are prepared for reopen, and failure of any * device will cause all device changes to be abandonded, and intermediate * data cleaned up. * * If all devices prepare successfully, then the changes are committed * to all devices. * */ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) { int ret = -1; BlockReopenQueueEntry *bs_entry, *next; Error *local_err = NULL; assert(bs_queue != NULL); bdrv_drain_all(); QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, &local_err)) { error_propagate(errp, local_err); goto cleanup; } bs_entry->prepared = true; } /* If we reach this point, we have success and just need to apply the * changes */ QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { bdrv_reopen_commit(&bs_entry->state); } ret = 0; cleanup: QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { if (ret && bs_entry->prepared) { bdrv_reopen_abort(&bs_entry->state); } g_free(bs_entry); } g_free(bs_queue); return ret; } /* Reopen a single BlockDriverState with the specified flags. */ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp) { int ret = -1; Error *local_err = NULL; BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, bdrv_flags); ret = bdrv_reopen_multiple(queue, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); } return ret; } /* * Prepares a BlockDriverState for reopen. All changes are staged in the * 'opaque' field of the BDRVReopenState, which is used and allocated by * the block driver layer .bdrv_reopen_prepare() * * bs is the BlockDriverState to reopen * flags are the new open flags * queue is the reopen queue * * Returns 0 on success, non-zero on error. On error errp will be set * as well. * * On failure, bdrv_reopen_abort() will be called to clean up any data. * It is the responsibility of the caller to then call the abort() or * commit() for any other BDS that have been left in a prepare() state * */ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp) { int ret = -1; Error *local_err = NULL; BlockDriver *drv; assert(reopen_state != NULL); assert(reopen_state->bs->drv != NULL); drv = reopen_state->bs->drv; /* if we are to stay read-only, do not allow permission change * to r/w */ if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) && reopen_state->flags & BDRV_O_RDWR) { error_set(errp, QERR_DEVICE_IS_READ_ONLY, reopen_state->bs->device_name); goto error; } ret = bdrv_flush(reopen_state->bs); if (ret) { error_set(errp, ERROR_CLASS_GENERIC_ERROR, "Error (%s) flushing drive", strerror(-ret)); goto error; } if (drv->bdrv_reopen_prepare) { ret = drv->bdrv_reopen_prepare(reopen_state, queue, &local_err); if (ret) { if (local_err != NULL) { error_propagate(errp, local_err); } else { error_setg(errp, "failed while preparing to reopen image '%s'", reopen_state->bs->filename); } goto error; } } else { /* It is currently mandatory to have a bdrv_reopen_prepare() * handler for each supported drv. */ error_set(errp, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, drv->format_name, reopen_state->bs->device_name, "reopening of file"); ret = -1; goto error; } ret = 0; error: return ret; } /* * Takes the staged changes for the reopen from bdrv_reopen_prepare(), and * makes them final by swapping the staging BlockDriverState contents into * the active BlockDriverState contents. */ void bdrv_reopen_commit(BDRVReopenState *reopen_state) { BlockDriver *drv; assert(reopen_state != NULL); drv = reopen_state->bs->drv; assert(drv != NULL); /* If there are any driver level actions to take */ if (drv->bdrv_reopen_commit) { drv->bdrv_reopen_commit(reopen_state); } /* set BDS specific flags now */ reopen_state->bs->open_flags = reopen_state->flags; reopen_state->bs->enable_write_cache = !!(reopen_state->flags & BDRV_O_CACHE_WB); reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); } /* * Abort the reopen, and delete and free the staged changes in * reopen_state */ void bdrv_reopen_abort(BDRVReopenState *reopen_state) { BlockDriver *drv; assert(reopen_state != NULL); drv = reopen_state->bs->drv; assert(drv != NULL); if (drv->bdrv_reopen_abort) { drv->bdrv_reopen_abort(reopen_state); } } void bdrv_close(BlockDriverState *bs) { if (bs->job) { block_job_cancel_sync(bs->job); } bdrv_drain_all(); /* complete I/O */ bdrv_flush(bs); bdrv_drain_all(); /* in case flush left pending I/O */ notifier_list_notify(&bs->close_notifiers, bs); if (bs->drv) { if (bs->backing_hd) { bdrv_delete(bs->backing_hd); bs->backing_hd = NULL; } bs->drv->bdrv_close(bs); g_free(bs->opaque); #ifdef _WIN32 if (bs->is_temporary) { unlink(bs->filename); } #endif bs->opaque = NULL; bs->drv = NULL; bs->copy_on_read = 0; bs->backing_file[0] = '\0'; bs->backing_format[0] = '\0'; bs->total_sectors = 0; bs->encrypted = 0; bs->valid_key = 0; bs->sg = 0; bs->growable = 0; QDECREF(bs->options); bs->options = NULL; if (bs->file != NULL) { bdrv_delete(bs->file); bs->file = NULL; } } bdrv_dev_change_media_cb(bs, false); /*throttling disk I/O limits*/ if (bs->io_limits_enabled) { bdrv_io_limits_disable(bs); } } void bdrv_close_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { bdrv_close(bs); } } /* * Wait for pending requests to complete across all BlockDriverStates * * This function does not flush data to disk, use bdrv_flush_all() for that * after calling this function. * * Note that completion of an asynchronous I/O operation can trigger any * number of other I/O operations on other devices---for example a coroutine * can be arbitrarily complex and a constant flow of I/O can come until the * coroutine is complete. Because of this, it is not possible to have a * function to drain a single device's I/O queue. */ void bdrv_drain_all(void) { BlockDriverState *bs; bool busy; do { busy = qemu_aio_wait(); /* FIXME: We do not have timer support here, so this is effectively * a busy wait. */ QTAILQ_FOREACH(bs, &bdrv_states, list) { if (!qemu_co_queue_empty(&bs->throttled_reqs)) { qemu_co_queue_restart_all(&bs->throttled_reqs); busy = true; } } } while (busy); /* If requests are still pending there is a bug somewhere */ QTAILQ_FOREACH(bs, &bdrv_states, list) { assert(QLIST_EMPTY(&bs->tracked_requests)); assert(qemu_co_queue_empty(&bs->throttled_reqs)); } } /* make a BlockDriverState anonymous by removing from bdrv_state list. Also, NULL terminate the device_name to prevent double remove */ void bdrv_make_anon(BlockDriverState *bs) { if (bs->device_name[0] != '\0') { QTAILQ_REMOVE(&bdrv_states, bs, list); } bs->device_name[0] = '\0'; } static void bdrv_rebind(BlockDriverState *bs) { if (bs->drv && bs->drv->bdrv_rebind) { bs->drv->bdrv_rebind(bs); } } static void bdrv_move_feature_fields(BlockDriverState *bs_dest, BlockDriverState *bs_src) { /* move some fields that need to stay attached to the device */ bs_dest->open_flags = bs_src->open_flags; /* dev info */ bs_dest->dev_ops = bs_src->dev_ops; bs_dest->dev_opaque = bs_src->dev_opaque; bs_dest->dev = bs_src->dev; bs_dest->buffer_alignment = bs_src->buffer_alignment; bs_dest->copy_on_read = bs_src->copy_on_read; bs_dest->enable_write_cache = bs_src->enable_write_cache; /* i/o timing parameters */ bs_dest->slice_start = bs_src->slice_start; bs_dest->slice_end = bs_src->slice_end; bs_dest->slice_submitted = bs_src->slice_submitted; bs_dest->io_limits = bs_src->io_limits; bs_dest->throttled_reqs = bs_src->throttled_reqs; bs_dest->block_timer = bs_src->block_timer; bs_dest->io_limits_enabled = bs_src->io_limits_enabled; /* r/w error */ bs_dest->on_read_error = bs_src->on_read_error; bs_dest->on_write_error = bs_src->on_write_error; /* i/o status */ bs_dest->iostatus_enabled = bs_src->iostatus_enabled; bs_dest->iostatus = bs_src->iostatus; /* dirty bitmap */ bs_dest->dirty_bitmap = bs_src->dirty_bitmap; /* job */ bs_dest->in_use = bs_src->in_use; bs_dest->job = bs_src->job; /* keep the same entry in bdrv_states */ pstrcpy(bs_dest->device_name, sizeof(bs_dest->device_name), bs_src->device_name); bs_dest->list = bs_src->list; } /* * Swap bs contents for two image chains while they are live, * while keeping required fields on the BlockDriverState that is * actually attached to a device. * * This will modify the BlockDriverState fields, and swap contents * between bs_new and bs_old. Both bs_new and bs_old are modified. * * bs_new is required to be anonymous. * * This function does not create any image files. */ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) { BlockDriverState tmp; /* bs_new must be anonymous and shouldn't have anything fancy enabled */ assert(bs_new->device_name[0] == '\0'); assert(bs_new->dirty_bitmap == NULL); assert(bs_new->job == NULL); assert(bs_new->dev == NULL); assert(bs_new->in_use == 0); assert(bs_new->io_limits_enabled == false); assert(bs_new->block_timer == NULL); tmp = *bs_new; *bs_new = *bs_old; *bs_old = tmp; /* there are some fields that should not be swapped, move them back */ bdrv_move_feature_fields(&tmp, bs_old); bdrv_move_feature_fields(bs_old, bs_new); bdrv_move_feature_fields(bs_new, &tmp); /* bs_new shouldn't be in bdrv_states even after the swap! */ assert(bs_new->device_name[0] == '\0'); /* Check a few fields that should remain attached to the device */ assert(bs_new->dev == NULL); assert(bs_new->job == NULL); assert(bs_new->in_use == 0); assert(bs_new->io_limits_enabled == false); assert(bs_new->block_timer == NULL); bdrv_rebind(bs_new); bdrv_rebind(bs_old); } /* * Add new bs contents at the top of an image chain while the chain is * live, while keeping required fields on the top layer. * * This will modify the BlockDriverState fields, and swap contents * between bs_new and bs_top. Both bs_new and bs_top are modified. * * bs_new is required to be anonymous. * * This function does not create any image files. */ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top) { bdrv_swap(bs_new, bs_top); /* The contents of 'tmp' will become bs_top, as we are * swapping bs_new and bs_top contents. */ bs_top->backing_hd = bs_new; bs_top->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs_top->backing_file, sizeof(bs_top->backing_file), bs_new->filename); pstrcpy(bs_top->backing_format, sizeof(bs_top->backing_format), bs_new->drv ? bs_new->drv->format_name : ""); } void bdrv_delete(BlockDriverState *bs) { assert(!bs->dev); assert(!bs->job); assert(!bs->in_use); /* remove from list, if necessary */ bdrv_make_anon(bs); bdrv_close(bs); g_free(bs); } int bdrv_attach_dev(BlockDriverState *bs, void *dev) /* TODO change to DeviceState *dev when all users are qdevified */ { if (bs->dev) { return -EBUSY; } bs->dev = dev; bdrv_iostatus_reset(bs); return 0; } /* TODO qdevified devices don't use this, remove when devices are qdevified */ void bdrv_attach_dev_nofail(BlockDriverState *bs, void *dev) { if (bdrv_attach_dev(bs, dev) < 0) { abort(); } } void bdrv_detach_dev(BlockDriverState *bs, void *dev) /* TODO change to DeviceState *dev when all users are qdevified */ { assert(bs->dev == dev); bs->dev = NULL; bs->dev_ops = NULL; bs->dev_opaque = NULL; bs->buffer_alignment = 512; } /* TODO change to return DeviceState * when all users are qdevified */ void *bdrv_get_attached_dev(BlockDriverState *bs) { return bs->dev; } void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, void *opaque) { bs->dev_ops = ops; bs->dev_opaque = opaque; } void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, enum MonitorEvent ev, BlockErrorAction action, bool is_read) { QObject *data; const char *action_str; switch (action) { case BDRV_ACTION_REPORT: action_str = "report"; break; case BDRV_ACTION_IGNORE: action_str = "ignore"; break; case BDRV_ACTION_STOP: action_str = "stop"; break; default: abort(); } data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }", bdrv->device_name, action_str, is_read ? "read" : "write"); monitor_protocol_event(ev, data); qobject_decref(data); } static void bdrv_emit_qmp_eject_event(BlockDriverState *bs, bool ejected) { QObject *data; data = qobject_from_jsonf("{ 'device': %s, 'tray-open': %i }", bdrv_get_device_name(bs), ejected); monitor_protocol_event(QEVENT_DEVICE_TRAY_MOVED, data); qobject_decref(data); } static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) { if (bs->dev_ops && bs->dev_ops->change_media_cb) { bool tray_was_closed = !bdrv_dev_is_tray_open(bs); bs->dev_ops->change_media_cb(bs->dev_opaque, load); if (tray_was_closed) { /* tray open */ bdrv_emit_qmp_eject_event(bs, true); } if (load) { /* tray close */ bdrv_emit_qmp_eject_event(bs, false); } } } bool bdrv_dev_has_removable_media(BlockDriverState *bs) { return !bs->dev || (bs->dev_ops && bs->dev_ops->change_media_cb); } void bdrv_dev_eject_request(BlockDriverState *bs, bool force) { if (bs->dev_ops && bs->dev_ops->eject_request_cb) { bs->dev_ops->eject_request_cb(bs->dev_opaque, force); } } bool bdrv_dev_is_tray_open(BlockDriverState *bs) { if (bs->dev_ops && bs->dev_ops->is_tray_open) { return bs->dev_ops->is_tray_open(bs->dev_opaque); } return false; } static void bdrv_dev_resize_cb(BlockDriverState *bs) { if (bs->dev_ops && bs->dev_ops->resize_cb) { bs->dev_ops->resize_cb(bs->dev_opaque); } } bool bdrv_dev_is_medium_locked(BlockDriverState *bs) { if (bs->dev_ops && bs->dev_ops->is_medium_locked) { return bs->dev_ops->is_medium_locked(bs->dev_opaque); } return false; } /* * Run consistency checks on an image * * Returns 0 if the check could be completed (it doesn't mean that the image is * free of errors) or -errno when an internal error occurred. The results of the * check are stored in res. */ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { if (bs->drv->bdrv_check == NULL) { return -ENOTSUP; } memset(res, 0, sizeof(*res)); return bs->drv->bdrv_check(bs, res, fix); } #define COMMIT_BUF_SECTORS 2048 /* commit COW file into the raw image */ int bdrv_commit(BlockDriverState *bs) { BlockDriver *drv = bs->drv; int64_t sector, total_sectors; int n, ro, open_flags; int ret = 0; uint8_t *buf; char filename[PATH_MAX]; if (!drv) return -ENOMEDIUM; if (!bs->backing_hd) { return -ENOTSUP; } if (bdrv_in_use(bs) || bdrv_in_use(bs->backing_hd)) { return -EBUSY; } ro = bs->backing_hd->read_only; /* Use pstrcpy (not strncpy): filename must be NUL-terminated. */ pstrcpy(filename, sizeof(filename), bs->backing_hd->filename); open_flags = bs->backing_hd->open_flags; if (ro) { if (bdrv_reopen(bs->backing_hd, open_flags | BDRV_O_RDWR, NULL)) { return -EACCES; } } total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE); for (sector = 0; sector < total_sectors; sector += n) { if (bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n)) { if (bdrv_read(bs, sector, buf, n) != 0) { ret = -EIO; goto ro_cleanup; } if (bdrv_write(bs->backing_hd, sector, buf, n) != 0) { ret = -EIO; goto ro_cleanup; } } } if (drv->bdrv_make_empty) { ret = drv->bdrv_make_empty(bs); bdrv_flush(bs); } /* * Make sure all data we wrote to the backing device is actually * stable on disk. */ if (bs->backing_hd) bdrv_flush(bs->backing_hd); ro_cleanup: g_free(buf); if (ro) { /* ignoring error return here */ bdrv_reopen(bs->backing_hd, open_flags & ~BDRV_O_RDWR, NULL); } return ret; } int bdrv_commit_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { if (bs->drv && bs->backing_hd) { int ret = bdrv_commit(bs); if (ret < 0) { return ret; } } } return 0; } /** * Remove an active request from the tracked requests list * * This function should be called when a tracked request is completing. */ static void tracked_request_end(BdrvTrackedRequest *req) { QLIST_REMOVE(req, list); qemu_co_queue_restart_all(&req->wait_queue); } /** * Add an active request to the tracked requests list */ static void tracked_request_begin(BdrvTrackedRequest *req, BlockDriverState *bs, int64_t sector_num, int nb_sectors, bool is_write) { *req = (BdrvTrackedRequest){ .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .is_write = is_write, .co = qemu_coroutine_self(), }; qemu_co_queue_init(&req->wait_queue); QLIST_INSERT_HEAD(&bs->tracked_requests, req, list); } /** * Round a region to cluster boundaries */ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int64_t *cluster_sector_num, int *cluster_nb_sectors) { BlockDriverInfo bdi; if (bdrv_get_info(bs, &bdi) < 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; *cluster_nb_sectors = nb_sectors; } else { int64_t c = bdi.cluster_size / BDRV_SECTOR_SIZE; *cluster_sector_num = QEMU_ALIGN_DOWN(sector_num, c); *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } } static bool tracked_request_overlaps(BdrvTrackedRequest *req, int64_t sector_num, int nb_sectors) { /* aaaa bbbb */ if (sector_num >= req->sector_num + req->nb_sectors) { return false; } /* bbbb aaaa */ if (req->sector_num >= sector_num + nb_sectors) { return false; } return true; } static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BdrvTrackedRequest *req; int64_t cluster_sector_num; int cluster_nb_sectors; bool retry; /* If we touch the same cluster it counts as an overlap. This guarantees * that allocating writes will be serialized and not race with each other * for the same cluster. For example, in copy-on-read it ensures that the * CoR read and write operations are atomic and guest writes cannot * interleave between them. */ bdrv_round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); do { retry = false; QLIST_FOREACH(req, &bs->tracked_requests, list) { if (tracked_request_overlaps(req, cluster_sector_num, cluster_nb_sectors)) { /* Hitting this means there was a reentrant request, for * example, a block driver issuing nested requests. This must * never happen since it means deadlock. */ assert(qemu_coroutine_self() != req->co); qemu_co_queue_wait(&req->wait_queue); retry = true; break; } } } while (retry); } /* * Return values: * 0 - success * -EINVAL - backing format specified, but no file * -ENOSPC - can't update the backing file because no space is left in the * image file header * -ENOTSUP - format driver doesn't support changing the backing file */ int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { BlockDriver *drv = bs->drv; int ret; /* Backing file format doesn't make sense without a backing file */ if (backing_fmt && !backing_file) { return -EINVAL; } if (drv->bdrv_change_backing_file != NULL) { ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); } else { ret = -ENOTSUP; } if (ret == 0) { pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); } return ret; } /* * Finds the image layer in the chain that has 'bs' as its backing file. * * active is the current topmost image. * * Returns NULL if bs is not found in active's image chain, * or if active == bs. */ BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs) { BlockDriverState *overlay = NULL; BlockDriverState *intermediate; assert(active != NULL); assert(bs != NULL); /* if bs is the same as active, then by definition it has no overlay */ if (active == bs) { return NULL; } intermediate = active; while (intermediate->backing_hd) { if (intermediate->backing_hd == bs) { overlay = intermediate; break; } intermediate = intermediate->backing_hd; } return overlay; } typedef struct BlkIntermediateStates { BlockDriverState *bs; QSIMPLEQ_ENTRY(BlkIntermediateStates) entry; } BlkIntermediateStates; /* * Drops images above 'base' up to and including 'top', and sets the image * above 'top' to have base as its backing file. * * Requires that the overlay to 'top' is opened r/w, so that the backing file * information in 'bs' can be properly updated. * * E.g., this will convert the following chain: * bottom <- base <- intermediate <- top <- active * * to * * bottom <- base <- active * * It is allowed for bottom==base, in which case it converts: * * base <- intermediate <- top <- active * * to * * base <- active * * Error conditions: * if active == top, that is considered an error * */ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, BlockDriverState *base) { BlockDriverState *intermediate; BlockDriverState *base_bs = NULL; BlockDriverState *new_top_bs = NULL; BlkIntermediateStates *intermediate_state, *next; int ret = -EIO; QSIMPLEQ_HEAD(states_to_delete, BlkIntermediateStates) states_to_delete; QSIMPLEQ_INIT(&states_to_delete); if (!top->drv || !base->drv) { goto exit; } new_top_bs = bdrv_find_overlay(active, top); if (new_top_bs == NULL) { /* we could not find the image above 'top', this is an error */ goto exit; } /* special case of new_top_bs->backing_hd already pointing to base - nothing * to do, no intermediate images */ if (new_top_bs->backing_hd == base) { ret = 0; goto exit; } intermediate = top; /* now we will go down through the list, and add each BDS we find * into our deletion queue, until we hit the 'base' */ while (intermediate) { intermediate_state = g_malloc0(sizeof(BlkIntermediateStates)); intermediate_state->bs = intermediate; QSIMPLEQ_INSERT_TAIL(&states_to_delete, intermediate_state, entry); if (intermediate->backing_hd == base) { base_bs = intermediate->backing_hd; break; } intermediate = intermediate->backing_hd; } if (base_bs == NULL) { /* something went wrong, we did not end at the base. safely * unravel everything, and exit with error */ goto exit; } /* success - we can delete the intermediate states, and link top->base */ ret = bdrv_change_backing_file(new_top_bs, base_bs->filename, base_bs->drv ? base_bs->drv->format_name : ""); if (ret) { goto exit; } new_top_bs->backing_hd = base_bs; QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { /* so that bdrv_close() does not recursively close the chain */ intermediate_state->bs->backing_hd = NULL; bdrv_delete(intermediate_state->bs); } ret = 0; exit: QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { g_free(intermediate_state); } return ret; } static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, size_t size) { int64_t len; if (!bdrv_is_inserted(bs)) return -ENOMEDIUM; if (bs->growable) return 0; len = bdrv_getlength(bs); if (offset < 0) return -EIO; if ((offset > len) || (len - offset < size)) return -EIO; return 0; } static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE); } typedef struct RwCo { BlockDriverState *bs; int64_t sector_num; int nb_sectors; QEMUIOVector *qiov; bool is_write; int ret; } RwCo; static void coroutine_fn bdrv_rw_co_entry(void *opaque) { RwCo *rwco = opaque; if (!rwco->is_write) { rwco->ret = bdrv_co_do_readv(rwco->bs, rwco->sector_num, rwco->nb_sectors, rwco->qiov, 0); } else { rwco->ret = bdrv_co_do_writev(rwco->bs, rwco->sector_num, rwco->nb_sectors, rwco->qiov, 0); } } /* * Process a vectored synchronous request using coroutines */ static int bdrv_rwv_co(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, bool is_write) { Coroutine *co; RwCo rwco = { .bs = bs, .sector_num = sector_num, .nb_sectors = qiov->size >> BDRV_SECTOR_BITS, .qiov = qiov, .is_write = is_write, .ret = NOT_DONE, }; assert((qiov->size & (BDRV_SECTOR_SIZE - 1)) == 0); /** * In sync call context, when the vcpu is blocked, this throttling timer * will not fire; so the I/O throttling function has to be disabled here * if it has been enabled. */ if (bs->io_limits_enabled) { fprintf(stderr, "Disabling I/O throttling on '%s' due " "to synchronous I/O.\n", bdrv_get_device_name(bs)); bdrv_io_limits_disable(bs); } if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_rw_co_entry(&rwco); } else { co = qemu_coroutine_create(bdrv_rw_co_entry); qemu_coroutine_enter(co, &rwco); while (rwco.ret == NOT_DONE) { qemu_aio_wait(); } } return rwco.ret; } /* * Process a synchronous request using coroutines */ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors, bool is_write) { QEMUIOVector qiov; struct iovec iov = { .iov_base = (void *)buf, .iov_len = nb_sectors * BDRV_SECTOR_SIZE, }; qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_rwv_co(bs, sector_num, &qiov, is_write); } /* return < 0 if error. See bdrv_write() for the return codes */ int bdrv_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { return bdrv_rw_co(bs, sector_num, buf, nb_sectors, false); } /* Just like bdrv_read(), but with I/O throttling temporarily disabled */ int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { bool enabled; int ret; enabled = bs->io_limits_enabled; bs->io_limits_enabled = false; ret = bdrv_read(bs, 0, buf, 1); bs->io_limits_enabled = enabled; return ret; } /* Return < 0 if error. Important errors are: -EIO generic I/O error (may happen for all errors) -ENOMEDIUM No media inserted. -EINVAL Invalid sector number or nb_sectors -EACCES Trying to write a read-only device */ int bdrv_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { return bdrv_rw_co(bs, sector_num, (uint8_t *)buf, nb_sectors, true); } int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov) { return bdrv_rwv_co(bs, sector_num, qiov, true); } int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int count1) { uint8_t tmp_buf[BDRV_SECTOR_SIZE]; int len, nb_sectors, count; int64_t sector_num; int ret; count = count1; /* first read to align to sector start */ len = (BDRV_SECTOR_SIZE - offset) & (BDRV_SECTOR_SIZE - 1); if (len > count) len = count; sector_num = offset >> BDRV_SECTOR_BITS; if (len > 0) { if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0) return ret; memcpy(buf, tmp_buf + (offset & (BDRV_SECTOR_SIZE - 1)), len); count -= len; if (count == 0) return count1; sector_num++; buf += len; } /* read the sectors "in place" */ nb_sectors = count >> BDRV_SECTOR_BITS; if (nb_sectors > 0) { if ((ret = bdrv_read(bs, sector_num, buf, nb_sectors)) < 0) return ret; sector_num += nb_sectors; len = nb_sectors << BDRV_SECTOR_BITS; buf += len; count -= len; } /* add data from the last sector */ if (count > 0) { if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0) return ret; memcpy(buf, tmp_buf, count); } return count1; } int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov) { uint8_t tmp_buf[BDRV_SECTOR_SIZE]; int len, nb_sectors, count; int64_t sector_num; int ret; count = qiov->size; /* first write to align to sector start */ len = (BDRV_SECTOR_SIZE - offset) & (BDRV_SECTOR_SIZE - 1); if (len > count) len = count; sector_num = offset >> BDRV_SECTOR_BITS; if (len > 0) { if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0) return ret; qemu_iovec_to_buf(qiov, 0, tmp_buf + (offset & (BDRV_SECTOR_SIZE - 1)), len); if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0) return ret; count -= len; if (count == 0) return qiov->size; sector_num++; } /* write the sectors "in place" */ nb_sectors = count >> BDRV_SECTOR_BITS; if (nb_sectors > 0) { QEMUIOVector qiov_inplace; qemu_iovec_init(&qiov_inplace, qiov->niov); qemu_iovec_concat(&qiov_inplace, qiov, len, nb_sectors << BDRV_SECTOR_BITS); ret = bdrv_writev(bs, sector_num, &qiov_inplace); qemu_iovec_destroy(&qiov_inplace); if (ret < 0) { return ret; } sector_num += nb_sectors; len = nb_sectors << BDRV_SECTOR_BITS; count -= len; } /* add data from the last sector */ if (count > 0) { if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0) return ret; qemu_iovec_to_buf(qiov, qiov->size - count, tmp_buf, count); if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0) return ret; } return qiov->size; } int bdrv_pwrite(BlockDriverState *bs, int64_t offset, const void *buf, int count1) { QEMUIOVector qiov; struct iovec iov = { .iov_base = (void *) buf, .iov_len = count1, }; qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_pwritev(bs, offset, &qiov); } /* * Writes to the file and ensures that no writes are reordered across this * request (acts as a barrier) * * Returns 0 on success, -errno in error cases. */ int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, const void *buf, int count) { int ret; ret = bdrv_pwrite(bs, offset, buf, count); if (ret < 0) { return ret; } /* No flush needed for cache modes that already do it */ if (bs->enable_write_cache) { bdrv_flush(bs); } return 0; } static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { /* Perform I/O through a temporary buffer so that users who scribble over * their read buffer while the operation is in progress do not end up * modifying the image file. This is critical for zero-copy guest I/O * where anything might happen inside guest memory. */ void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_sector_num; int cluster_nb_sectors; size_t skip_bytes; int ret; /* Cover entire cluster so no additional backing file I/O is required when * allocating cluster in the image file. */ bdrv_round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors, cluster_sector_num, cluster_nb_sectors); iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE; iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len); qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); if (ret < 0) { goto err; } if (drv->bdrv_co_write_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num, cluster_nb_sectors); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. */ ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); } if (ret < 0) { /* It might be okay to ignore write errors for guest requests. If this * is a deliberate copy-on-read then we don't want to ignore the error. * Simply report it in all cases. */ goto err; } skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, nb_sectors * BDRV_SECTOR_SIZE); err: qemu_vfree(bounce_buffer); return ret; } /* * Handle a read request in coroutine context */ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; BdrvTrackedRequest req; int ret; if (!drv) { return -ENOMEDIUM; } if (bdrv_check_request(bs, sector_num, nb_sectors)) { return -EIO; } /* throttling disk read I/O */ if (bs->io_limits_enabled) { bdrv_io_limits_intercept(bs, false, nb_sectors); } if (bs->copy_on_read) { flags |= BDRV_REQ_COPY_ON_READ; } if (flags & BDRV_REQ_COPY_ON_READ) { bs->copy_on_read_in_flight++; } if (bs->copy_on_read_in_flight) { wait_for_overlapping_requests(bs, sector_num, nb_sectors); } tracked_request_begin(&req, bs, sector_num, nb_sectors, false); if (flags & BDRV_REQ_COPY_ON_READ) { int pnum; ret = bdrv_co_is_allocated(bs, sector_num, nb_sectors, &pnum); if (ret < 0) { goto out; } if (!ret || pnum != nb_sectors) { ret = bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors, qiov); goto out; } } ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); out: tracked_request_end(&req); if (flags & BDRV_REQ_COPY_ON_READ) { bs->copy_on_read_in_flight--; } return ret; } int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); } int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_copy_on_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, BDRV_REQ_COPY_ON_READ); } static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BlockDriver *drv = bs->drv; QEMUIOVector qiov; struct iovec iov; int ret; /* TODO Emulate only part of misaligned requests instead of letting block * drivers return -ENOTSUP and emulate everything */ /* First try the efficient write zeroes operation */ if (drv->bdrv_co_write_zeroes) { ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors); if (ret != -ENOTSUP) { return ret; } } /* Fall back to bounce buffer if write zeroes is unsupported */ iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; iov.iov_base = qemu_blockalign(bs, iov.iov_len); memset(iov.iov_base, 0, iov.iov_len); qemu_iovec_init_external(&qiov, &iov, 1); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, &qiov); qemu_vfree(iov.iov_base); return ret; } /* * Handle a write request in coroutine context */ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; BdrvTrackedRequest req; int ret; if (!bs->drv) { return -ENOMEDIUM; } if (bs->read_only) { return -EACCES; } if (bdrv_check_request(bs, sector_num, nb_sectors)) { return -EIO; } /* throttling disk write I/O */ if (bs->io_limits_enabled) { bdrv_io_limits_intercept(bs, true, nb_sectors); } if (bs->copy_on_read_in_flight) { wait_for_overlapping_requests(bs, sector_num, nb_sectors); } tracked_request_begin(&req, bs, sector_num, nb_sectors, true); ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req); if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors); } else { ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } if (ret == 0 && !bs->enable_write_cache) { ret = bdrv_co_flush(bs); } if (bs->dirty_bitmap) { bdrv_set_dirty(bs, sector_num, nb_sectors); } if (bs->wr_highest_sector < sector_num + nb_sectors - 1) { bs->wr_highest_sector = sector_num + nb_sectors - 1; } tracked_request_end(&req); return ret; } int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_writev(bs, sector_num, nb_sectors); return bdrv_co_do_writev(bs, sector_num, nb_sectors, qiov, 0); } int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors); return bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL, BDRV_REQ_ZERO_WRITE); } /** * Truncate file to 'offset' bytes (needed only for file protocols) */ int bdrv_truncate(BlockDriverState *bs, int64_t offset) { BlockDriver *drv = bs->drv; int ret; if (!drv) return -ENOMEDIUM; if (!drv->bdrv_truncate) return -ENOTSUP; if (bs->read_only) return -EACCES; if (bdrv_in_use(bs)) return -EBUSY; ret = drv->bdrv_truncate(bs, offset); if (ret == 0) { ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); bdrv_dev_resize_cb(bs); } return ret; } /** * Length of a allocated file in bytes. Sparse files are counted by actual * allocated space. Return < 0 if error or unknown. */ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (drv->bdrv_get_allocated_file_size) { return drv->bdrv_get_allocated_file_size(bs); } if (bs->file) { return bdrv_get_allocated_file_size(bs->file); } return -ENOTSUP; } /** * Length of a file in bytes. Return < 0 if error or unknown. */ int64_t bdrv_getlength(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (bs->growable || bdrv_dev_has_removable_media(bs)) { if (drv->bdrv_getlength) { return drv->bdrv_getlength(bs); } } return bs->total_sectors * BDRV_SECTOR_SIZE; } /* return 0 as number of sectors if no device present or error */ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) { int64_t length; length = bdrv_getlength(bs); if (length < 0) length = 0; else length = length >> BDRV_SECTOR_BITS; *nb_sectors_ptr = length; } /* throttling disk io limits */ void bdrv_set_io_limits(BlockDriverState *bs, BlockIOLimit *io_limits) { bs->io_limits = *io_limits; bs->io_limits_enabled = bdrv_io_limits_enabled(bs); } void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error, BlockdevOnError on_write_error) { bs->on_read_error = on_read_error; bs->on_write_error = on_write_error; } BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read) { return is_read ? bs->on_read_error : bs->on_write_error; } BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error) { BlockdevOnError on_err = is_read ? bs->on_read_error : bs->on_write_error; switch (on_err) { case BLOCKDEV_ON_ERROR_ENOSPC: return (error == ENOSPC) ? BDRV_ACTION_STOP : BDRV_ACTION_REPORT; case BLOCKDEV_ON_ERROR_STOP: return BDRV_ACTION_STOP; case BLOCKDEV_ON_ERROR_REPORT: return BDRV_ACTION_REPORT; case BLOCKDEV_ON_ERROR_IGNORE: return BDRV_ACTION_IGNORE; default: abort(); } } /* This is done by device models because, while the block layer knows * about the error, it does not know whether an operation comes from * the device or the block layer (from a job, for example). */ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error) { assert(error >= 0); bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); if (action == BDRV_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(bs, error); } } int bdrv_is_read_only(BlockDriverState *bs) { return bs->read_only; } int bdrv_is_sg(BlockDriverState *bs) { return bs->sg; } int bdrv_enable_write_cache(BlockDriverState *bs) { return bs->enable_write_cache; } void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce) { bs->enable_write_cache = wce; /* so a reopen() will preserve wce */ if (wce) { bs->open_flags |= BDRV_O_CACHE_WB; } else { bs->open_flags &= ~BDRV_O_CACHE_WB; } } int bdrv_is_encrypted(BlockDriverState *bs) { if (bs->backing_hd && bs->backing_hd->encrypted) return 1; return bs->encrypted; } int bdrv_key_required(BlockDriverState *bs) { BlockDriverState *backing_hd = bs->backing_hd; if (backing_hd && backing_hd->encrypted && !backing_hd->valid_key) return 1; return (bs->encrypted && !bs->valid_key); } int bdrv_set_key(BlockDriverState *bs, const char *key) { int ret; if (bs->backing_hd && bs->backing_hd->encrypted) { ret = bdrv_set_key(bs->backing_hd, key); if (ret < 0) return ret; if (!bs->encrypted) return 0; } if (!bs->encrypted) { return -EINVAL; } else if (!bs->drv || !bs->drv->bdrv_set_key) { return -ENOMEDIUM; } ret = bs->drv->bdrv_set_key(bs, key); if (ret < 0) { bs->valid_key = 0; } else if (!bs->valid_key) { bs->valid_key = 1; /* call the change callback now, we skipped it on open */ bdrv_dev_change_media_cb(bs, true); } return ret; } const char *bdrv_get_format_name(BlockDriverState *bs) { return bs->drv ? bs->drv->format_name : NULL; } void bdrv_iterate_format(void (*it)(void *opaque, const char *name), void *opaque) { BlockDriver *drv; QLIST_FOREACH(drv, &bdrv_drivers, list) { it(opaque, drv->format_name); } } BlockDriverState *bdrv_find(const char *name) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { if (!strcmp(name, bs->device_name)) { return bs; } } return NULL; } BlockDriverState *bdrv_next(BlockDriverState *bs) { if (!bs) { return QTAILQ_FIRST(&bdrv_states); } return QTAILQ_NEXT(bs, list); } void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { it(opaque, bs); } } const char *bdrv_get_device_name(BlockDriverState *bs) { return bs->device_name; } int bdrv_get_flags(BlockDriverState *bs) { return bs->open_flags; } int bdrv_flush_all(void) { BlockDriverState *bs; int result = 0; QTAILQ_FOREACH(bs, &bdrv_states, list) { int ret = bdrv_flush(bs); if (ret < 0 && !result) { result = ret; } } return result; } int bdrv_has_zero_init_1(BlockDriverState *bs) { return 1; } int bdrv_has_zero_init(BlockDriverState *bs) { assert(bs->drv); if (bs->drv->bdrv_has_zero_init) { return bs->drv->bdrv_has_zero_init(bs); } /* safe default */ return 0; } typedef struct BdrvCoIsAllocatedData { BlockDriverState *bs; BlockDriverState *base; int64_t sector_num; int nb_sectors; int *pnum; int ret; bool done; } BdrvCoIsAllocatedData; /* * Returns true iff the specified sector is present in the disk image. Drivers * not implementing the functionality are assumed to not support backing files, * hence all their sectors are reported as allocated. * * If 'sector_num' is beyond the end of the disk image the return value is 0 * and 'pnum' is set to 0. * * 'pnum' is set to the number of sectors (including and immediately following * the specified sector) that are known to be in the same * allocated/unallocated state. * * 'nb_sectors' is the max value 'pnum' should be set to. If nb_sectors goes * beyond the end of the disk image it will be clamped. */ int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { int64_t n; if (sector_num >= bs->total_sectors) { *pnum = 0; return 0; } n = bs->total_sectors - sector_num; if (n < nb_sectors) { nb_sectors = n; } if (!bs->drv->bdrv_co_is_allocated) { *pnum = nb_sectors; return 1; } return bs->drv->bdrv_co_is_allocated(bs, sector_num, nb_sectors, pnum); } /* Coroutine wrapper for bdrv_is_allocated() */ static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque) { BdrvCoIsAllocatedData *data = opaque; BlockDriverState *bs = data->bs; data->ret = bdrv_co_is_allocated(bs, data->sector_num, data->nb_sectors, data->pnum); data->done = true; } /* * Synchronous wrapper around bdrv_co_is_allocated(). * * See bdrv_co_is_allocated() for details. */ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoIsAllocatedData data = { .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; co = qemu_coroutine_create(bdrv_is_allocated_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { qemu_aio_wait(); } return data.ret; } /* * Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP] * * Return true if the given sector is allocated in any image between * BASE and TOP (inclusive). BASE can be NULL to check if the given * sector is allocated in any image of the chain. Return false otherwise. * * 'pnum' is set to the number of sectors (including and immediately following * the specified sector) that are known to be in the same * allocated/unallocated state. * */ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum) { BlockDriverState *intermediate; int ret, n = nb_sectors; intermediate = top; while (intermediate && intermediate != base) { int pnum_inter; ret = bdrv_co_is_allocated(intermediate, sector_num, nb_sectors, &pnum_inter); if (ret < 0) { return ret; } else if (ret) { *pnum = pnum_inter; return 1; } /* * [sector_num, nb_sectors] is unallocated on top but intermediate * might have * * [sector_num+x, nr_sectors] allocated. */ if (n > pnum_inter && (intermediate == top || sector_num + pnum_inter < intermediate->total_sectors)) { n = pnum_inter; } intermediate = intermediate->backing_hd; } *pnum = n; return 0; } /* Coroutine wrapper for bdrv_is_allocated_above() */ static void coroutine_fn bdrv_is_allocated_above_co_entry(void *opaque) { BdrvCoIsAllocatedData *data = opaque; BlockDriverState *top = data->bs; BlockDriverState *base = data->base; data->ret = bdrv_co_is_allocated_above(top, base, data->sector_num, data->nb_sectors, data->pnum); data->done = true; } /* * Synchronous wrapper around bdrv_co_is_allocated_above(). * * See bdrv_co_is_allocated_above() for details. */ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoIsAllocatedData data = { .bs = top, .base = base, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; co = qemu_coroutine_create(bdrv_is_allocated_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { qemu_aio_wait(); } return data.ret; } const char *bdrv_get_encrypted_filename(BlockDriverState *bs) { if (bs->backing_hd && bs->backing_hd->encrypted) return bs->backing_file; else if (bs->encrypted) return bs->filename; else return NULL; } void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { pstrcpy(filename, filename_size, bs->backing_file); } int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (!drv->bdrv_write_compressed) return -ENOTSUP; if (bdrv_check_request(bs, sector_num, nb_sectors)) return -EIO; assert(!bs->dirty_bitmap); return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors); } int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (!drv->bdrv_get_info) return -ENOTSUP; memset(bdi, 0, sizeof(*bdi)); return drv->bdrv_get_info(bs, bdi); } int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { QEMUIOVector qiov; struct iovec iov = { .iov_base = (void *) buf, .iov_len = size, }; qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_writev_vmstate(bs, &qiov, pos); } int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } else if (drv->bdrv_save_vmstate) { return drv->bdrv_save_vmstate(bs, qiov, pos); } else if (bs->file) { return bdrv_writev_vmstate(bs->file, qiov, pos); } return -ENOTSUP; } int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (drv->bdrv_load_vmstate) return drv->bdrv_load_vmstate(bs, buf, pos, size); if (bs->file) return bdrv_load_vmstate(bs->file, buf, pos, size); return -ENOTSUP; } void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event) { if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { return; } bs->drv->bdrv_debug_event(bs, event); } int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_breakpoint) { bs = bs->file; } if (bs && bs->drv && bs->drv->bdrv_debug_breakpoint) { return bs->drv->bdrv_debug_breakpoint(bs, event, tag); } return -ENOTSUP; } int bdrv_debug_resume(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_resume) { bs = bs->file; } if (bs && bs->drv && bs->drv->bdrv_debug_resume) { return bs->drv->bdrv_debug_resume(bs, tag); } return -ENOTSUP; } bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_is_suspended) { bs = bs->file; } if (bs && bs->drv && bs->drv->bdrv_debug_is_suspended) { return bs->drv->bdrv_debug_is_suspended(bs, tag); } return false; } int bdrv_is_snapshot(BlockDriverState *bs) { return !!(bs->open_flags & BDRV_O_SNAPSHOT); } /* backing_file can either be relative, or absolute, or a protocol. If it is * relative, it must be relative to the chain. So, passing in bs->filename * from a BDS as backing_file should not be done, as that may be relative to * the CWD rather than the chain. */ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file) { char *filename_full = NULL; char *backing_file_full = NULL; char *filename_tmp = NULL; int is_protocol = 0; BlockDriverState *curr_bs = NULL; BlockDriverState *retval = NULL; if (!bs || !bs->drv || !backing_file) { return NULL; } filename_full = g_malloc(PATH_MAX); backing_file_full = g_malloc(PATH_MAX); filename_tmp = g_malloc(PATH_MAX); is_protocol = path_has_protocol(backing_file); for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) { /* If either of the filename paths is actually a protocol, then * compare unmodified paths; otherwise make paths relative */ if (is_protocol || path_has_protocol(curr_bs->backing_file)) { if (strcmp(backing_file, curr_bs->backing_file) == 0) { retval = curr_bs->backing_hd; break; } } else { /* If not an absolute filename path, make it relative to the current * image's filename path */ path_combine(filename_tmp, PATH_MAX, curr_bs->filename, backing_file); /* We are going to compare absolute pathnames */ if (!realpath(filename_tmp, filename_full)) { continue; } /* We need to make sure the backing filename we are comparing against * is relative to the current image filename (or absolute) */ path_combine(filename_tmp, PATH_MAX, curr_bs->filename, curr_bs->backing_file); if (!realpath(filename_tmp, backing_file_full)) { continue; } if (strcmp(backing_file_full, filename_full) == 0) { retval = curr_bs->backing_hd; break; } } } g_free(filename_full); g_free(backing_file_full); g_free(filename_tmp); return retval; } int bdrv_get_backing_file_depth(BlockDriverState *bs) { if (!bs->drv) { return 0; } if (!bs->backing_hd) { return 0; } return 1 + bdrv_get_backing_file_depth(bs->backing_hd); } BlockDriverState *bdrv_find_base(BlockDriverState *bs) { BlockDriverState *curr_bs = NULL; if (!bs) { return NULL; } curr_bs = bs; while (curr_bs->backing_hd) { curr_bs = curr_bs->backing_hd; } return curr_bs; } /**************************************************************/ /* async I/Os */ BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { trace_bdrv_aio_readv(bs, sector_num, nb_sectors, opaque); return bdrv_co_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, false); } BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { trace_bdrv_aio_writev(bs, sector_num, nb_sectors, opaque); return bdrv_co_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, true); } typedef struct MultiwriteCB { int error; int num_requests; int num_callbacks; struct { BlockDriverCompletionFunc *cb; void *opaque; QEMUIOVector *free_qiov; } callbacks[]; } MultiwriteCB; static void multiwrite_user_cb(MultiwriteCB *mcb) { int i; for (i = 0; i < mcb->num_callbacks; i++) { mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error); if (mcb->callbacks[i].free_qiov) { qemu_iovec_destroy(mcb->callbacks[i].free_qiov); } g_free(mcb->callbacks[i].free_qiov); } } static void multiwrite_cb(void *opaque, int ret) { MultiwriteCB *mcb = opaque; trace_multiwrite_cb(mcb, ret); if (ret < 0 && !mcb->error) { mcb->error = ret; } mcb->num_requests--; if (mcb->num_requests == 0) { multiwrite_user_cb(mcb); g_free(mcb); } } static int multiwrite_req_compare(const void *a, const void *b) { const BlockRequest *req1 = a, *req2 = b; /* * Note that we can't simply subtract req2->sector from req1->sector * here as that could overflow the return value. */ if (req1->sector > req2->sector) { return 1; } else if (req1->sector < req2->sector) { return -1; } else { return 0; } } /* * Takes a bunch of requests and tries to merge them. Returns the number of * requests that remain after merging. */ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, int num_reqs, MultiwriteCB *mcb) { int i, outidx; // Sort requests by start sector qsort(reqs, num_reqs, sizeof(*reqs), &multiwrite_req_compare); // Check if adjacent requests touch the same clusters. If so, combine them, // filling up gaps with zero sectors. outidx = 0; for (i = 1; i < num_reqs; i++) { int merge = 0; int64_t oldreq_last = reqs[outidx].sector + reqs[outidx].nb_sectors; // Handle exactly sequential writes and overlapping writes. if (reqs[i].sector <= oldreq_last) { merge = 1; } if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) { merge = 0; } if (merge) { size_t size; QEMUIOVector *qiov = g_malloc0(sizeof(*qiov)); qemu_iovec_init(qiov, reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1); // Add the first request to the merged one. If the requests are // overlapping, drop the last sectors of the first request. size = (reqs[i].sector - reqs[outidx].sector) << 9; qemu_iovec_concat(qiov, reqs[outidx].qiov, 0, size); // We should need to add any zeros between the two requests assert (reqs[i].sector <= oldreq_last); // Add the second request qemu_iovec_concat(qiov, reqs[i].qiov, 0, reqs[i].qiov->size); reqs[outidx].nb_sectors = qiov->size >> 9; reqs[outidx].qiov = qiov; mcb->callbacks[i].free_qiov = reqs[outidx].qiov; } else { outidx++; reqs[outidx].sector = reqs[i].sector; reqs[outidx].nb_sectors = reqs[i].nb_sectors; reqs[outidx].qiov = reqs[i].qiov; } } return outidx + 1; } /* * Submit multiple AIO write requests at once. * * On success, the function returns 0 and all requests in the reqs array have * been submitted. In error case this function returns -1, and any of the * requests may or may not be submitted yet. In particular, this means that the * callback will be called for some of the requests, for others it won't. The * caller must check the error field of the BlockRequest to wait for the right * callbacks (if error != 0, no callback will be called). * * The implementation may modify the contents of the reqs array, e.g. to merge * requests. However, the fields opaque and error are left unmodified as they * are used to signal failure for a single request to the caller. */ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) { MultiwriteCB *mcb; int i; /* don't submit writes if we don't have a medium */ if (bs->drv == NULL) { for (i = 0; i < num_reqs; i++) { reqs[i].error = -ENOMEDIUM; } return -1; } if (num_reqs == 0) { return 0; } // Create MultiwriteCB structure mcb = g_malloc0(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks)); mcb->num_requests = 0; mcb->num_callbacks = num_reqs; for (i = 0; i < num_reqs; i++) { mcb->callbacks[i].cb = reqs[i].cb; mcb->callbacks[i].opaque = reqs[i].opaque; } // Check for mergable requests num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb); trace_bdrv_aio_multiwrite(mcb, mcb->num_callbacks, num_reqs); /* Run the aio requests. */ mcb->num_requests = num_reqs; for (i = 0; i < num_reqs; i++) { bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov, reqs[i].nb_sectors, multiwrite_cb, mcb); } return 0; } void bdrv_aio_cancel(BlockDriverAIOCB *acb) { acb->aiocb_info->cancel(acb); } /* block I/O throttling */ static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, bool is_write, double elapsed_time, uint64_t *wait) { uint64_t bps_limit = 0; uint64_t extension; double bytes_limit, bytes_base, bytes_res; double slice_time, wait_time; if (bs->io_limits.bps[BLOCK_IO_LIMIT_TOTAL]) { bps_limit = bs->io_limits.bps[BLOCK_IO_LIMIT_TOTAL]; } else if (bs->io_limits.bps[is_write]) { bps_limit = bs->io_limits.bps[is_write]; } else { if (wait) { *wait = 0; } return false; } slice_time = bs->slice_end - bs->slice_start; slice_time /= (NANOSECONDS_PER_SECOND); bytes_limit = bps_limit * slice_time; bytes_base = bs->slice_submitted.bytes[is_write]; if (bs->io_limits.bps[BLOCK_IO_LIMIT_TOTAL]) { bytes_base += bs->slice_submitted.bytes[!is_write]; } /* bytes_base: the bytes of data which have been read/written; and * it is obtained from the history statistic info. * bytes_res: the remaining bytes of data which need to be read/written. * (bytes_base + bytes_res) / bps_limit: used to calcuate * the total time for completing reading/writting all data. */ bytes_res = (unsigned) nb_sectors * BDRV_SECTOR_SIZE; if (bytes_base + bytes_res <= bytes_limit) { if (wait) { *wait = 0; } return false; } /* Calc approx time to dispatch */ wait_time = (bytes_base + bytes_res) / bps_limit - elapsed_time; /* When the I/O rate at runtime exceeds the limits, * bs->slice_end need to be extended in order that the current statistic * info can be kept until the timer fire, so it is increased and tuned * based on the result of experiment. */ extension = wait_time * NANOSECONDS_PER_SECOND; extension = DIV_ROUND_UP(extension, BLOCK_IO_SLICE_TIME) * BLOCK_IO_SLICE_TIME; bs->slice_end += extension; if (wait) { *wait = wait_time * NANOSECONDS_PER_SECOND; } return true; } static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, double elapsed_time, uint64_t *wait) { uint64_t iops_limit = 0; double ios_limit, ios_base; double slice_time, wait_time; if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) { iops_limit = bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]; } else if (bs->io_limits.iops[is_write]) { iops_limit = bs->io_limits.iops[is_write]; } else { if (wait) { *wait = 0; } return false; } slice_time = bs->slice_end - bs->slice_start; slice_time /= (NANOSECONDS_PER_SECOND); ios_limit = iops_limit * slice_time; ios_base = bs->slice_submitted.ios[is_write]; if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) { ios_base += bs->slice_submitted.ios[!is_write]; } if (ios_base + 1 <= ios_limit) { if (wait) { *wait = 0; } return false; } /* Calc approx time to dispatch, in seconds */ wait_time = (ios_base + 1) / iops_limit; if (wait_time > elapsed_time) { wait_time = wait_time - elapsed_time; } else { wait_time = 0; } /* Exceeded current slice, extend it by another slice time */ bs->slice_end += BLOCK_IO_SLICE_TIME; if (wait) { *wait = wait_time * NANOSECONDS_PER_SECOND; } return true; } static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors, bool is_write, int64_t *wait) { int64_t now, max_wait; uint64_t bps_wait = 0, iops_wait = 0; double elapsed_time; int bps_ret, iops_ret; now = qemu_get_clock_ns(vm_clock); if (now > bs->slice_end) { bs->slice_start = now; bs->slice_end = now + BLOCK_IO_SLICE_TIME; memset(&bs->slice_submitted, 0, sizeof(bs->slice_submitted)); } elapsed_time = now - bs->slice_start; elapsed_time /= (NANOSECONDS_PER_SECOND); bps_ret = bdrv_exceed_bps_limits(bs, nb_sectors, is_write, elapsed_time, &bps_wait); iops_ret = bdrv_exceed_iops_limits(bs, is_write, elapsed_time, &iops_wait); if (bps_ret || iops_ret) { max_wait = bps_wait > iops_wait ? bps_wait : iops_wait; if (wait) { *wait = max_wait; } now = qemu_get_clock_ns(vm_clock); if (bs->slice_end < now + max_wait) { bs->slice_end = now + max_wait; } return true; } if (wait) { *wait = 0; } bs->slice_submitted.bytes[is_write] += (int64_t)nb_sectors * BDRV_SECTOR_SIZE; bs->slice_submitted.ios[is_write]++; return false; } /**************************************************************/ /* async block device emulation */ typedef struct BlockDriverAIOCBSync { BlockDriverAIOCB common; QEMUBH *bh; int ret; /* vector translation state */ QEMUIOVector *qiov; uint8_t *bounce; int is_write; } BlockDriverAIOCBSync; static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb) { BlockDriverAIOCBSync *acb = container_of(blockacb, BlockDriverAIOCBSync, common); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_release(acb); } static const AIOCBInfo bdrv_em_aiocb_info = { .aiocb_size = sizeof(BlockDriverAIOCBSync), .cancel = bdrv_aio_cancel_em, }; static void bdrv_aio_bh_cb(void *opaque) { BlockDriverAIOCBSync *acb = opaque; if (!acb->is_write) qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); qemu_vfree(acb->bounce); acb->common.cb(acb->common.opaque, acb->ret); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_release(acb); } static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int is_write) { BlockDriverAIOCBSync *acb; acb = qemu_aio_get(&bdrv_em_aiocb_info, bs, cb, opaque); acb->is_write = is_write; acb->qiov = qiov; acb->bounce = qemu_blockalign(bs, qiov->size); acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb); if (is_write) { qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size); acb->ret = bs->drv->bdrv_write(bs, sector_num, acb->bounce, nb_sectors); } else { acb->ret = bs->drv->bdrv_read(bs, sector_num, acb->bounce, nb_sectors); } qemu_bh_schedule(acb->bh); return &acb->common; } static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { return bdrv_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); } static BlockDriverAIOCB *bdrv_aio_writev_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { return bdrv_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, 1); } typedef struct BlockDriverAIOCBCoroutine { BlockDriverAIOCB common; BlockRequest req; bool is_write; bool *done; QEMUBH* bh; } BlockDriverAIOCBCoroutine; static void bdrv_aio_co_cancel_em(BlockDriverAIOCB *blockacb) { BlockDriverAIOCBCoroutine *acb = container_of(blockacb, BlockDriverAIOCBCoroutine, common); bool done = false; acb->done = &done; while (!done) { qemu_aio_wait(); } } static const AIOCBInfo bdrv_em_co_aiocb_info = { .aiocb_size = sizeof(BlockDriverAIOCBCoroutine), .cancel = bdrv_aio_co_cancel_em, }; static void bdrv_co_em_bh(void *opaque) { BlockDriverAIOCBCoroutine *acb = opaque; acb->common.cb(acb->common.opaque, acb->req.error); if (acb->done) { *acb->done = true; } qemu_bh_delete(acb->bh); qemu_aio_release(acb); } /* Invoke bdrv_co_do_readv/bdrv_co_do_writev */ static void coroutine_fn bdrv_co_do_rw(void *opaque) { BlockDriverAIOCBCoroutine *acb = opaque; BlockDriverState *bs = acb->common.bs; if (!acb->is_write) { acb->req.error = bdrv_co_do_readv(bs, acb->req.sector, acb->req.nb_sectors, acb->req.qiov, 0); } else { acb->req.error = bdrv_co_do_writev(bs, acb->req.sector, acb->req.nb_sectors, acb->req.qiov, 0); } acb->bh = qemu_bh_new(bdrv_co_em_bh, acb); qemu_bh_schedule(acb->bh); } static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, bool is_write) { Coroutine *co; BlockDriverAIOCBCoroutine *acb; acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); acb->req.sector = sector_num; acb->req.nb_sectors = nb_sectors; acb->req.qiov = qiov; acb->is_write = is_write; acb->done = NULL; co = qemu_coroutine_create(bdrv_co_do_rw); qemu_coroutine_enter(co, acb); return &acb->common; } static void coroutine_fn bdrv_aio_flush_co_entry(void *opaque) { BlockDriverAIOCBCoroutine *acb = opaque; BlockDriverState *bs = acb->common.bs; acb->req.error = bdrv_co_flush(bs); acb->bh = qemu_bh_new(bdrv_co_em_bh, acb); qemu_bh_schedule(acb->bh); } BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque) { trace_bdrv_aio_flush(bs, opaque); Coroutine *co; BlockDriverAIOCBCoroutine *acb; acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); acb->done = NULL; co = qemu_coroutine_create(bdrv_aio_flush_co_entry); qemu_coroutine_enter(co, acb); return &acb->common; } static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque) { BlockDriverAIOCBCoroutine *acb = opaque; BlockDriverState *bs = acb->common.bs; acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors); acb->bh = qemu_bh_new(bdrv_co_em_bh, acb); qemu_bh_schedule(acb->bh); } BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { Coroutine *co; BlockDriverAIOCBCoroutine *acb; trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque); acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); acb->req.sector = sector_num; acb->req.nb_sectors = nb_sectors; acb->done = NULL; co = qemu_coroutine_create(bdrv_aio_discard_co_entry); qemu_coroutine_enter(co, acb); return &acb->common; } void bdrv_init(void) { module_call_init(MODULE_INIT_BLOCK); } void bdrv_init_with_whitelist(void) { use_bdrv_whitelist = 1; bdrv_init(); } void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque) { BlockDriverAIOCB *acb; acb = g_slice_alloc(aiocb_info->aiocb_size); acb->aiocb_info = aiocb_info; acb->bs = bs; acb->cb = cb; acb->opaque = opaque; return acb; } void qemu_aio_release(void *p) { BlockDriverAIOCB *acb = p; g_slice_free1(acb->aiocb_info->aiocb_size, acb); } /**************************************************************/ /* Coroutine block device emulation */ typedef struct CoroutineIOCompletion { Coroutine *coroutine; int ret; } CoroutineIOCompletion; static void bdrv_co_io_em_complete(void *opaque, int ret) { CoroutineIOCompletion *co = opaque; co->ret = ret; qemu_coroutine_enter(co->coroutine, NULL); } static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov, bool is_write) { CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; BlockDriverAIOCB *acb; if (is_write) { acb = bs->drv->bdrv_aio_writev(bs, sector_num, iov, nb_sectors, bdrv_co_io_em_complete, &co); } else { acb = bs->drv->bdrv_aio_readv(bs, sector_num, iov, nb_sectors, bdrv_co_io_em_complete, &co); } trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb); if (!acb) { return -EIO; } qemu_coroutine_yield(); return co.ret; } static int coroutine_fn bdrv_co_readv_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, false); } static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true); } static void coroutine_fn bdrv_flush_co_entry(void *opaque) { RwCo *rwco = opaque; rwco->ret = bdrv_co_flush(rwco->bs); } int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { int ret; if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) { return 0; } /* Write back cached data to the OS even with cache=unsafe */ BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS); if (bs->drv->bdrv_co_flush_to_os) { ret = bs->drv->bdrv_co_flush_to_os(bs); if (ret < 0) { return ret; } } /* But don't actually force it to the disk with cache=unsafe */ if (bs->open_flags & BDRV_O_NO_FLUSH) { goto flush_parent; } BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK); if (bs->drv->bdrv_co_flush_to_disk) { ret = bs->drv->bdrv_co_flush_to_disk(bs); } else if (bs->drv->bdrv_aio_flush) { BlockDriverAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_flush(bs, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } else { /* * Some block drivers always operate in either writethrough or unsafe * mode and don't support bdrv_flush therefore. Usually qemu doesn't * know how the server works (because the behaviour is hardcoded or * depends on server-side configuration), so we can't ensure that * everything is safe on disk. Returning an error doesn't work because * that would break guests even if the server operates in writethrough * mode. * * Let's hope the user knows what he's doing. */ ret = 0; } if (ret < 0) { return ret; } /* Now flush the underlying protocol. It will also have BDRV_O_NO_FLUSH * in the case of cache=unsafe, so there are no useless flushes. */ flush_parent: return bdrv_co_flush(bs->file); } void bdrv_invalidate_cache(BlockDriverState *bs) { if (bs->drv && bs->drv->bdrv_invalidate_cache) { bs->drv->bdrv_invalidate_cache(bs); } } void bdrv_invalidate_cache_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { bdrv_invalidate_cache(bs); } } void bdrv_clear_incoming_migration_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { bs->open_flags = bs->open_flags & ~(BDRV_O_INCOMING); } } int bdrv_flush(BlockDriverState *bs) { Coroutine *co; RwCo rwco = { .bs = bs, .ret = NOT_DONE, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_flush_co_entry(&rwco); } else { co = qemu_coroutine_create(bdrv_flush_co_entry); qemu_coroutine_enter(co, &rwco); while (rwco.ret == NOT_DONE) { qemu_aio_wait(); } } return rwco.ret; } static void coroutine_fn bdrv_discard_co_entry(void *opaque) { RwCo *rwco = opaque; rwco->ret = bdrv_co_discard(rwco->bs, rwco->sector_num, rwco->nb_sectors); } int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { if (!bs->drv) { return -ENOMEDIUM; } else if (bdrv_check_request(bs, sector_num, nb_sectors)) { return -EIO; } else if (bs->read_only) { return -EROFS; } if (bs->dirty_bitmap) { bdrv_reset_dirty(bs, sector_num, nb_sectors); } /* Do nothing if disabled. */ if (!(bs->open_flags & BDRV_O_UNMAP)) { return 0; } if (bs->drv->bdrv_co_discard) { return bs->drv->bdrv_co_discard(bs, sector_num, nb_sectors); } else if (bs->drv->bdrv_aio_discard) { BlockDriverAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors, bdrv_co_io_em_complete, &co); if (acb == NULL) { return -EIO; } else { qemu_coroutine_yield(); return co.ret; } } else { return 0; } } int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { Coroutine *co; RwCo rwco = { .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .ret = NOT_DONE, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_discard_co_entry(&rwco); } else { co = qemu_coroutine_create(bdrv_discard_co_entry); qemu_coroutine_enter(co, &rwco); while (rwco.ret == NOT_DONE) { qemu_aio_wait(); } } return rwco.ret; } /**************************************************************/ /* removable device support */ /** * Return TRUE if the media is present */ int bdrv_is_inserted(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv) return 0; if (!drv->bdrv_is_inserted) return 1; return drv->bdrv_is_inserted(bs); } /** * Return whether the media changed since the last call to this * function, or -ENOTSUP if we don't know. Most drivers don't know. */ int bdrv_media_changed(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_media_changed) { return drv->bdrv_media_changed(bs); } return -ENOTSUP; } /** * If eject_flag is TRUE, eject the media. Otherwise, close the tray */ void bdrv_eject(BlockDriverState *bs, bool eject_flag) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_eject) { drv->bdrv_eject(bs, eject_flag); } if (bs->device_name[0] != '\0') { bdrv_emit_qmp_eject_event(bs, eject_flag); } } /** * Lock or unlock the media (if it is locked, the user won't be able * to eject it manually). */ void bdrv_lock_medium(BlockDriverState *bs, bool locked) { BlockDriver *drv = bs->drv; trace_bdrv_lock_medium(bs, locked); if (drv && drv->bdrv_lock_medium) { drv->bdrv_lock_medium(bs, locked); } } /* needed for generic scsi interface */ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_ioctl) return drv->bdrv_ioctl(bs, req, buf); return -ENOTSUP; } BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_aio_ioctl) return drv->bdrv_aio_ioctl(bs, req, buf, cb, opaque); return NULL; } void bdrv_set_buffer_alignment(BlockDriverState *bs, int align) { bs->buffer_alignment = align; } void *qemu_blockalign(BlockDriverState *bs, size_t size) { return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size); } /* * Check if all memory in this vector is sector aligned. */ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) { int i; for (i = 0; i < qiov->niov; i++) { if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) { return false; } } return true; } void bdrv_set_dirty_tracking(BlockDriverState *bs, int granularity) { int64_t bitmap_size; assert((granularity & (granularity - 1)) == 0); if (granularity) { granularity >>= BDRV_SECTOR_BITS; assert(!bs->dirty_bitmap); bitmap_size = (bdrv_getlength(bs) >> BDRV_SECTOR_BITS); bs->dirty_bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1); } else { if (bs->dirty_bitmap) { hbitmap_free(bs->dirty_bitmap); bs->dirty_bitmap = NULL; } } } int bdrv_get_dirty(BlockDriverState *bs, int64_t sector) { if (bs->dirty_bitmap) { return hbitmap_get(bs->dirty_bitmap, sector); } else { return 0; } } void bdrv_dirty_iter_init(BlockDriverState *bs, HBitmapIter *hbi) { hbitmap_iter_init(hbi, bs->dirty_bitmap, 0); } void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors) { hbitmap_set(bs->dirty_bitmap, cur_sector, nr_sectors); } void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors) { hbitmap_reset(bs->dirty_bitmap, cur_sector, nr_sectors); } int64_t bdrv_get_dirty_count(BlockDriverState *bs) { if (bs->dirty_bitmap) { return hbitmap_count(bs->dirty_bitmap); } else { return 0; } } void bdrv_set_in_use(BlockDriverState *bs, int in_use) { assert(bs->in_use != in_use); bs->in_use = in_use; } int bdrv_in_use(BlockDriverState *bs) { return bs->in_use; } void bdrv_iostatus_enable(BlockDriverState *bs) { bs->iostatus_enabled = true; bs->iostatus = BLOCK_DEVICE_IO_STATUS_OK; } /* The I/O status is only enabled if the drive explicitly * enables it _and_ the VM is configured to stop on errors */ bool bdrv_iostatus_is_enabled(const BlockDriverState *bs) { return (bs->iostatus_enabled && (bs->on_write_error == BLOCKDEV_ON_ERROR_ENOSPC || bs->on_write_error == BLOCKDEV_ON_ERROR_STOP || bs->on_read_error == BLOCKDEV_ON_ERROR_STOP)); } void bdrv_iostatus_disable(BlockDriverState *bs) { bs->iostatus_enabled = false; } void bdrv_iostatus_reset(BlockDriverState *bs) { if (bdrv_iostatus_is_enabled(bs)) { bs->iostatus = BLOCK_DEVICE_IO_STATUS_OK; if (bs->job) { block_job_iostatus_reset(bs->job); } } } void bdrv_iostatus_set_err(BlockDriverState *bs, int error) { assert(bdrv_iostatus_is_enabled(bs)); if (bs->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { bs->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : BLOCK_DEVICE_IO_STATUS_FAILED; } } void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type) { assert(type < BDRV_MAX_IOTYPE); cookie->bytes = bytes; cookie->start_time_ns = get_clock(); cookie->type = type; } void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie) { assert(cookie->type < BDRV_MAX_IOTYPE); bs->nr_bytes[cookie->type] += cookie->bytes; bs->nr_ops[cookie->type]++; bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns; } void bdrv_img_create(const char *filename, const char *fmt, const char *base_filename, const char *base_fmt, char *options, uint64_t img_size, int flags, Error **errp, bool quiet) { QEMUOptionParameter *param = NULL, *create_options = NULL; QEMUOptionParameter *backing_fmt, *backing_file, *size; BlockDriverState *bs = NULL; BlockDriver *drv, *proto_drv; BlockDriver *backing_drv = NULL; int ret = 0; /* Find driver and parse its options */ drv = bdrv_find_format(fmt); if (!drv) { error_setg(errp, "Unknown file format '%s'", fmt); return; } proto_drv = bdrv_find_protocol(filename, true); if (!proto_drv) { error_setg(errp, "Unknown protocol '%s'", filename); return; } create_options = append_option_parameters(create_options, drv->create_options); create_options = append_option_parameters(create_options, proto_drv->create_options); /* Create parameter list with default values */ param = parse_option_parameters("", create_options, param); set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size); /* Parse -o options */ if (options) { param = parse_option_parameters(options, create_options, param); if (param == NULL) { error_setg(errp, "Invalid options for file format '%s'.", fmt); goto out; } } if (base_filename) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE, base_filename)) { error_setg(errp, "Backing file not supported for file format '%s'", fmt); goto out; } } if (base_fmt) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) { error_setg(errp, "Backing file format not supported for file " "format '%s'", fmt); goto out; } } backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); if (backing_file && backing_file->value.s) { if (!strcmp(filename, backing_file->value.s)) { error_setg(errp, "Error: Trying to create an image with the " "same filename as the backing file"); goto out; } } backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT); if (backing_fmt && backing_fmt->value.s) { backing_drv = bdrv_find_format(backing_fmt->value.s); if (!backing_drv) { error_setg(errp, "Unknown backing file format '%s'", backing_fmt->value.s); goto out; } } // The size for the image must always be specified, with one exception: // If we are using a backing file, we can obtain the size from there size = get_option_parameter(param, BLOCK_OPT_SIZE); if (size && size->value.n == -1) { if (backing_file && backing_file->value.s) { uint64_t size; char buf[32]; int back_flags; /* backing files always opened read-only */ back_flags = flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); bs = bdrv_new(""); ret = bdrv_open(bs, backing_file->value.s, NULL, back_flags, backing_drv); if (ret < 0) { error_setg_errno(errp, -ret, "Could not open '%s'", backing_file->value.s); goto out; } bdrv_get_geometry(bs, &size); size *= 512; snprintf(buf, sizeof(buf), "%" PRId64, size); set_option_parameter(param, BLOCK_OPT_SIZE, buf); } else { error_setg(errp, "Image creation needs a size parameter"); goto out; } } if (!quiet) { printf("Formatting '%s', fmt=%s ", filename, fmt); print_option_parameters(param); puts(""); } ret = bdrv_create(drv, filename, param); if (ret < 0) { if (ret == -ENOTSUP) { error_setg(errp,"Formatting or formatting option not supported for " "file format '%s'", fmt); } else if (ret == -EFBIG) { const char *cluster_size_hint = ""; if (get_option_parameter(create_options, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size_hint = " (try using a larger cluster size)"; } error_setg(errp, "The image size is too large for file format '%s'%s", fmt, cluster_size_hint); } else { error_setg(errp, "%s: error while creating %s: %s", filename, fmt, strerror(-ret)); } } out: free_option_parameters(create_options); free_option_parameters(param); if (bs) { bdrv_delete(bs); } } AioContext *bdrv_get_aio_context(BlockDriverState *bs) { /* Currently BlockDriverState always uses the main loop AioContext */ return qemu_get_aio_context(); } void bdrv_add_before_write_notifier(BlockDriverState *bs, NotifierWithReturn *notifier) { notifier_with_return_list_add(&bs->before_write_notifiers, notifier); } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qobject0000644000076200007630000000013212617742645020520 xustar000000000000000030 mtime=1447019941.783331993 30 atime=1447019949.333218415 30 ctime=1447019941.783331993 glusterfs-3.7.6/contrib/qemu/qobject/0000755000076200007630000000000012617742645021012 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/json-lexer.c0000644000076200007630000000013112617742532023021 xustar000000000000000030 mtime=1447019866.042471464 29 atime=1447019866.37446647 30 ctime=1447019941.751332475 glusterfs-3.7.6/contrib/qemu/qobject/json-lexer.c0000644000076200007630000002250112617742532023237 0ustar00jenkinsjenkins00000000000000/* * JSON lexer * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qapi/qmp/qstring.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" #include "qemu-common.h" #include "qapi/qmp/json-lexer.h" #define MAX_TOKEN_SIZE (64ULL << 20) /* * \"([^\\\"]|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*\" * '([^\\']|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*' * 0|([1-9][0-9]*(.[0-9]+)?([eE]([-+])?[0-9]+)) * [{}\[\],:] * [a-z]+ * */ enum json_lexer_state { IN_ERROR = 0, IN_DQ_UCODE3, IN_DQ_UCODE2, IN_DQ_UCODE1, IN_DQ_UCODE0, IN_DQ_STRING_ESCAPE, IN_DQ_STRING, IN_SQ_UCODE3, IN_SQ_UCODE2, IN_SQ_UCODE1, IN_SQ_UCODE0, IN_SQ_STRING_ESCAPE, IN_SQ_STRING, IN_ZERO, IN_DIGITS, IN_DIGIT, IN_EXP_E, IN_MANTISSA, IN_MANTISSA_DIGITS, IN_NONZERO_NUMBER, IN_NEG_NONZERO_NUMBER, IN_KEYWORD, IN_ESCAPE, IN_ESCAPE_L, IN_ESCAPE_LL, IN_ESCAPE_I, IN_ESCAPE_I6, IN_ESCAPE_I64, IN_WHITESPACE, IN_START, }; #define TERMINAL(state) [0 ... 0x7F] = (state) /* Return whether TERMINAL is a terminal state and the transition to it from OLD_STATE required lookahead. This happens whenever the table below uses the TERMINAL macro. */ #define TERMINAL_NEEDED_LOOKAHEAD(old_state, terminal) \ (json_lexer[(old_state)][0] == (terminal)) static const uint8_t json_lexer[][256] = { /* double quote string */ [IN_DQ_UCODE3] = { ['0' ... '9'] = IN_DQ_STRING, ['a' ... 'f'] = IN_DQ_STRING, ['A' ... 'F'] = IN_DQ_STRING, }, [IN_DQ_UCODE2] = { ['0' ... '9'] = IN_DQ_UCODE3, ['a' ... 'f'] = IN_DQ_UCODE3, ['A' ... 'F'] = IN_DQ_UCODE3, }, [IN_DQ_UCODE1] = { ['0' ... '9'] = IN_DQ_UCODE2, ['a' ... 'f'] = IN_DQ_UCODE2, ['A' ... 'F'] = IN_DQ_UCODE2, }, [IN_DQ_UCODE0] = { ['0' ... '9'] = IN_DQ_UCODE1, ['a' ... 'f'] = IN_DQ_UCODE1, ['A' ... 'F'] = IN_DQ_UCODE1, }, [IN_DQ_STRING_ESCAPE] = { ['b'] = IN_DQ_STRING, ['f'] = IN_DQ_STRING, ['n'] = IN_DQ_STRING, ['r'] = IN_DQ_STRING, ['t'] = IN_DQ_STRING, ['/'] = IN_DQ_STRING, ['\\'] = IN_DQ_STRING, ['\''] = IN_DQ_STRING, ['\"'] = IN_DQ_STRING, ['u'] = IN_DQ_UCODE0, }, [IN_DQ_STRING] = { [1 ... 0xBF] = IN_DQ_STRING, [0xC2 ... 0xF4] = IN_DQ_STRING, ['\\'] = IN_DQ_STRING_ESCAPE, ['"'] = JSON_STRING, }, /* single quote string */ [IN_SQ_UCODE3] = { ['0' ... '9'] = IN_SQ_STRING, ['a' ... 'f'] = IN_SQ_STRING, ['A' ... 'F'] = IN_SQ_STRING, }, [IN_SQ_UCODE2] = { ['0' ... '9'] = IN_SQ_UCODE3, ['a' ... 'f'] = IN_SQ_UCODE3, ['A' ... 'F'] = IN_SQ_UCODE3, }, [IN_SQ_UCODE1] = { ['0' ... '9'] = IN_SQ_UCODE2, ['a' ... 'f'] = IN_SQ_UCODE2, ['A' ... 'F'] = IN_SQ_UCODE2, }, [IN_SQ_UCODE0] = { ['0' ... '9'] = IN_SQ_UCODE1, ['a' ... 'f'] = IN_SQ_UCODE1, ['A' ... 'F'] = IN_SQ_UCODE1, }, [IN_SQ_STRING_ESCAPE] = { ['b'] = IN_SQ_STRING, ['f'] = IN_SQ_STRING, ['n'] = IN_SQ_STRING, ['r'] = IN_SQ_STRING, ['t'] = IN_SQ_STRING, ['/'] = IN_DQ_STRING, ['\\'] = IN_DQ_STRING, ['\''] = IN_SQ_STRING, ['\"'] = IN_SQ_STRING, ['u'] = IN_SQ_UCODE0, }, [IN_SQ_STRING] = { [1 ... 0xBF] = IN_SQ_STRING, [0xC2 ... 0xF4] = IN_SQ_STRING, ['\\'] = IN_SQ_STRING_ESCAPE, ['\''] = JSON_STRING, }, /* Zero */ [IN_ZERO] = { TERMINAL(JSON_INTEGER), ['0' ... '9'] = IN_ERROR, ['.'] = IN_MANTISSA, }, /* Float */ [IN_DIGITS] = { TERMINAL(JSON_FLOAT), ['0' ... '9'] = IN_DIGITS, }, [IN_DIGIT] = { ['0' ... '9'] = IN_DIGITS, }, [IN_EXP_E] = { ['-'] = IN_DIGIT, ['+'] = IN_DIGIT, ['0' ... '9'] = IN_DIGITS, }, [IN_MANTISSA_DIGITS] = { TERMINAL(JSON_FLOAT), ['0' ... '9'] = IN_MANTISSA_DIGITS, ['e'] = IN_EXP_E, ['E'] = IN_EXP_E, }, [IN_MANTISSA] = { ['0' ... '9'] = IN_MANTISSA_DIGITS, }, /* Number */ [IN_NONZERO_NUMBER] = { TERMINAL(JSON_INTEGER), ['0' ... '9'] = IN_NONZERO_NUMBER, ['e'] = IN_EXP_E, ['E'] = IN_EXP_E, ['.'] = IN_MANTISSA, }, [IN_NEG_NONZERO_NUMBER] = { ['0'] = IN_ZERO, ['1' ... '9'] = IN_NONZERO_NUMBER, }, /* keywords */ [IN_KEYWORD] = { TERMINAL(JSON_KEYWORD), ['a' ... 'z'] = IN_KEYWORD, }, /* whitespace */ [IN_WHITESPACE] = { TERMINAL(JSON_SKIP), [' '] = IN_WHITESPACE, ['\t'] = IN_WHITESPACE, ['\r'] = IN_WHITESPACE, ['\n'] = IN_WHITESPACE, }, /* escape */ [IN_ESCAPE_LL] = { ['d'] = JSON_ESCAPE, }, [IN_ESCAPE_L] = { ['d'] = JSON_ESCAPE, ['l'] = IN_ESCAPE_LL, }, [IN_ESCAPE_I64] = { ['d'] = JSON_ESCAPE, }, [IN_ESCAPE_I6] = { ['4'] = IN_ESCAPE_I64, }, [IN_ESCAPE_I] = { ['6'] = IN_ESCAPE_I6, }, [IN_ESCAPE] = { ['d'] = JSON_ESCAPE, ['i'] = JSON_ESCAPE, ['p'] = JSON_ESCAPE, ['s'] = JSON_ESCAPE, ['f'] = JSON_ESCAPE, ['l'] = IN_ESCAPE_L, ['I'] = IN_ESCAPE_I, }, /* top level rule */ [IN_START] = { ['"'] = IN_DQ_STRING, ['\''] = IN_SQ_STRING, ['0'] = IN_ZERO, ['1' ... '9'] = IN_NONZERO_NUMBER, ['-'] = IN_NEG_NONZERO_NUMBER, ['{'] = JSON_OPERATOR, ['}'] = JSON_OPERATOR, ['['] = JSON_OPERATOR, [']'] = JSON_OPERATOR, [','] = JSON_OPERATOR, [':'] = JSON_OPERATOR, ['a' ... 'z'] = IN_KEYWORD, ['%'] = IN_ESCAPE, [' '] = IN_WHITESPACE, ['\t'] = IN_WHITESPACE, ['\r'] = IN_WHITESPACE, ['\n'] = IN_WHITESPACE, }, }; void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func) { lexer->emit = func; lexer->state = IN_START; lexer->token = qstring_new(); lexer->x = lexer->y = 0; } static int json_lexer_feed_char(JSONLexer *lexer, char ch, bool flush) { int char_consumed, new_state; lexer->x++; if (ch == '\n') { lexer->x = 0; lexer->y++; } do { new_state = json_lexer[lexer->state][(uint8_t)ch]; char_consumed = !TERMINAL_NEEDED_LOOKAHEAD(lexer->state, new_state); if (char_consumed) { qstring_append_chr(lexer->token, ch); } switch (new_state) { case JSON_OPERATOR: case JSON_ESCAPE: case JSON_INTEGER: case JSON_FLOAT: case JSON_KEYWORD: case JSON_STRING: lexer->emit(lexer, lexer->token, new_state, lexer->x, lexer->y); /* fall through */ case JSON_SKIP: QDECREF(lexer->token); lexer->token = qstring_new(); new_state = IN_START; break; case IN_ERROR: /* XXX: To avoid having previous bad input leaving the parser in an * unresponsive state where we consume unpredictable amounts of * subsequent "good" input, percolate this error state up to the * tokenizer/parser by forcing a NULL object to be emitted, then * reset state. * * Also note that this handling is required for reliable channel * negotiation between QMP and the guest agent, since chr(0xFF) * is placed at the beginning of certain events to ensure proper * delivery when the channel is in an unknown state. chr(0xFF) is * never a valid ASCII/UTF-8 sequence, so this should reliably * induce an error/flush state. */ lexer->emit(lexer, lexer->token, JSON_ERROR, lexer->x, lexer->y); QDECREF(lexer->token); lexer->token = qstring_new(); new_state = IN_START; lexer->state = new_state; return 0; default: break; } lexer->state = new_state; } while (!char_consumed && !flush); /* Do not let a single token grow to an arbitrarily large size, * this is a security consideration. */ if (lexer->token->length > MAX_TOKEN_SIZE) { lexer->emit(lexer, lexer->token, lexer->state, lexer->x, lexer->y); QDECREF(lexer->token); lexer->token = qstring_new(); lexer->state = IN_START; } return 0; } int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size) { size_t i; for (i = 0; i < size; i++) { int err; err = json_lexer_feed_char(lexer, buffer[i], false); if (err < 0) { return err; } } return 0; } int json_lexer_flush(JSONLexer *lexer) { return lexer->state == IN_START ? 0 : json_lexer_feed_char(lexer, 0, true); } void json_lexer_destroy(JSONLexer *lexer) { QDECREF(lexer->token); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qint.c0000644000076200007630000000013112617742532021706 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.774332129 glusterfs-3.7.6/contrib/qemu/qobject/qint.c0000644000076200007630000000233412617742532022126 0ustar00jenkinsjenkins00000000000000/* * QInt Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #include "qapi/qmp/qint.h" #include "qapi/qmp/qobject.h" #include "qemu-common.h" static void qint_destroy_obj(QObject *obj); static const QType qint_type = { .code = QTYPE_QINT, .destroy = qint_destroy_obj, }; /** * qint_from_int(): Create a new QInt from an int64_t * * Return strong reference. */ QInt *qint_from_int(int64_t value) { QInt *qi; qi = g_malloc(sizeof(*qi)); qi->value = value; QOBJECT_INIT(qi, &qint_type); return qi; } /** * qint_get_int(): Get the stored integer */ int64_t qint_get_int(const QInt *qi) { return qi->value; } /** * qobject_to_qint(): Convert a QObject into a QInt */ QInt *qobject_to_qint(const QObject *obj) { if (qobject_type(obj) != QTYPE_QINT) return NULL; return container_of(obj, QInt, base); } /** * qint_destroy_obj(): Free all memory allocated by a * QInt object */ static void qint_destroy_obj(QObject *obj) { assert(obj != NULL); g_free(qobject_to_qint(obj)); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/json-parser.c0000644000076200007630000000013012617742532023175 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 29 ctime=1447019941.75433243 glusterfs-3.7.6/contrib/qemu/qobject/json-parser.c0000644000076200007630000004250212617742532023417 0ustar00jenkinsjenkins00000000000000/* * JSON Parser * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include #include "qemu-common.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/qerror.h" typedef struct JSONParserContext { Error *err; struct { QObject **buf; size_t pos; size_t count; } tokens; } JSONParserContext; #define BUG_ON(cond) assert(!(cond)) /** * TODO * * 0) make errors meaningful again * 1) add geometry information to tokens * 3) should we return a parsed size? * 4) deal with premature EOI */ static QObject *parse_value(JSONParserContext *ctxt, va_list *ap); /** * Token manipulators * * tokens are dictionaries that contain a type, a string value, and geometry information * about a token identified by the lexer. These are routines that make working with * these objects a bit easier. */ static const char *token_get_value(QObject *obj) { return qdict_get_str(qobject_to_qdict(obj), "token"); } static JSONTokenType token_get_type(QObject *obj) { return qdict_get_int(qobject_to_qdict(obj), "type"); } static int token_is_operator(QObject *obj, char op) { const char *val; if (token_get_type(obj) != JSON_OPERATOR) { return 0; } val = token_get_value(obj); return (val[0] == op) && (val[1] == 0); } static int token_is_keyword(QObject *obj, const char *value) { if (token_get_type(obj) != JSON_KEYWORD) { return 0; } return strcmp(token_get_value(obj), value) == 0; } static int token_is_escape(QObject *obj, const char *value) { if (token_get_type(obj) != JSON_ESCAPE) { return 0; } return (strcmp(token_get_value(obj), value) == 0); } /** * Error handler */ static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...) { va_list ap; char message[1024]; va_start(ap, msg); vsnprintf(message, sizeof(message), msg, ap); va_end(ap); if (ctxt->err) { error_free(ctxt->err); ctxt->err = NULL; } error_set(&ctxt->err, QERR_JSON_PARSE_ERROR, message); } /** * String helpers * * These helpers are used to unescape strings. */ static void wchar_to_utf8(uint16_t wchar, char *buffer, size_t buffer_length) { if (wchar <= 0x007F) { BUG_ON(buffer_length < 2); buffer[0] = wchar & 0x7F; buffer[1] = 0; } else if (wchar <= 0x07FF) { BUG_ON(buffer_length < 3); buffer[0] = 0xC0 | ((wchar >> 6) & 0x1F); buffer[1] = 0x80 | (wchar & 0x3F); buffer[2] = 0; } else { BUG_ON(buffer_length < 4); buffer[0] = 0xE0 | ((wchar >> 12) & 0x0F); buffer[1] = 0x80 | ((wchar >> 6) & 0x3F); buffer[2] = 0x80 | (wchar & 0x3F); buffer[3] = 0; } } static int hex2decimal(char ch) { if (ch >= '0' && ch <= '9') { return (ch - '0'); } else if (ch >= 'a' && ch <= 'f') { return 10 + (ch - 'a'); } else if (ch >= 'A' && ch <= 'F') { return 10 + (ch - 'A'); } return -1; } /** * parse_string(): Parse a json string and return a QObject * * string * "" * " chars " * chars * char * char chars * char * any-Unicode-character- * except-"-or-\-or- * control-character * \" * \\ * \/ * \b * \f * \n * \r * \t * \u four-hex-digits */ static QString *qstring_from_escaped_str(JSONParserContext *ctxt, QObject *token) { const char *ptr = token_get_value(token); QString *str; int double_quote = 1; if (*ptr == '"') { double_quote = 1; } else { double_quote = 0; } ptr++; str = qstring_new(); while (*ptr && ((double_quote && *ptr != '"') || (!double_quote && *ptr != '\''))) { if (*ptr == '\\') { ptr++; switch (*ptr) { case '"': qstring_append(str, "\""); ptr++; break; case '\'': qstring_append(str, "'"); ptr++; break; case '\\': qstring_append(str, "\\"); ptr++; break; case '/': qstring_append(str, "/"); ptr++; break; case 'b': qstring_append(str, "\b"); ptr++; break; case 'f': qstring_append(str, "\f"); ptr++; break; case 'n': qstring_append(str, "\n"); ptr++; break; case 'r': qstring_append(str, "\r"); ptr++; break; case 't': qstring_append(str, "\t"); ptr++; break; case 'u': { uint16_t unicode_char = 0; char utf8_char[4]; int i = 0; ptr++; for (i = 0; i < 4; i++) { if (qemu_isxdigit(*ptr)) { unicode_char |= hex2decimal(*ptr) << ((3 - i) * 4); } else { parse_error(ctxt, token, "invalid hex escape sequence in string"); goto out; } ptr++; } wchar_to_utf8(unicode_char, utf8_char, sizeof(utf8_char)); qstring_append(str, utf8_char); } break; default: parse_error(ctxt, token, "invalid escape sequence in string"); goto out; } } else { char dummy[2]; dummy[0] = *ptr++; dummy[1] = 0; qstring_append(str, dummy); } } return str; out: QDECREF(str); return NULL; } static QObject *parser_context_pop_token(JSONParserContext *ctxt) { QObject *token; g_assert(ctxt->tokens.pos < ctxt->tokens.count); token = ctxt->tokens.buf[ctxt->tokens.pos]; ctxt->tokens.pos++; return token; } /* Note: parser_context_{peek|pop}_token do not increment the * token object's refcount. In both cases the references will continue * to be tracked and cleaned up in parser_context_free(), so do not * attempt to free the token object. */ static QObject *parser_context_peek_token(JSONParserContext *ctxt) { QObject *token; g_assert(ctxt->tokens.pos < ctxt->tokens.count); token = ctxt->tokens.buf[ctxt->tokens.pos]; return token; } static JSONParserContext parser_context_save(JSONParserContext *ctxt) { JSONParserContext saved_ctxt = {0}; saved_ctxt.tokens.pos = ctxt->tokens.pos; saved_ctxt.tokens.count = ctxt->tokens.count; saved_ctxt.tokens.buf = ctxt->tokens.buf; return saved_ctxt; } static void parser_context_restore(JSONParserContext *ctxt, JSONParserContext saved_ctxt) { ctxt->tokens.pos = saved_ctxt.tokens.pos; ctxt->tokens.count = saved_ctxt.tokens.count; ctxt->tokens.buf = saved_ctxt.tokens.buf; } static void tokens_append_from_iter(QObject *obj, void *opaque) { JSONParserContext *ctxt = opaque; g_assert(ctxt->tokens.pos < ctxt->tokens.count); ctxt->tokens.buf[ctxt->tokens.pos++] = obj; qobject_incref(obj); } static JSONParserContext *parser_context_new(QList *tokens) { JSONParserContext *ctxt; size_t count; if (!tokens) { return NULL; } count = qlist_size(tokens); if (count == 0) { return NULL; } ctxt = g_malloc0(sizeof(JSONParserContext)); ctxt->tokens.pos = 0; ctxt->tokens.count = count; ctxt->tokens.buf = g_malloc(count * sizeof(QObject *)); qlist_iter(tokens, tokens_append_from_iter, ctxt); ctxt->tokens.pos = 0; return ctxt; } /* to support error propagation, ctxt->err must be freed separately */ static void parser_context_free(JSONParserContext *ctxt) { int i; if (ctxt) { for (i = 0; i < ctxt->tokens.count; i++) { qobject_decref(ctxt->tokens.buf[i]); } g_free(ctxt->tokens.buf); g_free(ctxt); } } /** * Parsing rules */ static int parse_pair(JSONParserContext *ctxt, QDict *dict, va_list *ap) { QObject *key = NULL, *token = NULL, *value, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } key = parse_value(ctxt, ap); if (!key || qobject_type(key) != QTYPE_QSTRING) { parse_error(ctxt, peek, "key is not a string in object"); goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(token, ':')) { parse_error(ctxt, token, "missing : in object pair"); goto out; } value = parse_value(ctxt, ap); if (value == NULL) { parse_error(ctxt, token, "Missing value in dict"); goto out; } qdict_put_obj(dict, qstring_get_str(qobject_to_qstring(key)), value); qobject_decref(key); return 0; out: parser_context_restore(ctxt, saved_ctxt); qobject_decref(key); return -1; } static QObject *parse_object(JSONParserContext *ctxt, va_list *ap) { QDict *dict = NULL; QObject *token, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (!token_is_operator(token, '{')) { goto out; } token = NULL; dict = qdict_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, '}')) { if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, '}')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in dict"); goto out; } token = NULL; if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } token = NULL; } else { token = parser_context_pop_token(ctxt); token = NULL; } return QOBJECT(dict); out: parser_context_restore(ctxt, saved_ctxt); QDECREF(dict); return NULL; } static QObject *parse_array(JSONParserContext *ctxt, va_list *ap) { QList *list = NULL; QObject *token, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (!token_is_operator(token, '[')) { token = NULL; goto out; } token = NULL; list = qlist_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, ']')) { QObject *obj; obj = parse_value(ctxt, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, ']')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in list"); goto out; } token = NULL; obj = parse_value(ctxt, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } token = NULL; } else { token = parser_context_pop_token(ctxt); token = NULL; } return QOBJECT(list); out: parser_context_restore(ctxt, saved_ctxt); QDECREF(list); return NULL; } static QObject *parse_keyword(JSONParserContext *ctxt) { QObject *token, *ret; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (token_get_type(token) != JSON_KEYWORD) { goto out; } if (token_is_keyword(token, "true")) { ret = QOBJECT(qbool_from_int(true)); } else if (token_is_keyword(token, "false")) { ret = QOBJECT(qbool_from_int(false)); } else { parse_error(ctxt, token, "invalid keyword `%s'", token_get_value(token)); goto out; } return ret; out: parser_context_restore(ctxt, saved_ctxt); return NULL; } static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap) { QObject *token = NULL, *obj; JSONParserContext saved_ctxt = parser_context_save(ctxt); if (ap == NULL) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (token_is_escape(token, "%p")) { obj = va_arg(*ap, QObject *); } else if (token_is_escape(token, "%i")) { obj = QOBJECT(qbool_from_int(va_arg(*ap, int))); } else if (token_is_escape(token, "%d")) { obj = QOBJECT(qint_from_int(va_arg(*ap, int))); } else if (token_is_escape(token, "%ld")) { obj = QOBJECT(qint_from_int(va_arg(*ap, long))); } else if (token_is_escape(token, "%lld") || token_is_escape(token, "%I64d")) { obj = QOBJECT(qint_from_int(va_arg(*ap, long long))); } else if (token_is_escape(token, "%s")) { obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *))); } else if (token_is_escape(token, "%f")) { obj = QOBJECT(qfloat_from_double(va_arg(*ap, double))); } else { goto out; } return obj; out: parser_context_restore(ctxt, saved_ctxt); return NULL; } static QObject *parse_literal(JSONParserContext *ctxt) { QObject *token, *obj; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } switch (token_get_type(token)) { case JSON_STRING: obj = QOBJECT(qstring_from_escaped_str(ctxt, token)); break; case JSON_INTEGER: { /* A possibility exists that this is a whole-valued float where the * fractional part was left out due to being 0 (.0). It's not a big * deal to treat these as ints in the parser, so long as users of the * resulting QObject know to expect a QInt in place of a QFloat in * cases like these. * * However, in some cases these values will overflow/underflow a * QInt/int64 container, thus we should assume these are to be handled * as QFloats/doubles rather than silently changing their values. * * strtoll() indicates these instances by setting errno to ERANGE */ int64_t value; errno = 0; /* strtoll doesn't set errno on success */ value = strtoll(token_get_value(token), NULL, 10); if (errno != ERANGE) { obj = QOBJECT(qint_from_int(value)); break; } /* fall through to JSON_FLOAT */ } case JSON_FLOAT: /* FIXME dependent on locale */ obj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL))); break; default: goto out; } return obj; out: parser_context_restore(ctxt, saved_ctxt); return NULL; } static QObject *parse_value(JSONParserContext *ctxt, va_list *ap) { QObject *obj; obj = parse_object(ctxt, ap); if (obj == NULL) { obj = parse_array(ctxt, ap); } if (obj == NULL) { obj = parse_escape(ctxt, ap); } if (obj == NULL) { obj = parse_keyword(ctxt); } if (obj == NULL) { obj = parse_literal(ctxt); } return obj; } QObject *json_parser_parse(QList *tokens, va_list *ap) { return json_parser_parse_err(tokens, ap, NULL); } QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp) { JSONParserContext *ctxt = parser_context_new(tokens); QObject *result; if (!ctxt) { return NULL; } result = parse_value(ctxt, ap); error_propagate(errp, ctxt->err); parser_context_free(ctxt); return result; } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qerror.c0000644000076200007630000000013112617742532022245 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.767332234 glusterfs-3.7.6/contrib/qemu/qobject/qerror.c0000644000076200007630000000606412617742532022471 0ustar00jenkinsjenkins00000000000000/* * QError Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #include "monitor/monitor.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qerror.h" #include "qemu-common.h" static void qerror_destroy_obj(QObject *obj); static const QType qerror_type = { .code = QTYPE_QERROR, .destroy = qerror_destroy_obj, }; /** * qerror_new(): Create a new QError * * Return strong reference. */ static QError *qerror_new(void) { QError *qerr; qerr = g_malloc0(sizeof(*qerr)); QOBJECT_INIT(qerr, &qerror_type); return qerr; } /** * qerror_from_info(): Create a new QError from error information * * Return strong reference. */ static QError *qerror_from_info(ErrorClass err_class, const char *fmt, va_list *va) { QError *qerr; qerr = qerror_new(); loc_save(&qerr->loc); qerr->err_msg = g_strdup_vprintf(fmt, *va); qerr->err_class = err_class; return qerr; } /** * qerror_human(): Format QError data into human-readable string. */ QString *qerror_human(const QError *qerror) { return qstring_from_str(qerror->err_msg); } /** * qerror_print(): Print QError data * * This function will print the member 'desc' of the specified QError object, * it uses error_report() for this, so that the output is routed to the right * place (ie. stderr or Monitor's device). */ static void qerror_print(QError *qerror) { QString *qstring = qerror_human(qerror); loc_push_restore(&qerror->loc); error_report("%s", qstring_get_str(qstring)); loc_pop(&qerror->loc); QDECREF(qstring); } void qerror_report(ErrorClass eclass, const char *fmt, ...) { va_list va; QError *qerror; va_start(va, fmt); qerror = qerror_from_info(eclass, fmt, &va); va_end(va); if (monitor_cur_is_qmp()) { monitor_set_error(cur_mon, qerror); } else { qerror_print(qerror); QDECREF(qerror); } } /* Evil... */ struct Error { char *msg; ErrorClass err_class; }; void qerror_report_err(Error *err) { QError *qerr; qerr = qerror_new(); loc_save(&qerr->loc); qerr->err_msg = g_strdup(err->msg); qerr->err_class = err->err_class; if (monitor_cur_is_qmp()) { monitor_set_error(cur_mon, qerr); } else { qerror_print(qerr); QDECREF(qerr); } } void assert_no_error(Error *err) { if (err) { qerror_report_err(err); abort(); } } /** * qobject_to_qerror(): Convert a QObject into a QError */ static QError *qobject_to_qerror(const QObject *obj) { if (qobject_type(obj) != QTYPE_QERROR) { return NULL; } return container_of(obj, QError, base); } /** * qerror_destroy_obj(): Free all memory allocated by a QError */ static void qerror_destroy_obj(QObject *obj) { QError *qerr; assert(obj != NULL); qerr = qobject_to_qerror(obj); g_free(qerr->err_msg); g_free(qerr); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qfloat.c0000644000076200007630000000013112617742532022221 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.770332189 glusterfs-3.7.6/contrib/qemu/qobject/qfloat.c0000644000076200007630000000241412617742532022440 0ustar00jenkinsjenkins00000000000000/* * QFloat Module * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qobject.h" #include "qemu-common.h" static void qfloat_destroy_obj(QObject *obj); static const QType qfloat_type = { .code = QTYPE_QFLOAT, .destroy = qfloat_destroy_obj, }; /** * qfloat_from_int(): Create a new QFloat from a float * * Return strong reference. */ QFloat *qfloat_from_double(double value) { QFloat *qf; qf = g_malloc(sizeof(*qf)); qf->value = value; QOBJECT_INIT(qf, &qfloat_type); return qf; } /** * qfloat_get_double(): Get the stored float */ double qfloat_get_double(const QFloat *qf) { return qf->value; } /** * qobject_to_qfloat(): Convert a QObject into a QFloat */ QFloat *qobject_to_qfloat(const QObject *obj) { if (qobject_type(obj) != QTYPE_QFLOAT) return NULL; return container_of(obj, QFloat, base); } /** * qfloat_destroy_obj(): Free all memory allocated by a * QFloat object */ static void qfloat_destroy_obj(QObject *obj) { assert(obj != NULL); g_free(qobject_to_qfloat(obj)); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/json-streamer.c0000644000076200007630000000013112617742532023524 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.757332385 glusterfs-3.7.6/contrib/qemu/qobject/json-streamer.c0000644000076200007630000000636212617742532023751 0ustar00jenkinsjenkins00000000000000/* * JSON streaming support * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qdict.h" #include "qemu-common.h" #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-streamer.h" #define MAX_TOKEN_SIZE (64ULL << 20) #define MAX_NESTING (1ULL << 10) static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTokenType type, int x, int y) { JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer); QDict *dict; if (type == JSON_OPERATOR) { switch (qstring_get_str(token)[0]) { case '{': parser->brace_count++; break; case '}': parser->brace_count--; break; case '[': parser->bracket_count++; break; case ']': parser->bracket_count--; break; default: break; } } dict = qdict_new(); qdict_put(dict, "type", qint_from_int(type)); QINCREF(token); qdict_put(dict, "token", token); qdict_put(dict, "x", qint_from_int(x)); qdict_put(dict, "y", qint_from_int(y)); parser->token_size += token->length; qlist_append(parser->tokens, dict); if (type == JSON_ERROR) { goto out_emit_bad; } else if (parser->brace_count < 0 || parser->bracket_count < 0 || (parser->brace_count == 0 && parser->bracket_count == 0)) { goto out_emit; } else if (parser->token_size > MAX_TOKEN_SIZE || parser->bracket_count > MAX_NESTING || parser->brace_count > MAX_NESTING) { /* Security consideration, we limit total memory allocated per object * and the maximum recursion depth that a message can force. */ goto out_emit; } return; out_emit_bad: /* clear out token list and tell the parser to emit and error * indication by passing it a NULL list */ QDECREF(parser->tokens); parser->tokens = NULL; out_emit: /* send current list of tokens to parser and reset tokenizer */ parser->brace_count = 0; parser->bracket_count = 0; parser->emit(parser, parser->tokens); if (parser->tokens) { QDECREF(parser->tokens); } parser->tokens = qlist_new(); parser->token_size = 0; } void json_message_parser_init(JSONMessageParser *parser, void (*func)(JSONMessageParser *, QList *)) { parser->emit = func; parser->brace_count = 0; parser->bracket_count = 0; parser->tokens = qlist_new(); parser->token_size = 0; json_lexer_init(&parser->lexer, json_message_process_token); } int json_message_parser_feed(JSONMessageParser *parser, const char *buffer, size_t size) { return json_lexer_feed(&parser->lexer, buffer, size); } int json_message_parser_flush(JSONMessageParser *parser) { return json_lexer_flush(&parser->lexer); } void json_message_parser_destroy(JSONMessageParser *parser) { json_lexer_destroy(&parser->lexer); QDECREF(parser->tokens); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qlist.c0000644000076200007630000000013112617742532022067 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.780332039 glusterfs-3.7.6/contrib/qemu/qobject/qlist.c0000644000076200007630000000633312617742532022312 0ustar00jenkinsjenkins00000000000000/* * QList Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qobject.h" #include "qemu/queue.h" #include "qemu-common.h" static void qlist_destroy_obj(QObject *obj); static const QType qlist_type = { .code = QTYPE_QLIST, .destroy = qlist_destroy_obj, }; /** * qlist_new(): Create a new QList * * Return strong reference. */ QList *qlist_new(void) { QList *qlist; qlist = g_malloc(sizeof(*qlist)); QTAILQ_INIT(&qlist->head); QOBJECT_INIT(qlist, &qlist_type); return qlist; } static void qlist_copy_elem(QObject *obj, void *opaque) { QList *dst = opaque; qobject_incref(obj); qlist_append_obj(dst, obj); } QList *qlist_copy(QList *src) { QList *dst = qlist_new(); qlist_iter(src, qlist_copy_elem, dst); return dst; } /** * qlist_append_obj(): Append an QObject into QList * * NOTE: ownership of 'value' is transferred to the QList */ void qlist_append_obj(QList *qlist, QObject *value) { QListEntry *entry; entry = g_malloc(sizeof(*entry)); entry->value = value; QTAILQ_INSERT_TAIL(&qlist->head, entry, next); } /** * qlist_iter(): Iterate over all the list's stored values. * * This function allows the user to provide an iterator, which will be * called for each stored value in the list. */ void qlist_iter(const QList *qlist, void (*iter)(QObject *obj, void *opaque), void *opaque) { QListEntry *entry; QTAILQ_FOREACH(entry, &qlist->head, next) iter(entry->value, opaque); } QObject *qlist_pop(QList *qlist) { QListEntry *entry; QObject *ret; if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) { return NULL; } entry = QTAILQ_FIRST(&qlist->head); QTAILQ_REMOVE(&qlist->head, entry, next); ret = entry->value; g_free(entry); return ret; } QObject *qlist_peek(QList *qlist) { QListEntry *entry; QObject *ret; if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) { return NULL; } entry = QTAILQ_FIRST(&qlist->head); ret = entry->value; return ret; } int qlist_empty(const QList *qlist) { return QTAILQ_EMPTY(&qlist->head); } static void qlist_size_iter(QObject *obj, void *opaque) { size_t *count = opaque; (*count)++; } size_t qlist_size(const QList *qlist) { size_t count = 0; qlist_iter(qlist, qlist_size_iter, &count); return count; } /** * qobject_to_qlist(): Convert a QObject into a QList */ QList *qobject_to_qlist(const QObject *obj) { if (qobject_type(obj) != QTYPE_QLIST) { return NULL; } return container_of(obj, QList, base); } /** * qlist_destroy_obj(): Free all the memory allocated by a QList */ static void qlist_destroy_obj(QObject *obj) { QList *qlist; QListEntry *entry, *next_entry; assert(obj != NULL); qlist = qobject_to_qlist(obj); QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) { QTAILQ_REMOVE(&qlist->head, entry, next); qobject_decref(entry->value); g_free(entry); } g_free(qlist); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qstring.c0000644000076200007630000000013112617742532022422 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.783331993 glusterfs-3.7.6/contrib/qemu/qobject/qstring.c0000644000076200007630000000634512617742532022650 0ustar00jenkinsjenkins00000000000000/* * QString Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" #include "qemu-common.h" static void qstring_destroy_obj(QObject *obj); static const QType qstring_type = { .code = QTYPE_QSTRING, .destroy = qstring_destroy_obj, }; /** * qstring_new(): Create a new empty QString * * Return strong reference. */ QString *qstring_new(void) { return qstring_from_str(""); } /** * qstring_get_length(): Get the length of a QString */ size_t qstring_get_length(const QString *qstring) { return qstring->length; } /** * qstring_from_substr(): Create a new QString from a C string substring * * Return string reference */ QString *qstring_from_substr(const char *str, int start, int end) { QString *qstring; qstring = g_malloc(sizeof(*qstring)); qstring->length = end - start + 1; qstring->capacity = qstring->length; qstring->string = g_malloc(qstring->capacity + 1); memcpy(qstring->string, str + start, qstring->length); qstring->string[qstring->length] = 0; QOBJECT_INIT(qstring, &qstring_type); return qstring; } /** * qstring_from_str(): Create a new QString from a regular C string * * Return strong reference. */ QString *qstring_from_str(const char *str) { return qstring_from_substr(str, 0, strlen(str) - 1); } static void capacity_increase(QString *qstring, size_t len) { if (qstring->capacity < (qstring->length + len)) { qstring->capacity += len; qstring->capacity *= 2; /* use exponential growth */ qstring->string = g_realloc(qstring->string, qstring->capacity + 1); } } /* qstring_append(): Append a C string to a QString */ void qstring_append(QString *qstring, const char *str) { size_t len = strlen(str); capacity_increase(qstring, len); memcpy(qstring->string + qstring->length, str, len); qstring->length += len; qstring->string[qstring->length] = 0; } void qstring_append_int(QString *qstring, int64_t value) { char num[32]; snprintf(num, sizeof(num), "%" PRId64, value); qstring_append(qstring, num); } /** * qstring_append_chr(): Append a C char to a QString */ void qstring_append_chr(QString *qstring, int c) { capacity_increase(qstring, 1); qstring->string[qstring->length++] = c; qstring->string[qstring->length] = 0; } /** * qobject_to_qstring(): Convert a QObject to a QString */ QString *qobject_to_qstring(const QObject *obj) { if (qobject_type(obj) != QTYPE_QSTRING) return NULL; return container_of(obj, QString, base); } /** * qstring_get_str(): Return a pointer to the stored string * * NOTE: Should be used with caution, if the object is deallocated * this pointer becomes invalid. */ const char *qstring_get_str(const QString *qstring) { return qstring->string; } /** * qstring_destroy_obj(): Free all memory allocated by a QString * object */ static void qstring_destroy_obj(QObject *obj) { QString *qs; assert(obj != NULL); qs = qobject_to_qstring(obj); g_free(qs->string); g_free(qs); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qbool.c0000644000076200007630000000013112617742532022047 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.761332324 glusterfs-3.7.6/contrib/qemu/qobject/qbool.c0000644000076200007630000000234112617742532022265 0ustar00jenkinsjenkins00000000000000/* * QBool Module * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qobject.h" #include "qemu-common.h" static void qbool_destroy_obj(QObject *obj); static const QType qbool_type = { .code = QTYPE_QBOOL, .destroy = qbool_destroy_obj, }; /** * qbool_from_int(): Create a new QBool from an int * * Return strong reference. */ QBool *qbool_from_int(int value) { QBool *qb; qb = g_malloc(sizeof(*qb)); qb->value = value; QOBJECT_INIT(qb, &qbool_type); return qb; } /** * qbool_get_int(): Get the stored int */ int qbool_get_int(const QBool *qb) { return qb->value; } /** * qobject_to_qbool(): Convert a QObject into a QBool */ QBool *qobject_to_qbool(const QObject *obj) { if (qobject_type(obj) != QTYPE_QBOOL) return NULL; return container_of(obj, QBool, base); } /** * qbool_destroy_obj(): Free all memory allocated by a * QBool object */ static void qbool_destroy_obj(QObject *obj) { assert(obj != NULL); g_free(qobject_to_qbool(obj)); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qdict.c0000644000076200007630000000013112617742532022037 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.764332279 glusterfs-3.7.6/contrib/qemu/qobject/qdict.c0000644000076200007630000002574512617742532022272 0ustar00jenkinsjenkins00000000000000/* * QDict Module * * Copyright (C) 2009 Red Hat Inc. * * Authors: * Luiz Capitulino * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qobject.h" #include "qemu/queue.h" #include "qemu-common.h" static void qdict_destroy_obj(QObject *obj); static const QType qdict_type = { .code = QTYPE_QDICT, .destroy = qdict_destroy_obj, }; /** * qdict_new(): Create a new QDict * * Return strong reference. */ QDict *qdict_new(void) { QDict *qdict; qdict = g_malloc0(sizeof(*qdict)); QOBJECT_INIT(qdict, &qdict_type); return qdict; } /** * qobject_to_qdict(): Convert a QObject into a QDict */ QDict *qobject_to_qdict(const QObject *obj) { if (qobject_type(obj) != QTYPE_QDICT) return NULL; return container_of(obj, QDict, base); } /** * tdb_hash(): based on the hash agorithm from gdbm, via tdb * (from module-init-tools) */ static unsigned int tdb_hash(const char *name) { unsigned value; /* Used to compute the hash value. */ unsigned i; /* Used to cycle through random values. */ /* Set the initial value from the key size. */ for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++) value = (value + (((const unsigned char *)name)[i] << (i*5 % 24))); return (1103515243 * value + 12345); } /** * alloc_entry(): allocate a new QDictEntry */ static QDictEntry *alloc_entry(const char *key, QObject *value) { QDictEntry *entry; entry = g_malloc0(sizeof(*entry)); entry->key = g_strdup(key); entry->value = value; return entry; } /** * qdict_entry_value(): Return qdict entry value * * Return weak reference. */ QObject *qdict_entry_value(const QDictEntry *entry) { return entry->value; } /** * qdict_entry_key(): Return qdict entry key * * Return a *pointer* to the string, it has to be duplicated before being * stored. */ const char *qdict_entry_key(const QDictEntry *entry) { return entry->key; } /** * qdict_find(): List lookup function */ static QDictEntry *qdict_find(const QDict *qdict, const char *key, unsigned int bucket) { QDictEntry *entry; QLIST_FOREACH(entry, &qdict->table[bucket], next) if (!strcmp(entry->key, key)) return entry; return NULL; } /** * qdict_put_obj(): Put a new QObject into the dictionary * * Insert the pair 'key:value' into 'qdict', if 'key' already exists * its 'value' will be replaced. * * This is done by freeing the reference to the stored QObject and * storing the new one in the same entry. * * NOTE: ownership of 'value' is transferred to the QDict */ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) { unsigned int bucket; QDictEntry *entry; bucket = tdb_hash(key) % QDICT_BUCKET_MAX; entry = qdict_find(qdict, key, bucket); if (entry) { /* replace key's value */ qobject_decref(entry->value); entry->value = value; } else { /* allocate a new entry */ entry = alloc_entry(key, value); QLIST_INSERT_HEAD(&qdict->table[bucket], entry, next); qdict->size++; } } /** * qdict_get(): Lookup for a given 'key' * * Return a weak reference to the QObject associated with 'key' if * 'key' is present in the dictionary, NULL otherwise. */ QObject *qdict_get(const QDict *qdict, const char *key) { QDictEntry *entry; entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_BUCKET_MAX); return (entry == NULL ? NULL : entry->value); } /** * qdict_haskey(): Check if 'key' exists * * Return 1 if 'key' exists in the dict, 0 otherwise */ int qdict_haskey(const QDict *qdict, const char *key) { unsigned int bucket = tdb_hash(key) % QDICT_BUCKET_MAX; return (qdict_find(qdict, key, bucket) == NULL ? 0 : 1); } /** * qdict_size(): Return the size of the dictionary */ size_t qdict_size(const QDict *qdict) { return qdict->size; } /** * qdict_get_obj(): Get a QObject of a specific type */ static QObject *qdict_get_obj(const QDict *qdict, const char *key, qtype_code type) { QObject *obj; obj = qdict_get(qdict, key); assert(obj != NULL); assert(qobject_type(obj) == type); return obj; } /** * qdict_get_double(): Get an number mapped by 'key' * * This function assumes that 'key' exists and it stores a * QFloat or QInt object. * * Return number mapped by 'key'. */ double qdict_get_double(const QDict *qdict, const char *key) { QObject *obj = qdict_get(qdict, key); assert(obj); switch (qobject_type(obj)) { case QTYPE_QFLOAT: return qfloat_get_double(qobject_to_qfloat(obj)); case QTYPE_QINT: return qint_get_int(qobject_to_qint(obj)); default: abort(); } } /** * qdict_get_int(): Get an integer mapped by 'key' * * This function assumes that 'key' exists and it stores a * QInt object. * * Return integer mapped by 'key'. */ int64_t qdict_get_int(const QDict *qdict, const char *key) { QObject *obj = qdict_get_obj(qdict, key, QTYPE_QINT); return qint_get_int(qobject_to_qint(obj)); } /** * qdict_get_bool(): Get a bool mapped by 'key' * * This function assumes that 'key' exists and it stores a * QBool object. * * Return bool mapped by 'key'. */ int qdict_get_bool(const QDict *qdict, const char *key) { QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL); return qbool_get_int(qobject_to_qbool(obj)); } /** * qdict_get_qlist(): Get the QList mapped by 'key' * * This function assumes that 'key' exists and it stores a * QList object. * * Return QList mapped by 'key'. */ QList *qdict_get_qlist(const QDict *qdict, const char *key) { return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST)); } /** * qdict_get_qdict(): Get the QDict mapped by 'key' * * This function assumes that 'key' exists and it stores a * QDict object. * * Return QDict mapped by 'key'. */ QDict *qdict_get_qdict(const QDict *qdict, const char *key) { return qobject_to_qdict(qdict_get_obj(qdict, key, QTYPE_QDICT)); } /** * qdict_get_str(): Get a pointer to the stored string mapped * by 'key' * * This function assumes that 'key' exists and it stores a * QString object. * * Return pointer to the string mapped by 'key'. */ const char *qdict_get_str(const QDict *qdict, const char *key) { QObject *obj = qdict_get_obj(qdict, key, QTYPE_QSTRING); return qstring_get_str(qobject_to_qstring(obj)); } /** * qdict_get_try_int(): Try to get integer mapped by 'key' * * Return integer mapped by 'key', if it is not present in * the dictionary or if the stored object is not of QInt type * 'def_value' will be returned. */ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QINT) return def_value; return qint_get_int(qobject_to_qint(obj)); } /** * qdict_get_try_bool(): Try to get a bool mapped by 'key' * * Return bool mapped by 'key', if it is not present in the * dictionary or if the stored object is not of QBool type * 'def_value' will be returned. */ int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QBOOL) return def_value; return qbool_get_int(qobject_to_qbool(obj)); } /** * qdict_get_try_str(): Try to get a pointer to the stored string * mapped by 'key' * * Return a pointer to the string mapped by 'key', if it is not present * in the dictionary or if the stored object is not of QString type * NULL will be returned. */ const char *qdict_get_try_str(const QDict *qdict, const char *key) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QSTRING) return NULL; return qstring_get_str(qobject_to_qstring(obj)); } /** * qdict_iter(): Iterate over all the dictionary's stored values. * * This function allows the user to provide an iterator, which will be * called for each stored value in the dictionary. */ void qdict_iter(const QDict *qdict, void (*iter)(const char *key, QObject *obj, void *opaque), void *opaque) { int i; QDictEntry *entry; for (i = 0; i < QDICT_BUCKET_MAX; i++) { QLIST_FOREACH(entry, &qdict->table[i], next) iter(entry->key, entry->value, opaque); } } static QDictEntry *qdict_next_entry(const QDict *qdict, int first_bucket) { int i; for (i = first_bucket; i < QDICT_BUCKET_MAX; i++) { if (!QLIST_EMPTY(&qdict->table[i])) { return QLIST_FIRST(&qdict->table[i]); } } return NULL; } /** * qdict_first(): Return first qdict entry for iteration. */ const QDictEntry *qdict_first(const QDict *qdict) { return qdict_next_entry(qdict, 0); } /** * qdict_next(): Return next qdict entry in an iteration. */ const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry) { QDictEntry *ret; ret = QLIST_NEXT(entry, next); if (!ret) { unsigned int bucket = tdb_hash(entry->key) % QDICT_BUCKET_MAX; ret = qdict_next_entry(qdict, bucket + 1); } return ret; } /** * qdict_clone_shallow(): Clones a given QDict. Its entries are not copied, but * another reference is added. */ QDict *qdict_clone_shallow(const QDict *src) { QDict *dest; QDictEntry *entry; int i; dest = qdict_new(); for (i = 0; i < QDICT_BUCKET_MAX; i++) { QLIST_FOREACH(entry, &src->table[i], next) { qobject_incref(entry->value); qdict_put_obj(dest, entry->key, entry->value); } } return dest; } /** * qentry_destroy(): Free all the memory allocated by a QDictEntry */ static void qentry_destroy(QDictEntry *e) { assert(e != NULL); assert(e->key != NULL); assert(e->value != NULL); qobject_decref(e->value); g_free(e->key); g_free(e); } /** * qdict_del(): Delete a 'key:value' pair from the dictionary * * This will destroy all data allocated by this entry. */ void qdict_del(QDict *qdict, const char *key) { QDictEntry *entry; entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_BUCKET_MAX); if (entry) { QLIST_REMOVE(entry, next); qentry_destroy(entry); qdict->size--; } } /** * qdict_destroy_obj(): Free all the memory allocated by a QDict */ static void qdict_destroy_obj(QObject *obj) { int i; QDict *qdict; assert(obj != NULL); qdict = qobject_to_qdict(obj); for (i = 0; i < QDICT_BUCKET_MAX; i++) { QDictEntry *entry = QLIST_FIRST(&qdict->table[i]); while (entry) { QDictEntry *tmp = QLIST_NEXT(entry, next); QLIST_REMOVE(entry, next); qentry_destroy(entry); entry = tmp; } } g_free(qdict); } glusterfs-3.7.6/contrib/qemu/qobject/PaxHeaders.7244/qjson.c0000644000076200007630000000013112617742532022065 xustar000000000000000030 mtime=1447019866.043471449 29 atime=1447019866.37446647 30 ctime=1447019941.777332084 glusterfs-3.7.6/contrib/qemu/qobject/qjson.c0000644000076200007630000001551212617742532022307 0ustar00jenkinsjenkins00000000000000/* * QObject JSON integration * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-streamer.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qdict.h" typedef struct JSONParsingState { JSONMessageParser parser; va_list *ap; QObject *result; } JSONParsingState; static void parse_json(JSONMessageParser *parser, QList *tokens) { JSONParsingState *s = container_of(parser, JSONParsingState, parser); s->result = json_parser_parse(tokens, s->ap); } QObject *qobject_from_jsonv(const char *string, va_list *ap) { JSONParsingState state = {}; state.ap = ap; json_message_parser_init(&state.parser, parse_json); json_message_parser_feed(&state.parser, string, strlen(string)); json_message_parser_flush(&state.parser); json_message_parser_destroy(&state.parser); return state.result; } QObject *qobject_from_json(const char *string) { return qobject_from_jsonv(string, NULL); } /* * IMPORTANT: This function aborts on error, thus it must not * be used with untrusted arguments. */ QObject *qobject_from_jsonf(const char *string, ...) { QObject *obj; va_list ap; va_start(ap, string); obj = qobject_from_jsonv(string, &ap); va_end(ap); assert(obj != NULL); return obj; } typedef struct ToJsonIterState { int indent; int pretty; int count; QString *str; } ToJsonIterState; static void to_json(const QObject *obj, QString *str, int pretty, int indent); static void to_json_dict_iter(const char *key, QObject *obj, void *opaque) { ToJsonIterState *s = opaque; QString *qkey; int j; if (s->count) qstring_append(s->str, ", "); if (s->pretty) { qstring_append(s->str, "\n"); for (j = 0 ; j < s->indent ; j++) qstring_append(s->str, " "); } qkey = qstring_from_str(key); to_json(QOBJECT(qkey), s->str, s->pretty, s->indent); QDECREF(qkey); qstring_append(s->str, ": "); to_json(obj, s->str, s->pretty, s->indent); s->count++; } static void to_json_list_iter(QObject *obj, void *opaque) { ToJsonIterState *s = opaque; int j; if (s->count) qstring_append(s->str, ", "); if (s->pretty) { qstring_append(s->str, "\n"); for (j = 0 ; j < s->indent ; j++) qstring_append(s->str, " "); } to_json(obj, s->str, s->pretty, s->indent); s->count++; } static void to_json(const QObject *obj, QString *str, int pretty, int indent) { switch (qobject_type(obj)) { case QTYPE_QINT: { QInt *val = qobject_to_qint(obj); char buffer[1024]; snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val)); qstring_append(str, buffer); break; } case QTYPE_QSTRING: { QString *val = qobject_to_qstring(obj); const char *ptr; int cp; char buf[16]; char *end; ptr = qstring_get_str(val); qstring_append(str, "\""); for (; *ptr; ptr = end) { cp = mod_utf8_codepoint(ptr, 6, &end); switch (cp) { case '\"': qstring_append(str, "\\\""); break; case '\\': qstring_append(str, "\\\\"); break; case '\b': qstring_append(str, "\\b"); break; case '\f': qstring_append(str, "\\f"); break; case '\n': qstring_append(str, "\\n"); break; case '\r': qstring_append(str, "\\r"); break; case '\t': qstring_append(str, "\\t"); break; default: if (cp < 0) { cp = 0xFFFD; /* replacement character */ } if (cp > 0xFFFF) { /* beyond BMP; need a surrogate pair */ snprintf(buf, sizeof(buf), "\\u%04X\\u%04X", 0xD800 + ((cp - 0x10000) >> 10), 0xDC00 + ((cp - 0x10000) & 0x3FF)); } else if (cp < 0x20 || cp >= 0x7F) { snprintf(buf, sizeof(buf), "\\u%04X", cp); } else { buf[0] = cp; buf[1] = 0; } qstring_append(str, buf); } }; qstring_append(str, "\""); break; } case QTYPE_QDICT: { ToJsonIterState s; QDict *val = qobject_to_qdict(obj); s.count = 0; s.str = str; s.indent = indent + 1; s.pretty = pretty; qstring_append(str, "{"); qdict_iter(val, to_json_dict_iter, &s); if (pretty) { int j; qstring_append(str, "\n"); for (j = 0 ; j < indent ; j++) qstring_append(str, " "); } qstring_append(str, "}"); break; } case QTYPE_QLIST: { ToJsonIterState s; QList *val = qobject_to_qlist(obj); s.count = 0; s.str = str; s.indent = indent + 1; s.pretty = pretty; qstring_append(str, "["); qlist_iter(val, (void *)to_json_list_iter, &s); if (pretty) { int j; qstring_append(str, "\n"); for (j = 0 ; j < indent ; j++) qstring_append(str, " "); } qstring_append(str, "]"); break; } case QTYPE_QFLOAT: { QFloat *val = qobject_to_qfloat(obj); char buffer[1024]; int len; len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val)); while (len > 0 && buffer[len - 1] == '0') { len--; } if (len && buffer[len - 1] == '.') { buffer[len - 1] = 0; } else { buffer[len] = 0; } qstring_append(str, buffer); break; } case QTYPE_QBOOL: { QBool *val = qobject_to_qbool(obj); if (qbool_get_int(val)) { qstring_append(str, "true"); } else { qstring_append(str, "false"); } break; } case QTYPE_QERROR: /* XXX: should QError be emitted? */ case QTYPE_NONE: break; } } QString *qobject_to_json(const QObject *obj) { QString *str = qstring_new(); to_json(obj, str, 0, 0); return str; } QString *qobject_to_json_pretty(const QObject *obj) { QString *str = qstring_new(); to_json(obj, str, 1, 0); return str; } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/qemu-coroutine.c0000644000076200007630000000013112617742532022260 xustar000000000000000030 mtime=1447019866.042471464 29 atime=1447019866.37446647 30 ctime=1447019941.644334084 glusterfs-3.7.6/contrib/qemu/qemu-coroutine.c0000644000076200007630000000557612617742532022513 0ustar00jenkinsjenkins00000000000000/* * QEMU coroutines * * Copyright IBM, Corp. 2011 * * Authors: * Stefan Hajnoczi * Kevin Wolf * * This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. * */ #include "trace.h" #include "qemu-common.h" #include "qemu/thread.h" #include "block/coroutine.h" #include "block/coroutine_int.h" enum { /* Maximum free pool size prevents holding too many freed coroutines */ POOL_MAX_SIZE = 0, }; /** Free list to speed up creation */ static QemuMutex pool_lock; static QSLIST_HEAD(, Coroutine) pool = QSLIST_HEAD_INITIALIZER(pool); static unsigned int pool_size; Coroutine *qemu_coroutine_create(CoroutineEntry *entry) { Coroutine *co; qemu_mutex_lock(&pool_lock); co = QSLIST_FIRST(&pool); if (co) { QSLIST_REMOVE_HEAD(&pool, pool_next); pool_size--; } qemu_mutex_unlock(&pool_lock); if (!co) { co = qemu_coroutine_new(); } co->entry = entry; QTAILQ_INIT(&co->co_queue_wakeup); return co; } static void coroutine_delete(Coroutine *co) { qemu_mutex_lock(&pool_lock); if (pool_size < POOL_MAX_SIZE) { QSLIST_INSERT_HEAD(&pool, co, pool_next); co->caller = NULL; pool_size++; qemu_mutex_unlock(&pool_lock); return; } qemu_mutex_unlock(&pool_lock); qemu_coroutine_delete(co); } static void __attribute__((constructor)) coroutine_pool_init(void) { qemu_mutex_init(&pool_lock); } static void __attribute__((destructor)) coroutine_pool_cleanup(void) { Coroutine *co; Coroutine *tmp; QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) { QSLIST_REMOVE_HEAD(&pool, pool_next); qemu_coroutine_delete(co); } qemu_mutex_destroy(&pool_lock); } static void coroutine_swap(Coroutine *from, Coroutine *to) { CoroutineAction ret; ret = qemu_coroutine_switch(from, to, COROUTINE_YIELD); qemu_co_queue_run_restart(to); switch (ret) { case COROUTINE_YIELD: return; case COROUTINE_TERMINATE: trace_qemu_coroutine_terminate(to); coroutine_delete(to); return; default: abort(); } } void qemu_coroutine_enter(Coroutine *co, void *opaque) { Coroutine *self = qemu_coroutine_self(); trace_qemu_coroutine_enter(self, co, opaque); if (co->caller) { fprintf(stderr, "Co-routine re-entered recursively\n"); abort(); } co->caller = self; co->entry_arg = opaque; coroutine_swap(self, co); } void coroutine_fn qemu_coroutine_yield(void) { Coroutine *self = qemu_coroutine_self(); Coroutine *to = self->caller; trace_qemu_coroutine_yield(self, to); if (!to) { fprintf(stderr, "Co-routine is yielding to no one\n"); abort(); } self->caller = NULL; coroutine_swap(self, to); } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/coroutine-ucontext.c0000644000076200007630000000013112617742532023162 xustar000000000000000029 mtime=1447019866.03547157 30 atime=1447019866.371466515 30 ctime=1447019941.654333935 glusterfs-3.7.6/contrib/qemu/coroutine-ucontext.c0000644000076200007630000001311712617742532023403 0ustar00jenkinsjenkins00000000000000/* * ucontext coroutine initialization code * * Copyright (C) 2006 Anthony Liguori * Copyright (C) 2011 Kevin Wolf * * 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.0 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, see . */ /* XXX Is there a nicer way to disable glibc's stack check for longjmp? */ #ifdef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE #endif #include #include #include #include #include #include "qemu-common.h" #include "block/coroutine_int.h" #ifdef CONFIG_VALGRIND_H #include #endif typedef struct { Coroutine base; void *stack; sigjmp_buf env; #ifdef CONFIG_VALGRIND_H unsigned int valgrind_stack_id; #endif } CoroutineUContext; /** * Per-thread coroutine bookkeeping */ typedef struct { /** Currently executing coroutine */ Coroutine *current; /** The default coroutine */ CoroutineUContext leader; } CoroutineThreadState; static pthread_key_t thread_state_key; /* * va_args to makecontext() must be type 'int', so passing * the pointer we need may require several int args. This * union is a quick hack to let us do that */ union cc_arg { void *p; int i[2]; }; static CoroutineThreadState *coroutine_get_thread_state(void) { CoroutineThreadState *s = pthread_getspecific(thread_state_key); if (!s) { s = g_malloc0(sizeof(*s)); s->current = &s->leader.base; pthread_setspecific(thread_state_key, s); } return s; } static void qemu_coroutine_thread_cleanup(void *opaque) { CoroutineThreadState *s = opaque; g_free(s); } static void __attribute__((constructor)) coroutine_init(void) { int ret; ret = pthread_key_create(&thread_state_key, qemu_coroutine_thread_cleanup); if (ret != 0) { fprintf(stderr, "unable to create leader key: %s\n", strerror(errno)); abort(); } } static void coroutine_trampoline(int i0, int i1) { union cc_arg arg; CoroutineUContext *self; Coroutine *co; arg.i[0] = i0; arg.i[1] = i1; self = arg.p; co = &self->base; /* Initialize longjmp environment and switch back the caller */ if (!sigsetjmp(self->env, 0)) { siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } while (true) { co->entry(co->entry_arg); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); } } Coroutine *qemu_coroutine_new(void) { const size_t stack_size = 1 << 20; CoroutineUContext *co; ucontext_t old_uc, uc; sigjmp_buf old_env; union cc_arg arg = {0}; /* The ucontext functions preserve signal masks which incurs a * system call overhead. sigsetjmp(buf, 0)/siglongjmp() does not * preserve signal masks but only works on the current stack. * Since we need a way to create and switch to a new stack, use * the ucontext functions for that but sigsetjmp()/siglongjmp() for * everything else. */ if (getcontext(&uc) == -1) { abort(); } co = g_malloc0(sizeof(*co)); co->stack = g_malloc(stack_size); co->base.entry_arg = &old_env; /* stash away our jmp_buf */ uc.uc_link = &old_uc; uc.uc_stack.ss_sp = co->stack; uc.uc_stack.ss_size = stack_size; uc.uc_stack.ss_flags = 0; #ifdef CONFIG_VALGRIND_H co->valgrind_stack_id = VALGRIND_STACK_REGISTER(co->stack, co->stack + stack_size); #endif arg.p = co; makecontext(&uc, (void (*)(void))coroutine_trampoline, 2, arg.i[0], arg.i[1]); /* swapcontext() in, siglongjmp() back out */ if (!sigsetjmp(old_env, 0)) { swapcontext(&old_uc, &uc); } return &co->base; } #ifdef CONFIG_VALGRIND_H #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE /* Work around an unused variable in the valgrind.h macro... */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif static inline void valgrind_stack_deregister(CoroutineUContext *co) { VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id); } #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE #pragma GCC diagnostic pop #endif #endif void qemu_coroutine_delete(Coroutine *co_) { CoroutineUContext *co = DO_UPCAST(CoroutineUContext, base, co_); #ifdef CONFIG_VALGRIND_H valgrind_stack_deregister(co); #endif g_free(co->stack); g_free(co); } CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, CoroutineAction action) { CoroutineUContext *from = DO_UPCAST(CoroutineUContext, base, from_); CoroutineUContext *to = DO_UPCAST(CoroutineUContext, base, to_); CoroutineThreadState *s = coroutine_get_thread_state(); int ret; s->current = to_; ret = sigsetjmp(from->env, 0); if (ret == 0) { siglongjmp(to->env, action); } return ret; } Coroutine *qemu_coroutine_self(void) { CoroutineThreadState *s = coroutine_get_thread_state(); return s->current; } bool qemu_in_coroutine(void) { CoroutineThreadState *s = pthread_getspecific(thread_state_key); return s && s->current->caller; } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/nop-symbols.c0000644000076200007630000000013212617742532021567 xustar000000000000000030 mtime=1447019866.042471464 30 atime=1447019866.373466485 30 ctime=1447019941.661333829 glusterfs-3.7.6/contrib/qemu/nop-symbols.c0000644000076200007630000000074312617742532022010 0ustar00jenkinsjenkins00000000000000int notifier_with_return_list_init () { return 0; } int notifier_with_return_list_notify () { return 0; } int notifier_with_return_list_add () { return 0; } int notifier_list_init () { return 0; } int notifier_list_notify () { return 0; } int notifier_list_add () { return 0; } int monitor_protocol_event () { return 0; } int block_job_cancel_sync () { return 0; } int block_job_iostatus_reset () { return 0; } int vm_stop () { return 0; } int qemu_get_aio_context () { return 0; } glusterfs-3.7.6/contrib/qemu/PaxHeaders.7244/util0000644000076200007630000000013212617742645020046 xustar000000000000000030 mtime=1447019941.705333167 30 atime=1447019949.333218415 30 ctime=1447019941.705333167 glusterfs-3.7.6/contrib/qemu/util/0000755000076200007630000000000012617742645020340 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/hbitmap.c0000644000076200007630000000013212617742532021706 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.680333542 glusterfs-3.7.6/contrib/qemu/util/hbitmap.c0000644000076200007630000003107612617742532022132 0ustar00jenkinsjenkins00000000000000/* * Hierarchical Bitmap Data Type * * Copyright Red Hat, Inc., 2012 * * Author: Paolo Bonzini * * This work is licensed under the terms of the GNU GPL, version 2 or * later. See the COPYING file in the top-level directory. */ #include #include #include #include "qemu/osdep.h" #include "qemu/hbitmap.h" #include "qemu/host-utils.h" #include "trace.h" /* HBitmaps provides an array of bits. The bits are stored as usual in an * array of unsigned longs, but HBitmap is also optimized to provide fast * iteration over set bits; going from one bit to the next is O(logB n) * worst case, with B = sizeof(long) * CHAR_BIT: the result is low enough * that the number of levels is in fact fixed. * * In order to do this, it stacks multiple bitmaps with progressively coarser * granularity; in all levels except the last, bit N is set iff the N-th * unsigned long is nonzero in the immediately next level. When iteration * completes on the last level it can examine the 2nd-last level to quickly * skip entire words, and even do so recursively to skip blocks of 64 words or * powers thereof (32 on 32-bit machines). * * Given an index in the bitmap, it can be split in group of bits like * this (for the 64-bit case): * * bits 0-57 => word in the last bitmap | bits 58-63 => bit in the word * bits 0-51 => word in the 2nd-last bitmap | bits 52-57 => bit in the word * bits 0-45 => word in the 3rd-last bitmap | bits 46-51 => bit in the word * * So it is easy to move up simply by shifting the index right by * log2(BITS_PER_LONG) bits. To move down, you shift the index left * similarly, and add the word index within the group. Iteration uses * ffs (find first set bit) to find the next word to examine; this * operation can be done in constant time in most current architectures. * * Setting or clearing a range of m bits on all levels, the work to perform * is O(m + m/W + m/W^2 + ...), which is O(m) like on a regular bitmap. * * When iterating on a bitmap, each bit (on any level) is only visited * once. Hence, The total cost of visiting a bitmap with m bits in it is * the number of bits that are set in all bitmaps. Unless the bitmap is * extremely sparse, this is also O(m + m/W + m/W^2 + ...), so the amortized * cost of advancing from one bit to the next is usually constant (worst case * O(logB n) as in the non-amortized complexity). */ struct HBitmap { /* Number of total bits in the bottom level. */ uint64_t size; /* Number of set bits in the bottom level. */ uint64_t count; /* A scaling factor. Given a granularity of G, each bit in the bitmap will * will actually represent a group of 2^G elements. Each operation on a * range of bits first rounds the bits to determine which group they land * in, and then affect the entire page; iteration will only visit the first * bit of each group. Here is an example of operations in a size-16, * granularity-1 HBitmap: * * initial state 00000000 * set(start=0, count=9) 11111000 (iter: 0, 2, 4, 6, 8) * reset(start=1, count=3) 00111000 (iter: 4, 6, 8) * set(start=9, count=2) 00111100 (iter: 4, 6, 8, 10) * reset(start=5, count=5) 00000000 * * From an implementation point of view, when setting or resetting bits, * the bitmap will scale bit numbers right by this amount of bits. When * iterating, the bitmap will scale bit numbers left by this amount of * bits. */ int granularity; /* A number of progressively less coarse bitmaps (i.e. level 0 is the * coarsest). Each bit in level N represents a word in level N+1 that * has a set bit, except the last level where each bit represents the * actual bitmap. * * Note that all bitmaps have the same number of levels. Even a 1-bit * bitmap will still allocate HBITMAP_LEVELS arrays. */ unsigned long *levels[HBITMAP_LEVELS]; }; #ifndef __NetBSD__ /* we have it in */ static inline int popcountl(unsigned long l) { return BITS_PER_LONG == 32 ? ctpop32(l) : ctpop64(l); } #endif /* Advance hbi to the next nonzero word and return it. hbi->pos * is updated. Returns zero if we reach the end of the bitmap. */ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi) { size_t pos = hbi->pos; const HBitmap *hb = hbi->hb; unsigned i = HBITMAP_LEVELS - 1; unsigned long cur; do { cur = hbi->cur[--i]; pos >>= BITS_PER_LEVEL; } while (cur == 0); /* Check for end of iteration. We always use fewer than BITS_PER_LONG * bits in the level 0 bitmap; thus we can repurpose the most significant * bit as a sentinel. The sentinel is set in hbitmap_alloc and ensures * that the above loop ends even without an explicit check on i. */ if (i == 0 && cur == (1UL << (BITS_PER_LONG - 1))) { return 0; } for (; i < HBITMAP_LEVELS - 1; i++) { /* Shift back pos to the left, matching the right shifts above. * The index of this word's least significant set bit provides * the low-order bits. */ assert(cur); pos = (pos << BITS_PER_LEVEL) + ctzl(cur); hbi->cur[i] = cur & (cur - 1); /* Set up next level for iteration. */ cur = hb->levels[i + 1][pos]; } hbi->pos = pos; trace_hbitmap_iter_skip_words(hbi->hb, hbi, pos, cur); assert(cur); return cur; } void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first) { unsigned i, bit; uint64_t pos; hbi->hb = hb; pos = first >> hb->granularity; assert(pos < hb->size); hbi->pos = pos >> BITS_PER_LEVEL; hbi->granularity = hb->granularity; for (i = HBITMAP_LEVELS; i-- > 0; ) { bit = pos & (BITS_PER_LONG - 1); pos >>= BITS_PER_LEVEL; /* Drop bits representing items before first. */ hbi->cur[i] = hb->levels[i][pos] & ~((1UL << bit) - 1); /* We have already added level i+1, so the lowest set bit has * been processed. Clear it. */ if (i != HBITMAP_LEVELS - 1) { hbi->cur[i] &= ~(1UL << bit); } } } bool hbitmap_empty(const HBitmap *hb) { return hb->count == 0; } int hbitmap_granularity(const HBitmap *hb) { return hb->granularity; } uint64_t hbitmap_count(const HBitmap *hb) { return hb->count << hb->granularity; } /* Count the number of set bits between start and end, not accounting for * the granularity. Also an example of how to use hbitmap_iter_next_word. */ static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last) { HBitmapIter hbi; uint64_t count = 0; uint64_t end = last + 1; unsigned long cur; size_t pos; hbitmap_iter_init(&hbi, hb, start << hb->granularity); for (;;) { pos = hbitmap_iter_next_word(&hbi, &cur); if (pos >= (end >> BITS_PER_LEVEL)) { break; } count += popcountl(cur); } if (pos == (end >> BITS_PER_LEVEL)) { /* Drop bits representing the END-th and subsequent items. */ int bit = end & (BITS_PER_LONG - 1); cur &= (1UL << bit) - 1; count += popcountl(cur); } return count; } /* Setting starts at the last layer and propagates up if an element * changes from zero to non-zero. */ static inline bool hb_set_elem(unsigned long *elem, uint64_t start, uint64_t last) { unsigned long mask; bool changed; assert((last >> BITS_PER_LEVEL) == (start >> BITS_PER_LEVEL)); assert(start <= last); mask = 2UL << (last & (BITS_PER_LONG - 1)); mask -= 1UL << (start & (BITS_PER_LONG - 1)); changed = (*elem == 0); *elem |= mask; return changed; } /* The recursive workhorse (the depth is limited to HBITMAP_LEVELS)... */ static void hb_set_between(HBitmap *hb, int level, uint64_t start, uint64_t last) { size_t pos = start >> BITS_PER_LEVEL; size_t lastpos = last >> BITS_PER_LEVEL; bool changed = false; size_t i; i = pos; if (i < lastpos) { uint64_t next = (start | (BITS_PER_LONG - 1)) + 1; changed |= hb_set_elem(&hb->levels[level][i], start, next - 1); for (;;) { start = next; next += BITS_PER_LONG; if (++i == lastpos) { break; } changed |= (hb->levels[level][i] == 0); hb->levels[level][i] = ~0UL; } } changed |= hb_set_elem(&hb->levels[level][i], start, last); /* If there was any change in this layer, we may have to update * the one above. */ if (level > 0 && changed) { hb_set_between(hb, level - 1, pos, lastpos); } } void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count) { /* Compute range in the last layer. */ uint64_t last = start + count - 1; trace_hbitmap_set(hb, start, count, start >> hb->granularity, last >> hb->granularity); start >>= hb->granularity; last >>= hb->granularity; count = last - start + 1; hb->count += count - hb_count_between(hb, start, last); hb_set_between(hb, HBITMAP_LEVELS - 1, start, last); } /* Resetting works the other way round: propagate up if the new * value is zero. */ static inline bool hb_reset_elem(unsigned long *elem, uint64_t start, uint64_t last) { unsigned long mask; bool blanked; assert((last >> BITS_PER_LEVEL) == (start >> BITS_PER_LEVEL)); assert(start <= last); mask = 2UL << (last & (BITS_PER_LONG - 1)); mask -= 1UL << (start & (BITS_PER_LONG - 1)); blanked = *elem != 0 && ((*elem & ~mask) == 0); *elem &= ~mask; return blanked; } /* The recursive workhorse (the depth is limited to HBITMAP_LEVELS)... */ static void hb_reset_between(HBitmap *hb, int level, uint64_t start, uint64_t last) { size_t pos = start >> BITS_PER_LEVEL; size_t lastpos = last >> BITS_PER_LEVEL; bool changed = false; size_t i; i = pos; if (i < lastpos) { uint64_t next = (start | (BITS_PER_LONG - 1)) + 1; /* Here we need a more complex test than when setting bits. Even if * something was changed, we must not blank bits in the upper level * unless the lower-level word became entirely zero. So, remove pos * from the upper-level range if bits remain set. */ if (hb_reset_elem(&hb->levels[level][i], start, next - 1)) { changed = true; } else { pos++; } for (;;) { start = next; next += BITS_PER_LONG; if (++i == lastpos) { break; } changed |= (hb->levels[level][i] != 0); hb->levels[level][i] = 0UL; } } /* Same as above, this time for lastpos. */ if (hb_reset_elem(&hb->levels[level][i], start, last)) { changed = true; } else { lastpos--; } if (level > 0 && changed) { hb_reset_between(hb, level - 1, pos, lastpos); } } void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count) { /* Compute range in the last layer. */ uint64_t last = start + count - 1; trace_hbitmap_reset(hb, start, count, start >> hb->granularity, last >> hb->granularity); start >>= hb->granularity; last >>= hb->granularity; hb->count -= hb_count_between(hb, start, last); hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last); } bool hbitmap_get(const HBitmap *hb, uint64_t item) { /* Compute position and bit in the last layer. */ uint64_t pos = item >> hb->granularity; unsigned long bit = 1UL << (pos & (BITS_PER_LONG - 1)); return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & bit) != 0; } void hbitmap_free(HBitmap *hb) { unsigned i; for (i = HBITMAP_LEVELS; i-- > 0; ) { g_free(hb->levels[i]); } g_free(hb); } HBitmap *hbitmap_alloc(uint64_t size, int granularity) { HBitmap *hb = g_malloc0(sizeof (struct HBitmap)); unsigned i; assert(granularity >= 0 && granularity < 64); size = (size + (1ULL << granularity) - 1) >> granularity; assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE)); hb->size = size; hb->granularity = granularity; for (i = HBITMAP_LEVELS; i-- > 0; ) { size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); hb->levels[i] = g_malloc0(size * sizeof(unsigned long)); } /* We necessarily have free bits in level 0 due to the definition * of HBITMAP_LEVELS, so use one for a sentinel. This speeds up * hbitmap_iter_skip_words. */ assert(size == 1); hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1); return hb; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/cutils.c0000644000076200007630000000013212617742532021565 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.673333649 glusterfs-3.7.6/contrib/qemu/util/cutils.c0000644000076200007630000003061412617742532022006 0ustar00jenkinsjenkins00000000000000/* * Simple C functions to supplement the C library * * Copyright (c) 2006 Fabrice Bellard * * 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. */ #include "qemu-common.h" #include "qemu/host-utils.h" #include #include "qemu/sockets.h" #include "qemu/iov.h" void strpadcpy(char *buf, int buf_size, const char *str, char pad) { int len = qemu_strnlen(str, buf_size); memcpy(buf, str, len); memset(buf + len, pad, buf_size - len); } void pstrcpy(char *buf, int buf_size, const char *str) { int c; char *q = buf; if (buf_size <= 0) return; for(;;) { c = *str++; if (c == 0 || q >= buf + buf_size - 1) break; *q++ = c; } *q = '\0'; } /* strcat and truncate. */ char *pstrcat(char *buf, int buf_size, const char *s) { int len; len = strlen(buf); if (len < buf_size) pstrcpy(buf + len, buf_size - len, s); return buf; } int strstart(const char *str, const char *val, const char **ptr) { const char *p, *q; p = str; q = val; while (*q != '\0') { if (*p != *q) return 0; p++; q++; } if (ptr) *ptr = p; return 1; } int stristart(const char *str, const char *val, const char **ptr) { const char *p, *q; p = str; q = val; while (*q != '\0') { if (qemu_toupper(*p) != qemu_toupper(*q)) return 0; p++; q++; } if (ptr) *ptr = p; return 1; } /* XXX: use host strnlen if available ? */ int qemu_strnlen(const char *s, int max_len) { int i; for(i = 0; i < max_len; i++) { if (s[i] == '\0') { break; } } return i; } char *qemu_strsep(char **input, const char *delim) { char *result = *input; if (result != NULL) { char *p; for (p = result; *p != '\0'; p++) { if (strchr(delim, *p)) { break; } } if (*p == '\0') { *input = NULL; } else { *p = '\0'; *input = p + 1; } } return result; } time_t mktimegm(struct tm *tm) { time_t t; int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday; if (m < 3) { m += 12; y--; } t = 86400ULL * (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469); t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec; return t; } int qemu_fls(int i) { return 32 - clz32(i); } /* * Make sure data goes on disk, but if possible do not bother to * write out the inode just for timestamp updates. * * Unfortunately even in 2009 many operating systems do not support * fdatasync and have to fall back to fsync. */ int qemu_fdatasync(int fd) { #ifdef HAVE_FDATASYNC return fdatasync(fd); #else return fsync(fd); #endif } /* * Searches for an area with non-zero content in a buffer * * Attention! The len must be a multiple of * BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR * sizeof(VECTYPE) * and addr must be a multiple of sizeof(VECTYPE) due to * restriction of optimizations in this function. * * can_use_buffer_find_nonzero_offset() can be used to check * these requirements. * * The return value is the offset of the non-zero area rounded * down to a multiple of sizeof(VECTYPE) for the first * BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR chunks and down to * BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR * sizeof(VECTYPE) * afterwards. * * If the buffer is all zero the return value is equal to len. */ size_t buffer_find_nonzero_offset(const void *buf, size_t len) { const VECTYPE *p = buf; const VECTYPE zero = (VECTYPE){0}; size_t i; assert(can_use_buffer_find_nonzero_offset(buf, len)); if (!len) { return 0; } for (i = 0; i < BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR; i++) { if (!ALL_EQ(p[i], zero)) { return i * sizeof(VECTYPE); } } for (i = BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR; i < len / sizeof(VECTYPE); i += BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR) { VECTYPE tmp0 = p[i + 0] | p[i + 1]; VECTYPE tmp1 = p[i + 2] | p[i + 3]; VECTYPE tmp2 = p[i + 4] | p[i + 5]; VECTYPE tmp3 = p[i + 6] | p[i + 7]; VECTYPE tmp01 = tmp0 | tmp1; VECTYPE tmp23 = tmp2 | tmp3; if (!ALL_EQ(tmp01 | tmp23, zero)) { break; } } return i * sizeof(VECTYPE); } /* * Checks if a buffer is all zeroes * * Attention! The len must be a multiple of 4 * sizeof(long) due to * restriction of optimizations in this function. */ bool buffer_is_zero(const void *buf, size_t len) { /* * Use long as the biggest available internal data type that fits into the * CPU register and unroll the loop to smooth out the effect of memory * latency. */ size_t i; long d0, d1, d2, d3; const long * const data = buf; /* use vector optimized zero check if possible */ if (can_use_buffer_find_nonzero_offset(buf, len)) { return buffer_find_nonzero_offset(buf, len) == len; } assert(len % (4 * sizeof(long)) == 0); len /= sizeof(long); for (i = 0; i < len; i += 4) { d0 = data[i + 0]; d1 = data[i + 1]; d2 = data[i + 2]; d3 = data[i + 3]; if (d0 || d1 || d2 || d3) { return false; } } return true; } #ifndef _WIN32 /* Sets a specific flag */ int fcntl_setfl(int fd, int flag) { int flags; flags = fcntl(fd, F_GETFL); if (flags == -1) return -errno; if (fcntl(fd, F_SETFL, flags | flag) == -1) return -errno; return 0; } #endif static int64_t suffix_mul(char suffix, int64_t unit) { switch (qemu_toupper(suffix)) { case STRTOSZ_DEFSUFFIX_B: return 1; case STRTOSZ_DEFSUFFIX_KB: return unit; case STRTOSZ_DEFSUFFIX_MB: return unit * unit; case STRTOSZ_DEFSUFFIX_GB: return unit * unit * unit; case STRTOSZ_DEFSUFFIX_TB: return unit * unit * unit * unit; case STRTOSZ_DEFSUFFIX_PB: return unit * unit * unit * unit * unit; case STRTOSZ_DEFSUFFIX_EB: return unit * unit * unit * unit * unit * unit; } return -1; } /* * Convert string to bytes, allowing either B/b for bytes, K/k for KB, * M/m for MB, G/g for GB or T/t for TB. End pointer will be returned * in *end, if not NULL. Return -ERANGE on overflow, Return -EINVAL on * other error. */ int64_t strtosz_suffix_unit(const char *nptr, char **end, const char default_suffix, int64_t unit) { int64_t retval = -EINVAL; char *endptr; unsigned char c; int mul_required = 0; double val, mul, integral, fraction; errno = 0; val = strtod(nptr, &endptr); if (isnan(val) || endptr == nptr || errno != 0) { goto fail; } fraction = modf(val, &integral); if (fraction != 0) { mul_required = 1; } c = *endptr; mul = suffix_mul(c, unit); if (mul >= 0) { endptr++; } else { mul = suffix_mul(default_suffix, unit); assert(mul >= 0); } if (mul == 1 && mul_required) { goto fail; } if ((val * mul >= INT64_MAX) || val < 0) { retval = -ERANGE; goto fail; } retval = val * mul; fail: if (end) { *end = endptr; } return retval; } int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { return strtosz_suffix_unit(nptr, end, default_suffix, 1024); } int64_t strtosz(const char *nptr, char **end) { return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB); } /** * parse_uint: * * @s: String to parse * @value: Destination for parsed integer value * @endptr: Destination for pointer to first character not consumed * @base: integer base, between 2 and 36 inclusive, or 0 * * Parse unsigned integer * * Parsed syntax is like strtoull()'s: arbitrary whitespace, a single optional * '+' or '-', an optional "0x" if @base is 0 or 16, one or more digits. * * If @s is null, or @base is invalid, or @s doesn't start with an * integer in the syntax above, set *@value to 0, *@endptr to @s, and * return -EINVAL. * * Set *@endptr to point right beyond the parsed integer (even if the integer * overflows or is negative, all digits will be parsed and *@endptr will * point right beyond them). * * If the integer is negative, set *@value to 0, and return -ERANGE. * * If the integer overflows unsigned long long, set *@value to * ULLONG_MAX, and return -ERANGE. * * Else, set *@value to the parsed integer, and return 0. */ int parse_uint(const char *s, unsigned long long *value, char **endptr, int base) { int r = 0; char *endp = (char *)s; unsigned long long val = 0; if (!s) { r = -EINVAL; goto out; } errno = 0; val = strtoull(s, &endp, base); if (errno) { r = -errno; goto out; } if (endp == s) { r = -EINVAL; goto out; } /* make sure we reject negative numbers: */ while (isspace((unsigned char)*s)) { s++; } if (*s == '-') { val = 0; r = -ERANGE; goto out; } out: *value = val; *endptr = endp; return r; } /** * parse_uint_full: * * @s: String to parse * @value: Destination for parsed integer value * @base: integer base, between 2 and 36 inclusive, or 0 * * Parse unsigned integer from entire string * * Have the same behavior of parse_uint(), but with an additional check * for additional data after the parsed number. If extra characters are present * after the parsed number, the function will return -EINVAL, and *@v will * be set to 0. */ int parse_uint_full(const char *s, unsigned long long *value, int base) { char *endp; int r; r = parse_uint(s, value, &endp, base); if (r < 0) { return r; } if (*endp) { *value = 0; return -EINVAL; } return 0; } int qemu_parse_fd(const char *param) { int fd; char *endptr = NULL; fd = strtol(param, &endptr, 10); if (*endptr || (fd == 0 && param == endptr)) { return -1; } return fd; } /* round down to the nearest power of 2*/ int64_t pow2floor(int64_t value) { if (!is_power_of_2(value)) { value = 0x8000000000000000ULL >> clz64(value); } return value; } /* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) * Input is limited to 14-bit numbers */ int uleb128_encode_small(uint8_t *out, uint32_t n) { g_assert(n <= 0x3fff); if (n < 0x80) { *out++ = n; return 1; } else { *out++ = (n & 0x7f) | 0x80; *out++ = n >> 7; return 2; } } int uleb128_decode_small(const uint8_t *in, uint32_t *n) { if (!(*in & 0x80)) { *n = *in++; return 1; } else { *n = *in++ & 0x7f; /* we exceed 14 bit number */ if (*in & 0x80) { return -1; } *n |= *in++ << 7; return 2; } } /* * helper to parse debug environment variables */ int parse_debug_env(const char *name, int max, int initial) { char *debug_env = getenv(name); char *inv = NULL; int debug; if (!debug_env) { return initial; } debug = strtol(debug_env, &inv, 10); if (inv == debug_env) { return initial; } if (debug < 0 || debug > max) { fprintf(stderr, "warning: %s not in [0, %d]", name, max); return initial; } return debug; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/qemu-thread-posix.c0000644000076200007630000000013212617742532023636 xustar000000000000000030 mtime=1447019866.046471404 30 atime=1447019866.375466455 30 ctime=1447019941.699333258 glusterfs-3.7.6/contrib/qemu/util/qemu-thread-posix.c0000644000076200007630000001543412617742532024062 0ustar00jenkinsjenkins00000000000000/* * Wrappers around mutex/cond/thread functions * * Copyright Red Hat, Inc. 2009 * * Author: * Marcelo Tosatti * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. * */ #include #include #include #include #include #include #include #include #include #include #include "qemu/thread.h" static void error_exit(int err, const char *msg) { fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err)); abort(); } void qemu_mutex_init(QemuMutex *mutex) { int err; pthread_mutexattr_t mutexattr; pthread_mutexattr_init(&mutexattr); pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK); err = pthread_mutex_init(&mutex->lock, &mutexattr); pthread_mutexattr_destroy(&mutexattr); if (err) error_exit(err, __func__); } void qemu_mutex_destroy(QemuMutex *mutex) { int err; err = pthread_mutex_destroy(&mutex->lock); if (err) error_exit(err, __func__); } void qemu_mutex_lock(QemuMutex *mutex) { int err; err = pthread_mutex_lock(&mutex->lock); if (err) error_exit(err, __func__); } int qemu_mutex_trylock(QemuMutex *mutex) { return pthread_mutex_trylock(&mutex->lock); } void qemu_mutex_unlock(QemuMutex *mutex) { int err; err = pthread_mutex_unlock(&mutex->lock); if (err) error_exit(err, __func__); } void qemu_cond_init(QemuCond *cond) { int err; err = pthread_cond_init(&cond->cond, NULL); if (err) error_exit(err, __func__); } void qemu_cond_destroy(QemuCond *cond) { int err; err = pthread_cond_destroy(&cond->cond); if (err) error_exit(err, __func__); } void qemu_cond_signal(QemuCond *cond) { int err; err = pthread_cond_signal(&cond->cond); if (err) error_exit(err, __func__); } void qemu_cond_broadcast(QemuCond *cond) { int err; err = pthread_cond_broadcast(&cond->cond); if (err) error_exit(err, __func__); } void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex) { int err; err = pthread_cond_wait(&cond->cond, &mutex->lock); if (err) error_exit(err, __func__); } void qemu_sem_init(QemuSemaphore *sem, int init) { int rc; #if defined(__APPLE__) || defined(__NetBSD__) rc = pthread_mutex_init(&sem->lock, NULL); if (rc != 0) { error_exit(rc, __func__); } rc = pthread_cond_init(&sem->cond, NULL); if (rc != 0) { error_exit(rc, __func__); } if (init < 0) { error_exit(EINVAL, __func__); } sem->count = init; #else rc = sem_init(&sem->sem, 0, init); if (rc < 0) { error_exit(errno, __func__); } #endif } void qemu_sem_destroy(QemuSemaphore *sem) { int rc; #if defined(__APPLE__) || defined(__NetBSD__) rc = pthread_cond_destroy(&sem->cond); if (rc < 0) { error_exit(rc, __func__); } rc = pthread_mutex_destroy(&sem->lock); if (rc < 0) { error_exit(rc, __func__); } #else rc = sem_destroy(&sem->sem); if (rc < 0) { error_exit(errno, __func__); } #endif } void qemu_sem_post(QemuSemaphore *sem) { int rc; #if defined(__APPLE__) || defined(__NetBSD__) pthread_mutex_lock(&sem->lock); if (sem->count == INT_MAX) { rc = EINVAL; } else if (sem->count++ < 0) { rc = pthread_cond_signal(&sem->cond); } else { rc = 0; } pthread_mutex_unlock(&sem->lock); if (rc != 0) { error_exit(rc, __func__); } #else rc = sem_post(&sem->sem); if (rc < 0) { error_exit(errno, __func__); } #endif } static void compute_abs_deadline(struct timespec *ts, int ms) { struct timeval tv; gettimeofday(&tv, NULL); ts->tv_nsec = tv.tv_usec * 1000 + (ms % 1000) * 1000000; ts->tv_sec = tv.tv_sec + ms / 1000; if (ts->tv_nsec >= 1000000000) { ts->tv_sec++; ts->tv_nsec -= 1000000000; } } int qemu_sem_timedwait(QemuSemaphore *sem, int ms) { int rc; struct timespec ts; #if defined(__APPLE__) || defined(__NetBSD__) compute_abs_deadline(&ts, ms); pthread_mutex_lock(&sem->lock); --sem->count; while (sem->count < 0) { rc = pthread_cond_timedwait(&sem->cond, &sem->lock, &ts); if (rc == ETIMEDOUT) { ++sem->count; break; } if (rc != 0) { error_exit(rc, __func__); } } pthread_mutex_unlock(&sem->lock); return (rc == ETIMEDOUT ? -1 : 0); #else if (ms <= 0) { /* This is cheaper than sem_timedwait. */ do { rc = sem_trywait(&sem->sem); } while (rc == -1 && errno == EINTR); if (rc == -1 && errno == EAGAIN) { return -1; } } else { compute_abs_deadline(&ts, ms); do { rc = sem_timedwait(&sem->sem, &ts); } while (rc == -1 && errno == EINTR); if (rc == -1 && errno == ETIMEDOUT) { return -1; } } if (rc < 0) { error_exit(errno, __func__); } return 0; #endif } void qemu_sem_wait(QemuSemaphore *sem) { #if defined(__APPLE__) || defined(__NetBSD__) pthread_mutex_lock(&sem->lock); --sem->count; while (sem->count < 0) { pthread_cond_wait(&sem->cond, &sem->lock); } pthread_mutex_unlock(&sem->lock); #else int rc; do { rc = sem_wait(&sem->sem); } while (rc == -1 && errno == EINTR); if (rc < 0) { error_exit(errno, __func__); } #endif } void qemu_thread_create(QemuThread *thread, void *(*start_routine)(void*), void *arg, int mode) { sigset_t set, oldset; int err; pthread_attr_t attr; err = pthread_attr_init(&attr); if (err) { error_exit(err, __func__); } if (mode == QEMU_THREAD_DETACHED) { err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (err) { error_exit(err, __func__); } } /* Leave signal handling to the iothread. */ sigfillset(&set); pthread_sigmask(SIG_SETMASK, &set, &oldset); err = pthread_create(&thread->thread, &attr, start_routine, arg); if (err) error_exit(err, __func__); pthread_sigmask(SIG_SETMASK, &oldset, NULL); pthread_attr_destroy(&attr); } void qemu_thread_get_self(QemuThread *thread) { thread->thread = pthread_self(); } bool qemu_thread_is_self(QemuThread *thread) { return pthread_equal(pthread_self(), thread->thread); } void qemu_thread_exit(void *retval) { pthread_exit(retval); } void *qemu_thread_join(QemuThread *thread) { int err; void *ret; err = pthread_join(thread->thread, &ret); if (err) { error_exit(err, __func__); } return ret; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/qemu-error.c0000644000076200007630000000013212617742532022360 xustar000000000000000030 mtime=1447019866.046471404 30 atime=1447019866.375466455 30 ctime=1447019941.696333304 glusterfs-3.7.6/contrib/qemu/util/qemu-error.c0000644000076200007630000001121012617742532022570 0ustar00jenkinsjenkins00000000000000/* * Error reporting * * Copyright (C) 2010 Red Hat Inc. * * Authors: * Markus Armbruster , * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #include #include "monitor/monitor.h" /* * Print to current monitor if we have one, else to stderr. * TODO should return int, so callers can calculate width, but that * requires surgery to monitor_vprintf(). Left for another day. */ void error_vprintf(const char *fmt, va_list ap) { if (cur_mon) { monitor_vprintf(cur_mon, fmt, ap); } else { vfprintf(stderr, fmt, ap); } } /* * Print to current monitor if we have one, else to stderr. * TODO just like error_vprintf() */ void error_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); error_vprintf(fmt, ap); va_end(ap); } void error_printf_unless_qmp(const char *fmt, ...) { va_list ap; if (!monitor_cur_is_qmp()) { va_start(ap, fmt); error_vprintf(fmt, ap); va_end(ap); } } static Location std_loc = { .kind = LOC_NONE }; static Location *cur_loc = &std_loc; /* * Push location saved in LOC onto the location stack, return it. * The top of that stack is the current location. * Needs a matching loc_pop(). */ Location *loc_push_restore(Location *loc) { assert(!loc->prev); loc->prev = cur_loc; cur_loc = loc; return loc; } /* * Initialize *LOC to "nowhere", push it onto the location stack. * The top of that stack is the current location. * Needs a matching loc_pop(). * Return LOC. */ Location *loc_push_none(Location *loc) { loc->kind = LOC_NONE; loc->prev = NULL; return loc_push_restore(loc); } /* * Pop the location stack. * LOC must be the current location, i.e. the top of the stack. */ Location *loc_pop(Location *loc) { assert(cur_loc == loc && loc->prev); cur_loc = loc->prev; loc->prev = NULL; return loc; } /* * Save the current location in LOC, return LOC. */ Location *loc_save(Location *loc) { *loc = *cur_loc; loc->prev = NULL; return loc; } /* * Change the current location to the one saved in LOC. */ void loc_restore(Location *loc) { Location *prev = cur_loc->prev; assert(!loc->prev); *cur_loc = *loc; cur_loc->prev = prev; } /* * Change the current location to "nowhere in particular". */ void loc_set_none(void) { cur_loc->kind = LOC_NONE; } /* * Change the current location to argument ARGV[IDX..IDX+CNT-1]. */ void loc_set_cmdline(char **argv, int idx, int cnt) { cur_loc->kind = LOC_CMDLINE; cur_loc->num = cnt; cur_loc->ptr = argv + idx; } /* * Change the current location to file FNAME, line LNO. */ void loc_set_file(const char *fname, int lno) { assert (fname || cur_loc->kind == LOC_FILE); cur_loc->kind = LOC_FILE; cur_loc->num = lno; if (fname) { cur_loc->ptr = fname; } } static const char *progname; /* * Set the program name for error_print_loc(). */ void error_set_progname(const char *argv0) { const char *p = strrchr(argv0, '/'); progname = p ? p + 1 : argv0; } const char *error_get_progname(void) { return progname; } /* * Print current location to current monitor if we have one, else to stderr. */ void error_print_loc(void) { const char *sep = ""; int i; const char *const *argp; if (!cur_mon && progname) { fprintf(stderr, "%s:", progname); sep = " "; } switch (cur_loc->kind) { case LOC_CMDLINE: argp = cur_loc->ptr; for (i = 0; i < cur_loc->num; i++) { error_printf("%s%s", sep, argp[i]); sep = " "; } error_printf(": "); break; case LOC_FILE: error_printf("%s:", (const char *)cur_loc->ptr); if (cur_loc->num) { error_printf("%d:", cur_loc->num); } error_printf(" "); break; default: error_printf("%s", sep); } } bool enable_timestamp_msg; /* * Print an error message to current monitor if we have one, else to stderr. * Format arguments like sprintf(). The result should not contain * newlines. * Prepend the current location and append a newline. * It's wrong to call this in a QMP monitor. Use qerror_report() there. */ void error_report(const char *fmt, ...) { va_list ap; GTimeVal tv; gchar *timestr; if (enable_timestamp_msg) { g_get_current_time(&tv); timestr = g_time_val_to_iso8601(&tv); error_printf("%s ", timestr); g_free(timestr); } error_print_loc(); va_start(ap, fmt); error_vprintf(fmt, ap); va_end(ap); error_printf("\n"); } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/aes.c0000644000076200007630000000013212617742532021032 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.664333784 glusterfs-3.7.6/contrib/qemu/util/aes.c0000644000076200007630000017644012617742532021263 0ustar00jenkinsjenkins00000000000000/** * * aes.c - integrated in QEMU by Fabrice Bellard from the OpenSSL project. */ /* * rijndael-alg-fst.c * * @version 3.0 (December 2000) * * Optimised ANSI C code for the Rijndael cipher (now AES) * * @author Vincent Rijmen * @author Antoon Bosselaers * @author Paulo Barreto * * This code is hereby placed in the public domain. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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. */ #include "qemu-common.h" #include "qemu/aes.h" #ifndef NDEBUG #define NDEBUG #endif typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t u8; /* This controls loop-unrolling in aes_core.c */ #undef FULL_UNROLL # define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) # define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } /* AES_Te0[x] = S [x].[02, 01, 01, 03]; AES_Te1[x] = S [x].[03, 02, 01, 01]; AES_Te2[x] = S [x].[01, 03, 02, 01]; AES_Te3[x] = S [x].[01, 01, 03, 02]; AES_Te4[x] = S [x].[01, 01, 01, 01]; AES_Td0[x] = Si[x].[0e, 09, 0d, 0b]; AES_Td1[x] = Si[x].[0b, 0e, 09, 0d]; AES_Td2[x] = Si[x].[0d, 0b, 0e, 09]; AES_Td3[x] = Si[x].[09, 0d, 0b, 0e]; AES_Td4[x] = Si[x].[01, 01, 01, 01]; */ const uint32_t AES_Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; const uint32_t AES_Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; const uint32_t AES_Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; const uint32_t AES_Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; const uint32_t AES_Te4[256] = { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; const uint32_t AES_Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; const uint32_t AES_Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; const uint32_t AES_Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; const uint32_t AES_Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; const uint32_t AES_Td4[256] = { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; static const u32 rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; /** * Expand the cipher key into the encryption key schedule. */ int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i = 0; u32 temp; if (!userKey || !key) return -1; if (bits != 128 && bits != 192 && bits != 256) return -2; rk = key->rd_key; if (bits==128) key->rounds = 10; else if (bits==192) key->rounds = 12; else key->rounds = 14; rk[0] = GETU32(userKey ); rk[1] = GETU32(userKey + 4); rk[2] = GETU32(userKey + 8); rk[3] = GETU32(userKey + 12); if (bits == 128) { while (1) { temp = rk[3]; rk[4] = rk[0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { return 0; } rk += 4; } } rk[4] = GETU32(userKey + 16); rk[5] = GETU32(userKey + 20); if (bits == 192) { while (1) { temp = rk[ 5]; rk[ 6] = rk[ 0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 9] = rk[ 3] ^ rk[ 8]; if (++i == 8) { return 0; } rk[10] = rk[ 4] ^ rk[ 9]; rk[11] = rk[ 5] ^ rk[10]; rk += 6; } } rk[6] = GETU32(userKey + 24); rk[7] = GETU32(userKey + 28); if (bits == 256) { while (1) { temp = rk[ 7]; rk[ 8] = rk[ 0] ^ (AES_Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp ) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 9] = rk[ 1] ^ rk[ 8]; rk[10] = rk[ 2] ^ rk[ 9]; rk[11] = rk[ 3] ^ rk[10]; if (++i == 7) { return 0; } temp = rk[11]; rk[12] = rk[ 4] ^ (AES_Te4[(temp >> 24) ] & 0xff000000) ^ (AES_Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(temp ) & 0xff] & 0x000000ff); rk[13] = rk[ 5] ^ rk[12]; rk[14] = rk[ 6] ^ rk[13]; rk[15] = rk[ 7] ^ rk[14]; rk += 8; } } return 0; } /** * Expand the cipher key into the decryption key schedule. */ int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i, j, status; u32 temp; /* first, start with an encryption schedule */ status = AES_set_encrypt_key(userKey, bits, key); if (status < 0) return status; rk = key->rd_key; /* invert the order of the round keys: */ for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) { temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; } /* apply the inverse MixColumn transform to all round keys but the first and the last: */ for (i = 1; i < (key->rounds); i++) { rk += 4; rk[0] = AES_Td0[AES_Te4[(rk[0] >> 24) ] & 0xff] ^ AES_Td1[AES_Te4[(rk[0] >> 16) & 0xff] & 0xff] ^ AES_Td2[AES_Te4[(rk[0] >> 8) & 0xff] & 0xff] ^ AES_Td3[AES_Te4[(rk[0] ) & 0xff] & 0xff]; rk[1] = AES_Td0[AES_Te4[(rk[1] >> 24) ] & 0xff] ^ AES_Td1[AES_Te4[(rk[1] >> 16) & 0xff] & 0xff] ^ AES_Td2[AES_Te4[(rk[1] >> 8) & 0xff] & 0xff] ^ AES_Td3[AES_Te4[(rk[1] ) & 0xff] & 0xff]; rk[2] = AES_Td0[AES_Te4[(rk[2] >> 24) ] & 0xff] ^ AES_Td1[AES_Te4[(rk[2] >> 16) & 0xff] & 0xff] ^ AES_Td2[AES_Te4[(rk[2] >> 8) & 0xff] & 0xff] ^ AES_Td3[AES_Te4[(rk[2] ) & 0xff] & 0xff]; rk[3] = AES_Td0[AES_Te4[(rk[3] >> 24) ] & 0xff] ^ AES_Td1[AES_Te4[(rk[3] >> 16) & 0xff] & 0xff] ^ AES_Td2[AES_Te4[(rk[3] >> 8) & 0xff] & 0xff] ^ AES_Td3[AES_Te4[(rk[3] ) & 0xff] & 0xff]; } return 0; } #ifndef AES_ASM /* * Encrypt a single block * in and out can overlap */ void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) { const u32 *rk; u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ assert(in && out && key); rk = key->rd_key; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(in ) ^ rk[0]; s1 = GETU32(in + 4) ^ rk[1]; s2 = GETU32(in + 8) ^ rk[2]; s3 = GETU32(in + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[ 4]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[ 5]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[ 6]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[ 8]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[ 9]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[10]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[11]; /* round 3: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[12]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[13]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[14]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[15]; /* round 4: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[16]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[17]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[18]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[19]; /* round 5: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[20]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[21]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[22]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[23]; /* round 6: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[24]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[25]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[26]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[27]; /* round 7: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[28]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[29]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[30]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[31]; /* round 8: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[32]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[33]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[34]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[35]; /* round 9: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[36]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[37]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[38]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[39]; if (key->rounds > 10) { /* round 10: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[40]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[41]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[42]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[43]; /* round 11: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[44]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[45]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[46]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[47]; if (key->rounds > 12) { /* round 12: */ s0 = AES_Te0[t0 >> 24] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[t3 & 0xff] ^ rk[48]; s1 = AES_Te0[t1 >> 24] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[t0 & 0xff] ^ rk[49]; s2 = AES_Te0[t2 >> 24] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[t1 & 0xff] ^ rk[50]; s3 = AES_Te0[t3 >> 24] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[t2 & 0xff] ^ rk[51]; /* round 13: */ t0 = AES_Te0[s0 >> 24] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[s3 & 0xff] ^ rk[52]; t1 = AES_Te0[s1 >> 24] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[s0 & 0xff] ^ rk[53]; t2 = AES_Te0[s2 >> 24] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[s1 & 0xff] ^ rk[54]; t3 = AES_Te0[s3 >> 24] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[s2 & 0xff] ^ rk[55]; } } rk += key->rounds << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = key->rounds >> 1; for (;;) { t0 = AES_Te0[(s0 >> 24) ] ^ AES_Te1[(s1 >> 16) & 0xff] ^ AES_Te2[(s2 >> 8) & 0xff] ^ AES_Te3[(s3 ) & 0xff] ^ rk[4]; t1 = AES_Te0[(s1 >> 24) ] ^ AES_Te1[(s2 >> 16) & 0xff] ^ AES_Te2[(s3 >> 8) & 0xff] ^ AES_Te3[(s0 ) & 0xff] ^ rk[5]; t2 = AES_Te0[(s2 >> 24) ] ^ AES_Te1[(s3 >> 16) & 0xff] ^ AES_Te2[(s0 >> 8) & 0xff] ^ AES_Te3[(s1 ) & 0xff] ^ rk[6]; t3 = AES_Te0[(s3 >> 24) ] ^ AES_Te1[(s0 >> 16) & 0xff] ^ AES_Te2[(s1 >> 8) & 0xff] ^ AES_Te3[(s2 ) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = AES_Te0[(t0 >> 24) ] ^ AES_Te1[(t1 >> 16) & 0xff] ^ AES_Te2[(t2 >> 8) & 0xff] ^ AES_Te3[(t3 ) & 0xff] ^ rk[0]; s1 = AES_Te0[(t1 >> 24) ] ^ AES_Te1[(t2 >> 16) & 0xff] ^ AES_Te2[(t3 >> 8) & 0xff] ^ AES_Te3[(t0 ) & 0xff] ^ rk[1]; s2 = AES_Te0[(t2 >> 24) ] ^ AES_Te1[(t3 >> 16) & 0xff] ^ AES_Te2[(t0 >> 8) & 0xff] ^ AES_Te3[(t1 ) & 0xff] ^ rk[2]; s3 = AES_Te0[(t3 >> 24) ] ^ AES_Te1[(t0 >> 16) & 0xff] ^ AES_Te2[(t1 >> 8) & 0xff] ^ AES_Te3[(t2 ) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (AES_Te4[(t0 >> 24) ] & 0xff000000) ^ (AES_Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(t3 ) & 0xff] & 0x000000ff) ^ rk[0]; PUTU32(out , s0); s1 = (AES_Te4[(t1 >> 24) ] & 0xff000000) ^ (AES_Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(t0 ) & 0xff] & 0x000000ff) ^ rk[1]; PUTU32(out + 4, s1); s2 = (AES_Te4[(t2 >> 24) ] & 0xff000000) ^ (AES_Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(t1 ) & 0xff] & 0x000000ff) ^ rk[2]; PUTU32(out + 8, s2); s3 = (AES_Te4[(t3 >> 24) ] & 0xff000000) ^ (AES_Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Te4[(t2 ) & 0xff] & 0x000000ff) ^ rk[3]; PUTU32(out + 12, s3); } /* * Decrypt a single block * in and out can overlap */ void AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) { const u32 *rk; u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ assert(in && out && key); rk = key->rd_key; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(in ) ^ rk[0]; s1 = GETU32(in + 4) ^ rk[1]; s2 = GETU32(in + 8) ^ rk[2]; s3 = GETU32(in + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[ 4]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[ 5]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[ 6]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[ 8]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[ 9]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[10]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[11]; /* round 3: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[12]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[13]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[14]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[15]; /* round 4: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[16]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[17]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[18]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[19]; /* round 5: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[20]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[21]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[22]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[23]; /* round 6: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[24]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[25]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[26]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[27]; /* round 7: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[28]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[29]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[30]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[31]; /* round 8: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[32]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[33]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[34]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[35]; /* round 9: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[36]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[37]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[38]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[39]; if (key->rounds > 10) { /* round 10: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[40]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[41]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[42]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[43]; /* round 11: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[44]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[45]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[46]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[47]; if (key->rounds > 12) { /* round 12: */ s0 = AES_Td0[t0 >> 24] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[t1 & 0xff] ^ rk[48]; s1 = AES_Td0[t1 >> 24] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[t2 & 0xff] ^ rk[49]; s2 = AES_Td0[t2 >> 24] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[t3 & 0xff] ^ rk[50]; s3 = AES_Td0[t3 >> 24] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[t0 & 0xff] ^ rk[51]; /* round 13: */ t0 = AES_Td0[s0 >> 24] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[s1 & 0xff] ^ rk[52]; t1 = AES_Td0[s1 >> 24] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[s2 & 0xff] ^ rk[53]; t2 = AES_Td0[s2 >> 24] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[s3 & 0xff] ^ rk[54]; t3 = AES_Td0[s3 >> 24] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[s0 & 0xff] ^ rk[55]; } } rk += key->rounds << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = key->rounds >> 1; for (;;) { t0 = AES_Td0[(s0 >> 24) ] ^ AES_Td1[(s3 >> 16) & 0xff] ^ AES_Td2[(s2 >> 8) & 0xff] ^ AES_Td3[(s1 ) & 0xff] ^ rk[4]; t1 = AES_Td0[(s1 >> 24) ] ^ AES_Td1[(s0 >> 16) & 0xff] ^ AES_Td2[(s3 >> 8) & 0xff] ^ AES_Td3[(s2 ) & 0xff] ^ rk[5]; t2 = AES_Td0[(s2 >> 24) ] ^ AES_Td1[(s1 >> 16) & 0xff] ^ AES_Td2[(s0 >> 8) & 0xff] ^ AES_Td3[(s3 ) & 0xff] ^ rk[6]; t3 = AES_Td0[(s3 >> 24) ] ^ AES_Td1[(s2 >> 16) & 0xff] ^ AES_Td2[(s1 >> 8) & 0xff] ^ AES_Td3[(s0 ) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = AES_Td0[(t0 >> 24) ] ^ AES_Td1[(t3 >> 16) & 0xff] ^ AES_Td2[(t2 >> 8) & 0xff] ^ AES_Td3[(t1 ) & 0xff] ^ rk[0]; s1 = AES_Td0[(t1 >> 24) ] ^ AES_Td1[(t0 >> 16) & 0xff] ^ AES_Td2[(t3 >> 8) & 0xff] ^ AES_Td3[(t2 ) & 0xff] ^ rk[1]; s2 = AES_Td0[(t2 >> 24) ] ^ AES_Td1[(t1 >> 16) & 0xff] ^ AES_Td2[(t0 >> 8) & 0xff] ^ AES_Td3[(t3 ) & 0xff] ^ rk[2]; s3 = AES_Td0[(t3 >> 24) ] ^ AES_Td1[(t2 >> 16) & 0xff] ^ AES_Td2[(t1 >> 8) & 0xff] ^ AES_Td3[(t0 ) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (AES_Td4[(t0 >> 24) ] & 0xff000000) ^ (AES_Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Td4[(t1 ) & 0xff] & 0x000000ff) ^ rk[0]; PUTU32(out , s0); s1 = (AES_Td4[(t1 >> 24) ] & 0xff000000) ^ (AES_Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Td4[(t2 ) & 0xff] & 0x000000ff) ^ rk[1]; PUTU32(out + 4, s1); s2 = (AES_Td4[(t2 >> 24) ] & 0xff000000) ^ (AES_Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Td4[(t3 ) & 0xff] & 0x000000ff) ^ rk[2]; PUTU32(out + 8, s2); s3 = (AES_Td4[(t3 >> 24) ] & 0xff000000) ^ (AES_Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (AES_Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (AES_Td4[(t0 ) & 0xff] & 0x000000ff) ^ rk[3]; PUTU32(out + 12, s3); } #endif /* AES_ASM */ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, const int enc) { unsigned long n; unsigned long len = length; unsigned char tmp[AES_BLOCK_SIZE]; assert(in && out && key && ivec); if (enc) { while (len >= AES_BLOCK_SIZE) { for(n=0; n < AES_BLOCK_SIZE; ++n) tmp[n] = in[n] ^ ivec[n]; AES_encrypt(tmp, out, key); memcpy(ivec, out, AES_BLOCK_SIZE); len -= AES_BLOCK_SIZE; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } if (len) { for(n=0; n < len; ++n) tmp[n] = in[n] ^ ivec[n]; for(n=len; n < AES_BLOCK_SIZE; ++n) tmp[n] = ivec[n]; AES_encrypt(tmp, tmp, key); memcpy(out, tmp, AES_BLOCK_SIZE); memcpy(ivec, tmp, AES_BLOCK_SIZE); } } else { while (len >= AES_BLOCK_SIZE) { memcpy(tmp, in, AES_BLOCK_SIZE); AES_decrypt(in, out, key); for(n=0; n < AES_BLOCK_SIZE; ++n) out[n] ^= ivec[n]; memcpy(ivec, tmp, AES_BLOCK_SIZE); len -= AES_BLOCK_SIZE; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } if (len) { memcpy(tmp, in, AES_BLOCK_SIZE); AES_decrypt(tmp, tmp, key); for(n=0; n < len; ++n) out[n] = tmp[n] ^ ivec[n]; memcpy(ivec, tmp, AES_BLOCK_SIZE); } } } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/module.c0000644000076200007630000000013212617742532021547 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.686333453 glusterfs-3.7.6/contrib/qemu/util/module.c0000644000076200007630000000265112617742532021770 0ustar00jenkinsjenkins00000000000000/* * QEMU Module Infrastructure * * Copyright IBM, Corp. 2009 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" #include "qemu/queue.h" #include "qemu/module.h" typedef struct ModuleEntry { void (*init)(void); QTAILQ_ENTRY(ModuleEntry) node; } ModuleEntry; typedef QTAILQ_HEAD(, ModuleEntry) ModuleTypeList; static ModuleTypeList init_type_list[MODULE_INIT_MAX]; static void init_types(void) { static int inited; int i; if (inited) { return; } for (i = 0; i < MODULE_INIT_MAX; i++) { QTAILQ_INIT(&init_type_list[i]); } inited = 1; } static ModuleTypeList *find_type(module_init_type type) { ModuleTypeList *l; init_types(); l = &init_type_list[type]; return l; } void register_module_init(void (*fn)(void), module_init_type type) { ModuleEntry *e; ModuleTypeList *l; e = g_malloc0(sizeof(*e)); e->init = fn; l = find_type(type); QTAILQ_INSERT_TAIL(l, e, node); } void module_call_init(module_init_type type) { ModuleTypeList *l; ModuleEntry *e; l = find_type(type); QTAILQ_FOREACH(e, l, node) { e->init(); } } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/oslib-posix.c0000644000076200007630000000013212617742532022532 xustar000000000000000030 mtime=1447019866.046471404 30 atime=1447019866.375466455 30 ctime=1447019941.689333408 glusterfs-3.7.6/contrib/qemu/util/oslib-posix.c0000644000076200007630000001456512617742532022762 0ustar00jenkinsjenkins00000000000000/* * os-posix-lib.c * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2010 Red Hat, Inc. * * QEMU library functions on POSIX which are shared between QEMU and * the QEMU tools. * * 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. */ /* The following block of code temporarily renames the daemon() function so the compiler does not see the warning associated with it in stdlib.h on OSX */ #ifdef __APPLE__ #define daemon qemu_fake_daemon_function #include #undef daemon extern int daemon(int, int); #endif #if defined(__linux__) && (defined(__x86_64__) || defined(__arm__)) /* Use 2 MiB alignment so transparent hugepages can be used by KVM. Valgrind does not support alignments larger than 1 MiB, therefore we need special code which handles running on Valgrind. */ # define QEMU_VMALLOC_ALIGN (512 * 4096) #elif defined(__linux__) && defined(__s390x__) /* Use 1 MiB (segment size) alignment so gmap can be used by KVM. */ # define QEMU_VMALLOC_ALIGN (256 * 4096) #else # define QEMU_VMALLOC_ALIGN getpagesize() #endif #include #include "config-host.h" #include "qemu-common.h" #include "sysemu/sysemu.h" #include "trace.h" #include "qemu/sockets.h" #include #ifdef CONFIG_LINUX #include #endif int qemu_get_thread_id(void) { #if defined(__linux__) return syscall(SYS_gettid); #else return getpid(); #endif } int qemu_daemon(int nochdir, int noclose) { return daemon(nochdir, noclose); } void *qemu_oom_check(void *ptr) { if (ptr == NULL) { fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno)); abort(); } return ptr; } void *qemu_memalign(size_t alignment, size_t size) { void *ptr; #if defined(_POSIX_C_SOURCE) && !defined(__sun__) || defined(__APPLE__) int ret; ret = posix_memalign(&ptr, alignment, size); if (ret != 0) { fprintf(stderr, "Failed to allocate %zu B: %s\n", size, strerror(ret)); abort(); } #elif defined(GF_BSD_HOST_OS) ptr = qemu_oom_check(valloc(size)); #else ptr = qemu_oom_check(memalign(alignment, size)); #endif trace_qemu_memalign(alignment, size, ptr); return ptr; } /* alloc shared memory pages */ void *qemu_anon_ram_alloc(size_t size) { size_t align = QEMU_VMALLOC_ALIGN; size_t total = size + align - getpagesize(); void *ptr = mmap(0, total, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; if (ptr == MAP_FAILED) { fprintf(stderr, "Failed to allocate %zu B: %s\n", size, strerror(errno)); abort(); } ptr += offset; total -= offset; if (offset > 0) { munmap(ptr - offset, offset); } if (total > size) { munmap(ptr + size, total - size); } trace_qemu_anon_ram_alloc(size, ptr); return ptr; } void qemu_vfree(void *ptr) { trace_qemu_vfree(ptr); free(ptr); } void qemu_anon_ram_free(void *ptr, size_t size) { trace_qemu_anon_ram_free(ptr, size); if (ptr) { munmap(ptr, size); } } void qemu_set_block(int fd) { int f; f = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, f & ~O_NONBLOCK); } void qemu_set_nonblock(int fd) { int f; f = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, f | O_NONBLOCK); } void qemu_set_cloexec(int fd) { int f; f = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, f | FD_CLOEXEC); } /* * Creates a pipe with FD_CLOEXEC set on both file descriptors */ int qemu_pipe(int pipefd[2]) { int ret; #ifdef CONFIG_PIPE2 #ifdef pipe2 ret = pipe2(pipefd, O_CLOEXEC); if (ret != -1 || errno != ENOSYS) { return ret; } #endif #endif ret = pipe(pipefd); if (ret == 0) { qemu_set_cloexec(pipefd[0]); qemu_set_cloexec(pipefd[1]); } return ret; } int qemu_utimens(const char *path, const struct timespec *times) { struct timeval tv[2], tv_now; struct stat st; int i; #if defined(CONFIG_UTIMENSAT) #ifdef utimensat int ret; ret = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); if (ret != -1 || errno != ENOSYS) { return ret; } #endif #endif /* Fallback: use utimes() instead of utimensat() */ /* happy if special cases */ if (times[0].tv_nsec == UTIME_OMIT && times[1].tv_nsec == UTIME_OMIT) { return 0; } if (times[0].tv_nsec == UTIME_NOW && times[1].tv_nsec == UTIME_NOW) { return utimes(path, NULL); } /* prepare for hard cases */ if (times[0].tv_nsec == UTIME_NOW || times[1].tv_nsec == UTIME_NOW) { gettimeofday(&tv_now, NULL); } if (times[0].tv_nsec == UTIME_OMIT || times[1].tv_nsec == UTIME_OMIT) { stat(path, &st); } for (i = 0; i < 2; i++) { if (times[i].tv_nsec == UTIME_NOW) { tv[i].tv_sec = tv_now.tv_sec; tv[i].tv_usec = tv_now.tv_usec; } else if (times[i].tv_nsec == UTIME_OMIT) { tv[i].tv_sec = (i == 0) ? st.st_atime : st.st_mtime; tv[i].tv_usec = 0; } else { tv[i].tv_sec = times[i].tv_sec; tv[i].tv_usec = times[i].tv_nsec / 1000; } } return utimes(path, &tv[0]); } char * qemu_get_local_state_pathname(const char *relative_pathname) { return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR, relative_pathname); } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/hexdump.c0000644000076200007630000000013212617742532021734 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.706333152 glusterfs-3.7.6/contrib/qemu/util/hexdump.c0000644000076200007630000000175212617742532022156 0ustar00jenkinsjenkins00000000000000/* * Helper to hexdump a buffer * * Copyright (c) 2013 Red Hat, Inc. * Copyright (c) 2013 Gerd Hoffmann * Copyright (c) 2013 Peter Crosthwaite * Copyright (c) 2013 Xilinx, Inc * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size) { unsigned int b; for (b = 0; b < size; b++) { if ((b % 16) == 0) { fprintf(fp, "%s: %04x:", prefix, b); } if ((b % 4) == 0) { fprintf(fp, " "); } fprintf(fp, " %02x", (unsigned char)buf[b]); if ((b % 16) == 15) { fprintf(fp, "\n"); } } if ((b % 16) != 0) { fprintf(fp, "\n"); } } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/bitops.c0000644000076200007630000000013212617742532021562 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.670333693 glusterfs-3.7.6/contrib/qemu/util/bitops.c0000644000076200007630000000747412617742532022013 0ustar00jenkinsjenkins00000000000000/* * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * Copyright (C) 2008 IBM Corporation * Written by Rusty Russell * (Inspired by David Howell's find_next_bit implementation) * * 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 "qemu/bitops.h" #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) /* * Find the next set bit in a memory region. */ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; if (offset >= size) { return size; } size -= result; offset %= BITS_PER_LONG; if (offset) { tmp = *(p++); tmp &= (~0UL << offset); if (size < BITS_PER_LONG) { goto found_first; } if (tmp) { goto found_middle; } size -= BITS_PER_LONG; result += BITS_PER_LONG; } while (size >= 4*BITS_PER_LONG) { unsigned long d1, d2, d3; tmp = *p; d1 = *(p+1); d2 = *(p+2); d3 = *(p+3); if (tmp) { goto found_middle; } if (d1 | d2 | d3) { break; } p += 4; result += 4*BITS_PER_LONG; size -= 4*BITS_PER_LONG; } while (size >= BITS_PER_LONG) { if ((tmp = *(p++))) { goto found_middle; } result += BITS_PER_LONG; size -= BITS_PER_LONG; } if (!size) { return result; } tmp = *p; found_first: tmp &= (~0UL >> (BITS_PER_LONG - size)); if (tmp == 0UL) { /* Are any bits set? */ return result + size; /* Nope. */ } found_middle: return result + ctzl(tmp); } /* * This implementation of find_{first,next}_zero_bit was stolen from * Linus' asm-alpha/bitops.h. */ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; if (offset >= size) { return size; } size -= result; offset %= BITS_PER_LONG; if (offset) { tmp = *(p++); tmp |= ~0UL >> (BITS_PER_LONG - offset); if (size < BITS_PER_LONG) { goto found_first; } if (~tmp) { goto found_middle; } size -= BITS_PER_LONG; result += BITS_PER_LONG; } while (size & ~(BITS_PER_LONG-1)) { if (~(tmp = *(p++))) { goto found_middle; } result += BITS_PER_LONG; size -= BITS_PER_LONG; } if (!size) { return result; } tmp = *p; found_first: tmp |= ~0UL << size; if (tmp == ~0UL) { /* Are any bits zero? */ return result + size; /* Nope. */ } found_middle: return result + ctzl(~tmp); } unsigned long find_last_bit(const unsigned long *addr, unsigned long size) { unsigned long words; unsigned long tmp; /* Start at final word. */ words = size / BITS_PER_LONG; /* Partial final word? */ if (size & (BITS_PER_LONG-1)) { tmp = (addr[words] & (~0UL >> (BITS_PER_LONG - (size & (BITS_PER_LONG-1))))); if (tmp) { goto found; } } while (words) { tmp = addr[--words]; if (tmp) { found: return words * BITS_PER_LONG + BITS_PER_LONG - 1 - clzl(tmp); } } /* Not found */ return size; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/bitmap.c0000644000076200007630000000013212617742532021536 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.667333738 glusterfs-3.7.6/contrib/qemu/util/bitmap.c0000644000076200007630000001454612617742532021765 0ustar00jenkinsjenkins00000000000000/* * Bitmap Module * * Stolen from linux/src/lib/bitmap.c * * Copyright (C) 2010 Corentin Chary * * This source code is licensed under the GNU General Public License, * Version 2. */ #include "qemu/bitops.h" #include "qemu/bitmap.h" /* * bitmaps provide an array of bits, implemented using an an * array of unsigned longs. The number of valid bits in a * given bitmap does _not_ need to be an exact multiple of * BITS_PER_LONG. * * The possible unused bits in the last, partially used word * of a bitmap are 'don't care'. The implementation makes * no particular effort to keep them zero. It ensures that * their value will not affect the results of any operation. * The bitmap operations that return Boolean (bitmap_empty, * for example) or scalar (bitmap_weight, for example) results * carefully filter out these unused bits from impacting their * results. * * These operations actually hold to a slightly stronger rule: * if you don't input any bitmaps to these ops that have some * unused bits set, then they won't output any set unused bits * in output bitmaps. * * The byte ordering of bitmaps is more natural on little * endian architectures. */ int slow_bitmap_empty(const unsigned long *bitmap, int bits) { int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) { if (bitmap[k]) { return 0; } } if (bits % BITS_PER_LONG) { if (bitmap[k] & BITMAP_LAST_WORD_MASK(bits)) { return 0; } } return 1; } int slow_bitmap_full(const unsigned long *bitmap, int bits) { int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) { if (~bitmap[k]) { return 0; } } if (bits % BITS_PER_LONG) { if (~bitmap[k] & BITMAP_LAST_WORD_MASK(bits)) { return 0; } } return 1; } int slow_bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) { if (bitmap1[k] != bitmap2[k]) { return 0; } } if (bits % BITS_PER_LONG) { if ((bitmap1[k] ^ bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) { return 0; } } return 1; } void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, int bits) { int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) { dst[k] = ~src[k]; } if (bits % BITS_PER_LONG) { dst[k] = ~src[k] & BITMAP_LAST_WORD_MASK(bits); } } int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k; int nr = BITS_TO_LONGS(bits); unsigned long result = 0; for (k = 0; k < nr; k++) { result |= (dst[k] = bitmap1[k] & bitmap2[k]); } return result != 0; } void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k; int nr = BITS_TO_LONGS(bits); for (k = 0; k < nr; k++) { dst[k] = bitmap1[k] | bitmap2[k]; } } void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k; int nr = BITS_TO_LONGS(bits); for (k = 0; k < nr; k++) { dst[k] = bitmap1[k] ^ bitmap2[k]; } } int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k; int nr = BITS_TO_LONGS(bits); unsigned long result = 0; for (k = 0; k < nr; k++) { result |= (dst[k] = bitmap1[k] & ~bitmap2[k]); } return result != 0; } #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) void bitmap_set(unsigned long *map, int start, int nr) { unsigned long *p = map + BIT_WORD(start); const int size = start + nr; int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start); while (nr - bits_to_set >= 0) { *p |= mask_to_set; nr -= bits_to_set; bits_to_set = BITS_PER_LONG; mask_to_set = ~0UL; p++; } if (nr) { mask_to_set &= BITMAP_LAST_WORD_MASK(size); *p |= mask_to_set; } } void bitmap_clear(unsigned long *map, int start, int nr) { unsigned long *p = map + BIT_WORD(start); const int size = start + nr; int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); while (nr - bits_to_clear >= 0) { *p &= ~mask_to_clear; nr -= bits_to_clear; bits_to_clear = BITS_PER_LONG; mask_to_clear = ~0UL; p++; } if (nr) { mask_to_clear &= BITMAP_LAST_WORD_MASK(size); *p &= ~mask_to_clear; } } #define ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) /** * bitmap_find_next_zero_area - find a contiguous aligned zero area * @map: The address to base the search on * @size: The bitmap size in bits * @start: The bitnumber to start searching at * @nr: The number of zeroed bits we're looking for * @align_mask: Alignment mask for zero area * * The @align_mask should be one less than a power of 2; the effect is that * the bit offset of all zero areas this function finds is multiples of that * power of 2. A @align_mask of 0 means no alignment is required. */ unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long align_mask) { unsigned long index, end, i; again: index = find_next_zero_bit(map, size, start); /* Align allocation */ index = ALIGN_MASK(index, align_mask); end = index + nr; if (end > size) { return end; } i = find_next_bit(map, end, index); if (i < end) { start = i + 1; goto again; } return index; } int slow_bitmap_intersects(const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { int k, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; ++k) { if (bitmap1[k] & bitmap2[k]) { return 1; } } if (bits % BITS_PER_LONG) { if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) { return 1; } } return 0; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/qemu-option.c0000644000076200007630000000013212617742532022537 xustar000000000000000030 mtime=1447019866.046471404 30 atime=1447019866.375466455 30 ctime=1447019941.693333347 glusterfs-3.7.6/contrib/qemu/util/qemu-option.c0000644000076200007630000007134712617742532022770 0ustar00jenkinsjenkins00000000000000/* * Commandline option parsing functions * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2009 Kevin Wolf * * 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. */ #include #include #include "qemu-common.h" #include "qemu/error-report.h" #include "qapi/qmp/types.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/option_int.h" /* * Extracts the name of an option from the parameter string (p points at the * first byte of the option name) * * The option name is delimited by delim (usually , or =) or the string end * and is copied into buf. If the option name is longer than buf_size, it is * truncated. buf is always zero terminated. * * The return value is the position of the delimiter/zero byte after the option * name in p. */ const char *get_opt_name(char *buf, int buf_size, const char *p, char delim) { char *q; q = buf; while (*p != '\0' && *p != delim) { if (q && (q - buf) < buf_size - 1) *q++ = *p; p++; } if (q) *q = '\0'; return p; } /* * Extracts the value of an option from the parameter string p (p points at the * first byte of the option value) * * This function is comparable to get_opt_name with the difference that the * delimiter is fixed to be comma which starts a new option. To specify an * option value that contains commas, double each comma. */ const char *get_opt_value(char *buf, int buf_size, const char *p) { char *q; q = buf; while (*p != '\0') { if (*p == ',') { if (*(p + 1) != ',') break; p++; } if (q && (q - buf) < buf_size - 1) *q++ = *p; p++; } if (q) *q = '\0'; return p; } int get_next_param_value(char *buf, int buf_size, const char *tag, const char **pstr) { const char *p; char option[128]; p = *pstr; for(;;) { p = get_opt_name(option, sizeof(option), p, '='); if (*p != '=') break; p++; if (!strcmp(tag, option)) { *pstr = get_opt_value(buf, buf_size, p); if (**pstr == ',') { (*pstr)++; } return strlen(buf); } else { p = get_opt_value(NULL, 0, p); } if (*p != ',') break; p++; } return 0; } int get_param_value(char *buf, int buf_size, const char *tag, const char *str) { return get_next_param_value(buf, buf_size, tag, &str); } /* * Searches an option list for an option with the given name */ QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, const char *name) { while (list && list->name) { if (!strcmp(list->name, name)) { return list; } list++; } return NULL; } static void parse_option_bool(const char *name, const char *value, bool *ret, Error **errp) { if (value != NULL) { if (!strcmp(value, "on")) { *ret = 1; } else if (!strcmp(value, "off")) { *ret = 0; } else { error_set(errp,QERR_INVALID_PARAMETER_VALUE, name, "'on' or 'off'"); } } else { *ret = 1; } } static void parse_option_number(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; uint64_t number; if (value != NULL) { number = strtoull(value, &postfix, 0); if (*postfix != '\0') { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number"); return; } *ret = number; } else { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number"); } } static void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; double sizef; if (value != NULL) { sizef = strtod(value, &postfix); switch (*postfix) { case 'T': sizef *= 1024; /* fall through */ case 'G': sizef *= 1024; /* fall through */ case 'M': sizef *= 1024; /* fall through */ case 'K': case 'k': sizef *= 1024; /* fall through */ case 'b': case '\0': *ret = (uint64_t) sizef; break; default: error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); #if 0 /* conversion from qerror_report() to error_set() broke this: */ error_printf_unless_qmp("You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); #endif return; } } else { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); } } /* * Sets the value of a parameter in a given option list. The parsing of the * value depends on the type of option: * * OPT_FLAG (uses value.n): * If no value is given, the flag is set to 1. * Otherwise the value must be "on" (set to 1) or "off" (set to 0) * * OPT_STRING (uses value.s): * value is strdup()ed and assigned as option value * * OPT_SIZE (uses value.n): * The value is converted to an integer. Suffixes for kilobytes etc. are * allowed (powers of 1024). * * Returns 0 on succes, -1 in error cases */ int set_option_parameter(QEMUOptionParameter *list, const char *name, const char *value) { bool flag; Error *local_err = NULL; // Find a matching parameter list = get_option_parameter(list, name); if (list == NULL) { fprintf(stderr, "Unknown option '%s'\n", name); return -1; } // Process parameter switch (list->type) { case OPT_FLAG: parse_option_bool(name, value, &flag, &local_err); if (!error_is_set(&local_err)) { list->value.n = flag; } break; case OPT_STRING: if (value != NULL) { list->value.s = g_strdup(value); } else { fprintf(stderr, "Option '%s' needs a parameter\n", name); return -1; } break; case OPT_SIZE: parse_option_size(name, value, &list->value.n, &local_err); break; default: fprintf(stderr, "Bug: Option '%s' has an unknown type\n", name); return -1; } if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); return -1; } return 0; } /* * Sets the given parameter to an integer instead of a string. * This function cannot be used to set string options. * * Returns 0 on success, -1 in error cases */ int set_option_parameter_int(QEMUOptionParameter *list, const char *name, uint64_t value) { // Find a matching parameter list = get_option_parameter(list, name); if (list == NULL) { fprintf(stderr, "Unknown option '%s'\n", name); return -1; } // Process parameter switch (list->type) { case OPT_FLAG: case OPT_NUMBER: case OPT_SIZE: list->value.n = value; break; default: return -1; } return 0; } /* * Frees a option list. If it contains strings, the strings are freed as well. */ void free_option_parameters(QEMUOptionParameter *list) { QEMUOptionParameter *cur = list; while (cur && cur->name) { if (cur->type == OPT_STRING) { g_free(cur->value.s); } cur++; } g_free(list); } /* * Count valid options in list */ static size_t count_option_parameters(QEMUOptionParameter *list) { size_t num_options = 0; while (list && list->name) { num_options++; list++; } return num_options; } /* * Append an option list (list) to an option list (dest). * * If dest is NULL, a new copy of list is created. * * Returns a pointer to the first element of dest (or the newly allocated copy) */ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, QEMUOptionParameter *list) { size_t num_options, num_dest_options; num_options = count_option_parameters(dest); num_dest_options = num_options; num_options += count_option_parameters(list); dest = g_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter)); dest[num_dest_options].name = NULL; while (list && list->name) { if (get_option_parameter(dest, list->name) == NULL) { dest[num_dest_options++] = *list; dest[num_dest_options].name = NULL; } list++; } return dest; } /* * Parses a parameter string (param) into an option list (dest). * * list is the template option list. If dest is NULL, a new copy of list is * created. If list is NULL, this function fails. * * A parameter string consists of one or more parameters, separated by commas. * Each parameter consists of its name and possibly of a value. In the latter * case, the value is delimited by an = character. To specify a value which * contains commas, double each comma so it won't be recognized as the end of * the parameter. * * For more details of the parsing see above. * * Returns a pointer to the first element of dest (or the newly allocated copy) * or NULL in error cases */ QEMUOptionParameter *parse_option_parameters(const char *param, QEMUOptionParameter *list, QEMUOptionParameter *dest) { QEMUOptionParameter *allocated = NULL; char name[256]; char value[256]; char *param_delim, *value_delim; char next_delim; if (list == NULL) { return NULL; } if (dest == NULL) { dest = allocated = append_option_parameters(NULL, list); } while (*param) { // Find parameter name and value in the string param_delim = strchr(param, ','); value_delim = strchr(param, '='); if (value_delim && (value_delim < param_delim || !param_delim)) { next_delim = '='; } else { next_delim = ','; value_delim = NULL; } param = get_opt_name(name, sizeof(name), param, next_delim); if (value_delim) { param = get_opt_value(value, sizeof(value), param + 1); } if (*param != '\0') { param++; } // Set the parameter if (set_option_parameter(dest, name, value_delim ? value : NULL)) { goto fail; } } return dest; fail: // Only free the list if it was newly allocated free_option_parameters(allocated); return NULL; } /* * Prints all options of a list that have a value to stdout */ void print_option_parameters(QEMUOptionParameter *list) { while (list && list->name) { switch (list->type) { case OPT_STRING: if (list->value.s != NULL) { printf("%s='%s' ", list->name, list->value.s); } break; case OPT_FLAG: printf("%s=%s ", list->name, list->value.n ? "on" : "off"); break; case OPT_SIZE: case OPT_NUMBER: printf("%s=%" PRId64 " ", list->name, list->value.n); break; default: printf("%s=(unknown type) ", list->name); break; } list++; } } /* * Prints an overview of all available options */ void print_option_help(QEMUOptionParameter *list) { printf("Supported options:\n"); while (list && list->name) { printf("%-16s %s\n", list->name, list->help ? list->help : "No description available"); list++; } } /* ------------------------------------------------------------------ */ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) { QemuOpt *opt; QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) { if (strcmp(opt->name, name) != 0) continue; return opt; } return NULL; } const char *qemu_opt_get(QemuOpts *opts, const char *name) { QemuOpt *opt = qemu_opt_find(opts, name); return opt ? opt->str : NULL; } bool qemu_opt_has_help_opt(QemuOpts *opts) { QemuOpt *opt; QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) { if (is_help_option(opt->name)) { return true; } } return false; } bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval) { QemuOpt *opt = qemu_opt_find(opts, name); if (opt == NULL) return defval; assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL); return opt->value.boolean; } uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval) { QemuOpt *opt = qemu_opt_find(opts, name); if (opt == NULL) return defval; assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER); return opt->value.uint; } uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval) { QemuOpt *opt = qemu_opt_find(opts, name); if (opt == NULL) return defval; assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE); return opt->value.uint; } static void qemu_opt_parse(QemuOpt *opt, Error **errp) { if (opt->desc == NULL) return; switch (opt->desc->type) { case QEMU_OPT_STRING: /* nothing */ return; case QEMU_OPT_BOOL: parse_option_bool(opt->name, opt->str, &opt->value.boolean, errp); break; case QEMU_OPT_NUMBER: parse_option_number(opt->name, opt->str, &opt->value.uint, errp); break; case QEMU_OPT_SIZE: parse_option_size(opt->name, opt->str, &opt->value.uint, errp); break; default: abort(); } } static void qemu_opt_del(QemuOpt *opt) { QTAILQ_REMOVE(&opt->opts->head, opt, next); g_free((/* !const */ char*)opt->name); g_free((/* !const */ char*)opt->str); g_free(opt); } static bool opts_accepts_any(const QemuOpts *opts) { return opts->list->desc[0].name == NULL; } static const QemuOptDesc *find_desc_by_name(const QemuOptDesc *desc, const char *name) { int i; for (i = 0; desc[i].name != NULL; i++) { if (strcmp(desc[i].name, name) == 0) { return &desc[i]; } } return NULL; } static void opt_set(QemuOpts *opts, const char *name, const char *value, bool prepend, Error **errp) { QemuOpt *opt; const QemuOptDesc *desc; Error *local_err = NULL; desc = find_desc_by_name(opts->list->desc, name); if (!desc && !opts_accepts_any(opts)) { error_set(errp, QERR_INVALID_PARAMETER, name); return; } opt = g_malloc0(sizeof(*opt)); opt->name = g_strdup(name); opt->opts = opts; if (prepend) { QTAILQ_INSERT_HEAD(&opts->head, opt, next); } else { QTAILQ_INSERT_TAIL(&opts->head, opt, next); } opt->desc = desc; opt->str = g_strdup(value); qemu_opt_parse(opt, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); qemu_opt_del(opt); } } int qemu_opt_set(QemuOpts *opts, const char *name, const char *value) { Error *local_err = NULL; opt_set(opts, name, value, false, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); return -1; } return 0; } void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, Error **errp) { opt_set(opts, name, value, false, errp); } int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val) { QemuOpt *opt; const QemuOptDesc *desc = opts->list->desc; opt = g_malloc0(sizeof(*opt)); opt->desc = find_desc_by_name(desc, name); if (!opt->desc && !opts_accepts_any(opts)) { qerror_report(QERR_INVALID_PARAMETER, name); g_free(opt); return -1; } opt->name = g_strdup(name); opt->opts = opts; opt->value.boolean = !!val; opt->str = g_strdup(val ? "on" : "off"); QTAILQ_INSERT_TAIL(&opts->head, opt, next); return 0; } int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val) { QemuOpt *opt; const QemuOptDesc *desc = opts->list->desc; opt = g_malloc0(sizeof(*opt)); opt->desc = find_desc_by_name(desc, name); if (!opt->desc && !opts_accepts_any(opts)) { qerror_report(QERR_INVALID_PARAMETER, name); g_free(opt); return -1; } opt->name = g_strdup(name); opt->opts = opts; opt->value.uint = val; opt->str = g_strdup_printf("%" PRId64, val); QTAILQ_INSERT_TAIL(&opts->head, opt, next); return 0; } int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, int abort_on_failure) { QemuOpt *opt; int rc = 0; QTAILQ_FOREACH(opt, &opts->head, next) { rc = func(opt->name, opt->str, opaque); if (abort_on_failure && rc != 0) break; } return rc; } QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) { QemuOpts *opts; QTAILQ_FOREACH(opts, &list->head, next) { if (!opts->id && !id) { return opts; } if (opts->id && id && !strcmp(opts->id, id)) { return opts; } } return NULL; } static int id_wellformed(const char *id) { int i; if (!qemu_isalpha(id[0])) { return 0; } for (i = 1; id[i]; i++) { if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) { return 0; } } return 1; } QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists, Error **errp) { QemuOpts *opts = NULL; if (id) { if (!id_wellformed(id)) { error_set(errp,QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); #if 0 /* conversion from qerror_report() to error_set() broke this: */ error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n"); #endif return NULL; } opts = qemu_opts_find(list, id); if (opts != NULL) { if (fail_if_exists && !list->merge_lists) { error_set(errp, QERR_DUPLICATE_ID, id, list->name); return NULL; } else { return opts; } } } else if (list->merge_lists) { opts = qemu_opts_find(list, NULL); if (opts) { return opts; } } opts = g_malloc0(sizeof(*opts)); opts->id = g_strdup(id); opts->list = list; loc_save(&opts->loc); QTAILQ_INIT(&opts->head); QTAILQ_INSERT_TAIL(&list->head, opts, next); return opts; } QemuOpts *qemu_opts_create_nofail(QemuOptsList *list) { QemuOpts *opts; Error *errp = NULL; opts = qemu_opts_create(list, NULL, 0, &errp); assert_no_error(errp); return opts; } void qemu_opts_reset(QemuOptsList *list) { QemuOpts *opts, *next_opts; QTAILQ_FOREACH_SAFE(opts, &list->head, next, next_opts) { qemu_opts_del(opts); } } void qemu_opts_loc_restore(QemuOpts *opts) { loc_restore(&opts->loc); } int qemu_opts_set(QemuOptsList *list, const char *id, const char *name, const char *value) { QemuOpts *opts; Error *local_err = NULL; opts = qemu_opts_create(list, id, 1, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); return -1; } return qemu_opt_set(opts, name, value); } const char *qemu_opts_id(QemuOpts *opts) { return opts->id; } void qemu_opts_del(QemuOpts *opts) { QemuOpt *opt; for (;;) { opt = QTAILQ_FIRST(&opts->head); if (opt == NULL) break; qemu_opt_del(opt); } QTAILQ_REMOVE(&opts->list->head, opts, next); g_free(opts->id); g_free(opts); } int qemu_opts_print(QemuOpts *opts, void *dummy) { QemuOpt *opt; fprintf(stderr, "%s: %s:", opts->list->name, opts->id ? opts->id : ""); QTAILQ_FOREACH(opt, &opts->head, next) { fprintf(stderr, " %s=\"%s\"", opt->name, opt->str); } fprintf(stderr, "\n"); return 0; } static int opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, bool prepend) { char option[128], value[1024]; const char *p,*pe,*pc; Error *local_err = NULL; for (p = params; *p != '\0'; p++) { pe = strchr(p, '='); pc = strchr(p, ','); if (!pe || (pc && pc < pe)) { /* found "foo,more" */ if (p == params && firstname) { /* implicitly named first option */ pstrcpy(option, sizeof(option), firstname); p = get_opt_value(value, sizeof(value), p); } else { /* option without value, probably a flag */ p = get_opt_name(option, sizeof(option), p, ','); if (strncmp(option, "no", 2) == 0) { memmove(option, option+2, strlen(option+2)+1); pstrcpy(value, sizeof(value), "off"); } else { pstrcpy(value, sizeof(value), "on"); } } } else { /* found "foo=bar,more" */ p = get_opt_name(option, sizeof(option), p, '='); if (*p != '=') { break; } p++; p = get_opt_value(value, sizeof(value), p); } if (strcmp(option, "id") != 0) { /* store and parse */ opt_set(opts, option, value, prepend, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); return -1; } } if (*p != ',') { break; } } return 0; } int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname) { return opts_do_parse(opts, params, firstname, false); } static QemuOpts *opts_parse(QemuOptsList *list, const char *params, int permit_abbrev, bool defaults) { const char *firstname; char value[1024], *id = NULL; const char *p; QemuOpts *opts; Error *local_err = NULL; assert(!permit_abbrev || list->implied_opt_name); firstname = permit_abbrev ? list->implied_opt_name : NULL; if (strncmp(params, "id=", 3) == 0) { get_opt_value(value, sizeof(value), params+3); id = value; } else if ((p = strstr(params, ",id=")) != NULL) { get_opt_value(value, sizeof(value), p+4); id = value; } opts = qemu_opts_create(list, id, !defaults, &local_err); if (opts == NULL) { if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); } return NULL; } if (opts_do_parse(opts, params, firstname, defaults) != 0) { qemu_opts_del(opts); return NULL; } return opts; } QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev) { return opts_parse(list, params, permit_abbrev, false); } void qemu_opts_set_defaults(QemuOptsList *list, const char *params, int permit_abbrev) { QemuOpts *opts; opts = opts_parse(list, params, permit_abbrev, true); assert(opts); } typedef struct OptsFromQDictState { QemuOpts *opts; Error **errp; } OptsFromQDictState; static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque) { OptsFromQDictState *state = opaque; char buf[32]; const char *value; int n; if (!strcmp(key, "id") || error_is_set(state->errp)) { return; } switch (qobject_type(obj)) { case QTYPE_QSTRING: value = qstring_get_str(qobject_to_qstring(obj)); break; case QTYPE_QINT: n = snprintf(buf, sizeof(buf), "%" PRId64, qint_get_int(qobject_to_qint(obj))); assert(n < sizeof(buf)); value = buf; break; case QTYPE_QFLOAT: n = snprintf(buf, sizeof(buf), "%.17g", qfloat_get_double(qobject_to_qfloat(obj))); assert(n < sizeof(buf)); value = buf; break; case QTYPE_QBOOL: pstrcpy(buf, sizeof(buf), qbool_get_int(qobject_to_qbool(obj)) ? "on" : "off"); value = buf; break; default: return; } qemu_opt_set_err(state->opts, key, value, state->errp); } /* * Create QemuOpts from a QDict. * Use value of key "id" as ID if it exists and is a QString. * Only QStrings, QInts, QFloats and QBools are copied. Entries with * other types are silently ignored. */ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, Error **errp) { OptsFromQDictState state; Error *local_err = NULL; QemuOpts *opts; opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return NULL; } assert(opts != NULL); state.errp = &local_err; state.opts = opts; qdict_iter(qdict, qemu_opts_from_qdict_1, &state); if (error_is_set(&local_err)) { error_propagate(errp, local_err); qemu_opts_del(opts); return NULL; } return opts; } /* * Adds all QDict entries to the QemuOpts that can be added and removes them * from the QDict. When this function returns, the QDict contains only those * entries that couldn't be added to the QemuOpts. */ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp) { const QDictEntry *entry, *next; entry = qdict_first(qdict); while (entry != NULL) { Error *local_err = NULL; OptsFromQDictState state = { .errp = &local_err, .opts = opts, }; next = qdict_next(qdict, entry); if (find_desc_by_name(opts->list->desc, entry->key)) { qemu_opts_from_qdict_1(entry->key, entry->value, &state); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return; } else { qdict_del(qdict, entry->key); } } entry = next; } } /* * Convert from QemuOpts to QDict. * The QDict values are of type QString. * TODO We'll want to use types appropriate for opt->desc->type, but * this is enough for now. */ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict) { QemuOpt *opt; QObject *val; if (!qdict) { qdict = qdict_new(); } if (opts->id) { qdict_put(qdict, "id", qstring_from_str(opts->id)); } QTAILQ_FOREACH(opt, &opts->head, next) { val = QOBJECT(qstring_from_str(opt->str)); qdict_put_obj(qdict, opt->name, val); } return qdict; } /* Validate parsed opts against descriptions where no * descriptions were provided in the QemuOptsList. */ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) { QemuOpt *opt; Error *local_err = NULL; assert(opts_accepts_any(opts)); QTAILQ_FOREACH(opt, &opts->head, next) { opt->desc = find_desc_by_name(desc, opt->name); if (!opt->desc) { error_set(errp, QERR_INVALID_PARAMETER, opt->name); return; } qemu_opt_parse(opt, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return; } } } int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, int abort_on_failure) { Location loc; QemuOpts *opts; int rc = 0; loc_push_none(&loc); QTAILQ_FOREACH(opts, &list->head, next) { loc_restore(&opts->loc); rc |= func(opts, opaque); if (abort_on_failure && rc != 0) break; } loc_pop(&loc); return rc; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/error.c0000644000076200007630000000013212617742532021413 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.677333589 glusterfs-3.7.6/contrib/qemu/util/error.c0000644000076200007630000000430012617742532021625 0ustar00jenkinsjenkins00000000000000/* * QEMU Error Objects * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU LGPL, version 2. See * the COPYING.LIB file in the top-level directory. */ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qdict.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" struct Error { char *msg; ErrorClass err_class; }; void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) { Error *err; va_list ap; if (errp == NULL) { return; } assert(*errp == NULL); err = g_malloc0(sizeof(*err)); va_start(ap, fmt); err->msg = g_strdup_vprintf(fmt, ap); va_end(ap); err->err_class = err_class; *errp = err; } void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, const char *fmt, ...) { Error *err; char *msg1; va_list ap; if (errp == NULL) { return; } assert(*errp == NULL); err = g_malloc0(sizeof(*err)); va_start(ap, fmt); msg1 = g_strdup_vprintf(fmt, ap); if (os_errno != 0) { err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno)); g_free(msg1); } else { err->msg = msg1; } va_end(ap); err->err_class = err_class; *errp = err; } void error_setg_file_open(Error **errp, int os_errno, const char *filename) { error_setg_errno(errp, os_errno, "Could not open '%s'", filename); } Error *error_copy(const Error *err) { Error *err_new; err_new = g_malloc0(sizeof(*err)); err_new->msg = g_strdup(err->msg); err_new->err_class = err->err_class; return err_new; } bool error_is_set(Error **errp) { return (errp && *errp); } ErrorClass error_get_class(const Error *err) { return err->err_class; } const char *error_get_pretty(Error *err) { return err->msg; } void error_free(Error *err) { if (err) { g_free(err->msg); g_free(err); } } void error_propagate(Error **dst_err, Error *local_err) { if (dst_err && !*dst_err) { *dst_err = local_err; } else if (local_err) { error_free(local_err); } } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/unicode.c0000644000076200007630000000013212617742532021710 xustar000000000000000030 mtime=1447019866.046471404 30 atime=1447019866.375466455 30 ctime=1447019941.702333211 glusterfs-3.7.6/contrib/qemu/util/unicode.c0000644000076200007630000000623012617742532022126 0ustar00jenkinsjenkins00000000000000/* * Dealing with Unicode * * Copyright (C) 2013 Red Hat, Inc. * * Authors: * Markus Armbruster * * This work is licensed under the terms of the GNU GPL, version 2 or * later. See the COPYING file in the top-level directory. */ #include "qemu-common.h" /** * mod_utf8_codepoint: * @s: string encoded in modified UTF-8 * @n: maximum number of bytes to read from @s, if less than 6 * @end: set to end of sequence on return * * Convert the modified UTF-8 sequence at the start of @s. Modified * UTF-8 is exactly like UTF-8, except U+0000 is encoded as * "\xC0\x80". * * If @n is zero or @s points to a zero byte, the sequence is invalid, * and @end is set to @s. * * If @s points to an impossible byte (0xFE or 0xFF) or a continuation * byte, the sequence is invalid, and @end is set to @s + 1 * * Else, the first byte determines how many continuation bytes are * expected. If there are fewer, the sequence is invalid, and @end is * set to @s + 1 + actual number of continuation bytes. Else, the * sequence is well-formed, and @end is set to @s + 1 + expected * number of continuation bytes. * * A well-formed sequence is valid unless it encodes a codepoint * outside the Unicode range U+0000..U+10FFFF, one of Unicode's 66 * noncharacters, a surrogate codepoint, or is overlong. Except the * overlong sequence "\xC0\x80" is valid. * * Conversion succeeds if and only if the sequence is valid. * * Returns: the Unicode codepoint on success, -1 on failure. */ int mod_utf8_codepoint(const char *s, size_t n, char **end) { static int min_cp[5] = { 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; const unsigned char *p; unsigned byte, mask, len, i; int cp; if (n == 0 || *s == 0) { /* empty sequence */ *end = (char *)s; return -1; } p = (const unsigned char *)s; byte = *p++; if (byte < 0x80) { cp = byte; /* one byte sequence */ } else if (byte >= 0xFE) { cp = -1; /* impossible bytes 0xFE, 0xFF */ } else if ((byte & 0x40) == 0) { cp = -1; /* unexpected continuation byte */ } else { /* multi-byte sequence */ len = 0; for (mask = 0x80; byte & mask; mask >>= 1) { len++; } assert(len > 1 && len < 7); cp = byte & (mask - 1); for (i = 1; i < len; i++) { byte = i < n ? *p : 0; if ((byte & 0xC0) != 0x80) { cp = -1; /* continuation byte missing */ goto out; } p++; cp <<= 6; cp |= byte & 0x3F; } if (cp > 0x10FFFF) { cp = -1; /* beyond Unicode range */ } else if ((cp >= 0xFDD0 && cp <= 0xFDEF) || (cp & 0xFFFE) == 0xFFFE) { cp = -1; /* noncharacter */ } else if (cp >= 0xD800 && cp <= 0xDFFF) { cp = -1; /* surrogate code point */ } else if (cp < min_cp[len - 2] && !(cp == 0 && len == 2)) { cp = -1; /* overlong, not \xC0\x80 */ } } out: *end = (char *)p; return cp; } glusterfs-3.7.6/contrib/qemu/util/PaxHeaders.7244/iov.c0000644000076200007630000000013212617742532021057 xustar000000000000000030 mtime=1447019866.045471419 30 atime=1447019866.375466455 30 ctime=1447019941.683333498 glusterfs-3.7.6/contrib/qemu/util/iov.c0000644000076200007630000002644212617742532021304 0ustar00jenkinsjenkins00000000000000/* * Helpers for getting linearized buffers from iov / filling buffers into iovs * * Copyright IBM, Corp. 2007, 2008 * Copyright (C) 2010 Red Hat, Inc. * * Author(s): * Anthony Liguori * Amit Shah * Michael Tokarev * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu/iov.h" #ifdef _WIN32 # include # include #else # include # include #endif size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, size_t offset, const void *buf, size_t bytes) { size_t done; unsigned int i; for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { if (offset < iov[i].iov_len) { size_t len = MIN(iov[i].iov_len - offset, bytes - done); memcpy(iov[i].iov_base + offset, buf + done, len); done += len; offset = 0; } else { offset -= iov[i].iov_len; } } assert(offset == 0); return done; } size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, size_t offset, void *buf, size_t bytes) { size_t done; unsigned int i; for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { if (offset < iov[i].iov_len) { size_t len = MIN(iov[i].iov_len - offset, bytes - done); memcpy(buf + done, iov[i].iov_base + offset, len); done += len; offset = 0; } else { offset -= iov[i].iov_len; } } assert(offset == 0); return done; } size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t offset, int fillc, size_t bytes) { size_t done; unsigned int i; for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { if (offset < iov[i].iov_len) { size_t len = MIN(iov[i].iov_len - offset, bytes - done); memset(iov[i].iov_base + offset, fillc, len); done += len; offset = 0; } else { offset -= iov[i].iov_len; } } assert(offset == 0); return done; } size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt) { size_t len; unsigned int i; len = 0; for (i = 0; i < iov_cnt; i++) { len += iov[i].iov_len; } return len; } /* helper function for iov_send_recv() */ static ssize_t do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send) { #ifdef CONFIG_POSIX ssize_t ret; struct msghdr msg; memset(&msg, 0, sizeof(msg)); msg.msg_iov = iov; msg.msg_iovlen = iov_cnt; do { ret = do_send ? sendmsg(sockfd, &msg, 0) : recvmsg(sockfd, &msg, 0); } while (ret < 0 && errno == EINTR); return ret; #else /* else send piece-by-piece */ /*XXX Note: windows has WSASend() and WSARecv() */ unsigned i = 0; ssize_t ret = 0; while (i < iov_cnt) { ssize_t r = do_send ? send(sockfd, iov[i].iov_base, iov[i].iov_len, 0) : recv(sockfd, iov[i].iov_base, iov[i].iov_len, 0); if (r > 0) { ret += r; } else if (!r) { break; } else if (errno == EINTR) { continue; } else { /* else it is some "other" error, * only return if there was no data processed. */ if (ret == 0) { ret = -1; } break; } i++; } return ret; #endif } ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, size_t offset, size_t bytes, bool do_send) { ssize_t total = 0; ssize_t ret; size_t orig_len, tail; unsigned niov; while (bytes > 0) { /* Find the start position, skipping `offset' bytes: * first, skip all full-sized vector elements, */ for (niov = 0; niov < iov_cnt && offset >= iov[niov].iov_len; ++niov) { offset -= iov[niov].iov_len; } /* niov == iov_cnt would only be valid if bytes == 0, which * we already ruled out in the loop condition. */ assert(niov < iov_cnt); iov += niov; iov_cnt -= niov; if (offset) { /* second, skip `offset' bytes from the (now) first element, * undo it on exit */ iov[0].iov_base += offset; iov[0].iov_len -= offset; } /* Find the end position skipping `bytes' bytes: */ /* first, skip all full-sized elements */ tail = bytes; for (niov = 0; niov < iov_cnt && iov[niov].iov_len <= tail; ++niov) { tail -= iov[niov].iov_len; } if (tail) { /* second, fixup the last element, and remember the original * length */ assert(niov < iov_cnt); assert(iov[niov].iov_len > tail); orig_len = iov[niov].iov_len; iov[niov++].iov_len = tail; } ret = do_send_recv(sockfd, iov, niov, do_send); /* Undo the changes above before checking for errors */ if (tail) { iov[niov-1].iov_len = orig_len; } if (offset) { iov[0].iov_base -= offset; iov[0].iov_len += offset; } if (ret < 0) { assert(errno != EINTR); if (errno == EAGAIN && total > 0) { return total; } return -1; } /* Prepare for the next iteration */ offset += ret; total += ret; bytes -= ret; } return total; } void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, FILE *fp, const char *prefix, size_t limit) { int v; size_t size = 0; char *buf; for (v = 0; v < iov_cnt; v++) { size += iov[v].iov_len; } size = size > limit ? limit : size; buf = g_malloc(size); iov_to_buf(iov, iov_cnt, 0, buf, size); qemu_hexdump(buf, fp, prefix, size); g_free(buf); } unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, const struct iovec *iov, unsigned int iov_cnt, size_t offset, size_t bytes) { size_t len; unsigned int i, j; for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) { if (offset >= iov[i].iov_len) { offset -= iov[i].iov_len; continue; } len = MIN(bytes, iov[i].iov_len - offset); dst_iov[j].iov_base = iov[i].iov_base + offset; dst_iov[j].iov_len = len; j++; bytes -= len; offset = 0; } assert(offset == 0); return j; } /* io vectors */ void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) { qiov->iov = g_malloc(alloc_hint * sizeof(struct iovec)); qiov->niov = 0; qiov->nalloc = alloc_hint; qiov->size = 0; } void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov) { int i; qiov->iov = iov; qiov->niov = niov; qiov->nalloc = -1; qiov->size = 0; for (i = 0; i < niov; i++) qiov->size += iov[i].iov_len; } void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len) { assert(qiov->nalloc != -1); if (qiov->niov == qiov->nalloc) { qiov->nalloc = 2 * qiov->nalloc + 1; qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec)); } qiov->iov[qiov->niov].iov_base = base; qiov->iov[qiov->niov].iov_len = len; qiov->size += len; ++qiov->niov; } /* * Concatenates (partial) iovecs from src_iov to the end of dst. * It starts copying after skipping `soffset' bytes at the * beginning of src and adds individual vectors from src to * dst copies up to `sbytes' bytes total, or up to the end * of src_iov if it comes first. This way, it is okay to specify * very large value for `sbytes' to indicate "up to the end * of src". * Only vector pointers are processed, not the actual data buffers. */ void qemu_iovec_concat_iov(QEMUIOVector *dst, struct iovec *src_iov, unsigned int src_cnt, size_t soffset, size_t sbytes) { int i; size_t done; if (!sbytes) { return; } assert(dst->nalloc != -1); for (i = 0, done = 0; done < sbytes && i < src_cnt; i++) { if (soffset < src_iov[i].iov_len) { size_t len = MIN(src_iov[i].iov_len - soffset, sbytes - done); qemu_iovec_add(dst, src_iov[i].iov_base + soffset, len); done += len; soffset = 0; } else { soffset -= src_iov[i].iov_len; } } assert(soffset == 0); /* offset beyond end of src */ } /* * Concatenates (partial) iovecs from src to the end of dst. * It starts copying after skipping `soffset' bytes at the * beginning of src and adds individual vectors from src to * dst copies up to `sbytes' bytes total, or up to the end * of src if it comes first. This way, it is okay to specify * very large value for `sbytes' to indicate "up to the end * of src". * Only vector pointers are processed, not the actual data buffers. */ void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes) { qemu_iovec_concat_iov(dst, src->iov, src->niov, soffset, sbytes); } void qemu_iovec_destroy(QEMUIOVector *qiov) { assert(qiov->nalloc != -1); qemu_iovec_reset(qiov); g_free(qiov->iov); qiov->nalloc = 0; qiov->iov = NULL; } void qemu_iovec_reset(QEMUIOVector *qiov) { assert(qiov->nalloc != -1); qiov->niov = 0; qiov->size = 0; } size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, void *buf, size_t bytes) { return iov_to_buf(qiov->iov, qiov->niov, offset, buf, bytes); } size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, const void *buf, size_t bytes) { return iov_from_buf(qiov->iov, qiov->niov, offset, buf, bytes); } size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int fillc, size_t bytes) { return iov_memset(qiov->iov, qiov->niov, offset, fillc, bytes); } size_t iov_discard_front(struct iovec **iov, unsigned int *iov_cnt, size_t bytes) { size_t total = 0; struct iovec *cur; for (cur = *iov; *iov_cnt > 0; cur++) { if (cur->iov_len > bytes) { cur->iov_base += bytes; cur->iov_len -= bytes; total += bytes; break; } bytes -= cur->iov_len; total += cur->iov_len; *iov_cnt -= 1; } *iov = cur; return total; } size_t iov_discard_back(struct iovec *iov, unsigned int *iov_cnt, size_t bytes) { size_t total = 0; struct iovec *cur; if (*iov_cnt == 0) { return 0; } cur = iov + (*iov_cnt - 1); while (*iov_cnt > 0) { if (cur->iov_len > bytes) { cur->iov_len -= bytes; total += bytes; break; } bytes -= cur->iov_len; total += cur->iov_len; cur--; *iov_cnt -= 1; } return total; } glusterfs-3.7.6/contrib/PaxHeaders.7244/stdlib0000644000076200007630000000013012617742634017377 xustar000000000000000030 mtime=1447019932.234475645 28 atime=1447019949.3342184 30 ctime=1447019932.234475645 glusterfs-3.7.6/contrib/stdlib/0000755000076200007630000000000012617742634017673 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/stdlib/PaxHeaders.7244/gf_mkostemp.c0000644000076200007630000000013112617742532022131 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019932.234475645 glusterfs-3.7.6/contrib/stdlib/gf_mkostemp.c0000644000076200007630000000675312617742532022362 0ustar00jenkinsjenkins00000000000000/* Borrowed from glibc-2.16/sysdeps/posix/tempname.c */ /* Copyright (C) 1991-2001, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see . */ #include #include #include #include #include #include #include #include #include #include static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /* Generate a temporary file name based on TMPL. TMPL must match the rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). */ #if !defined(TMP_MAX) #define TMP_MAX 238328 #endif int gf_mkostemp (char *tmpl, int suffixlen, int flags) { int len; char *XXXXXX; static uint64_t value; uint64_t random_time_bits; unsigned int count; int fd = -1; /* A lower bound on the number of temporary files to attempt to generate. The maximum total number of temporary file names that can exist for a given template is 62**6. It should never be necessary to try all these combinations. Instead if a reasonable number of names is tried (we define reasonable as 62**3) fail to give the system administrator the chance to remove the problems. */ unsigned int attempts = TMP_MAX; /* TMP_MAX == 62³ */ len = strlen (tmpl); if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6)) return -1; /* This is where the Xs start. */ XXXXXX = &tmpl[len - 6 - suffixlen]; /* Get some more or less random data. */ # if HAVE_GETTIMEOFDAY struct timeval tv; gettimeofday (&tv, NULL); random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; # else random_time_bits = time (NULL); # endif value += random_time_bits ^ getpid (); for (count = 0; count < attempts; value += 7777, ++count) { uint64_t v = value; /* Fill in the random bits. */ XXXXXX[0] = letters[v % 62]; v /= 62; XXXXXX[1] = letters[v % 62]; v /= 62; XXXXXX[2] = letters[v % 62]; v /= 62; XXXXXX[3] = letters[v % 62]; v /= 62; XXXXXX[4] = letters[v % 62]; v /= 62; XXXXXX[5] = letters[v % 62]; fd = open (tmpl, (flags & ~O_ACCMODE) | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); if (fd >= 0) return fd; else if (errno != EEXIST) return -1; } /* We got out of the loop because we ran out of combinations to try. */ return -1; } glusterfs-3.7.6/contrib/PaxHeaders.7244/fuse-include0000644000076200007630000000013012617742647020505 xustar000000000000000030 mtime=1447019943.466306675 28 atime=1447019949.3342184 30 ctime=1447019943.466306675 glusterfs-3.7.6/contrib/fuse-include/0000755000076200007630000000000012617742647021001 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/fuse-include/PaxHeaders.7244/fuse-misc.h0000644000076200007630000000013112617742532022620 xustar000000000000000030 mtime=1447019866.026471705 29 atime=1447019866.36646659 30 ctime=1447019943.446306976 glusterfs-3.7.6/contrib/fuse-include/fuse-misc.h0000644000076200007630000000070612617742532023041 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB */ #define OFFSET_MAX 0x7fffffffffffffffLL unsigned long calc_timeout_sec (double t); unsigned int calc_timeout_nsec (double t); void convert_fuse_file_lock (struct fuse_file_lock *fl, struct gf_flock *flock, uint64_t lk_owner); glusterfs-3.7.6/contrib/fuse-include/PaxHeaders.7244/fuse-mount.h0000644000076200007630000000013112617742532023027 xustar000000000000000030 mtime=1447019866.026471705 29 atime=1447019866.36646659 30 ctime=1447019943.443307021 glusterfs-3.7.6/contrib/fuse-include/fuse-mount.h0000644000076200007630000000074512617742532023253 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi Copyright (c) 2010 Gluster, Inc. This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ void gf_fuse_unmount (const char *mountpoint, int fd); int gf_fuse_mount (const char *mountpoint, char *fsname, unsigned long mountflags, char *mnt_param, pid_t *mtab_pid, int status_fd); glusterfs-3.7.6/contrib/fuse-include/PaxHeaders.7244/mount_util.h0000644000076200007630000000013112617742532023124 xustar000000000000000030 mtime=1447019866.026471705 29 atime=1447019866.36646659 30 ctime=1447019943.460306765 glusterfs-3.7.6/contrib/fuse-include/mount_util.h0000644000076200007630000000122112617742532023336 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ #include int fuse_mnt_add_mount(const char *progname, const char *fsname, const char *mnt, const char *type, const char *opts); int fuse_mnt_umount(const char *progname, const char *abs_mnt, const char *rel_mnt, int lazy); char *fuse_mnt_resolve_path(const char *progname, const char *orig); int fuse_mnt_check_empty(const char *progname, const char *mnt, mode_t rootmode, off_t rootsize); int fuse_mnt_check_fuseblk(void); glusterfs-3.7.6/contrib/fuse-include/PaxHeaders.7244/fuse_kernel.h0000644000076200007630000000013012617742532023226 xustar000000000000000030 mtime=1447019866.026471705 29 atime=1447019866.36646659 29 ctime=1447019943.45730681 glusterfs-3.7.6/contrib/fuse-include/fuse_kernel.h0000644000076200007630000003703312617742532023453 0ustar00jenkinsjenkins00000000000000/* This file defines the kernel interface of FUSE Copyright (C) 2001-2008 Miklos Szeredi This program can be distributed under the terms of the GNU GPL. See the file COPYING. This -- and only this -- header file may also be distributed under the terms of the BSD Licence as follows: Copyright (C) 2001-2007 Miklos Szeredi. 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. THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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. */ /* * This file defines the kernel interface of FUSE * * Protocol changelog: * * 7.9: * - new fuse_getattr_in input argument of GETATTR * - add lk_flags in fuse_lk_in * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in * - add blksize field to fuse_attr * - add file flags field to fuse_read_in and fuse_write_in * * 7.10 * - add nonseekable open flag * * 7.11 * - add IOCTL message * - add unsolicited notification support * - add POLL message and NOTIFY_POLL notification * * 7.12 * - add umask flag to input argument of open, mknod and mkdir * - add notification messages for invalidation of inodes and * directory entries * * 7.13 * - make max number of background requests and congestion threshold * tunables * * 7.14 * - add splice support to fuse device * * 7.15 * - add store notify * - add retrieve notify * * 7.16 * - add BATCH_FORGET request * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct * fuse_ioctl_iovec' instead of ambiguous 'struct iovec' * - add FUSE_IOCTL_32BIT flag * * 7.17 * - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK * * 7.18 * - add FUSE_IOCTL_DIR flag * - add FUSE_NOTIFY_DELETE * * 7.19 * - add FUSE_FALLOCATE * * 7.20 * - add FUSE_AUTO_INVAL_DATA * * 7.21 * - add FUSE_READDIRPLUS * - send the requested events in POLL request * * 7.22 * - add FUSE_ASYNC_DIO */ #ifndef _LINUX_FUSE_H #define _LINUX_FUSE_H #ifdef __KERNEL__ #include #else #include #endif /* * Version negotiation: * * Both the kernel and userspace send the version they support in the * INIT request and reply respectively. * * If the major versions match then both shall use the smallest * of the two minor versions for communication. * * If the kernel supports a larger major version, then userspace shall * reply with the major version it supports, ignore the rest of the * INIT message and expect a new INIT message from the kernel with a * matching major version. * * If the library supports a larger major version, then it shall fall * back to the major protocol version sent by the kernel for * communication and reply with that major version (and an arbitrary * supported minor version). */ /** Version number of this interface */ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ #define FUSE_KERNEL_MINOR_VERSION 22 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 /* Make sure all structures are padded to 64bit boundary, so 32bit userspace works under 64bit kernels */ struct fuse_attr { uint64_t ino; uint64_t size; uint64_t blocks; uint64_t atime; uint64_t mtime; uint64_t ctime; uint32_t atimensec; uint32_t mtimensec; uint32_t ctimensec; uint32_t mode; uint32_t nlink; uint32_t uid; uint32_t gid; uint32_t rdev; uint32_t blksize; uint32_t padding; }; struct fuse_kstatfs { uint64_t blocks; uint64_t bfree; uint64_t bavail; uint64_t files; uint64_t ffree; uint32_t bsize; uint32_t namelen; uint32_t frsize; uint32_t padding; uint32_t spare[6]; }; struct fuse_file_lock { uint64_t start; uint64_t end; uint32_t type; uint32_t pid; /* tgid */ }; /** * Bitmasks for fuse_setattr_in.valid */ #define FATTR_MODE (1 << 0) #define FATTR_UID (1 << 1) #define FATTR_GID (1 << 2) #define FATTR_SIZE (1 << 3) #define FATTR_ATIME (1 << 4) #define FATTR_MTIME (1 << 5) #define FATTR_FH (1 << 6) #define FATTR_ATIME_NOW (1 << 7) #define FATTR_MTIME_NOW (1 << 8) #define FATTR_LOCKOWNER (1 << 9) /** * Flags returned by the OPEN request * * FOPEN_DIRECT_IO: bypass page cache for this open file * FOPEN_KEEP_CACHE: don't invalidate the data cache on open * FOPEN_NONSEEKABLE: the file is not seekable */ #define FOPEN_DIRECT_IO (1 << 0) #define FOPEN_KEEP_CACHE (1 << 1) #define FOPEN_NONSEEKABLE (1 << 2) /** * INIT request/reply flags * * FUSE_ASYNC_READ: asynchronous read requests * FUSE_POSIX_LOCKS: remote locking for POSIX file locks * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported) * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB * FUSE_DONT_MASK: don't apply umask to file mode on create operations * FUSE_SPLICE_WRITE: kernel supports splice write on the device * FUSE_SPLICE_MOVE: kernel supports splice move on the device * FUSE_SPLICE_READ: kernel supports splice read on the device * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one) * FUSE_READDIRPLUS_AUTO: adaptive readdirplus * FUSE_ASYNC_DIO: asynchronous direct I/O submission */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) #define FUSE_FILE_OPS (1 << 2) #define FUSE_ATOMIC_O_TRUNC (1 << 3) #define FUSE_EXPORT_SUPPORT (1 << 4) #define FUSE_BIG_WRITES (1 << 5) #define FUSE_DONT_MASK (1 << 6) #define FUSE_SPLICE_WRITE (1 << 7) #define FUSE_SPLICE_MOVE (1 << 8) #define FUSE_SPLICE_READ (1 << 9) #define FUSE_FLOCK_LOCKS (1 << 10) #define FUSE_HAS_IOCTL_DIR (1 << 11) #define FUSE_AUTO_INVAL_DATA (1 << 12) #define FUSE_DO_READDIRPLUS (1 << 13) #define FUSE_READDIRPLUS_AUTO (1 << 14) #define FUSE_ASYNC_DIO (1 << 15) /** * CUSE INIT request/reply flags * * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl */ #define CUSE_UNRESTRICTED_IOCTL (1 << 0) /** * Release flags */ #define FUSE_RELEASE_FLUSH (1 << 0) #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1) /** * Getattr flags */ #define FUSE_GETATTR_FH (1 << 0) /** * Lock flags */ #define FUSE_LK_FLOCK (1 << 0) /** * WRITE flags * * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed * FUSE_WRITE_LOCKOWNER: lock_owner field is valid */ #define FUSE_WRITE_CACHE (1 << 0) #define FUSE_WRITE_LOCKOWNER (1 << 1) /** * Read flags */ #define FUSE_READ_LOCKOWNER (1 << 1) /** * Ioctl flags * * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed * FUSE_IOCTL_RETRY: retry with new iovecs * FUSE_IOCTL_32BIT: 32bit ioctl * FUSE_IOCTL_DIR: is a directory * * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs */ #define FUSE_IOCTL_COMPAT (1 << 0) #define FUSE_IOCTL_UNRESTRICTED (1 << 1) #define FUSE_IOCTL_RETRY (1 << 2) #define FUSE_IOCTL_32BIT (1 << 3) #define FUSE_IOCTL_DIR (1 << 4) #define FUSE_IOCTL_MAX_IOV 256 /** * Poll flags * * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify */ #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) enum fuse_opcode { FUSE_LOOKUP = 1, FUSE_FORGET = 2, /* no reply */ FUSE_GETATTR = 3, FUSE_SETATTR = 4, FUSE_READLINK = 5, FUSE_SYMLINK = 6, FUSE_MKNOD = 8, FUSE_MKDIR = 9, FUSE_UNLINK = 10, FUSE_RMDIR = 11, FUSE_RENAME = 12, FUSE_LINK = 13, FUSE_OPEN = 14, FUSE_READ = 15, FUSE_WRITE = 16, FUSE_STATFS = 17, FUSE_RELEASE = 18, FUSE_FSYNC = 20, FUSE_SETXATTR = 21, FUSE_GETXATTR = 22, FUSE_LISTXATTR = 23, FUSE_REMOVEXATTR = 24, FUSE_FLUSH = 25, FUSE_INIT = 26, FUSE_OPENDIR = 27, FUSE_READDIR = 28, FUSE_RELEASEDIR = 29, FUSE_FSYNCDIR = 30, FUSE_GETLK = 31, FUSE_SETLK = 32, FUSE_SETLKW = 33, FUSE_ACCESS = 34, FUSE_CREATE = 35, FUSE_INTERRUPT = 36, FUSE_BMAP = 37, FUSE_DESTROY = 38, FUSE_IOCTL = 39, FUSE_POLL = 40, FUSE_NOTIFY_REPLY = 41, FUSE_BATCH_FORGET = 42, FUSE_FALLOCATE = 43, FUSE_READDIRPLUS = 44, /* CUSE specific operations */ CUSE_INIT = 4096, }; enum fuse_notify_code { FUSE_NOTIFY_POLL = 1, FUSE_NOTIFY_INVAL_INODE = 2, FUSE_NOTIFY_INVAL_ENTRY = 3, FUSE_NOTIFY_STORE = 4, FUSE_NOTIFY_RETRIEVE = 5, FUSE_NOTIFY_DELETE = 6, FUSE_NOTIFY_CODE_MAX, }; /* The read buffer is required to be at least 8k, but may be much larger */ #define FUSE_MIN_READ_BUFFER 8192 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 struct fuse_entry_out { uint64_t nodeid; /* Inode ID */ uint64_t generation; /* Inode generation: nodeid:gen must be unique for the fs's lifetime */ uint64_t entry_valid; /* Cache timeout for the name */ uint64_t attr_valid; /* Cache timeout for the attributes */ uint32_t entry_valid_nsec; uint32_t attr_valid_nsec; struct fuse_attr attr; }; struct fuse_forget_in { uint64_t nlookup; }; struct fuse_forget_one { uint64_t nodeid; uint64_t nlookup; }; struct fuse_batch_forget_in { uint32_t count; uint32_t dummy; }; struct fuse_getattr_in { uint32_t getattr_flags; uint32_t dummy; uint64_t fh; }; #define FUSE_COMPAT_ATTR_OUT_SIZE 96 struct fuse_attr_out { uint64_t attr_valid; /* Cache timeout for the attributes */ uint32_t attr_valid_nsec; uint32_t dummy; struct fuse_attr attr; }; #define FUSE_COMPAT_MKNOD_IN_SIZE 8 struct fuse_mknod_in { uint32_t mode; uint32_t rdev; uint32_t umask; uint32_t padding; }; struct fuse_mkdir_in { uint32_t mode; uint32_t umask; }; struct fuse_rename_in { uint64_t newdir; }; struct fuse_link_in { uint64_t oldnodeid; }; struct fuse_setattr_in { uint32_t valid; uint32_t padding; uint64_t fh; uint64_t size; uint64_t lock_owner; uint64_t atime; uint64_t mtime; uint64_t unused2; uint32_t atimensec; uint32_t mtimensec; uint32_t unused3; uint32_t mode; uint32_t unused4; uint32_t uid; uint32_t gid; uint32_t unused5; }; struct fuse_open_in { uint32_t flags; uint32_t unused; }; struct fuse_create_in { uint32_t flags; uint32_t mode; uint32_t umask; uint32_t padding; }; struct fuse_open_out { uint64_t fh; uint32_t open_flags; uint32_t padding; }; struct fuse_release_in { uint64_t fh; uint32_t flags; uint32_t release_flags; uint64_t lock_owner; }; struct fuse_flush_in { uint64_t fh; uint32_t unused; uint32_t padding; uint64_t lock_owner; }; struct fuse_read_in { uint64_t fh; uint64_t offset; uint32_t size; uint32_t read_flags; uint64_t lock_owner; uint32_t flags; uint32_t padding; }; #define FUSE_COMPAT_WRITE_IN_SIZE 24 struct fuse_write_in { uint64_t fh; uint64_t offset; uint32_t size; uint32_t write_flags; uint64_t lock_owner; uint32_t flags; uint32_t padding; }; struct fuse_write_out { uint32_t size; uint32_t padding; }; #define FUSE_COMPAT_STATFS_SIZE 48 struct fuse_statfs_out { struct fuse_kstatfs st; }; struct fuse_fsync_in { uint64_t fh; uint32_t fsync_flags; uint32_t padding; }; struct fuse_setxattr_in { uint32_t size; uint32_t flags; }; struct fuse_getxattr_in { uint32_t size; uint32_t padding; }; struct fuse_getxattr_out { uint32_t size; uint32_t padding; }; struct fuse_lk_in { uint64_t fh; uint64_t owner; struct fuse_file_lock lk; uint32_t lk_flags; uint32_t padding; }; struct fuse_lk_out { struct fuse_file_lock lk; }; struct fuse_access_in { uint32_t mask; uint32_t padding; }; struct fuse_init_in { uint32_t major; uint32_t minor; uint32_t max_readahead; uint32_t flags; }; struct fuse_init_out { uint32_t major; uint32_t minor; uint32_t max_readahead; uint32_t flags; uint16_t max_background; uint16_t congestion_threshold; uint32_t max_write; }; #define CUSE_INIT_INFO_MAX 4096 struct cuse_init_in { uint32_t major; uint32_t minor; uint32_t unused; uint32_t flags; }; struct cuse_init_out { uint32_t major; uint32_t minor; uint32_t unused; uint32_t flags; uint32_t max_read; uint32_t max_write; uint32_t dev_major; /* chardev major */ uint32_t dev_minor; /* chardev minor */ uint32_t spare[10]; }; struct fuse_interrupt_in { uint64_t unique; }; struct fuse_bmap_in { uint64_t block; uint32_t blocksize; uint32_t padding; }; struct fuse_bmap_out { uint64_t block; }; struct fuse_ioctl_in { uint64_t fh; uint32_t flags; uint32_t cmd; uint64_t arg; uint32_t in_size; uint32_t out_size; }; struct fuse_ioctl_iovec { uint64_t base; uint64_t len; }; struct fuse_ioctl_out { int32_t result; uint32_t flags; uint32_t in_iovs; uint32_t out_iovs; }; struct fuse_poll_in { uint64_t fh; uint64_t kh; uint32_t flags; uint32_t events; }; struct fuse_poll_out { uint32_t revents; uint32_t padding; }; struct fuse_notify_poll_wakeup_out { uint64_t kh; }; struct fuse_fallocate_in { uint64_t fh; uint64_t offset; uint64_t length; uint32_t mode; uint32_t padding; }; struct fuse_in_header { uint32_t len; uint32_t opcode; uint64_t unique; uint64_t nodeid; uint32_t uid; uint32_t gid; uint32_t pid; uint32_t padding; }; struct fuse_out_header { uint32_t len; int32_t error; uint64_t unique; }; struct fuse_dirent { uint64_t ino; uint64_t off; uint32_t namelen; uint32_t type; char name[]; }; #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) #define FUSE_DIRENT_ALIGN(x) \ (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) #define FUSE_DIRENT_SIZE(d) \ FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) struct fuse_direntplus { struct fuse_entry_out entry_out; struct fuse_dirent dirent; }; #define FUSE_NAME_OFFSET_DIRENTPLUS \ offsetof(struct fuse_direntplus, dirent.name) #define FUSE_DIRENTPLUS_SIZE(d) \ FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen) struct fuse_notify_inval_inode_out { uint64_t ino; int64_t off; int64_t len; }; struct fuse_notify_inval_entry_out { uint64_t parent; uint32_t namelen; uint32_t padding; }; struct fuse_notify_delete_out { uint64_t parent; uint64_t child; uint32_t namelen; uint32_t padding; }; struct fuse_notify_store_out { uint64_t nodeid; uint64_t offset; uint32_t size; uint32_t padding; }; struct fuse_notify_retrieve_out { uint64_t notify_unique; uint64_t nodeid; uint64_t offset; uint32_t size; uint32_t padding; }; /* Matches the size of fuse_write_in */ struct fuse_notify_retrieve_in { uint64_t dummy1; uint64_t offset; uint32_t size; uint32_t dummy2; uint64_t dummy3; uint64_t dummy4; }; #endif /* _LINUX_FUSE_H */ glusterfs-3.7.6/contrib/fuse-include/PaxHeaders.7244/fuse_kernel_macfuse.h0000644000076200007630000000013112617742532024732 xustar000000000000000030 mtime=1447019866.026471705 29 atime=1447019866.36646659 30 ctime=1447019943.466306675 glusterfs-3.7.6/contrib/fuse-include/fuse_kernel_macfuse.h0000644000076200007630000002421512617742532025154 0ustar00jenkinsjenkins00000000000000/* This file defines the kernel interface of FUSE Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU GPL. See the file COPYING. This -- and only this -- header file may also be distributed under the terms of the BSD Licence as follows: Copyright (C) 2001-2007 Miklos Szeredi. 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. THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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 linux #include #define __u64 uint64_t #define __u32 uint32_t #define __s32 int32_t #else #include #include #endif /** Version number of this interface */ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ #define FUSE_KERNEL_MINOR_VERSION 8 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 /** The major number of the fuse character device */ #define FUSE_MAJOR MISC_MAJOR /** The minor number of the fuse character device */ #define FUSE_MINOR 229 /* Make sure all structures are padded to 64bit boundary, so 32bit userspace works under 64bit kernels */ struct fuse_attr { __u64 ino; __u64 size; __u64 blocks; __u64 atime; __u64 mtime; __u64 ctime; __u64 crtime; __u32 atimensec; __u32 mtimensec; __u32 ctimensec; __u32 crtimensec; __u32 mode; __u32 nlink; __u32 uid; __u32 gid; __u32 rdev; __u32 flags; /* file flags; see chflags(2) */ }; struct fuse_kstatfs { __u64 blocks; __u64 bfree; __u64 bavail; __u64 files; __u64 ffree; __u32 bsize; __u32 namelen; __u32 frsize; __u32 padding; __u32 spare[6]; }; struct fuse_file_lock { __u64 start; __u64 end; __u32 type; __u32 pid; /* tgid */ }; /** * Bitmasks for fuse_setattr_in.valid */ #define FATTR_MODE (1 << 0) #define FATTR_UID (1 << 1) #define FATTR_GID (1 << 2) #define FATTR_SIZE (1 << 3) #define FATTR_ATIME (1 << 4) #define FATTR_MTIME (1 << 5) #define FATTR_FH (1 << 6) #define FATTR_CRTIME (1 << 28) #define FATTR_CHGTIME (1 << 29) #define FATTR_BKUPTIME (1 << 30) #define FATTR_FLAGS (1 << 31) /** * Flags returned by the OPEN request * * FOPEN_DIRECT_IO: bypass page cache for this open file * FOPEN_KEEP_CACHE: don't invalidate the data cache on open */ #define FOPEN_DIRECT_IO (1 << 0) #define FOPEN_KEEP_CACHE (1 << 1) #define FOPEN_PURGE_ATTR (1 << 30) #define FOPEN_PURGE_UBC (1 << 31) /** * INIT request/reply flags */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) #define FUSE_CASE_INSENSITIVE (1 << 29) #define FUSE_VOL_RENAME (1 << 30) #define FUSE_XTIMES (1 << 31) /** * Release flags */ #define FUSE_RELEASE_FLUSH (1 << 0) enum fuse_opcode { FUSE_LOOKUP = 1, FUSE_FORGET = 2, /* no reply */ FUSE_GETATTR = 3, FUSE_SETATTR = 4, FUSE_READLINK = 5, FUSE_SYMLINK = 6, FUSE_MKNOD = 8, FUSE_MKDIR = 9, FUSE_UNLINK = 10, FUSE_RMDIR = 11, FUSE_RENAME = 12, FUSE_LINK = 13, FUSE_OPEN = 14, FUSE_READ = 15, FUSE_WRITE = 16, FUSE_STATFS = 17, FUSE_RELEASE = 18, FUSE_FSYNC = 20, FUSE_SETXATTR = 21, FUSE_GETXATTR = 22, FUSE_LISTXATTR = 23, FUSE_REMOVEXATTR = 24, FUSE_FLUSH = 25, FUSE_INIT = 26, FUSE_OPENDIR = 27, FUSE_READDIR = 28, FUSE_RELEASEDIR = 29, FUSE_FSYNCDIR = 30, FUSE_GETLK = 31, FUSE_SETLK = 32, FUSE_SETLKW = 33, FUSE_ACCESS = 34, FUSE_CREATE = 35, FUSE_INTERRUPT = 36, FUSE_BMAP = 37, FUSE_DESTROY = 38, /* FUSE_IOCTL = 39, FUSE_POLL = 40, FUSE_NOTIFY_REPLY = 41, FUSE_BATCH_FORGET = 42, FUSE_FALLOCATE = 43, FUSE_READDIRPLUS = 44, */ FUSE_SETVOLNAME = 61, FUSE_GETXTIMES = 62, FUSE_EXCHANGE = 63, }; /* The read buffer is required to be at least 8k, but may be much larger */ #define FUSE_MIN_READ_BUFFER 8192 struct fuse_entry_out { __u64 nodeid; /* Inode ID */ __u64 generation; /* Inode generation: nodeid:gen must be unique for the fs's lifetime */ __u64 entry_valid; /* Cache timeout for the name */ __u64 attr_valid; /* Cache timeout for the attributes */ __u32 entry_valid_nsec; __u32 attr_valid_nsec; struct fuse_attr attr; }; struct fuse_forget_in { __u64 nlookup; }; struct fuse_attr_out { __u64 attr_valid; /* Cache timeout for the attributes */ __u32 attr_valid_nsec; __u32 dummy; struct fuse_attr attr; }; struct fuse_getxtimes_out { __u64 bkuptime; __u64 crtime; __u32 bkuptimensec; __u32 crtimensec; }; struct fuse_mknod_in { __u32 mode; __u32 rdev; }; struct fuse_mkdir_in { __u32 mode; __u32 padding; }; struct fuse_rename_in { __u64 newdir; }; struct fuse_exchange_in { __u64 olddir; __u64 newdir; __u64 options; }; struct fuse_link_in { __u64 oldnodeid; }; struct fuse_setattr_in { __u32 valid; __u32 padding; __u64 fh; __u64 size; __u64 unused1; __u64 atime; __u64 mtime; __u64 unused2; __u32 atimensec; __u32 mtimensec; __u32 unused3; __u32 mode; __u32 unused4; __u32 uid; __u32 gid; __u32 unused5; __u64 bkuptime; __u64 chgtime; __u64 crtime; __u32 bkuptimensec; __u32 chgtimensec; __u32 crtimensec; __u32 flags; /* file flags; see chflags(2) */ }; struct fuse_open_in { __u32 flags; __u32 mode; }; struct fuse_open_out { __u64 fh; __u32 open_flags; __u32 padding; }; struct fuse_release_in { __u64 fh; __u32 flags; __u32 release_flags; __u64 lock_owner; }; struct fuse_flush_in { __u64 fh; __u32 unused; __u32 padding; __u64 lock_owner; }; struct fuse_read_in { __u64 fh; __u64 offset; __u32 size; __u32 padding; }; struct fuse_write_in { __u64 fh; __u64 offset; __u32 size; __u32 write_flags; }; struct fuse_write_out { __u32 size; __u32 padding; }; #define FUSE_COMPAT_STATFS_SIZE 48 struct fuse_statfs_out { struct fuse_kstatfs st; }; struct fuse_fsync_in { __u64 fh; __u32 fsync_flags; __u32 padding; }; struct fuse_setxattr_in { __u32 size; __u32 flags; __u32 position; __u32 padding; }; struct fuse_getxattr_in { __u32 size; __u32 padding; __u32 position; __u32 padding2; }; struct fuse_getxattr_out { __u32 size; __u32 padding; }; struct fuse_lk_in { __u64 fh; __u64 owner; struct fuse_file_lock lk; }; struct fuse_lk_out { struct fuse_file_lock lk; }; struct fuse_access_in { __u32 mask; __u32 padding; }; struct fuse_init_in { __u32 major; __u32 minor; __u32 max_readahead; __u32 flags; }; struct fuse_init_out { __u32 major; __u32 minor; __u32 max_readahead; __u32 flags; __u32 unused; __u32 max_write; }; struct fuse_interrupt_in { __u64 unique; }; struct fuse_bmap_in { __u64 block; __u32 blocksize; __u32 padding; }; struct fuse_bmap_out { __u64 block; }; struct fuse_in_header { __u32 len; __u32 opcode; __u64 unique; __u64 nodeid; __u32 uid; __u32 gid; __u32 pid; __u32 padding; }; struct fuse_out_header { __u32 len; __s32 error; __u64 unique; }; struct fuse_dirent { __u64 ino; __u64 off; __u32 namelen; __u32 type; char name[0]; }; #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) #define FUSE_DIRENT_SIZE(d) \ FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) glusterfs-3.7.6/contrib/PaxHeaders.7244/umountd0000644000076200007630000000013012617742655017614 xustar000000000000000030 mtime=1447019949.325218534 28 atime=1447019949.3342184 30 ctime=1447019949.325218534 glusterfs-3.7.6/contrib/umountd/0000755000076200007630000000000012617742655020110 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/umountd/PaxHeaders.7244/Makefile0000644000076200007630000000013112617742617021330 xustar000000000000000029 mtime=1447019919.12667284 30 atime=1447019928.789527471 30 ctime=1447019929.891510893 glusterfs-3.7.6/contrib/umountd/Makefile0000644000076200007630000005414112617742617021553 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # contrib/umountd/Makefile. Generated from Makefile.in by configure. # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. pkgdatadir = $(datadir)/glusterfs pkgincludedir = $(includedir)/glusterfs pkglibdir = $(libdir)/glusterfs pkglibexecdir = $(libexecdir)/glusterfs am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = x86_64-unknown-linux-gnu host_triplet = x86_64-unknown-linux-gnu sbin_PROGRAMS = umountd$(EXEEXT) subdir = contrib/umountd DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/contrib/aclocal/mkdirp.m4 \ $(top_srcdir)/contrib/aclocal/python.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) am_umountd_OBJECTS = umountd-umountd.$(OBJEXT) umountd_OBJECTS = $(am_umountd_OBJECTS) am__DEPENDENCIES_1 = umountd_DEPENDENCIES = \ $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent umountd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(umountd_CFLAGS) \ $(CFLAGS) $(umountd_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I. -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(umountd_SOURCES) DIST_SOURCES = $(umountd_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run aclocal-1.11 ACL_LIBS = -lacl AMTAR = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run tar AM_DEFAULT_VERBOSITY = 0 AM_LIBTOOLFLAGS = --quiet AM_MAKEFLAGS = --no-print-directory --quiet AR = ar ARGP_STANDALONE_CPPFLAGS = ARGP_STANDALONE_DIR = ARGP_STANDALONE_LDADD = AUTOCONF = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run autoconf AUTOHEADER = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run autoheader AUTOMAKE = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run automake-1.11 AWK = gawk BUILD_PYTHON_INC = /usr/include/python2.6 BUILD_PYTHON_LIB = python2.6 BUILD_PYTHON_SITE_PACKAGES = /usr/lib/python2.6/site-packages CC = gcc CCDEPMODE = depmode=gcc3 CFLAGS = -g -O2 -g -O2 -Wformat -Werror=format-security -Werror=implicit-function-declaration CONTRIBDIR = $(top_srcdir)/contrib CPP = gcc -E CPPFLAGS = CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H DEPDIR = .deps DSYMUTIL = DTRACE = yes DUMPBIN = ECHO_C = ECHO_N = -n ECHO_T = EGREP = /bin/grep -E EXEEXT = FGREP = /bin/grep -F FUSERMOUNT_SUBDIR = contrib/fuse-util FUSE_CLIENT_SUBDIR = fuse GEOREP_EXTRAS_SUBDIR = geo-rep GFAPI_EXTRA_LDFLAGS = -Wl,--version-script=$(top_srcdir)/api/src/gfapi.map GFAPI_LIBS = -lacl GFAPI_LT_VERSION = 0:0:0 GFAPI_VERSION = 7.3.7.6 GF_CFLAGS = -g -O2 -g -O2 -Wformat -Werror=format-security -g -O2 -g -O2 -Wformat -Werror=format-security -Werror=implicit-function-declaration GF_CPPFLAGS = -I$(CONTRIBDIR)/uuid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS) -I$(top_srcdir)/libglusterfs/src GF_DISTRIBUTION = Redhat GF_FUSE_CFLAGS = -DFUSERMOUNT_DIR=\"$(bindir)\" GF_FUSE_LDADD = GF_HOST_OS = GF_LINUX_HOST_OS GF_LDADD = -lm GF_LDFLAGS = -rdynamic GLIB_CFLAGS = -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include GLIB_LIBS = -lglib-2.0 GLUPY_SUBDIR = glupy GLUPY_SUBDIR_MAKEFILE = xlators/features/glupy/Makefile GLUPY_SUBDIR_SRC_MAKEFILE = xlators/features/glupy/src/Makefile GLUSTERD_VOLFILE = /usr/local/etc/glusterfs/glusterd.vol GLUSTERD_WORKDIR = /var/lib/glusterd GLUSTERFSD_MISCDIR = /usr/local/var/lib/misc/glusterfsd GLUSTERFS_LIBEXECDIR = /usr/local/libexec/glusterfs GREP = /bin/grep HAVE_BACKTRACE = HAVE_LINKAT = HAVE_MALLOC_STATS = HAVE_SPINLOCK = HAVE_STRNLEN = IBVERBS_SUBDIR = ib-verbs INSTALL = /usr/bin/install -c INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = $(install_sh) -c -s LD = /usr/bin/ld -m elf_x86_64 LDFLAGS = LEX = flex LEXLIB = LEX_OUTPUT_ROOT = lex.yy LIBAIO = -laio LIBGFCHANGELOG_LT_VERSION = 0:1:0 LIBGFCHANGELOG_VERSION = 0.0.1 LIBGFDB_VERSION = 0.0.1 LIBGFRPC_LT_VERSION = 0:1:0 LIBGFXDR_LT_VERSION = 0:1:0 LIBGLUSTERFS_LT_VERSION = 0:1:0 LIBOBJS = LIBS = -lrt -lpthread -lcrypto LIBTOOL = $(SHELL) $(top_builddir)/libtool LIPO = LN_S = ln -s LTLIBOBJS = MAKEINFO = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/missing --run makeinfo MATH_LIB = -lm MKDIR_P = /bin/mkdir -p NM = /usr/bin/nm -B NMEDIT = OBJDUMP = objdump OBJEXT = o OCF_SUBDIR = ocf OTOOL = OTOOL64 = PACKAGE = glusterfs PACKAGE_BUGREPORT = gluster-users@gluster.org PACKAGE_NAME = glusterfs PACKAGE_RELEASE = 0 PACKAGE_STRING = glusterfs 3.7.6 PACKAGE_TARNAME = glusterfs PACKAGE_VERSION = 3.7.6 PATH_SEPARATOR = : PKGCONFIG_UUID = PKG_CONFIG = /usr/bin/pkg-config PYTHON = /usr/bin/python PYTHONDEV_CFLAGS = -I/usr/include/python2.6 -I/usr/include/python2.6 -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv PYTHONDEV_CPPFLAGS = -I/usr/include/python2.6 -I/usr/include/python2.6 -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv PYTHONDEV_LDFLAGS = -L/usr/lib -L/usr/${exec_prefix}/lib -lpthread -ldl -lutil -lm -lpython2.6 PYTHON_CFLAGS = PYTHON_EXEC_PREFIX = ${exec_prefix} PYTHON_LIBS = PYTHON_PLATFORM = linux2 PYTHON_PREFIX = ${prefix} PYTHON_VERSION = 2.6 RANLIB = ranlib RDMA_SUBDIR = rdma RLLIBS = -lreadline -lncurses RPCGEN = yes SED = /bin/sed SET_MAKE = SHELL = /bin/sh SIZEOF_INT = 4 SIZEOF_LONG = 8 SIZEOF_LONG_LONG = 8 SIZEOF_SHORT = 2 SQLITE_CFLAGS = SQLITE_LIBS = -lsqlite3 STRIP = strip SYNCDAEMON_COMPILE = 1 SYNCDAEMON_SUBDIR = geo-replication UMOUNTD_SUBDIR = UNITTEST_CFLAGS = -DUNIT_TESTING=1 -g -DDEBUG -O0 --coverage UNITTEST_LDFLAGS = UNITTEST_LIBS = URCU_CDS_CFLAGS = URCU_CDS_LIBS = -lurcu-cds URCU_CFLAGS = URCU_LIBS = -lurcu-bp USE_POSIX_ACLS = 1 UUID_CFLAGS = -I$(CONTRIBDIR)/uuid UUID_LIBS = VERSION = 3.7.6 XML2_CONFIG = /usr/bin/xml2-config XML_CPPFLAGS = -I/usr/include/libxml2 XML_LIBS = -lxml2 -lz -lm YACC = bison -y YFLAGS = ZLIB_CFLAGS = ZLIB_LIBS = -lz abs_builddir = /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/contrib/umountd abs_srcdir = /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/contrib/umountd abs_top_builddir = /var/lib/jenkins/work/releases/3.7.6/glusterfs.git abs_top_srcdir = /var/lib/jenkins/work/releases/3.7.6/glusterfs.git ac_ct_CC = gcc ac_ct_DUMPBIN = am__include = include am__leading_dot = . am__quote = am__tar = tar --format=posix -chf - "$$tardir" am__untar = tar -xf - bindir = ${exec_prefix}/bin build = x86_64-unknown-linux-gnu build_alias = build_cpu = x86_64 build_os = linux-gnu build_vendor = unknown builddir = . datadir = ${datarootdir} datarootdir = ${prefix}/share docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} dvidir = ${docdir} exec_prefix = ${prefix} host = x86_64-unknown-linux-gnu host_alias = host_cpu = x86_64 host_os = linux-gnu host_vendor = unknown htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info initdir = /etc/init.d install_sh = ${SHELL} /var/lib/jenkins/work/releases/3.7.6/glusterfs.git/install-sh launchddir = /Library/LaunchDaemons libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale localstatedir = /var lt_ECHO = echo mandir = ${datarootdir}/man mkdir_p = /bin/mkdir -p mountutildir = /sbin oldincludedir = /usr/include pdfdir = ${docdir} pkgconfigdir = ${libdir}/pkgconfig pkgpyexecdir = ${pyexecdir}/glusterfs pkgpythondir = ${pythondir}/glusterfs prefix = /usr/local program_transform_name = s,x,x, psdir = ${docdir} pyexecdir = ${exec_prefix}/lib64/python2.6/site-packages pythondir = ${prefix}/lib/python2.6/site-packages sbindir = ${exec_prefix}/sbin sharedstatedir = ${prefix}/com shrext_cmds = .so srcdir = . subdirs = sysconfdir = ${prefix}/etc systemddir = /usr/lib/systemd/system target_alias = tmpfilesdir = top_build_prefix = ../../ top_builddir = ../.. top_srcdir = ../.. umountd_SOURCES = umountd.c umountd_CFLAGS = $(GF_CFLAGS) -DDATADIR=\"$(localstatedir)\" umountd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la ${GF_LDADD} umountd_LDFLAGS = $(GF_LDFLAGS) AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/umountd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign contrib/umountd/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list umountd$(EXEEXT): $(umountd_OBJECTS) $(umountd_DEPENDENCIES) @rm -f umountd$(EXEEXT) $(AM_V_CCLD)$(umountd_LINK) $(umountd_OBJECTS) $(umountd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c include ./$(DEPDIR)/umountd-umountd.Po .c.o: $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po # $(AM_V_CC) \ # source='$<' object='$@' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(COMPILE) -c $< .c.obj: $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po # $(AM_V_CC) \ # source='$<' object='$@' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo # $(AM_V_CC) \ # source='$<' object='$@' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(LTCOMPILE) -c -o $@ $< umountd-umountd.o: umountd.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -MT umountd-umountd.o -MD -MP -MF $(DEPDIR)/umountd-umountd.Tpo -c -o umountd-umountd.o `test -f 'umountd.c' || echo '$(srcdir)/'`umountd.c $(AM_V_at)$(am__mv) $(DEPDIR)/umountd-umountd.Tpo $(DEPDIR)/umountd-umountd.Po # $(AM_V_CC) \ # source='umountd.c' object='umountd-umountd.o' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -c -o umountd-umountd.o `test -f 'umountd.c' || echo '$(srcdir)/'`umountd.c umountd-umountd.obj: umountd.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -MT umountd-umountd.obj -MD -MP -MF $(DEPDIR)/umountd-umountd.Tpo -c -o umountd-umountd.obj `if test -f 'umountd.c'; then $(CYGPATH_W) 'umountd.c'; else $(CYGPATH_W) '$(srcdir)/umountd.c'; fi` $(AM_V_at)$(am__mv) $(DEPDIR)/umountd-umountd.Tpo $(DEPDIR)/umountd-umountd.Po # $(AM_V_CC) \ # source='umountd.c' object='umountd-umountd.obj' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -c -o umountd-umountd.obj `if test -f 'umountd.c'; then $(CYGPATH_W) 'umountd.c'; else $(CYGPATH_W) '$(srcdir)/umountd.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-sbinPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-sbinPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-sbinPROGRAMS ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-sbinPROGRAMS install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-sbinPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/contrib/umountd/PaxHeaders.7244/Makefile.am0000644000076200007630000000013112617742532021720 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019929.891510893 glusterfs-3.7.6/contrib/umountd/Makefile.am0000644000076200007630000000051312617742532022135 0ustar00jenkinsjenkins00000000000000sbin_PROGRAMS = umountd umountd_SOURCES = umountd.c umountd_CFLAGS = $(GF_CFLAGS) -DDATADIR=\"$(localstatedir)\" umountd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la ${GF_LDADD} umountd_LDFLAGS = $(GF_LDFLAGS) AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = glusterfs-3.7.6/contrib/umountd/PaxHeaders.7244/umountd.c0000644000076200007630000000013112617742532021523 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019929.891510893 glusterfs-3.7.6/contrib/umountd/umountd.c0000644000076200007630000001543112617742532021745 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2008-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "glusterfs.h" #include "globals.h" #include "logging.h" #include "syscall.h" #include "mem-types.h" static void usage (void) { fprintf (stderr, "Usage: umountd [-d dev] [-t timeout] [-r] path\n"); exit (EXIT_FAILURE); } static int sanity_check (char *path, dev_t *devp) { struct stat st; struct stat parent_st; int ret; char pathtmp[PATH_MAX]; char *parent; if (path == NULL) usage (); if ((ret = stat (path, &st)) != 0) { switch (errno) { case ENOTCONN: /* volume is stopped */ break; default: gf_log ("umountd", GF_LOG_ERROR, "Cannot access %s\n", path, strerror (errno)); goto out; } } /* If dev was not specified, get it from path */ if (*devp == -1 && ret == 0) *devp = st.st_dev; strncpy (pathtmp, path, PATH_MAX); parent = dirname (pathtmp); if (stat (parent, &parent_st) != 0) { gf_log ("umountd", GF_LOG_ERROR, "Cannot access %s\n", parent, strerror (errno)); goto out; } if (st.st_dev == parent_st.st_dev) { gf_log ("umountd", GF_LOG_ERROR, "No filesystem mounted on %s\n", path); goto out; } ret = 0; out: return ret; } static void log_rotate (int signum) { gf_log_logrotate (1); if (signal (SIGHUP, *log_rotate) == SIG_ERR) { gf_log ("umountd", GF_LOG_ERROR, "signal () failed"); exit (EXIT_FAILURE); } return; } static int logging_init (void) { glusterfs_ctx_t *ctx; char log_file[PATH_MAX]; int ret = -1; ctx = glusterfs_ctx_new (); if (!ctx) { fprintf (stderr, "glusterfs_ctx_new failed\n"); goto out; } ret = glusterfs_globals_init (ctx); if (ret) { fprintf (stderr, "glusterfs_globals_init failed\n"); goto out; } THIS->ctx = ctx; xlator_mem_acct_init (THIS, gf_common_mt_end); snprintf (log_file, PATH_MAX, "%s/umountd.log", DEFAULT_LOG_FILE_DIRECTORY); ret = gf_log_init (ctx, log_file, "umountd"); if (ret) { fprintf (stderr, "gf_log_init failed\n"); goto out; } if (signal (SIGHUP, *log_rotate) == SIG_ERR) { gf_log ("umountd", GF_LOG_ERROR, "signal () failed"); goto out; } ret = 0; out: return ret; } static int umountd_async (char *path, dev_t dev, int frmdir, int timeout) { int ret = -1; struct stat stbuf = {0, }; int unmount_ret = 0; do { unmount_ret = unmount (path, 0); if (unmount_ret == 0) gf_log ("umountd", GF_LOG_INFO, "Unmounted %s", path); if (unmount_ret != 0 && errno != EBUSY) { gf_log ("umountd", GF_LOG_WARNING, "umount %s failed: %s", path, strerror (errno)); } ret = sys_lstat (path, &stbuf); if (ret != 0) { gf_log ("umountd", GF_LOG_WARNING, "Cannot stat device from %s", path, strerror (errno)); break; } if (stbuf.st_dev != dev) { if (unmount_ret != 0) gf_log ("umountd", GF_LOG_INFO, "device mismatch " "(expect %lld, found %lld), " "someone else unmounted %s", dev, stbuf.st_dev, path); ret = 0; break; } sleep (timeout); } while (1/*CONSTCOND*/); if (ret) { gf_log ("umountd", GF_LOG_ERROR, "Asynchronous unmount of %s failed: %s", path, strerror (errno)); } else { if (frmdir) { ret = rmdir (path); if (ret) gf_log ("umountd", GF_LOG_WARNING, "rmdir %s failed: %s", path, strerror (errno)); else gf_log ("umountd", GF_LOG_INFO, "Removed %s", path); } } return ret; } int main (int argc, char **argv) { char *path = NULL; dev_t dev = -1; int frmdir = 0; int timeout = 30; int f; while ((f = getopt (argc, argv, "d:rt:")) != -1) { switch (f) { case 'p': path = optarg; break; case 'd': dev = strtoll (optarg, NULL, 10); break; case 't': timeout = atoi (optarg); break; case 'r': frmdir = 1; break; default: usage (); break; } } argc -= optind; argv += optind; if (argc != 1) usage (); path = argv[0]; if (logging_init () != 0) exit (EXIT_FAILURE); if (sanity_check (path, &dev) != 0) exit (EXIT_FAILURE); if (daemon (0, 0) != 0) exit (EXIT_FAILURE); if (umountd_async (path, dev, frmdir, timeout) != 0) exit (EXIT_FAILURE); return EXIT_SUCCESS; } glusterfs-3.7.6/contrib/umountd/PaxHeaders.7244/Makefile.in0000644000076200007630000000013212617742544021735 xustar000000000000000030 mtime=1447019876.306317047 30 atime=1447019919.115673005 30 ctime=1447019929.892510878 glusterfs-3.7.6/contrib/umountd/Makefile.in0000644000076200007630000005361012617742544022157 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ sbin_PROGRAMS = umountd$(EXEEXT) subdir = contrib/umountd DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/contrib/aclocal/mkdirp.m4 \ $(top_srcdir)/contrib/aclocal/python.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) am_umountd_OBJECTS = umountd-umountd.$(OBJEXT) umountd_OBJECTS = $(am_umountd_OBJECTS) am__DEPENDENCIES_1 = umountd_DEPENDENCIES = \ $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent umountd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(umountd_CFLAGS) \ $(CFLAGS) $(umountd_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(umountd_SOURCES) DIST_SOURCES = $(umountd_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ACL_LIBS = @ACL_LIBS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LIBTOOLFLAGS = @AM_LIBTOOLFLAGS@ AM_MAKEFLAGS = @AM_MAKEFLAGS@ AR = @AR@ ARGP_STANDALONE_CPPFLAGS = @ARGP_STANDALONE_CPPFLAGS@ ARGP_STANDALONE_DIR = @ARGP_STANDALONE_DIR@ ARGP_STANDALONE_LDADD = @ARGP_STANDALONE_LDADD@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_PYTHON_INC = @BUILD_PYTHON_INC@ BUILD_PYTHON_LIB = @BUILD_PYTHON_LIB@ BUILD_PYTHON_SITE_PACKAGES = @BUILD_PYTHON_SITE_PACKAGES@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONTRIBDIR = @CONTRIBDIR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FUSERMOUNT_SUBDIR = @FUSERMOUNT_SUBDIR@ FUSE_CLIENT_SUBDIR = @FUSE_CLIENT_SUBDIR@ GEOREP_EXTRAS_SUBDIR = @GEOREP_EXTRAS_SUBDIR@ GFAPI_EXTRA_LDFLAGS = @GFAPI_EXTRA_LDFLAGS@ GFAPI_LIBS = @GFAPI_LIBS@ GFAPI_LT_VERSION = @GFAPI_LT_VERSION@ GFAPI_VERSION = @GFAPI_VERSION@ GF_CFLAGS = @GF_CFLAGS@ GF_CPPFLAGS = @GF_CPPFLAGS@ GF_DISTRIBUTION = @GF_DISTRIBUTION@ GF_FUSE_CFLAGS = @GF_FUSE_CFLAGS@ GF_FUSE_LDADD = @GF_FUSE_LDADD@ GF_HOST_OS = @GF_HOST_OS@ GF_LDADD = @GF_LDADD@ GF_LDFLAGS = @GF_LDFLAGS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GLUPY_SUBDIR = @GLUPY_SUBDIR@ GLUPY_SUBDIR_MAKEFILE = @GLUPY_SUBDIR_MAKEFILE@ GLUPY_SUBDIR_SRC_MAKEFILE = @GLUPY_SUBDIR_SRC_MAKEFILE@ GLUSTERD_VOLFILE = @GLUSTERD_VOLFILE@ GLUSTERD_WORKDIR = @GLUSTERD_WORKDIR@ GLUSTERFSD_MISCDIR = @GLUSTERFSD_MISCDIR@ GLUSTERFS_LIBEXECDIR = @GLUSTERFS_LIBEXECDIR@ GREP = @GREP@ HAVE_BACKTRACE = @HAVE_BACKTRACE@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_MALLOC_STATS = @HAVE_MALLOC_STATS@ HAVE_SPINLOCK = @HAVE_SPINLOCK@ HAVE_STRNLEN = @HAVE_STRNLEN@ IBVERBS_SUBDIR = @IBVERBS_SUBDIR@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBAIO = @LIBAIO@ LIBGFCHANGELOG_LT_VERSION = @LIBGFCHANGELOG_LT_VERSION@ LIBGFCHANGELOG_VERSION = @LIBGFCHANGELOG_VERSION@ LIBGFDB_VERSION = @LIBGFDB_VERSION@ LIBGFRPC_LT_VERSION = @LIBGFRPC_LT_VERSION@ LIBGFXDR_LT_VERSION = @LIBGFXDR_LT_VERSION@ LIBGLUSTERFS_LT_VERSION = @LIBGLUSTERFS_LT_VERSION@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCF_SUBDIR = @OCF_SUBDIR@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_RELEASE = @PACKAGE_RELEASE@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_UUID = @PKGCONFIG_UUID@ PKG_CONFIG = @PKG_CONFIG@ PYTHON = @PYTHON@ PYTHONDEV_CFLAGS = @PYTHONDEV_CFLAGS@ PYTHONDEV_CPPFLAGS = @PYTHONDEV_CPPFLAGS@ PYTHONDEV_LDFLAGS = @PYTHONDEV_LDFLAGS@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RDMA_SUBDIR = @RDMA_SUBDIR@ RLLIBS = @RLLIBS@ RPCGEN = @RPCGEN@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIZEOF_INT = @SIZEOF_INT@ SIZEOF_LONG = @SIZEOF_LONG@ SIZEOF_LONG_LONG = @SIZEOF_LONG_LONG@ SIZEOF_SHORT = @SIZEOF_SHORT@ SQLITE_CFLAGS = @SQLITE_CFLAGS@ SQLITE_LIBS = @SQLITE_LIBS@ STRIP = @STRIP@ SYNCDAEMON_COMPILE = @SYNCDAEMON_COMPILE@ SYNCDAEMON_SUBDIR = @SYNCDAEMON_SUBDIR@ UMOUNTD_SUBDIR = @UMOUNTD_SUBDIR@ UNITTEST_CFLAGS = @UNITTEST_CFLAGS@ UNITTEST_LDFLAGS = @UNITTEST_LDFLAGS@ UNITTEST_LIBS = @UNITTEST_LIBS@ URCU_CDS_CFLAGS = @URCU_CDS_CFLAGS@ URCU_CDS_LIBS = @URCU_CDS_LIBS@ URCU_CFLAGS = @URCU_CFLAGS@ URCU_LIBS = @URCU_LIBS@ USE_POSIX_ACLS = @USE_POSIX_ACLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ XML_LIBS = @XML_LIBS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ initdir = @initdir@ install_sh = @install_sh@ launchddir = @launchddir@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ mountutildir = @mountutildir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ shrext_cmds = @shrext_cmds@ srcdir = @srcdir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemddir = @systemddir@ target_alias = @target_alias@ tmpfilesdir = @tmpfilesdir@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ umountd_SOURCES = umountd.c umountd_CFLAGS = $(GF_CFLAGS) -DDATADIR=\"$(localstatedir)\" umountd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la ${GF_LDADD} umountd_LDFLAGS = $(GF_LDFLAGS) AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/umountd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign contrib/umountd/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list umountd$(EXEEXT): $(umountd_OBJECTS) $(umountd_DEPENDENCIES) @rm -f umountd$(EXEEXT) $(AM_V_CCLD)$(umountd_LINK) $(umountd_OBJECTS) $(umountd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/umountd-umountd.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< umountd-umountd.o: umountd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -MT umountd-umountd.o -MD -MP -MF $(DEPDIR)/umountd-umountd.Tpo -c -o umountd-umountd.o `test -f 'umountd.c' || echo '$(srcdir)/'`umountd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/umountd-umountd.Tpo $(DEPDIR)/umountd-umountd.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='umountd.c' object='umountd-umountd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -c -o umountd-umountd.o `test -f 'umountd.c' || echo '$(srcdir)/'`umountd.c umountd-umountd.obj: umountd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -MT umountd-umountd.obj -MD -MP -MF $(DEPDIR)/umountd-umountd.Tpo -c -o umountd-umountd.obj `if test -f 'umountd.c'; then $(CYGPATH_W) 'umountd.c'; else $(CYGPATH_W) '$(srcdir)/umountd.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/umountd-umountd.Tpo $(DEPDIR)/umountd-umountd.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='umountd.c' object='umountd-umountd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(umountd_CFLAGS) $(CFLAGS) -c -o umountd-umountd.obj `if test -f 'umountd.c'; then $(CYGPATH_W) 'umountd.c'; else $(CYGPATH_W) '$(srcdir)/umountd.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-sbinPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-sbinPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-sbinPROGRAMS ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-sbinPROGRAMS install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-sbinPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/contrib/PaxHeaders.7244/timer-wheel0000644000076200007630000000013012617742634020340 xustar000000000000000030 mtime=1447019932.260475254 28 atime=1447019949.3342184 30 ctime=1447019932.260475254 glusterfs-3.7.6/contrib/timer-wheel/0000755000076200007630000000000012617742634020634 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/timer-wheel/PaxHeaders.7244/timer-wheel.h0000644000076200007630000000013112617742532023006 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019932.065478188 glusterfs-3.7.6/contrib/timer-wheel/timer-wheel.h0000644000076200007630000000414212617742532023225 0ustar00jenkinsjenkins00000000000000/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __TIMER_WHEEL_H #define __TIMER_WHEEL_H #include #include "list.h" #define TVR_BITS 8 #define TVN_BITS 6 #define TVR_SIZE (1 << TVR_BITS) #define TVN_SIZE (1 << TVN_BITS) #define TVR_MASK (TVR_SIZE - 1) #define TVN_MASK (TVN_SIZE - 1) #define BITS_PER_LONG 64 struct tvec { struct list_head vec[TVN_SIZE]; }; struct tvec_root { struct list_head vec[TVR_SIZE]; }; struct tvec_base { pthread_spinlock_t lock; /* base lock */ pthread_t runner; /* run_timer() */ unsigned long timer_sec; /* time counter */ struct tvec_root tv1; struct tvec tv2; struct tvec tv3; struct tvec tv4; struct tvec tv5; }; struct gf_tw_timer_list { void *data; unsigned long expires; /** callback routine */ void (*function)(struct gf_tw_timer_list *, void *, unsigned long); struct list_head entry; }; /** The API! */ struct tvec_base *gf_tw_init_timers (); int gf_tw_cleanup_timers (struct tvec_base *); void gf_tw_add_timer (struct tvec_base *, struct gf_tw_timer_list *); int gf_tw_del_timer (struct tvec_base *, struct gf_tw_timer_list *); int gf_tw_mod_timer_pending (struct tvec_base *, struct gf_tw_timer_list *, unsigned long); int gf_tw_mod_timer (struct tvec_base *, struct gf_tw_timer_list *, unsigned long); #endif glusterfs-3.7.6/contrib/timer-wheel/PaxHeaders.7244/find_last_bit.c0000644000076200007630000000013112617742532023360 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019932.260475254 glusterfs-3.7.6/contrib/timer-wheel/find_last_bit.c0000644000076200007630000000322412617742532023577 0ustar00jenkinsjenkins00000000000000/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /** * @find_last_bit * optimized implementation of find last bit in */ #ifndef BITS_PER_LONG #define BITS_PER_LONG 64 #endif static inline int fls(int x) { int r = 32; if (!x) return 0; if (!(x & 0xffff0000u)) { x <<= 16; r -= 16; } if (!(x & 0xff000000u)) { x <<= 8; r -= 8; } if (!(x & 0xf0000000u)) { x <<= 4; r -= 4; } if (!(x & 0xc0000000u)) { x <<= 2; r -= 2; } if (!(x & 0x80000000u)) { x <<= 1; r -= 1; } return r; } unsigned long gf_tw_find_last_bit(const unsigned long *addr, unsigned long size) { unsigned long words; unsigned long tmp; /* Start at final word. */ words = size / BITS_PER_LONG; /* Partial final word? */ if (size & (BITS_PER_LONG-1)) { tmp = (addr[words] & (~0UL >> (BITS_PER_LONG - (size & (BITS_PER_LONG-1))))); if (tmp) goto found; } while (words) { tmp = addr[--words]; if (tmp) { found: return words * BITS_PER_LONG + fls(tmp); } } /* Not found */ return size; } glusterfs-3.7.6/contrib/timer-wheel/PaxHeaders.7244/timer-wheel.c0000644000076200007630000000013112617742532023001 xustar000000000000000030 mtime=1447019866.047471389 29 atime=1447019866.37646644 30 ctime=1447019932.257475299 glusterfs-3.7.6/contrib/timer-wheel/timer-wheel.c0000644000076200007630000002251312617742532023222 0ustar00jenkinsjenkins00000000000000/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include #include "timer-wheel.h" static inline void __gf_tw_add_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) { int i; unsigned long idx; unsigned long expires; struct list_head *vec; expires = timer->expires; idx = expires - base->timer_sec; if (idx < TVR_SIZE) { i = expires & TVR_MASK; vec = base->tv1.vec + i; } else if (idx < 1 << (TVR_BITS + TVN_BITS)) { i = (expires >> TVR_BITS) & TVN_MASK; vec = base->tv2.vec + i; } else if (idx < 1 << (TVR_BITS + 2*TVN_BITS)) { i = (expires >> (TVR_BITS + TVN_BITS)) & TVN_MASK; vec = base->tv3.vec + i; } else if (idx < 1 << (TVR_BITS + 3*TVN_BITS)) { i = (expires >> (TVR_BITS + 2*TVN_BITS)) & TVN_MASK; vec = base->tv4.vec + i; } else if (idx < 0) { vec = base->tv1.vec + (base->timer_sec & TVR_MASK); } else { i = (expires >> (TVR_BITS + 3*TVN_BITS)) & TVN_MASK; vec = base->tv5.vec + i; } list_add_tail (&timer->entry, vec); } /* optimized find_last_bit() */ unsigned long gf_tw_find_last_bit(const unsigned long *, unsigned long); static inline unsigned long apply_slack(struct tvec_base *base, struct gf_tw_timer_list *timer) { long delta; unsigned long mask, expires, expires_limit; expires = timer->expires; delta = expires - base->timer_sec; if (delta < 256) return expires; expires_limit = expires + delta / 256; mask = expires ^ expires_limit; if (mask == 0) return expires; int bit = gf_tw_find_last_bit (&mask, BITS_PER_LONG); mask = (1UL << bit) - 1; expires_limit = expires_limit & ~(mask); return expires_limit; } static inline void __gf_tw_detach_timer (struct gf_tw_timer_list *timer) { struct list_head *entry = &timer->entry; list_del (entry); entry->next = NULL; } static inline int cascade (struct tvec_base *base, struct tvec *tv, int index) { struct gf_tw_timer_list *timer, *tmp; struct list_head tv_list; list_replace_init (tv->vec + index, &tv_list); list_for_each_entry_safe (timer, tmp, &tv_list, entry) { __gf_tw_add_timer (base, timer); } return index; } #define INDEX(N) ((base->timer_sec >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK) /** * run expired timers */ static inline void run_timers (struct tvec_base *base) { unsigned long index, call_time; struct gf_tw_timer_list *timer; struct list_head work_list; struct list_head *head = &work_list; pthread_spin_lock (&base->lock); { index = base->timer_sec & TVR_MASK; if (!index && (!cascade (base, &base->tv2, INDEX(0))) && (!cascade (base, &base->tv3, INDEX(1))) && (!cascade (base, &base->tv4, INDEX(2)))) cascade (base, &base->tv5, INDEX(3)); call_time = base->timer_sec++; list_replace_init (base->tv1.vec + index, head); while (!list_empty(head)) { void (*fn)(struct gf_tw_timer_list *, void *, unsigned long); void *data; timer = list_first_entry (head, struct gf_tw_timer_list, entry); fn = timer->function; data = timer->data; __gf_tw_detach_timer (timer); fn (timer, data, call_time); } } pthread_spin_unlock (&base->lock); } void *runner (void *arg) { struct timeval tv = {0,}; struct tvec_base *base = arg; while (1) { run_timers (base); tv.tv_sec = 1; tv.tv_usec = 0; (void) select (0, NULL, NULL, NULL, &tv); } return NULL; } static inline int timer_pending (struct gf_tw_timer_list *timer) { struct list_head *entry = &timer->entry; return (entry->next != NULL); } static inline int __detach_if_pending (struct gf_tw_timer_list *timer) { if (!timer_pending (timer)) return 0; __gf_tw_detach_timer (timer); return 1; } static inline int __mod_timer (struct tvec_base *base, struct gf_tw_timer_list *timer, int pending_only) { int ret = 0; ret = __detach_if_pending (timer); if (!ret && pending_only) goto done; ret = 1; __gf_tw_add_timer (base, timer); done: return ret; } /* interface */ /** * Add a timer in the timer wheel */ void gf_tw_add_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) { pthread_spin_lock (&base->lock); { timer->expires += base->timer_sec; timer->expires = apply_slack (base, timer); __gf_tw_add_timer (base, timer); } pthread_spin_unlock (&base->lock); } /** * Remove a timer from the timer wheel */ int gf_tw_del_timer (struct tvec_base *base, struct gf_tw_timer_list *timer) { int ret = 0; pthread_spin_lock (&base->lock); { if (timer_pending (timer)) { ret = 1; __gf_tw_detach_timer (timer); } } pthread_spin_unlock (&base->lock); return ret; } int gf_tw_mod_timer_pending (struct tvec_base *base, struct gf_tw_timer_list *timer, unsigned long expires) { int ret = 1; pthread_spin_lock (&base->lock); { timer->expires = expires + base->timer_sec; timer->expires = apply_slack (base, timer); ret = __mod_timer (base, timer, 1); } pthread_spin_unlock (&base->lock); return ret; } int gf_tw_mod_timer (struct tvec_base *base, struct gf_tw_timer_list *timer, unsigned long expires) { int ret = 1; pthread_spin_lock (&base->lock); { /* fast path optimization */ if (timer_pending (timer) && timer->expires == expires) goto unblock; timer->expires = expires + base->timer_sec; timer->expires = apply_slack (base, timer); ret = __mod_timer (base, timer, 0); } unblock: pthread_spin_unlock (&base->lock); return ret; } int gf_tw_cleanup_timers (struct tvec_base *base) { int ret = 0; void *res = NULL; /* terminate runner */ ret = pthread_cancel (base->runner); if (ret != 0) goto error_return; ret = pthread_join (base->runner, &res); if (ret != 0) goto error_return; if (res != PTHREAD_CANCELED) goto error_return; /* destroy lock */ ret = pthread_spin_destroy (&base->lock); if (ret != 0) goto error_return; /* deallocated timer base */ free (base); return 0; error_return: return -1; } /** * Initialize various timer wheel lists and spawn a thread that * invokes run_timers() */ struct tvec_base *gf_tw_init_timers () { int j = 0; int ret = 0; struct timeval tv = {0,}; struct tvec_base *base = NULL; base = malloc (sizeof (*base)); if (!base) goto error_return; ret = pthread_spin_init (&base->lock, 0); if (ret != 0) goto error_dealloc; for (j = 0; j < TVN_SIZE; j++) { INIT_LIST_HEAD (base->tv5.vec + j); INIT_LIST_HEAD (base->tv4.vec + j); INIT_LIST_HEAD (base->tv3.vec + j); INIT_LIST_HEAD (base->tv2.vec + j); } for (j = 0; j < TVR_SIZE; j++) { INIT_LIST_HEAD (base->tv1.vec + j); } ret = gettimeofday (&tv, 0); if (ret < 0) goto destroy_lock; base->timer_sec = tv.tv_sec; ret = pthread_create (&base->runner, NULL, runner, base); if (ret != 0) goto destroy_lock; return base; destroy_lock: (void) pthread_spin_destroy (&base->lock); error_dealloc: free (base); error_return: return NULL; } glusterfs-3.7.6/contrib/PaxHeaders.7244/fuse-util0000644000076200007630000000012612617742651020037 xustar000000000000000029 mtime=1447019945.29327919 28 atime=1447019949.3342184 29 ctime=1447019945.29327919 glusterfs-3.7.6/contrib/fuse-util/0000755000076200007630000000000012617742651020326 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/fuse-util/PaxHeaders.7244/Makefile.am0000644000076200007630000000013112617742532022142 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 30 ctime=1447019945.280279386 glusterfs-3.7.6/contrib/fuse-util/Makefile.am0000644000076200007630000000071112617742532022357 0ustar00jenkinsjenkins00000000000000bin_PROGRAMS = fusermount-glusterfs fusermount_glusterfs_SOURCES = fusermount.c mount_util.c $(CONTRIBDIR)/fuse-lib/mount-common.c noinst_HEADERS = $(CONTRIBDIR)/fuse-include/mount_util.h AM_CPPFLAGS = $(GF_CPPFLAGS) -DFUSE_UTIL -I$(CONTRIBDIR)/fuse-include -I$(CONTRIBDIR)/fuse-lib AM_CFLAGS = -Wall $(GF_CFLAGS) install-exec-hook: -chown root $(DESTDIR)$(bindir)/fusermount-glusterfs chmod u+s $(DESTDIR)$(bindir)/fusermount-glusterfs CLEANFILES = glusterfs-3.7.6/contrib/fuse-util/PaxHeaders.7244/mount_util.c0000644000076200007630000000013112617742532022451 xustar000000000000000030 mtime=1447019866.028471675 30 atime=1447019866.367466575 29 ctime=1447019945.29327919 glusterfs-3.7.6/contrib/fuse-util/mount_util.c0000644000076200007630000000246012617742532022671 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ #include #include #include #include #include #include int fuse_mnt_check_empty(const char *progname, const char *mnt, mode_t rootmode, off_t rootsize) { int isempty = 1; if (S_ISDIR(rootmode)) { struct dirent *ent; DIR *dp = opendir(mnt); if (dp == NULL) { fprintf(stderr, "%s: failed to open mountpoint for reading: %s\n", progname, strerror(errno)); return -1; } while ((ent = readdir(dp)) != NULL) { if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) { isempty = 0; break; } } closedir(dp); } else if (rootsize) isempty = 0; if (!isempty) { fprintf(stderr, "%s: mountpoint is not empty\n", progname); fprintf(stderr, "%s: if you are sure this is safe, use the 'nonempty' mount option\n", progname); return -1; } return 0; } int fuse_mnt_check_fuseblk(void) { char buf[256]; FILE *f = fopen("/proc/filesystems", "r"); if (!f) return 1; while (fgets(buf, sizeof(buf), f)) if (strstr(buf, "fuseblk\n")) { fclose(f); return 1; } fclose(f); return 0; } glusterfs-3.7.6/contrib/fuse-util/PaxHeaders.7244/fusermount.c0000644000076200007630000000013212617742532022462 xustar000000000000000030 mtime=1447019866.028471675 30 atime=1447019866.367466575 30 ctime=1447019945.290279236 glusterfs-3.7.6/contrib/fuse-util/fusermount.c0000644000076200007630000006751712617742532022717 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU GPL. See the file COPYING. */ /* This program does the mounting and unmounting of FUSE filesystems */ #include #include "mount_util.h" #ifndef HAVE_UMOUNT2 #include "mount-gluster-compat.h" #endif #include #include #include #include #include #include #include #include #include #include #if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS) #include #endif /* __NetBSD__ */ #include #include #ifdef HAVE_SET_FSID #include #endif #ifdef GF_DARWIN_HOST_OS #include #endif #include #include #include #include #define FUSE_DEVFD_ENV "_FUSE_DEVFD" #define FUSE_COMMFD_ENV "_FUSE_COMMFD" #define FUSE_DEV_OLD "/proc/fs/fuse/dev" #define FUSE_DEV_NEW "/dev/fuse" #define FUSE_VERSION_FILE_OLD "/proc/fs/fuse/version" #define FUSE_CONF "/etc/fuse.conf" #ifndef MS_DIRSYNC #define MS_DIRSYNC 128 #endif #ifndef MS_REC #define MS_REC 16384 #endif #ifndef MS_PRIVATE #define MS_PRIVATE (1<<18) #endif static const char *progname; static int user_allow_other = 0; static int mount_max = 1000; static const char *get_user_name(void) { struct passwd *pw = getpwuid(getuid()); if (pw != NULL && pw->pw_name != NULL) return pw->pw_name; else { fprintf(stderr, "%s: could not determine username\n", progname); return NULL; } } #ifdef HAVE_SET_FSID static uid_t oldfsuid; static gid_t oldfsgid; #endif static void drop_privs(void) { if (getuid() != 0) { #ifdef HAVE_SET_FSID oldfsuid = setfsuid(getuid()); oldfsgid = setfsgid(getgid()); #else fprintf(stderr, "%s: Implement alternative setfsuid/gid \n", progname); #endif } } static void restore_privs(void) { if (getuid() != 0) { #ifdef HAVE_SET_FSID setfsuid(oldfsuid); setfsgid(oldfsgid); #else fprintf(stderr, "%s: Implement alternative setfsuid/gid \n", progname); #endif } } #ifndef IGNORE_MTAB /* * Make sure that /etc/mtab is checked and updated atomically */ static int lock_umount(void) { const char *mtab_lock = _PATH_MOUNTED ".fuselock"; int mtablock; int res; struct stat mtab_stat; /* /etc/mtab could be a symlink to /proc/mounts */ if (lstat(_PATH_MOUNTED, &mtab_stat) == 0 && S_ISLNK(mtab_stat.st_mode)) return -1; mtablock = open(mtab_lock, O_RDWR | O_CREAT, 0600); if (mtablock == -1) { fprintf(stderr, "%s: unable to open fuse lock file: %s\n", progname, strerror(errno)); return -1; } res = lockf(mtablock, F_LOCK, 0); if (res < 0) { fprintf(stderr, "%s: error getting lock: %s\n", progname, strerror(errno)); close(mtablock); return -1; } return mtablock; } static void unlock_umount(int mtablock) { if (mtablock >= 0) { int res; res = lockf(mtablock, F_ULOCK, 0); if (res < 0) { fprintf(stderr, "%s: error releasing lock: %s\n", progname, strerror(errno)); } close(mtablock); } } static int add_mount(const char *source, const char *mnt, const char *type, const char *opts) { return fuse_mnt_add_mount(progname, source, mnt, type, opts); } static int may_unmount(const char *mnt, int quiet) { struct mntent *entp; FILE *fp; const char *user = NULL; char uidstr[32]; unsigned uidlen = 0; int found; const char *mtab = _PATH_MOUNTED; user = get_user_name(); if (user == NULL) return -1; fp = setmntent(mtab, "r"); if (fp == NULL) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, mtab, strerror(errno)); return -1; } uidlen = sprintf(uidstr, "%u", getuid()); found = 0; while ((entp = getmntent(fp)) != NULL) { if (!found && strcmp(entp->mnt_dir, mnt) == 0 && (strcmp(entp->mnt_type, "fuse") == 0 || strcmp(entp->mnt_type, "fuseblk") == 0 || strncmp(entp->mnt_type, "fuse.", 5) == 0 || strncmp(entp->mnt_type, "fuseblk.", 8) == 0)) { char *p = strstr(entp->mnt_opts, "user="); if (p && (p == entp->mnt_opts || *(p-1) == ',') && strcmp(p + 5, user) == 0) { found = 1; break; } /* /etc/mtab is a link pointing to /proc/mounts: */ else if ((p = strstr(entp->mnt_opts, "user_id=")) && (p == entp->mnt_opts || *(p-1) == ',') && strncmp(p + 8, uidstr, uidlen) == 0 && (*(p+8+uidlen) == ',' || *(p+8+uidlen) == '\0')) { found = 1; break; } } } endmntent(fp); if (!found) { if (!quiet) fprintf(stderr, "%s: entry for %s not found in %s\n", progname, mnt, mtab); return -1; } return 0; } /* * Check whether the file specified in "fusermount -u" is really a * mountpoint and not a symlink. This is necessary otherwise the user * could move the mountpoint away and replace it with a symlink * pointing to an arbitrary mount, thereby tricking fusermount into * unmounting that (umount(2) will follow symlinks). * * This is the child process running in a separate mount namespace, so * we don't mess with the global namespace and if the process is * killed for any reason, mounts are automatically cleaned up. * * First make sure nothing is propagated back into the parent * namespace by marking all mounts "private". * * Then bind mount parent onto a stable base where the user can't move * it around. * * Finally check /proc/mounts for an entry matching the requested * mountpoint. If it's found then we are OK, and the user can't move * it around within the parent directory as rename() will return * EBUSY. Be careful to ignore any mounts that existed before the * bind. */ static int check_is_mount_child(void *p) { const char **a = p; const char *last = a[0]; const char *mnt = a[1]; int res; const char *procmounts = "/proc/mounts"; int found; FILE *fp; struct mntent *entp; int count; res = mount("", "/", "", MS_PRIVATE | MS_REC, NULL); if (res == -1) { fprintf(stderr, "%s: failed to mark mounts private: %s\n", progname, strerror(errno)); return 1; } fp = setmntent(procmounts, "r"); if (fp == NULL) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, procmounts, strerror(errno)); return 1; } count = 0; while (getmntent(fp) != NULL) count++; endmntent(fp); fp = setmntent(procmounts, "r"); if (fp == NULL) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, procmounts, strerror(errno)); return 1; } res = mount(".", "/", "", MS_BIND | MS_REC, NULL); if (res == -1) { fprintf(stderr, "%s: failed to bind parent to /: %s\n", progname, strerror(errno)); return 1; } found = 0; while ((entp = getmntent(fp)) != NULL) { if (count > 0) { count--; continue; } if (entp->mnt_dir[0] == '/' && strcmp(entp->mnt_dir + 1, last) == 0) { found = 1; break; } } endmntent(fp); if (!found) { fprintf(stderr, "%s: %s not mounted\n", progname, mnt); return 1; } return 0; } static pid_t clone_newns(void *a) { char buf[131072]; char *stack = buf + (sizeof(buf) / 2 - ((size_t) buf & 15)); #ifdef __ia64__ extern int __clone2(int (*fn)(void *), void *child_stack_base, size_t stack_size, int flags, void *arg, pid_t *ptid, void *tls, pid_t *ctid); return __clone2(check_is_mount_child, stack, sizeof(buf) / 2, CLONE_NEWNS, a, NULL, NULL, NULL); #else return clone(check_is_mount_child, stack, CLONE_NEWNS, a); #endif } static int check_is_mount(const char *last, const char *mnt) { pid_t pid, p; int status; const char *a[2] = { last, mnt }; pid = clone_newns((void *) a); if (pid == (pid_t) -1) { fprintf(stderr, "%s: failed to clone namespace: %s\n", progname, strerror(errno)); return -1; } p = waitpid(pid, &status, __WCLONE); if (p == (pid_t) -1) { fprintf(stderr, "%s: waitpid failed: %s\n", progname, strerror(errno)); return -1; } if (!WIFEXITED(status)) { fprintf(stderr, "%s: child terminated abnormally (status %i)\n", progname, status); return -1; } if (WEXITSTATUS(status) != 0) return -1; return 0; } static int chdir_to_parent(char *copy, const char **lastp) { char *tmp; const char *parent; char buf[65536]; int res; tmp = strrchr(copy, '/'); if (tmp == NULL || tmp[1] == '\0') { fprintf(stderr, "%s: internal error: invalid abs path: <%s>\n", progname, copy); return -1; } if (tmp != copy) { *tmp = '\0'; parent = copy; *lastp = tmp + 1; } else if (tmp[1] != '\0') { *lastp = tmp + 1; parent = "/"; } else { *lastp = "."; parent = "/"; } res = chdir(parent); if (res == -1) { fprintf(stderr, "%s: failed to chdir to %s: %s\n", progname, parent, strerror(errno)); return -1; } if (getcwd(buf, sizeof(buf)) == NULL) { fprintf(stderr, "%s: failed to obtain current directory: %s\n", progname, strerror(errno)); return -1; } if (strcmp(buf, parent) != 0) { fprintf(stderr, "%s: mountpoint moved (%s -> %s)\n", progname, parent, buf); return -1; } return 0; } static int unmount_fuse_locked(const char *mnt, int quiet, int lazy) { char *copy; const char *last; int res; if (getuid() != 0) { res = may_unmount(mnt, quiet); if (res == -1) return -1; } copy = strdup(mnt); if (copy == NULL) { fprintf(stderr, "%s: failed to allocate memory\n", progname); return -1; } res = chdir_to_parent(copy, &last); if (res == -1) goto out; res = check_is_mount(last, mnt); if (res == -1) goto out; res = fuse_mnt_umount(progname, mnt, last, lazy); out: free(copy); return res; } static int unmount_fuse(const char *mnt, int quiet, int lazy) { int res; int mtablock = lock_umount(); res = unmount_fuse_locked(mnt, quiet, lazy); unlock_umount(mtablock); return res; } static int count_fuse_fs(void) { struct mntent *entp; int count = 0; const char *mtab = _PATH_MOUNTED; FILE *fp = setmntent(mtab, "r"); if (fp == NULL) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, mtab, strerror(errno)); return -1; } while ((entp = getmntent(fp)) != NULL) { if (strcmp(entp->mnt_type, "fuse") == 0 || strncmp(entp->mnt_type, "fuse.", 5) == 0) count ++; } endmntent(fp); return count; } #else /* IGNORE_MTAB */ static int count_fuse_fs() { return 0; } static int add_mount(const char *source, const char *mnt, const char *type, const char *opts) { (void) source; (void) mnt; (void) type; (void) opts; return 0; } static int unmount_fuse(const char *mnt, int quiet, int lazy) { return fuse_mnt_umount(progname, mnt, mnt, lazy); } #endif /* IGNORE_MTAB */ static void strip_line(char *line) { char *s = strchr(line, '#'); if (s != NULL) s[0] = '\0'; for (s = line + strlen(line) - 1; s >= line && isspace((unsigned char) *s); s--); s[1] = '\0'; for (s = line; isspace((unsigned char) *s); s++); if (s != line) memmove(line, s, strlen(s)+1); } static void parse_line(char *line, int linenum) { int tmp; if (strcmp(line, "user_allow_other") == 0) user_allow_other = 1; else if (sscanf(line, "mount_max = %i", &tmp) == 1) mount_max = tmp; else if(line[0]) fprintf(stderr, "%s: unknown parameter in %s at line %i: '%s'\n", progname, FUSE_CONF, linenum, line); } static void read_conf(void) { FILE *fp = fopen(FUSE_CONF, "r"); if (fp != NULL) { int linenum = 1; char line[256]; int isnewline = 1; while (fgets(line, sizeof(line), fp) != NULL) { if (isnewline) { if (strlen(line) && line[strlen(line)-1] == '\n') { strip_line(line); parse_line(line, linenum); } else { isnewline = 0; } } else if(strlen(line) && line[strlen(line)-1] == '\n') { fprintf(stderr, "%s: reading %s: line %i too long\n", progname, FUSE_CONF, linenum); isnewline = 1; } if (isnewline) linenum ++; } if (!isnewline) { fprintf(stderr, "%s: reading %s: missing newline at end of file\n", progname, FUSE_CONF); } fclose(fp); } else if (errno != ENOENT) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, FUSE_CONF, strerror(errno)); } } static int begins_with(const char *s, const char *beg) { if (strncmp(s, beg, strlen(beg)) == 0) return 1; else return 0; } struct mount_flags { const char *opt; unsigned long flag; int on; int safe; }; static struct mount_flags mount_flags[] = { {"rw", MS_RDONLY, 0, 1}, {"ro", MS_RDONLY, 1, 1}, {"suid", MS_NOSUID, 0, 0}, {"nosuid", MS_NOSUID, 1, 1}, {"dev", MS_NODEV, 0, 0}, {"nodev", MS_NODEV, 1, 1}, {"exec", MS_NOEXEC, 0, 1}, {"noexec", MS_NOEXEC, 1, 1}, {"async", MS_SYNCHRONOUS, 0, 1}, {"sync", MS_SYNCHRONOUS, 1, 1}, {"atime", MS_NOATIME, 0, 1}, {"noatime", MS_NOATIME, 1, 1}, {"dirsync", MS_DIRSYNC, 1, 1}, {NULL, 0, 0, 0} }; static int find_mount_flag(const char *s, unsigned len, int *on, int *flag) { int i; for (i = 0; mount_flags[i].opt != NULL; i++) { const char *opt = mount_flags[i].opt; if (strlen(opt) == len && strncmp(opt, s, len) == 0) { *on = mount_flags[i].on; *flag = mount_flags[i].flag; if (!mount_flags[i].safe && getuid() != 0) { *flag = 0; fprintf(stderr, "%s: unsafe option %s ignored\n", progname, opt); } return 1; } } return 0; } static int add_option(char **optsp, const char *opt, unsigned expand) { char *newopts; if (*optsp == NULL) newopts = strdup(opt); else { unsigned oldsize = strlen(*optsp); unsigned newsize = oldsize + 1 + strlen(opt) + expand + 1; newopts = (char *) realloc(*optsp, newsize); if (newopts) sprintf(newopts + oldsize, ",%s", opt); } if (newopts == NULL) { fprintf(stderr, "%s: failed to allocate memory\n", progname); return -1; } *optsp = newopts; return 0; } static int get_mnt_opts(int flags, char *opts, char **mnt_optsp) { int i; size_t l; if (!(flags & MS_RDONLY) && add_option(mnt_optsp, "rw", 0) == -1) return -1; for (i = 0; mount_flags[i].opt != NULL; i++) { if (mount_flags[i].on && (flags & mount_flags[i].flag) && add_option(mnt_optsp, mount_flags[i].opt, 0) == -1) return -1; } if (add_option(mnt_optsp, opts, 0) == -1) return -1; /* remove comma from end of opts*/ l = strlen(*mnt_optsp); if (l && (*mnt_optsp)[l-1] == ',') (*mnt_optsp)[l-1] = '\0'; if (getuid() != 0) { const char *user = get_user_name(); if (user == NULL) return -1; if (add_option(mnt_optsp, "user=", strlen(user)) == -1) return -1; strcat(*mnt_optsp, user); } return 0; } static int opt_eq(const char *s, unsigned len, const char *opt) { if(strlen(opt) == len && strncmp(s, opt, len) == 0) return 1; else return 0; } static int get_string_opt(const char *s, unsigned len, const char *opt, char **val) { int i; unsigned opt_len = strlen(opt); char *d; free(*val); *val = (char *) malloc(len - opt_len + 1); if (!*val) { fprintf(stderr, "%s: failed to allocate memory\n", progname); return 0; } d = *val; s += opt_len; len -= opt_len; for (i = 0; i < len; i++) { if (s[i] == '\\' && i + 1 < len) i++; *d++ = s[i]; } *d = '\0'; return 1; } static int do_mount(const char *mnt, char **typep, mode_t rootmode, int fd, const char *opts, const char *dev, char **sourcep, char **mnt_optsp, off_t rootsize) { int res; int flags = MS_NOSUID | MS_NODEV; char *optbuf; char *mnt_opts = NULL; const char *s; char *d; char *fsname = NULL; char *subtype = NULL; char *source = NULL; char *type = NULL; int check_empty = 1; int blkdev = 0; optbuf = (char *) malloc(strlen(opts) + 128); if (!optbuf) { fprintf(stderr, "%s: failed to allocate memory\n", progname); return -1; } for (s = opts, d = optbuf; *s;) { unsigned len; const char *fsname_str = "fsname="; const char *subtype_str = "subtype="; for (len = 0; s[len]; len++) { if (s[len] == '\\' && s[len + 1]) len++; else if (s[len] == ',') break; } if (begins_with(s, fsname_str)) { if (!get_string_opt(s, len, fsname_str, &fsname)) goto err; } else if (begins_with(s, subtype_str)) { if (!get_string_opt(s, len, subtype_str, &subtype)) goto err; } else if (opt_eq(s, len, "blkdev")) { if (getuid() != 0) { fprintf(stderr, "%s: option blkdev is privileged\n", progname); goto err; } blkdev = 1; } else if (opt_eq(s, len, "nonempty")) { check_empty = 0; } else if (!begins_with(s, "fd=") && !begins_with(s, "rootmode=") && !begins_with(s, "user_id=") && !begins_with(s, "group_id=")) { int on; int flag; int skip_option = 0; if (opt_eq(s, len, "large_read")) { struct utsname utsname; unsigned kmaj, kmin; res = uname(&utsname); if (res == 0 && sscanf(utsname.release, "%u.%u", &kmaj, &kmin) == 2 && (kmaj > 2 || (kmaj == 2 && kmin > 4))) { fprintf(stderr, "%s: note: 'large_read' mount option is deprecated for %i.%i kernels\n", progname, kmaj, kmin); skip_option = 1; } } if (getuid() != 0 && !user_allow_other && (opt_eq(s, len, "allow_other") || opt_eq(s, len, "allow_root"))) { fprintf(stderr, "%s: option %.*s only allowed if 'user_allow_other' is set in /etc/fuse.conf\n", progname, len, s); goto err; } if (!skip_option) { if (find_mount_flag(s, len, &on, &flag)) { if (on) flags |= flag; else flags &= ~flag; } else { memcpy(d, s, len); d += len; *d++ = ','; } } } s += len; if (*s) s++; } *d = '\0'; res = get_mnt_opts(flags, optbuf, &mnt_opts); if (res == -1) goto err; sprintf(d, "fd=%i,rootmode=%o,user_id=%i,group_id=%i", fd, rootmode, getuid(), getgid()); if (check_empty && fuse_mnt_check_empty(progname, mnt, rootmode, rootsize) == -1) goto err; source = malloc((fsname ? strlen(fsname) : 0) + (subtype ? strlen(subtype) : 0) + strlen(dev) + 32); type = malloc((subtype ? strlen(subtype) : 0) + 32); if (!type || !source) { fprintf(stderr, "%s: failed to allocate memory\n", progname); goto err; } if (subtype) sprintf(type, "%s.%s", blkdev ? "fuseblk" : "fuse", subtype); else strcpy(type, blkdev ? "fuseblk" : "fuse"); if (fsname) strcpy(source, fsname); else strcpy(source, subtype ? subtype : dev); res = mount(source, mnt, type, flags, optbuf); if (res == -1 && errno == ENODEV && subtype) { /* Probably missing subtype support */ strcpy(type, blkdev ? "fuseblk" : "fuse"); if (fsname) { if (!blkdev) sprintf(source, "%s#%s", subtype, fsname); } else { strcpy(source, type); } res = mount(source, mnt, type, flags, optbuf); } if (res == -1 && errno == EINVAL) { /* It could be an old version not supporting group_id */ sprintf(d, "fd=%i,rootmode=%o,user_id=%i", fd, rootmode, getuid()); res = mount(source, mnt, type, flags, optbuf); } if (res == -1) { int errno_save = errno; if (blkdev && errno == ENODEV && !fuse_mnt_check_fuseblk()) fprintf(stderr, "%s: 'fuseblk' support missing\n", progname); else fprintf(stderr, "%s: mount failed: %s\n", progname, strerror(errno_save)); goto err; } *sourcep = source; *typep = type; *mnt_optsp = mnt_opts; free(fsname); free(optbuf); return 0; err: free(fsname); free(subtype); free(source); free(type); free(mnt_opts); free(optbuf); return -1; } static int check_version(const char *dev) { int res; int majorver; int minorver; const char *version_file; FILE *vf; if (strcmp(dev, FUSE_DEV_OLD) != 0) return 0; version_file = FUSE_VERSION_FILE_OLD; vf = fopen(version_file, "r"); if (vf == NULL) { fprintf(stderr, "%s: kernel interface too old\n", progname); return -1; } res = fscanf(vf, "%i.%i", &majorver, &minorver); fclose(vf); if (res != 2) { fprintf(stderr, "%s: error reading %s\n", progname, version_file); return -1; } if (majorver < 3) { fprintf(stderr, "%s: kernel interface too old\n", progname); return -1; } return 0; } static int check_perm(const char **mntp, struct stat *stbuf, int *mountpoint_fd) { int res; const char *mnt = *mntp; const char *origmnt = mnt; res = lstat(mnt, stbuf); if (res == -1) { fprintf(stderr, "%s: failed to access mountpoint %s: %s\n", progname, mnt, strerror(errno)); return -1; } /* No permission checking is done for root */ if (getuid() == 0) return 0; if (S_ISDIR(stbuf->st_mode)) { res = chdir(mnt); if (res == -1) { fprintf(stderr, "%s: failed to chdir to mountpoint: %s\n", progname, strerror(errno)); return -1; } mnt = *mntp = "."; res = lstat(mnt, stbuf); if (res == -1) { fprintf(stderr, "%s: failed to access mountpoint %s: %s\n", progname, origmnt, strerror(errno)); return -1; } if ((stbuf->st_mode & S_ISVTX) && stbuf->st_uid != getuid()) { fprintf(stderr, "%s: mountpoint %s not owned by user\n", progname, origmnt); return -1; } res = access(mnt, W_OK); if (res == -1) { fprintf(stderr, "%s: user has no write access to mountpoint %s\n", progname, origmnt); return -1; } } else if (S_ISREG(stbuf->st_mode)) { static char procfile[256]; *mountpoint_fd = open(mnt, O_WRONLY); if (*mountpoint_fd == -1) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, mnt, strerror(errno)); return -1; } res = fstat(*mountpoint_fd, stbuf); if (res == -1) { fprintf(stderr, "%s: failed to access mountpoint %s: %s\n", progname, mnt, strerror(errno)); return -1; } if (!S_ISREG(stbuf->st_mode)) { fprintf(stderr, "%s: mountpoint %s is no longer a regular file\n", progname, mnt); return -1; } sprintf(procfile, "/proc/self/fd/%i", *mountpoint_fd); *mntp = procfile; } else { fprintf(stderr, "%s: mountpoint %s is not a directory or a regular file\n", progname, mnt); return -1; } return 0; } static int try_open(const char *dev, char **devp, int silent) { int fd = open(dev, O_RDWR); if (fd != -1) { *devp = strdup(dev); if (*devp == NULL) { fprintf(stderr, "%s: failed to allocate memory\n", progname); close(fd); fd = -1; } } else if (errno == ENODEV || errno == ENOENT)/* check for ENOENT too, for the udev case */ return -2; else if (!silent) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, dev, strerror(errno)); } return fd; } static int try_open_fuse_device(char **devp) { int fd; int err; drop_privs(); fd = try_open(FUSE_DEV_NEW, devp, 0); restore_privs(); if (fd >= 0) return fd; err = fd; fd = try_open(FUSE_DEV_OLD, devp, 1); if (fd >= 0) return fd; return err; } static int open_fuse_device(char **devp) { int fd = try_open_fuse_device(devp); if (fd >= -1) return fd; fprintf(stderr, "%s: fuse device not found, try 'modprobe fuse' first\n", progname); return -1; } static int check_fuse_device(char *devfd, char **devp) { int res; char *devlink; res = asprintf(&devlink, "/proc/self/fd/%s", devfd); if (res == -1) { fprintf(stderr, "%s: failed to allocate memory\n", progname); return -1; } *devp = (char *) calloc(1, PATH_MAX + 1); if (!*devp) { fprintf(stderr, "%s: failed to allocate memory\n", progname); free(devlink); return -1; } res = readlink (devlink, *devp, PATH_MAX); free (devlink); if (res == -1) { fprintf(stderr, "%s: specified fuse fd is invalid\n", progname); return -1; } return atoi(devfd); } static int mount_fuse(const char *mnt, const char *opts, char *devfd) { int res; int fd; char *dev; struct stat stbuf; char *type = NULL; char *source = NULL; char *mnt_opts = NULL; const char *real_mnt = mnt; int mountpoint_fd = -1; fd = devfd ? check_fuse_device(devfd, &dev) : open_fuse_device(&dev); if (fd == -1) return -1; drop_privs(); read_conf(); if (getuid() != 0 && mount_max != -1) { int mount_count = count_fuse_fs(); if (mount_count >= mount_max) { fprintf(stderr, "%s: too many FUSE filesystems mounted; mount_max=N can be set in /etc/fuse.conf\n", progname); goto fail_close_fd; } } res = check_version(dev); if (res != -1) { res = check_perm(&real_mnt, &stbuf, &mountpoint_fd); restore_privs(); if (res != -1) res = do_mount(real_mnt, &type, stbuf.st_mode & S_IFMT, fd, opts, dev, &source, &mnt_opts, stbuf.st_size); } else restore_privs(); if (mountpoint_fd != -1) close(mountpoint_fd); if (res == -1) goto fail_close_fd; res = chdir("/"); if (res == -1) { fprintf(stderr, "%s: failed to chdir to '/'\n", progname); goto fail_close_fd; } if (geteuid() == 0) { res = add_mount(source, mnt, type, mnt_opts); if (res == -1) { /* Can't clean up mount in a non-racy way */ goto fail_close_fd; } } out_free: free(source); free(type); free(mnt_opts); free(dev); return fd; fail_close_fd: close(fd); fd = -1; goto out_free; } static int send_fd(int sock_fd, int fd) { int retval; struct msghdr msg; struct cmsghdr *p_cmsg; struct iovec vec; size_t cmsgbuf[CMSG_SPACE(sizeof(fd)) / sizeof(size_t)]; int *p_fds; char sendchar = 0; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); p_cmsg = CMSG_FIRSTHDR(&msg); p_cmsg->cmsg_level = SOL_SOCKET; p_cmsg->cmsg_type = SCM_RIGHTS; p_cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); p_fds = (int *) CMSG_DATA(p_cmsg); *p_fds = fd; msg.msg_controllen = p_cmsg->cmsg_len; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &vec; msg.msg_iovlen = 1; msg.msg_flags = 0; /* "To pass file descriptors or credentials you need to send/read at * least one byte" (man 7 unix) */ vec.iov_base = &sendchar; vec.iov_len = sizeof(sendchar); while ((retval = sendmsg(sock_fd, &msg, 0)) == -1 && errno == EINTR); if (retval != 1) { perror("sending file descriptor"); return -1; } return 0; } static void usage(void) { fprintf(stderr, "%s: [options] mountpoint\n" "Options:\n" " -h print help\n" " -V print version\n" " -o opt[,opt...] mount options\n" " -u unmount\n" " -q quiet\n" " -z lazy unmount\n", progname); exit(1); } static void show_version(void) { printf("fusermount version: %s\n", PACKAGE_VERSION); exit(0); } int main(int argc, char *argv[]) { int ch; int fd; int res; char *origmnt; char *mnt; static int unmount = 0; static int lazy = 0; static int quiet = 0; char *devfd; char *commfd; int cfd; const char *opts = ""; static const struct option long_opts[] = { {"unmount", no_argument, NULL, 'u'}, {"lazy", no_argument, NULL, 'z'}, {"quiet", no_argument, NULL, 'q'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0}}; progname = strdup(argv[0]); if (progname == NULL) { fprintf(stderr, "%s: failed to allocate memory\n", argv[0]); exit(1); } while ((ch = getopt_long(argc, argv, "hVo:uzq", long_opts, NULL)) != -1) { switch (ch) { case 'h': usage(); break; case 'V': show_version(); break; case 'o': opts = optarg; break; case 'u': unmount = 1; break; case 'z': lazy = 1; break; case 'q': quiet = 1; break; default: exit(1); } } if (lazy && !unmount) { fprintf(stderr, "%s: -z can only be used with -u\n", progname); exit(1); } if (optind >= argc) { fprintf(stderr, "%s: missing mountpoint argument\n", progname); exit(1); } else if (argc > optind + 1) { fprintf(stderr, "%s: extra arguments after the mountpoint\n", progname); exit(1); } origmnt = argv[optind]; drop_privs(); mnt = fuse_mnt_resolve_path(progname, origmnt); if (mnt != NULL) { res = chdir("/"); if (res == -1) { fprintf(stderr, "%s: failed to chdir to '/'\n", progname); exit(1); } } restore_privs(); if (mnt == NULL) exit(1); umask(033); if (unmount) { if (geteuid() == 0) res = unmount_fuse(mnt, quiet, lazy); else { res = umount2(mnt, lazy ? 2 : 0); if (res == -1 && !quiet) fprintf(stderr, "%s: failed to unmount %s: %s\n", progname, mnt, strerror(errno)); } if (res == -1) exit(1); return 0; } devfd = getenv(FUSE_DEVFD_ENV); if (devfd == NULL) { commfd = getenv(FUSE_COMMFD_ENV); if (commfd == NULL) { fprintf(stderr, "%s: old style mounting not supported\n", progname); exit(1); } } fd = mount_fuse(mnt, opts, devfd); if (fd == -1) exit(1); if (devfd == NULL) { cfd = atoi(commfd); res = send_fd(cfd, fd); if (res == -1) exit(1); } return 0; } glusterfs-3.7.6/contrib/fuse-util/PaxHeaders.7244/Makefile.in0000644000076200007630000000013212617742544022157 xustar000000000000000030 mtime=1447019876.226318251 30 atime=1447019919.074673622 30 ctime=1447019945.283279341 glusterfs-3.7.6/contrib/fuse-util/Makefile.in0000644000076200007630000005503312617742544022402 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = fusermount-glusterfs$(EXEEXT) subdir = contrib/fuse-util DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in COPYING ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/contrib/aclocal/mkdirp.m4 \ $(top_srcdir)/contrib/aclocal/python.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_fusermount_glusterfs_OBJECTS = fusermount.$(OBJEXT) \ mount_util.$(OBJEXT) mount-common.$(OBJEXT) fusermount_glusterfs_OBJECTS = $(am_fusermount_glusterfs_OBJECTS) fusermount_glusterfs_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(fusermount_glusterfs_SOURCES) DIST_SOURCES = $(fusermount_glusterfs_SOURCES) HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ACL_LIBS = @ACL_LIBS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LIBTOOLFLAGS = @AM_LIBTOOLFLAGS@ AM_MAKEFLAGS = @AM_MAKEFLAGS@ AR = @AR@ ARGP_STANDALONE_CPPFLAGS = @ARGP_STANDALONE_CPPFLAGS@ ARGP_STANDALONE_DIR = @ARGP_STANDALONE_DIR@ ARGP_STANDALONE_LDADD = @ARGP_STANDALONE_LDADD@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_PYTHON_INC = @BUILD_PYTHON_INC@ BUILD_PYTHON_LIB = @BUILD_PYTHON_LIB@ BUILD_PYTHON_SITE_PACKAGES = @BUILD_PYTHON_SITE_PACKAGES@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONTRIBDIR = @CONTRIBDIR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FUSERMOUNT_SUBDIR = @FUSERMOUNT_SUBDIR@ FUSE_CLIENT_SUBDIR = @FUSE_CLIENT_SUBDIR@ GEOREP_EXTRAS_SUBDIR = @GEOREP_EXTRAS_SUBDIR@ GFAPI_EXTRA_LDFLAGS = @GFAPI_EXTRA_LDFLAGS@ GFAPI_LIBS = @GFAPI_LIBS@ GFAPI_LT_VERSION = @GFAPI_LT_VERSION@ GFAPI_VERSION = @GFAPI_VERSION@ GF_CFLAGS = @GF_CFLAGS@ GF_CPPFLAGS = @GF_CPPFLAGS@ GF_DISTRIBUTION = @GF_DISTRIBUTION@ GF_FUSE_CFLAGS = @GF_FUSE_CFLAGS@ GF_FUSE_LDADD = @GF_FUSE_LDADD@ GF_HOST_OS = @GF_HOST_OS@ GF_LDADD = @GF_LDADD@ GF_LDFLAGS = @GF_LDFLAGS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GLUPY_SUBDIR = @GLUPY_SUBDIR@ GLUPY_SUBDIR_MAKEFILE = @GLUPY_SUBDIR_MAKEFILE@ GLUPY_SUBDIR_SRC_MAKEFILE = @GLUPY_SUBDIR_SRC_MAKEFILE@ GLUSTERD_VOLFILE = @GLUSTERD_VOLFILE@ GLUSTERD_WORKDIR = @GLUSTERD_WORKDIR@ GLUSTERFSD_MISCDIR = @GLUSTERFSD_MISCDIR@ GLUSTERFS_LIBEXECDIR = @GLUSTERFS_LIBEXECDIR@ GREP = @GREP@ HAVE_BACKTRACE = @HAVE_BACKTRACE@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_MALLOC_STATS = @HAVE_MALLOC_STATS@ HAVE_SPINLOCK = @HAVE_SPINLOCK@ HAVE_STRNLEN = @HAVE_STRNLEN@ IBVERBS_SUBDIR = @IBVERBS_SUBDIR@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBAIO = @LIBAIO@ LIBGFCHANGELOG_LT_VERSION = @LIBGFCHANGELOG_LT_VERSION@ LIBGFCHANGELOG_VERSION = @LIBGFCHANGELOG_VERSION@ LIBGFDB_VERSION = @LIBGFDB_VERSION@ LIBGFRPC_LT_VERSION = @LIBGFRPC_LT_VERSION@ LIBGFXDR_LT_VERSION = @LIBGFXDR_LT_VERSION@ LIBGLUSTERFS_LT_VERSION = @LIBGLUSTERFS_LT_VERSION@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCF_SUBDIR = @OCF_SUBDIR@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_RELEASE = @PACKAGE_RELEASE@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_UUID = @PKGCONFIG_UUID@ PKG_CONFIG = @PKG_CONFIG@ PYTHON = @PYTHON@ PYTHONDEV_CFLAGS = @PYTHONDEV_CFLAGS@ PYTHONDEV_CPPFLAGS = @PYTHONDEV_CPPFLAGS@ PYTHONDEV_LDFLAGS = @PYTHONDEV_LDFLAGS@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RDMA_SUBDIR = @RDMA_SUBDIR@ RLLIBS = @RLLIBS@ RPCGEN = @RPCGEN@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIZEOF_INT = @SIZEOF_INT@ SIZEOF_LONG = @SIZEOF_LONG@ SIZEOF_LONG_LONG = @SIZEOF_LONG_LONG@ SIZEOF_SHORT = @SIZEOF_SHORT@ SQLITE_CFLAGS = @SQLITE_CFLAGS@ SQLITE_LIBS = @SQLITE_LIBS@ STRIP = @STRIP@ SYNCDAEMON_COMPILE = @SYNCDAEMON_COMPILE@ SYNCDAEMON_SUBDIR = @SYNCDAEMON_SUBDIR@ UMOUNTD_SUBDIR = @UMOUNTD_SUBDIR@ UNITTEST_CFLAGS = @UNITTEST_CFLAGS@ UNITTEST_LDFLAGS = @UNITTEST_LDFLAGS@ UNITTEST_LIBS = @UNITTEST_LIBS@ URCU_CDS_CFLAGS = @URCU_CDS_CFLAGS@ URCU_CDS_LIBS = @URCU_CDS_LIBS@ URCU_CFLAGS = @URCU_CFLAGS@ URCU_LIBS = @URCU_LIBS@ USE_POSIX_ACLS = @USE_POSIX_ACLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ VERSION = @VERSION@ XML2_CONFIG = @XML2_CONFIG@ XML_CPPFLAGS = @XML_CPPFLAGS@ XML_LIBS = @XML_LIBS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ initdir = @initdir@ install_sh = @install_sh@ launchddir = @launchddir@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ mountutildir = @mountutildir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ shrext_cmds = @shrext_cmds@ srcdir = @srcdir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemddir = @systemddir@ target_alias = @target_alias@ tmpfilesdir = @tmpfilesdir@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ fusermount_glusterfs_SOURCES = fusermount.c mount_util.c $(CONTRIBDIR)/fuse-lib/mount-common.c noinst_HEADERS = $(CONTRIBDIR)/fuse-include/mount_util.h AM_CPPFLAGS = $(GF_CPPFLAGS) -DFUSE_UTIL -I$(CONTRIBDIR)/fuse-include -I$(CONTRIBDIR)/fuse-lib AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/fuse-util/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign contrib/fuse-util/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list fusermount-glusterfs$(EXEEXT): $(fusermount_glusterfs_OBJECTS) $(fusermount_glusterfs_DEPENDENCIES) @rm -f fusermount-glusterfs$(EXEEXT) $(AM_V_CCLD)$(LINK) $(fusermount_glusterfs_OBJECTS) $(fusermount_glusterfs_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusermount.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount-common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount_util.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mount-common.o: $(CONTRIBDIR)/fuse-lib/mount-common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mount-common.o -MD -MP -MF $(DEPDIR)/mount-common.Tpo -c -o mount-common.o `test -f '$(CONTRIBDIR)/fuse-lib/mount-common.c' || echo '$(srcdir)/'`$(CONTRIBDIR)/fuse-lib/mount-common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mount-common.Tpo $(DEPDIR)/mount-common.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(CONTRIBDIR)/fuse-lib/mount-common.c' object='mount-common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mount-common.o `test -f '$(CONTRIBDIR)/fuse-lib/mount-common.c' || echo '$(srcdir)/'`$(CONTRIBDIR)/fuse-lib/mount-common.c mount-common.obj: $(CONTRIBDIR)/fuse-lib/mount-common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mount-common.obj -MD -MP -MF $(DEPDIR)/mount-common.Tpo -c -o mount-common.obj `if test -f '$(CONTRIBDIR)/fuse-lib/mount-common.c'; then $(CYGPATH_W) '$(CONTRIBDIR)/fuse-lib/mount-common.c'; else $(CYGPATH_W) '$(srcdir)/$(CONTRIBDIR)/fuse-lib/mount-common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mount-common.Tpo $(DEPDIR)/mount-common.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(CONTRIBDIR)/fuse-lib/mount-common.c' object='mount-common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mount-common.obj `if test -f '$(CONTRIBDIR)/fuse-lib/mount-common.c'; then $(CYGPATH_W) '$(CONTRIBDIR)/fuse-lib/mount-common.c'; else $(CYGPATH_W) '$(srcdir)/$(CONTRIBDIR)/fuse-lib/mount-common.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-exec-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-exec-hook \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS install-exec-hook: -chown root $(DESTDIR)$(bindir)/fusermount-glusterfs chmod u+s $(DESTDIR)$(bindir)/fusermount-glusterfs # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/contrib/fuse-util/PaxHeaders.7244/COPYING0000644000076200007630000000013112617742532021141 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 30 ctime=1447019945.287279281 glusterfs-3.7.6/contrib/fuse-util/COPYING0000644000076200007630000004311012617742532021356 0ustar00jenkinsjenkins00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 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. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, 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 software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, 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 redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's 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 give any other recipients of the Program a copy of this License along with the Program. 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 Program or any portion of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, 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 Program, 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 Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) 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; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, 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 executable. 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. If distribution of executable or 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 counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. 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 Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program 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. 7. 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 Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program 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 Program. 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. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program 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. 9. The Free Software Foundation may publish revised and/or new versions of the 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 Program 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 Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, 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 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. 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. Copyright (C) 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 Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. glusterfs-3.7.6/contrib/PaxHeaders.7244/libgen0000644000076200007630000000013012617742634017356 xustar000000000000000030 mtime=1447019932.231475691 28 atime=1447019949.3342184 30 ctime=1447019932.231475691 glusterfs-3.7.6/contrib/libgen/0000755000076200007630000000000012617742634017652 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/libgen/PaxHeaders.7244/dirname_r.c0000644000076200007630000000013112617742532021535 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019932.231475691 glusterfs-3.7.6/contrib/libgen/dirname_r.c0000644000076200007630000002007412617742532021756 0ustar00jenkinsjenkins00000000000000/* * Borrowed from glibc-2.12.1/string/memrchr.c * Based on strlen implementation by Torbjorn Granlund (tege@sics.se), * Removed code for long bigger than 32 bytes, renamed __ptr_t as void * * changed reg_char type to char. */ #include #include #ifdef THREAD_UNSAFE_DIRNAME /* memrchr -- find the last occurrence of a byte in a memory block Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). The GNU C 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. The GNU C 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 the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ void * __memrchr (s, c_in, n) const void * s; int c_in; size_t n; { const unsigned char *char_ptr; const unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; unsigned char c; c = (unsigned char) c_in; /* Handle the last few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = (const unsigned char *) s + n; n > 0 && ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; --n) if (*--char_ptr == c) return (void *) char_ptr; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (const unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ if (sizeof (longword) != 4 && sizeof (longword) != 8) abort (); magic_bits = 0x7efefeff; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); charmask |= charmask << 16; /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ while (n >= sizeof (longword)) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. 3) But wait! Aren't we looking for C, not zero? Good point. So what we do is XOR LONGWORD with a longword, each of whose bytes is C. This turns each byte that is C into a zero. */ longword = *--longword_ptr ^ charmask; /* Add MAGIC_BITS to LONGWORD. */ if ((((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) != 0) { /* Which of the bytes was C? If none of them were, it was a misfire; continue the search. */ const unsigned char *cp = (const unsigned char *) longword_ptr; if (cp[3] == c) return (void *) &cp[3]; if (cp[2] == c) return (void *) &cp[2]; if (cp[1] == c) return (void *) &cp[1]; if (cp[0] == c) return (void *) cp; } n -= sizeof (longword); } char_ptr = (const unsigned char *) longword_ptr; while (n-- > 0) { if (*--char_ptr == c) return (void *) char_ptr; } return 0; } /* * Borrowed from glibc-2.12.1/misc/dirname.c */ /* dirname - return directory part of PATH. Copyright (C) 1996, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. The GNU C 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. The GNU C 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 the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ char * dirname_r (char *path) { static const char dot[] = "."; char *last_slash; /* Find last '/'. */ last_slash = path != NULL ? strrchr (path, '/') : NULL; if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') { /* Determine whether all remaining characters are slashes. */ char *runp; for (runp = last_slash; runp != path; --runp) if (runp[-1] != '/') break; /* The '/' is the last character, we have to look further. */ if (runp != path) last_slash = __memrchr (path, '/', runp - path); } if (last_slash != NULL) { /* Determine whether all remaining characters are slashes. */ char *runp; for (runp = last_slash; runp != path; --runp) if (runp[-1] != '/') break; /* Terminate the path. */ if (runp == path) { /* The last slash is the first character in the string. We have to return "/". As a special case we have to return "//" if there are exactly two slashes at the beginning of the string. See XBD 4.10 Path Name Resolution for more information. */ if (last_slash == path + 1) ++last_slash; else last_slash = path + 1; } else last_slash = runp; last_slash[0] = '\0'; } else /* This assignment is ill-designed but the XPG specs require to return a string containing "." in any case no directory part is found and so a static and constant string is required. */ path = (char *) dot; return path; } #endif /* THREAD_UNSAFE_DIRNAME */ glusterfs-3.7.6/contrib/libgen/PaxHeaders.7244/basename_r.c0000644000076200007630000000013112617742532021671 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019932.228475736 glusterfs-3.7.6/contrib/libgen/basename_r.c0000644000076200007630000000250612617742532022112 0ustar00jenkinsjenkins00000000000000/* * borrowed from glibc-2.12.1/string/basename.c * Modified to return "." for NULL or "", as required for SUSv2. */ #include #include #ifdef THREAD_UNSAFE_BASENAME /* Return the name-within-directory of a file name. Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ char * basename_r (filename) const char *filename; { char *p; if ((filename == NULL) || (*filename == '\0')) return "."; p = strrchr (filename, '/'); return p ? p + 1 : (char *) filename; } #endif /* THREAD_UNSAFE_BASENAME */ glusterfs-3.7.6/contrib/PaxHeaders.7244/argp-standalone0000644000076200007630000000013012617742655021200 xustar000000000000000030 mtime=1447019949.322218581 28 atime=1447019949.3342184 30 ctime=1447019949.322218581 glusterfs-3.7.6/contrib/argp-standalone/0000755000076200007630000000000012617742655021474 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/strndup.c0000644000076200007630000000013012617742532023112 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.877511103 glusterfs-3.7.6/contrib/argp-standalone/strndup.c0000644000076200007630000000073412617742532023335 0ustar00jenkinsjenkins00000000000000/* strndup.c * */ /* Written by Niels Möller * * This file is hereby placed in the public domain. */ #include #include char * strndup (const char *, size_t); char * strndup (const char *s, size_t size) { char *r; char *end = memchr(s, 0, size); if (end) /* Length + 1 */ size = end - s + 1; r = malloc(size); if (size) { memcpy(r, s, size-1); r[size-1] = '\0'; } return r; } glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/vsnprintf.c0000644000076200007630000000013012617742532023444 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.877511103 glusterfs-3.7.6/contrib/argp-standalone/vsnprintf.c0000644000076200007630000004602112617742532023666 0ustar00jenkinsjenkins00000000000000/* Copied from http://www.fiction.net/blong/programs/snprintf.c */ /* * Copyright Patrick Powell 1995 * This code is based on code written by Patrick Powell (papowell@astart.com) * It may be used for any purpose as long as this notice remains intact * on all source code distributions */ /************************************************************** * Original: * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 * A bombproof version of doprnt (dopr) included. * Sigh. This sort of thing is always nasty do deal with. Note that * the version here does not include floating point... * * snprintf() is used instead of sprintf() as it does limit checks * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from * causing nast effects. * * More Recently: * Brandon Long 9/15/96 for mutt 0.43 * This was ugly. It is still ugly. I opted out of floating point * numbers, but the formatter understands just about everything * from the normal C string format, at least as far as I can tell from * the Solaris 2.5 printf(3S) man page. * * Brandon Long 10/22/97 for mutt 0.87.1 * Ok, added some minimal floating point support, which means this * probably requires libm on most operating systems. Don't yet * support the exponent (e,E) and sigfig (g,G). Also, fmtint() * was pretty badly broken, it just wasn't being exercised in ways * which showed it, so that's been fixed. Also, formated the code * to mutt conventions, and removed dead code left over from the * original. Also, there is now a builtin-test, just compile with: * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm * and run snprintf for results. * * Thomas Roessler 01/27/98 for mutt 0.89i * The PGP code was using unsigned hexadecimal formats. * Unfortunately, unsigned formats simply didn't work. * * Michael Elkins 03/05/98 for mutt 0.90.8 * The original code assumed that both snprintf() and vsnprintf() were * missing. Some systems only have snprintf() but not vsnprintf(), so * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. * * Andrew Tridgell (tridge@samba.org) Oct 1998 * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * * Russ Allbery 2000-08-26 * fixed return value to comply with C99 * fixed handling of snprintf(NULL, ...) * * Niels Möller 2004-03-05 * fixed calls to isdigit to use unsigned char. * fixed calls to va_arg; short arguments are always passed as int. * **************************************************************/ #if HAVE_CONFIG_H # include "config.h" #endif #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) #include #include #include /* Define this as a fall through, HAVE_STDARG_H is probably already set */ #define HAVE_VARARGS_H /* varargs declarations: */ #if defined(HAVE_STDARG_H) # include # define HAVE_STDARGS /* let's hope that works everywhere (mj) */ # define VA_LOCAL_DECL va_list ap # define VA_START(f) va_start(ap, f) # define VA_SHIFT(v,t) ; /* no-op for ANSI */ # define VA_END va_end(ap) #else # if defined(HAVE_VARARGS_H) # include # undef HAVE_STDARGS # define VA_LOCAL_DECL va_list ap # define VA_START(f) va_start(ap) /* f is ignored! */ # define VA_SHIFT(v,t) v = va_arg(ap,t) # define VA_END va_end(ap) # else /*XX ** NO VARARGS ** XX*/ # endif #endif #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double #else #define LDOUBLE double #endif int snprintf (char *str, size_t count, const char *fmt, ...); int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); static int dopr (char *buffer, size_t maxlen, const char *format, va_list args); static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static int fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* * dopr(): poor man's version of doprintf */ /* format read states */ #define DP_S_DEFAULT 0 #define DP_S_FLAGS 1 #define DP_S_MIN 2 #define DP_S_DOT 3 #define DP_S_MAX 4 #define DP_S_MOD 5 #define DP_S_CONV 6 #define DP_S_DONE 7 /* format flags - Bits */ #define DP_F_MINUS (1 << 0) #define DP_F_PLUS (1 << 1) #define DP_F_SPACE (1 << 2) #define DP_F_NUM (1 << 3) #define DP_F_ZERO (1 << 4) #define DP_F_UP (1 << 5) #define DP_F_UNSIGNED (1 << 6) /* Conversion Flags */ #define DP_C_SHORT 1 #define DP_C_LONG 2 #define DP_C_LDOUBLE 3 #define char_to_int(p) (p - '0') #define MAX(p,q) ((p >= q) ? p : q) #define MIN(p,q) ((p <= q) ? p : q) static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) { unsigned char ch; long value; LDOUBLE fvalue; char *strvalue; int min; int max; int state; int flags; int cflags; int total; size_t currlen; state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; ch = *format++; total = 0; while (state != DP_S_DONE) { if (ch == '\0') state = DP_S_DONE; switch(state) { case DP_S_DEFAULT: if (ch == '%') state = DP_S_FLAGS; else total += dopr_outch (buffer, &currlen, maxlen, ch); ch = *format++; break; case DP_S_FLAGS: switch (ch) { case '-': flags |= DP_F_MINUS; ch = *format++; break; case '+': flags |= DP_F_PLUS; ch = *format++; break; case ' ': flags |= DP_F_SPACE; ch = *format++; break; case '#': flags |= DP_F_NUM; ch = *format++; break; case '0': flags |= DP_F_ZERO; ch = *format++; break; default: state = DP_S_MIN; break; } break; case DP_S_MIN: if (isdigit(ch)) { min = 10*min + char_to_int (ch); ch = *format++; } else if (ch == '*') { min = va_arg (args, int); ch = *format++; state = DP_S_DOT; } else state = DP_S_DOT; break; case DP_S_DOT: if (ch == '.') { state = DP_S_MAX; ch = *format++; } else state = DP_S_MOD; break; case DP_S_MAX: if (isdigit(ch)) { if (max < 0) max = 0; max = 10*max + char_to_int (ch); ch = *format++; } else if (ch == '*') { max = va_arg (args, int); ch = *format++; state = DP_S_MOD; } else state = DP_S_MOD; break; case DP_S_MOD: /* Currently, we don't support Long Long, bummer */ switch (ch) { case 'h': cflags = DP_C_SHORT; ch = *format++; break; case 'l': cflags = DP_C_LONG; ch = *format++; break; case 'L': cflags = DP_C_LDOUBLE; ch = *format++; break; default: break; } state = DP_S_CONV; break; case DP_S_CONV: switch (ch) { case 'd': case 'i': if (cflags == DP_C_SHORT) value = (short) va_arg (args, int); else if (cflags == DP_C_LONG) value = va_arg (args, long int); else value = va_arg (args, int); total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'o': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = (unsigned short) va_arg (args, unsigned); else if (cflags == DP_C_LONG) value = va_arg (args, unsigned long int); else value = va_arg (args, unsigned int); total += fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); break; case 'u': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = (unsigned short) va_arg (args, unsigned); else if (cflags == DP_C_LONG) value = va_arg (args, unsigned long int); else value = va_arg (args, unsigned int); total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'X': flags |= DP_F_UP; case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = (unsigned short) va_arg (args, unsigned); else if (cflags == DP_C_LONG) value = va_arg (args, unsigned long int); else value = va_arg (args, unsigned int); total += fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); break; case 'f': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); /* um, floating point? */ total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'G': flags |= DP_F_UP; case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'c': total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); break; case 's': strvalue = va_arg (args, char *); total += fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); break; case 'p': strvalue = va_arg (args, void *); total += fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); break; case 'n': if (cflags == DP_C_SHORT) { short int *num; num = va_arg (args, short int *); *num = currlen; } else if (cflags == DP_C_LONG) { long int *num; num = va_arg (args, long int *); *num = currlen; } else { int *num; num = va_arg (args, int *); *num = currlen; } break; case '%': total += dopr_outch (buffer, &currlen, maxlen, ch); break; case 'w': /* not supported yet, treat as next char */ ch = *format++; break; default: /* Unknown, skip */ break; } ch = *format++; state = DP_S_DEFAULT; flags = cflags = min = 0; max = -1; break; case DP_S_DONE: break; default: /* hmm? */ break; /* some picky compilers need this */ } } if (buffer != NULL) { if (currlen < maxlen - 1) buffer[currlen] = '\0'; else buffer[maxlen - 1] = '\0'; } return total; } static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; int total = 0; if (value == 0) { value = ""; } for (strln = 0; value[strln]; ++strln); /* strlen */ if (max >= 0 && max < strln) strln = max; padlen = min - strln; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ while (padlen > 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); --padlen; } while (*value && ((max < 0) || (cnt < max))) { total += dopr_outch (buffer, currlen, maxlen, *value++); ++cnt; } while (padlen < 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; } return total; } /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static int fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; int total = 0; if (max < 0) max = 0; uvalue = value; if(!(flags & DP_F_UNSIGNED)) { if( value < 0 ) { signvalue = '-'; uvalue = -value; } else if (flags & DP_F_PLUS) /* Do a sign (+/i) */ signvalue = '+'; else if (flags & DP_F_SPACE) signvalue = ' '; } if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ do { convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") [uvalue % (unsigned)base ]; uvalue = (uvalue / (unsigned)base ); } while(uvalue && (place < 20)); if (place == 20) place--; convert[place] = 0; zpadlen = max - place; spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); if (zpadlen < 0) zpadlen = 0; if (spadlen < 0) spadlen = 0; if (flags & DP_F_ZERO) { zpadlen = MAX(zpadlen, spadlen); spadlen = 0; } if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ #ifdef DEBUG_SNPRINTF dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", zpadlen, spadlen, min, max, place)); #endif /* Spaces */ while (spadlen > 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); --spadlen; } /* Sign */ if (signvalue) total += dopr_outch (buffer, currlen, maxlen, signvalue); /* Zeros */ if (zpadlen > 0) { while (zpadlen > 0) { total += dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } } /* Digits */ while (place > 0) total += dopr_outch (buffer, currlen, maxlen, convert[--place]); /* Left Justified spaces */ while (spadlen < 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); ++spadlen; } return total; } static LDOUBLE abs_val (LDOUBLE value) { LDOUBLE result = value; if (value < 0) result = -value; return result; } static LDOUBLE pow10_argp (int exp) { LDOUBLE result = 1; while (exp) { result *= 10; exp--; } return result; } static long round_argp (LDOUBLE value) { long intpart; intpart = value; value = value - intpart; if (value >= 0.5) intpart++; return intpart; } static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; char iconvert[20]; char fconvert[20]; int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ int zpadlen = 0; int caps = 0; int total = 0; long intpart; long fracpart; /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 */ if (max < 0) max = 6; ufvalue = abs_val (fvalue); if (fvalue < 0) signvalue = '-'; else if (flags & DP_F_PLUS) /* Do a sign (+/i) */ signvalue = '+'; else if (flags & DP_F_SPACE) signvalue = ' '; #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif intpart = ufvalue; /* * Sorry, we only support 9 digits past the decimal because of our * conversion method */ if (max > 9) max = 9; /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 */ fracpart = round_argp ((pow10_argp (max)) * (ufvalue - intpart)); if (fracpart >= pow10_argp (max)) { intpart++; fracpart -= pow10_argp (max); } #ifdef DEBUG_SNPRINTF dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart)); #endif /* Convert integer part */ do { iconvert[iplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) iplace--; iconvert[iplace] = 0; /* Convert fractional part */ do { fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; fracpart = (fracpart / 10); } while(fracpart && (fplace < 20)); if (fplace == 20) fplace--; fconvert[fplace] = 0; /* -1 for decimal point, another -1 if we are printing a sign */ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) { total += dopr_outch (buffer, currlen, maxlen, signvalue); --padlen; signvalue = 0; } while (padlen > 0) { total += dopr_outch (buffer, currlen, maxlen, '0'); --padlen; } } while (padlen > 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); --padlen; } if (signvalue) total += dopr_outch (buffer, currlen, maxlen, signvalue); while (iplace > 0) total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); /* * Decimal point. This should probably use locale to find the correct * char to print out. */ if (max > 0) { total += dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); } while (zpadlen > 0) { total += dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } while (padlen < 0) { total += dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; } return total; } static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen + 1 < maxlen) buffer[(*currlen)++] = c; return 1; } #ifndef HAVE_VSNPRINTF int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { if (str != NULL) str[0] = 0; return dopr(str, count, fmt, args); } #endif /* !HAVE_VSNPRINTF */ #ifndef HAVE_SNPRINTF /* VARARGS3 */ #ifdef HAVE_STDARGS int snprintf (char *str,size_t count,const char *fmt,...) #else int snprintf (va_alist) va_dcl #endif { #ifndef HAVE_STDARGS char *str; size_t count; char *fmt; #endif VA_LOCAL_DECL; int total; VA_START (fmt); VA_SHIFT (str, char *); VA_SHIFT (count, size_t ); VA_SHIFT (fmt, char *); total = vsnprintf(str, count, fmt, ap); VA_END; return total; } #endif /* !HAVE_SNPRINTF */ #ifdef TEST_SNPRINTF #ifndef LONG_STRING #define LONG_STRING 1024 #endif int main (void) { char buf1[LONG_STRING]; char buf2[LONG_STRING]; char *fp_fmt[] = { "%-1.5f", "%1.5f", "%123.9f", "%10.5f", "% 10.5f", "%+22.9f", "%+4.9f", "%01.3f", "%4f", "%3.1f", "%3.2f", "%.0f", "%.1f", NULL }; double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996, 4.136, 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", "%123.9d", "%5.5d", "%10.5d", "% 10.5d", "%+22.33d", "%01.3d", "%4d", NULL }; long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; int x, y; int fail = 0; int num = 0; printf ("Testing snprintf format codes against system sprintf...\n"); for (x = 0; fp_fmt[x] != NULL ; x++) for (y = 0; fp_nums[y] != 0 ; y++) { snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", fp_fmt[x], buf1, buf2); fail++; } num++; } for (x = 0; int_fmt[x] != NULL ; x++) for (y = 0; int_nums[y] != 0 ; y++) { snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", int_fmt[x], buf1, buf2); fail++; } num++; } printf ("%d tests failed out of %d.\n", fail, num); } #endif /* SNPRINTF_TEST */ #endif /* !HAVE_SNPRINTF */ glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/Makefile.am0000644000076200007630000000013112617742532023304 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.878511088 glusterfs-3.7.6/contrib/argp-standalone/Makefile.am0000644000076200007630000000244712617742532023531 0ustar00jenkinsjenkins00000000000000# From glibc # Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C 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. # The GNU C 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 the GNU C Library; see the file COPYING.LIB. If # not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AUTOMAKE_OPTIONS = foreign SUBDIRS = . LIBOBJS = @LIBOBJS@ noinst_LIBRARIES = libargp.a noinst_HEADERS = argp.h argp-fmtstream.h argp-namefrob.h EXTRA_DIST = mempcpy.c strchrnul.c strndup.c strcasecmp.c vsnprintf.c autogen.sh # Leaves out argp-fs-xinl.c and argp-xinl.c libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c \ argp-help.c argp-parse.c argp-pv.c \ argp-pvh.c libargp_a_LIBADD = $(LIBOBJS) glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp.h0000644000076200007630000000013012617742532022351 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.878511088 glusterfs-3.7.6/contrib/argp-standalone/argp.h0000644000076200007630000006346312617742532022604 0ustar00jenkinsjenkins00000000000000/* Hierarchial argument parsing. Copyright (C) 1995, 96, 97, 98, 99, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _ARGP_H #define _ARGP_H #include #include #define __need_error_t #include #ifndef __THROW # define __THROW #endif #ifndef __const # define __const const #endif #ifndef __error_t_defined typedef int error_t; # define __error_t_defined #endif /* FIXME: What's the right way to check for __restrict? Sun's cc seems not to have it. Perhaps it's easiest to just delete the use of __restrict from the prototypes. */ #ifndef __restrict # ifndef __GNUC___ # define __restrict # endif #endif /* NOTE: We can't use the autoconf tests, since this is supposed to be an installed header file and argp's config.h is of course not installed. */ #ifndef PRINTF_STYLE # if __GNUC__ >= 2 # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a))) # else # define PRINTF_STYLE(f, a) # endif #endif #ifdef __cplusplus extern "C" { #endif /* A description of a particular option. A pointer to an array of these is passed in the OPTIONS field of an argp structure. Each option entry can correspond to one long option and/or one short option; more names for the same option can be added by following an entry in an option array with options having the OPTION_ALIAS flag set. */ struct argp_option { /* The long option name. For more than one name for the same option, you can use following options with the OPTION_ALIAS flag set. */ __const char *name; /* What key is returned for this option. If > 0 and printable, then it's also accepted as a short option. */ int key; /* If non-NULL, this is the name of the argument associated with this option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */ __const char *arg; /* OPTION_ flags. */ int flags; /* The doc string for this option. If both NAME and KEY are 0, This string will be printed outdented from the normal option column, making it useful as a group header (it will be the first thing printed in its group); in this usage, it's conventional to end the string with a `:'. */ __const char *doc; /* The group this option is in. In a long help message, options are sorted alphabetically within each group, and the groups presented in the order 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with if this field 0 will inherit the group number of the previous entry, or zero if it's the first one, unless its a group header (NAME and KEY both 0), in which case, the previous entry + 1 is the default. Automagic options such as --help are put into group -1. */ int group; }; /* The argument associated with this option is optional. */ #define OPTION_ARG_OPTIONAL 0x1 /* This option isn't displayed in any help messages. */ #define OPTION_HIDDEN 0x2 /* This option is an alias for the closest previous non-alias option. This means that it will be displayed in the same help entry, and will inherit fields other than NAME and KEY from the aliased option. */ #define OPTION_ALIAS 0x4 /* This option isn't actually an option (and so should be ignored by the actual option parser), but rather an arbitrary piece of documentation that should be displayed in much the same manner as the options. If this flag is set, then the option NAME field is displayed unmodified (e.g., no `--' prefix is added) at the left-margin (where a *short* option would normally be displayed), and the documentation string in the normal place. For purposes of sorting, any leading whitespace and puncuation is ignored, except that if the first non-whitespace character is not `-', this entry is displayed after all options (and OPTION_DOC entries with a leading `-') in the same group. */ #define OPTION_DOC 0x8 /* This option shouldn't be included in `long' usage messages (but is still included in help messages). This is mainly intended for options that are completely documented in an argp's ARGS_DOC field, in which case including the option in the generic usage list would be redundant. For instance, if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to distinguish these two cases, -x should probably be marked OPTION_NO_USAGE. */ #define OPTION_NO_USAGE 0x10 struct argp; /* fwd declare this type */ struct argp_state; /* " */ struct argp_child; /* " */ /* The type of a pointer to an argp parsing function. */ typedef error_t (*argp_parser_t) (int key, char *arg, struct argp_state *state); /* What to return for unrecognized keys. For special ARGP_KEY_ keys, such returns will simply be ignored. For user keys, this error will be turned into EINVAL (if the call to argp_parse is such that errors are propagated back to the user instead of exiting); returning EINVAL itself would result in an immediate stop to parsing in *all* cases. */ #define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */ /* Special values for the KEY argument to an argument parsing function. ARGP_ERR_UNKNOWN should be returned if they aren't understood. The sequence of keys to a parsing function is either (where each uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key): INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized The third case is where every parser returned ARGP_KEY_UNKNOWN for an argument, in which case parsing stops at that argument (returning the unparsed arguments to the caller of argp_parse if requested, or stopping with an error message if not). If an error occurs (either detected by argp, or because the parsing function returned an error value), then the parser is called with ARGP_KEY_ERROR, and no further calls are made. */ /* This is not an option at all, but rather a command line argument. If a parser receiving this key returns success, the fact is recorded, and the ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the argument, a parser function decrements the NEXT field of the state it's passed, the option won't be considered processed; this is to allow you to actually modify the argument (perhaps into an option), and have it processed again. */ #define ARGP_KEY_ARG 0 /* There are remaining arguments not parsed by any parser, which may be found starting at (STATE->argv + STATE->next). If success is returned, but STATE->next left untouched, it's assumed that all arguments were consume, otherwise, the parser should adjust STATE->next to reflect any arguments consumed. */ #define ARGP_KEY_ARGS 0x1000006 /* There are no more command line arguments at all. */ #define ARGP_KEY_END 0x1000001 /* Because it's common to want to do some special processing if there aren't any non-option args, user parsers are called with this key if they didn't successfully process any non-option arguments. Called just before ARGP_KEY_END (where more general validity checks on previously parsed arguments can take place). */ #define ARGP_KEY_NO_ARGS 0x1000002 /* Passed in before any parsing is done. Afterwards, the values of each element of the CHILD_INPUT field, if any, in the state structure is copied to each child's state to be the initial value of the INPUT field. */ #define ARGP_KEY_INIT 0x1000003 /* Use after all other keys, including SUCCESS & END. */ #define ARGP_KEY_FINI 0x1000007 /* Passed in when parsing has successfully been completed (even if there are still arguments remaining). */ #define ARGP_KEY_SUCCESS 0x1000004 /* Passed in if an error occurs. */ #define ARGP_KEY_ERROR 0x1000005 /* An argp structure contains a set of options declarations, a function to deal with parsing one, documentation string, a possible vector of child argp's, and perhaps a function to filter help output. When actually parsing options, getopt is called with the union of all the argp structures chained together through their CHILD pointers, with conflicts being resolved in favor of the first occurrence in the chain. */ struct argp { /* An array of argp_option structures, terminated by an entry with both NAME and KEY having a value of 0. */ __const struct argp_option *options; /* What to do with an option from this structure. KEY is the key associated with the option, and ARG is any associated argument (NULL if none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then parsing is stopped immediately, and that value is returned from argp_parse(). For special (non-user-supplied) values of KEY, see the ARGP_KEY_ definitions below. */ argp_parser_t parser; /* A string describing what other arguments are wanted by this program. It is only used by argp_usage to print the `Usage:' message. If it contains newlines, the strings separated by them are considered alternative usage patterns, and printed on separate lines (lines after the first are prefix by ` or: ' instead of `Usage:'). */ __const char *args_doc; /* If non-NULL, a string containing extra text to be printed before and after the options in a long help message (separated by a vertical tab `\v' character). */ __const char *doc; /* A vector of argp_children structures, terminated by a member with a 0 argp field, pointing to child argps should be parsed with this one. Any conflicts are resolved in favor of this argp, or early argps in the CHILDREN list. This field is useful if you use libraries that supply their own argp structure, which you want to use in conjunction with your own. */ __const struct argp_child *children; /* If non-zero, this should be a function to filter the output of help messages. KEY is either a key from an option, in which case TEXT is that option's help text, or a special key from the ARGP_KEY_HELP_ defines, below, describing which other help text TEXT is. The function should return either TEXT, if it should be used as-is, a replacement string, which should be malloced, and will be freed by argp, or NULL, meaning `print nothing'. The value for TEXT is *after* any translation has been done, so if any of the replacement text also needs translation, that should be done by the filter function. INPUT is either the input supplied to argp_parse, or NULL, if argp_help was called directly. */ char *(*help_filter) (int __key, __const char *__text, void *__input); /* If non-zero the strings used in the argp library are translated using the domain described by this string. Otherwise the currently installed default domain is used. */ const char *argp_domain; }; /* Possible KEY arguments to a help filter function. */ #define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */ #define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */ #define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */ #define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation; TEXT is NULL for this key. */ /* Explanatory note emitted when duplicate option arguments have been suppressed. */ #define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005 #define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */ /* When an argp has a non-zero CHILDREN field, it should point to a vector of argp_child structures, each of which describes a subsidiary argp. */ struct argp_child { /* The child parser. */ __const struct argp *argp; /* Flags for this child. */ int flags; /* If non-zero, an optional header to be printed in help output before the child options. As a side-effect, a non-zero value forces the child options to be grouped together; to achieve this effect without actually printing a header string, use a value of "". */ __const char *header; /* Where to group the child options relative to the other (`consolidated') options in the parent argp; the values are the same as the GROUP field in argp_option structs, but all child-groupings follow parent options at a particular group level. If both this field and HEADER are zero, then they aren't grouped at all, but rather merged with the parent options (merging the child's grouping levels with the parents). */ int group; }; /* Parsing state. This is provided to parsing functions called by argp, which may examine and, as noted, modify fields. */ struct argp_state { /* The top level ARGP being parsed. */ __const struct argp *root_argp; /* The argument vector being parsed. May be modified. */ int argc; char **argv; /* The index in ARGV of the next arg that to be parsed. May be modified. */ int next; /* The flags supplied to argp_parse. May be modified. */ unsigned flags; /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the number of the current arg, starting at zero, and incremented after each such call returns. At all other times, this is the number of such arguments that have been processed. */ unsigned arg_num; /* If non-zero, the index in ARGV of the first argument following a special `--' argument (which prevents anything following being interpreted as an option). Only set once argument parsing has proceeded past this point. */ int quoted; /* An arbitrary pointer passed in from the user. */ void *input; /* Values to pass to child parsers. This vector will be the same length as the number of children for the current parser. */ void **child_inputs; /* For the parser's use. Initialized to 0. */ void *hook; /* The name used when printing messages. This is initialized to ARGV[0], or PROGRAM_INVOCATION_NAME if that is unavailable. */ char *name; /* Streams used when argp prints something. */ FILE *err_stream; /* For errors; initialized to stderr. */ FILE *out_stream; /* For information; initialized to stdout. */ void *pstate; /* Private, for use by argp. */ }; /* Flags for argp_parse (note that the defaults are those that are convenient for program command line parsing): */ /* Don't ignore the first element of ARGV. Normally (and always unless ARGP_NO_ERRS is set) the first element of the argument vector is skipped for option parsing purposes, as it corresponds to the program name in a command line. */ #define ARGP_PARSE_ARGV0 0x01 /* Don't print error messages for unknown options to stderr; unless this flag is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program name in the error messages. This flag implies ARGP_NO_EXIT (on the assumption that silent exiting upon errors is bad behaviour). */ #define ARGP_NO_ERRS 0x02 /* Don't parse any non-option args. Normally non-option args are parsed by calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg as the value. Since it's impossible to know which parse function wants to handle it, each one is called in turn, until one returns 0 or an error other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the argp_parse returns prematurely (but with a return value of 0). If all args have been parsed without error, all parsing functions are called one last time with a key of ARGP_KEY_END. This flag needn't normally be set, as the normal behavior is to stop parsing as soon as some argument can't be handled. */ #define ARGP_NO_ARGS 0x04 /* Parse options and arguments in the same order they occur on the command line -- normally they're rearranged so that all options come first. */ #define ARGP_IN_ORDER 0x08 /* Don't provide the standard long option --help, which causes usage and option help information to be output to stdout, and exit (0) called. */ #define ARGP_NO_HELP 0x10 /* Don't exit on errors (they may still result in error messages). */ #define ARGP_NO_EXIT 0x20 /* Use the gnu getopt `long-only' rules for parsing arguments. */ #define ARGP_LONG_ONLY 0x40 /* Turns off any message-printing/exiting options. */ #define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP) /* Parse the options strings in ARGC & ARGV according to the options in ARGP. FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the index in ARGV of the first unparsed option is returned in it. If an unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser routine returned a non-zero value, it is returned; otherwise 0 is returned. This function may also call exit unless the ARGP_NO_HELP flag is set. INPUT is a pointer to a value to be passed in to the parser. */ extern error_t argp_parse (__const struct argp *__restrict argp, int argc, char **__restrict argv, unsigned flags, int *__restrict arg_index, void *__restrict input) __THROW; extern error_t __argp_parse (__const struct argp *__restrict argp, int argc, char **__restrict argv, unsigned flags, int *__restrict arg_index, void *__restrict input) __THROW; /* Global variables. */ /* If defined or set by the user program to a non-zero value, then a default option --version is added (unless the ARGP_NO_HELP flag is used), which will print this string followed by a newline and exit (unless the ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ extern __const char *argp_program_version; /* If defined or set by the user program to a non-zero value, then a default option --version is added (unless the ARGP_NO_HELP flag is used), which calls this function with a stream to print the version to and a pointer to the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ extern void (*argp_program_version_hook) (FILE *__restrict __stream, struct argp_state *__restrict __state); /* If defined or set by the user program, it should point to string that is the bug-reporting address for the program. It will be printed by argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help messages), embedded in a sentence that says something like `Report bugs to ADDR.'. */ extern __const char *argp_program_bug_address; /* The exit status that argp will use when exiting due to a parsing error. If not defined or set by the user program, this defaults to EX_USAGE from . */ extern error_t argp_err_exit_status; /* Flags for argp_help. */ #define ARGP_HELP_USAGE 0x01 /* a Usage: message. */ #define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */ #define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */ #define ARGP_HELP_LONG 0x08 /* a long help message. */ #define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */ #define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */ #define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC) #define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */ #define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to reflect ARGP_LONG_ONLY mode. */ /* These ARGP_HELP flags are only understood by argp_state_help. */ #define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */ #define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */ /* The standard thing to do after a program command line parsing error, if an error message has already been printed. */ #define ARGP_HELP_STD_ERR \ (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR) /* The standard thing to do after a program command line parsing error, if no more specific error message has been printed. */ #define ARGP_HELP_STD_USAGE \ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR) /* The standard thing to do in response to a --help option. */ #define ARGP_HELP_STD_HELP \ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \ | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR) /* Output a usage message for ARGP to STREAM. FLAGS are from the set ARGP_HELP_*. */ extern void argp_help (__const struct argp *__restrict __argp, FILE *__restrict __stream, unsigned __flags, char *__restrict __name) __THROW; extern void __argp_help (__const struct argp *__restrict __argp, FILE *__restrict __stream, unsigned __flags, char *__name) __THROW; /* The following routines are intended to be called from within an argp parsing routine (thus taking an argp_state structure as the first argument). They may or may not print an error message and exit, depending on the flags in STATE -- in any case, the caller should be prepared for them *not* to exit, and should return an appropiate error after calling them. [argp_usage & argp_error should probably be called argp_state_..., but they're used often enough that they should be short] */ /* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are from the set ARGP_HELP_*. */ extern void argp_state_help (__const struct argp_state *__restrict __state, FILE *__restrict __stream, unsigned int __flags) __THROW; extern void __argp_state_help (__const struct argp_state *__restrict __state, FILE *__restrict __stream, unsigned int __flags) __THROW; /* Possibly output the standard usage message for ARGP to stderr and exit. */ extern void argp_usage (__const struct argp_state *__state) __THROW; extern void __argp_usage (__const struct argp_state *__state) __THROW; /* If appropriate, print the printf string FMT and following args, preceded by the program name and `:', to stderr, and followed by a `Try ... --help' message, then exit (1). */ extern void argp_error (__const struct argp_state *__restrict __state, __const char *__restrict __fmt, ...) __THROW PRINTF_STYLE(2,3); extern void __argp_error (__const struct argp_state *__restrict __state, __const char *__restrict __fmt, ...) __THROW PRINTF_STYLE(2,3); /* Similar to the standard gnu error-reporting function error(), but will respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print to STATE->err_stream. This is useful for argument parsing code that is shared between program startup (when exiting is desired) and runtime option parsing (when typically an error code is returned instead). The difference between this function and argp_error is that the latter is for *parsing errors*, and the former is for other problems that occur during parsing but don't reflect a (syntactic) problem with the input. */ extern void argp_failure (__const struct argp_state *__restrict __state, int __status, int __errnum, __const char *__restrict __fmt, ...) __THROW PRINTF_STYLE(4,5); extern void __argp_failure (__const struct argp_state *__restrict __state, int __status, int __errnum, __const char *__restrict __fmt, ...) __THROW PRINTF_STYLE(4,5); /* Returns true if the option OPT is a valid short option. */ extern int _option_is_short (__const struct argp_option *__opt) __THROW; extern int __option_is_short (__const struct argp_option *__opt) __THROW; /* Returns true if the option OPT is in fact the last (unused) entry in an options array. */ extern int _option_is_end (__const struct argp_option *__opt) __THROW; extern int __option_is_end (__const struct argp_option *__opt) __THROW; /* Return the input field for ARGP in the parser corresponding to STATE; used by the help routines. */ extern void *_argp_input (__const struct argp *__restrict __argp, __const struct argp_state *__restrict __state) __THROW; extern void *__argp_input (__const struct argp *__restrict __argp, __const struct argp_state *__restrict __state) __THROW; /* Used for extracting the program name from argv[0] */ extern char *_argp_basename(char *name) __THROW; extern char *__argp_basename(char *name) __THROW; /* Getting the program name given an argp state */ extern char * _argp_short_program_name(const struct argp_state *state) __THROW; extern char * __argp_short_program_name(const struct argp_state *state) __THROW; #ifdef __USE_EXTERN_INLINES # if !_LIBC # define __argp_usage argp_usage # define __argp_state_help argp_state_help # define __option_is_short _option_is_short # define __option_is_end _option_is_end # endif # ifndef ARGP_EI # define ARGP_EI extern __inline__ # endif ARGP_EI void __argp_usage (__const struct argp_state *__state) { __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); } ARGP_EI int __option_is_short (__const struct argp_option *__opt) { if (__opt->flags & OPTION_DOC) return 0; else { int __key = __opt->key; return __key > 0 && isprint (__key); } } ARGP_EI int __option_is_end (__const struct argp_option *__opt) { return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; } # if !_LIBC # undef __argp_usage # undef __argp_state_help # undef __option_is_short # undef __option_is_end # endif #endif /* Use extern inlines. */ #ifdef __cplusplus } #endif #endif /* argp.h */ glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/configure.ac0000644000076200007630000000013012617742532023535 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.878511088 glusterfs-3.7.6/contrib/argp-standalone/configure.ac0000644000076200007630000000600712617742532023757 0ustar00jenkinsjenkins00000000000000dnl Process this file with autoconf to produce a configure script. dnl This configure.ac is only for building a standalone argp library. AC_INIT([argp], [standalone-1.3]) AC_PREREQ(2.54) AC_CONFIG_SRCDIR([argp-ba.c]) # Needed to stop autoconf from looking for files in parent directories. AC_CONFIG_AUX_DIR([.]) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS(config.h) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) # GNU libc defaults to supplying the ISO C library functions only. The # _GNU_SOURCE define enables these extensions, in particular we want # errno.h to declare program_invocation_name. Enable it on all # systems; no problems have been reported with it so far. AC_GNU_SOURCE # Checks for programs. AC_PROG_CC AC_PROG_MAKE_SET AC_PROG_RANLIB AC_PROG_CC if test "x$am_cv_prog_cc_stdc" = xno ; then AC_ERROR([the C compiler doesn't handle ANSI-C]) fi # Checks for libraries. # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(libintl.h limits.h malloc.h unistd.h sysexits.h stdarg.h) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T LSH_GCC_ATTRIBUTES # Checks for library functions. AC_FUNC_ALLOCA AC_FUNC_VPRINTF AC_CHECK_FUNCS(strerror sleep getpid snprintf) AC_REPLACE_FUNCS(mempcpy strndup strchrnul strcasecmp vsnprintf) dnl ARGP_CHECK_FUNC(includes, function-call [, if-found [, if-not-found]]) AC_DEFUN([ARGP_CHECK_FUNC], [AS_VAR_PUSHDEF([ac_func], m4_substr([$2], 0, m4_index([$2], [(]))) AS_VAR_PUSHDEF([ac_var], [ac_cv_func_call_]ac_func) AH_TEMPLATE(AS_TR_CPP(HAVE_[]ac_func), [Define to 1 if you have the `]ac_func[' function.]) AC_CACHE_CHECK([for $2], ac_var, [AC_TRY_LINK([$1], [$2], [AS_VAR_SET(ac_var, yes)], [AS_VAR_SET(ac_var, no)])]) if test AS_VAR_GET(ac_var) = yes ; then ifelse([$3],, [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))], [$3 ]) else ifelse([$4],, true, [$4]) fi AS_VAR_POPDEF([ac_var]) AS_VAR_POPDEF([ac_func]) ]) # At least on freebsd, putc_unlocked is a macro, so the standard # AC_CHECK_FUNCS doesn't work well. ARGP_CHECK_FUNC([#include ], [putc_unlocked('x', stdout)]) AC_CHECK_FUNCS(flockfile) AC_CHECK_FUNCS(fputs_unlocked fwrite_unlocked) # Used only by argp-test.c, so don't use AC_REPLACE_FUNCS. AC_CHECK_FUNCS(strdup asprintf) AC_CHECK_DECLS([program_invocation_name, program_invocation_short_name], [], [], [[#include ]]) # Set these flags *last*, or else the test programs won't compile if test x$GCC = xyes ; then # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then true else CFLAGS="$CFLAGS -ggdb3" fi CFLAGS="$CFLAGS -Wall -W \ -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \ -Waggregate-return \ -Wpointer-arith -Wbad-function-cast -Wnested-externs" fi CPPFLAGS="$CPPFLAGS -I$srcdir" dnl Added for C99 standards CFLAGS="$CFLAGS -std=gnu89 -static" AC_OUTPUT(Makefile) glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/autogen.sh0000644000076200007630000000013012617742532023245 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.878511088 glusterfs-3.7.6/contrib/argp-standalone/autogen.sh0000755000076200007630000000012412617742532023464 0ustar00jenkinsjenkins00000000000000#!/bin/sh aclocal -I . autoheader autoconf automake --add-missing --copy --foreign glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-pv.c0000644000076200007630000000013112617742532022770 xustar000000000000000030 mtime=1447019866.024471735 29 atime=1447019866.36646659 30 ctime=1447019929.878511088 glusterfs-3.7.6/contrib/argp-standalone/argp-pv.c0000644000076200007630000000245712617742532023216 0ustar00jenkinsjenkins00000000000000/* Default definition for ARGP_PROGRAM_VERSION. Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* If set by the user program to a non-zero value, then a default option --version is added (unless the ARGP_NO_HELP flag is used), which will print this this string followed by a newline and exit (unless the ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ const char *argp_program_version = 0; glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-fmtstream.c0000644000076200007630000000013112617742532024345 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-fmtstream.c0000644000076200007630000003107312617742532024567 0ustar00jenkinsjenkins00000000000000/* Word-wrapping and line-truncating streams Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This package emulates glibc `line_wrap_stream' semantics for systems that don't have that. */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "argp-fmtstream.h" #include "argp-namefrob.h" #ifndef ARGP_FMTSTREAM_USE_LINEWRAP #ifndef isblank #define isblank(ch) ((ch)==' ' || (ch)=='\t') #endif #if defined _LIBC && defined USE_IN_LIBIO # include # define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a) #endif #define INIT_BUF_SIZE 200 #define PRINTF_SIZE_GUESS 150 /* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines written on it with LMARGIN spaces and limits them to RMARGIN columns total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by replacing the whitespace before them with a newline and WMARGIN spaces. Otherwise, chars beyond RMARGIN are simply dropped until a newline. Returns NULL if there was an error. */ argp_fmtstream_t __argp_make_fmtstream (FILE *stream, size_t lmargin, size_t rmargin, ssize_t wmargin) { argp_fmtstream_t fs = malloc (sizeof (struct argp_fmtstream)); if (fs) { fs->stream = stream; fs->lmargin = lmargin; fs->rmargin = rmargin; fs->wmargin = wmargin; fs->point_col = 0; fs->point_offs = 0; fs->buf = malloc (INIT_BUF_SIZE); if (! fs->buf) { free (fs); fs = 0; } else { fs->p = fs->buf; fs->end = fs->buf + INIT_BUF_SIZE; } } return fs; } #ifdef weak_alias weak_alias (__argp_make_fmtstream, argp_make_fmtstream) #endif /* Flush FS to its stream, and free it (but don't close the stream). */ void __argp_fmtstream_free (argp_fmtstream_t fs) { __argp_fmtstream_update (fs); if (fs->p > fs->buf) FWRITE_UNLOCKED (fs->buf, 1, fs->p - fs->buf, fs->stream); free (fs->buf); free (fs); } #ifdef weak_alias weak_alias (__argp_fmtstream_free, argp_fmtstream_free) #endif /* Process FS's buffer so that line wrapping is done from POINT_OFFS to the end of its buffer. This code is mostly from glibc stdio/linewrap.c. */ void __argp_fmtstream_update (argp_fmtstream_t fs) { char *buf, *nl; size_t len; /* Scan the buffer for newlines. */ buf = fs->buf + fs->point_offs; while (buf < fs->p) { size_t r; if (fs->point_col == 0 && fs->lmargin != 0) { /* We are starting a new line. Print spaces to the left margin. */ const size_t pad = fs->lmargin; if (fs->p + pad < fs->end) { /* We can fit in them in the buffer by moving the buffer text up and filling in the beginning. */ memmove (buf + pad, buf, fs->p - buf); fs->p += pad; /* Compensate for bigger buffer. */ memset (buf, ' ', pad); /* Fill in the spaces. */ buf += pad; /* Don't bother searching them. */ } else { /* No buffer space for spaces. Must flush. */ size_t i; for (i = 0; i < pad; i++) PUTC_UNLOCKED (' ', fs->stream); } fs->point_col = pad; } len = fs->p - buf; nl = memchr (buf, '\n', len); if (fs->point_col < 0) fs->point_col = 0; if (!nl) { /* The buffer ends in a partial line. */ if (fs->point_col + len < fs->rmargin) { /* The remaining buffer text is a partial line and fits within the maximum line width. Advance point for the characters to be written and stop scanning. */ fs->point_col += len; break; } else /* Set the end-of-line pointer for the code below to the end of the buffer. */ nl = fs->p; } else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin) { /* The buffer contains a full line that fits within the maximum line width. Reset point and scan the next line. */ fs->point_col = 0; buf = nl + 1; continue; } /* This line is too long. */ r = fs->rmargin - 1; if (fs->wmargin < 0) { /* Truncate the line by overwriting the excess with the newline and anything after it in the buffer. */ if (nl < fs->p) { memmove (buf + (r - fs->point_col), nl, fs->p - nl); fs->p -= buf + (r - fs->point_col) - nl; /* Reset point for the next line and start scanning it. */ fs->point_col = 0; buf += r + 1; /* Skip full line plus \n. */ } else { /* The buffer ends with a partial line that is beyond the maximum line width. Advance point for the characters written, and discard those past the max from the buffer. */ fs->point_col += len; fs->p -= fs->point_col - r; break; } } else { /* Do word wrap. Go to the column just past the maximum line width and scan back for the beginning of the word there. Then insert a line break. */ char *p, *nextline; int i; p = buf + (r + 1 - fs->point_col); while (p >= buf && !isblank (*p)) --p; nextline = p + 1; /* This will begin the next line. */ if (nextline > buf) { /* Swallow separating blanks. */ if (p >= buf) do --p; while (p >= buf && isblank (*p)); nl = p + 1; /* The newline will replace the first blank. */ } else { /* A single word that is greater than the maximum line width. Oh well. Put it on an overlong line by itself. */ p = buf + (r + 1 - fs->point_col); /* Find the end of the long word. */ do ++p; while (p < nl && !isblank (*p)); if (p == nl) { /* It already ends a line. No fussing required. */ fs->point_col = 0; buf = nl + 1; continue; } /* We will move the newline to replace the first blank. */ nl = p; /* Swallow separating blanks. */ do ++p; while (isblank (*p)); /* The next line will start here. */ nextline = p; } /* Note: There are a bunch of tests below for NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall at the end of the buffer, and NEXTLINE is in fact empty (and so we need not be careful to maintain its contents). */ if (nextline == buf + len + 1 ? fs->end - nl < fs->wmargin + 1 : nextline - (nl + 1) < fs->wmargin) { /* The margin needs more blanks than we removed. */ if (fs->end - fs->p > fs->wmargin + 1) /* Make some space for them. */ { size_t mv = fs->p - nextline; memmove (nl + 1 + fs->wmargin, nextline, mv); nextline = nl + 1 + fs->wmargin; len = nextline + mv - buf; *nl++ = '\n'; } else /* Output the first line so we can use the space. */ { if (nl > fs->buf) FWRITE_UNLOCKED (fs->buf, 1, nl - fs->buf, fs->stream); PUTC_UNLOCKED ('\n', fs->stream); len += buf - fs->buf; nl = buf = fs->buf; } } else /* We can fit the newline and blanks in before the next word. */ *nl++ = '\n'; if (nextline - nl >= fs->wmargin || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin)) /* Add blanks up to the wrap margin column. */ for (i = 0; i < fs->wmargin; ++i) *nl++ = ' '; else for (i = 0; i < fs->wmargin; ++i) PUTC_UNLOCKED (' ', fs->stream); /* Copy the tail of the original buffer into the current buffer position. */ if (nl < nextline) memmove (nl, nextline, buf + len - nextline); len -= nextline - buf; /* Continue the scan on the remaining lines in the buffer. */ buf = nl; /* Restore bufp to include all the remaining text. */ fs->p = nl + len; /* Reset the counter of what has been output this line. If wmargin is 0, we want to avoid the lmargin getting added, so we set point_col to a magic value of -1 in that case. */ fs->point_col = fs->wmargin ? fs->wmargin : -1; } } /* Remember that we've scanned as far as the end of the buffer. */ fs->point_offs = fs->p - fs->buf; } /* Ensure that FS has space for AMOUNT more bytes in its buffer, either by growing the buffer, or by flushing it. True is returned iff we succeed. */ int __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount) { if ((size_t) (fs->end - fs->p) < amount) { ssize_t wrote; /* Flush FS's buffer. */ __argp_fmtstream_update (fs); wrote = FWRITE_UNLOCKED (fs->buf, 1, fs->p - fs->buf, fs->stream); if (wrote == fs->p - fs->buf) { fs->p = fs->buf; fs->point_offs = 0; } else { fs->p -= wrote; fs->point_offs -= wrote; memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf); return 0; } if ((size_t) (fs->end - fs->buf) < amount) /* Gotta grow the buffer. */ { size_t new_size = fs->end - fs->buf + amount; char *new_buf = realloc (fs->buf, new_size); if (! new_buf) { __set_errno (ENOMEM); return 0; } fs->buf = new_buf; fs->end = new_buf + new_size; fs->p = fs->buf; } } return 1; } ssize_t __argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...) { size_t out; size_t avail; size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */ do { va_list args; if (! __argp_fmtstream_ensure (fs, size_guess)) return -1; va_start (args, fmt); avail = fs->end - fs->p; out = __vsnprintf (fs->p, avail, fmt, args); va_end (args); if (out >= avail) size_guess = out + 1; } while (out >= avail); fs->p += out; return out; } #ifdef weak_alias weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf) #endif #if __STDC_VERSION__ - 199900L < 1 /* Duplicate the inline definitions in argp-fmtstream.h, for compilers * that don't do inlining. */ size_t __argp_fmtstream_write (argp_fmtstream_t __fs, __const char *__str, size_t __len) { if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len)) { memcpy (__fs->p, __str, __len); __fs->p += __len; return __len; } else return 0; } int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str) { size_t __len = strlen (__str); if (__len) { size_t __wrote = __argp_fmtstream_write (__fs, __str, __len); return __wrote == __len ? 0 : -1; } else return 0; } int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch) { if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1)) return *__fs->p++ = __ch; else return EOF; } /* Set __FS's left margin to __LMARGIN and return the old value. */ size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->lmargin; __fs->lmargin = __lmargin; return __old; } /* Set __FS's right margin to __RMARGIN and return the old value. */ size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->rmargin; __fs->rmargin = __rmargin; return __old; } /* Set FS's wrap margin to __WMARGIN and return the old value. */ size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->wmargin; __fs->wmargin = __wmargin; return __old; } /* Return the column number of the current output point in __FS. */ size_t __argp_fmtstream_point (argp_fmtstream_t __fs) { if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); return __fs->point_col >= 0 ? __fs->point_col : 0; } #endif /* __STDC_VERSION__ - 199900L < 1 */ #endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */ glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-ba.c0000644000076200007630000000013112617742532022725 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-ba.c0000644000076200007630000000251412617742532023145 0ustar00jenkinsjenkins00000000000000/* Default definition for ARGP_PROGRAM_BUG_ADDRESS. Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* If set by the user program, it should point to string that is the bug-reporting address for the program. It will be printed by argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help messages), embedded in a sentence that says something like `Report bugs to ADDR.'. */ const char *argp_program_bug_address = 0; glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/install-sh0000644000076200007630000000013212617742566023261 xustar000000000000000030 mtime=1447019894.172048265 30 atime=1447019894.172048265 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/install-sh0000755000076200007630000003253712617742566023513 0ustar00jenkinsjenkins00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/depcomp0000644000076200007630000000013212617742566022632 xustar000000000000000030 mtime=1447019894.218047573 30 atime=1447019894.217047588 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/depcomp0000755000076200007630000004426712617742566023067 0ustar00jenkinsjenkins00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-fmtstream.h0000644000076200007630000000013112617742532024352 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-fmtstream.h0000644000076200007630000002647312617742532024604 0ustar00jenkinsjenkins00000000000000/* Word-wrapping and line-truncating streams. Copyright (C) 1997, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This package emulates glibc `line_wrap_stream' semantics for systems that don't have that. If the system does have it, it is just a wrapper for that. This header file is only used internally while compiling argp, and shouldn't be installed. */ #ifndef _ARGP_FMTSTREAM_H #define _ARGP_FMTSTREAM_H #include #include #if HAVE_UNISTD_H # include #else /* This is a kludge to make the code compile on windows. Perhaps it would be better to just replace ssize_t with int through out the code. */ # define ssize_t int #endif #if _LIBC || (defined (HAVE_FLOCKFILE) && defined(HAVE_PUTC_UNLOCKED) \ && defined (HAVE_FPUTS_UNLOCKED) && defined (HAVE_FWRITE_UNLOCKED) ) /* Use locking funxtions */ # define FLOCKFILE(f) flockfile(f) # define FUNLOCKFILE(f) funlockfile(f) # define PUTC_UNLOCKED(c, f) putc_unlocked((c), (f)) # define FPUTS_UNLOCKED(s, f) fputs_unlocked((s), (f)) # define FWRITE_UNLOCKED(b, s, n, f) fwrite_unlocked((b), (s), (n), (f)) #else /* Disable stdio locking */ # define FLOCKFILE(f) # define FUNLOCKFILE(f) # define PUTC_UNLOCKED(c, f) putc((c), (f)) # define FPUTS_UNLOCKED(s, f) fputs((s), (f)) # define FWRITE_UNLOCKED(b, s, n, f) fwrite((b), (s), (n), (f)) #endif /* No thread safe i/o */ #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) /* line_wrap_stream is available, so use that. */ #define ARGP_FMTSTREAM_USE_LINEWRAP #endif #ifdef ARGP_FMTSTREAM_USE_LINEWRAP /* Just be a simple wrapper for line_wrap_stream; the semantics are *slightly* different, as line_wrap_stream doesn't actually make a new object, it just modifies the given stream (reversibly) to do line-wrapping. Since we control who uses this code, it doesn't matter. */ #include typedef FILE *argp_fmtstream_t; #define argp_make_fmtstream line_wrap_stream #define __argp_make_fmtstream line_wrap_stream #define argp_fmtstream_free line_unwrap_stream #define __argp_fmtstream_free line_unwrap_stream #define __argp_fmtstream_putc(fs,ch) putc(ch,fs) #define argp_fmtstream_putc(fs,ch) putc(ch,fs) #define __argp_fmtstream_puts(fs,str) fputs(str,fs) #define argp_fmtstream_puts(fs,str) fputs(str,fs) #define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs) #define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs) #define __argp_fmtstream_printf fprintf #define argp_fmtstream_printf fprintf #define __argp_fmtstream_lmargin line_wrap_lmargin #define argp_fmtstream_lmargin line_wrap_lmargin #define __argp_fmtstream_set_lmargin line_wrap_set_lmargin #define argp_fmtstream_set_lmargin line_wrap_set_lmargin #define __argp_fmtstream_rmargin line_wrap_rmargin #define argp_fmtstream_rmargin line_wrap_rmargin #define __argp_fmtstream_set_rmargin line_wrap_set_rmargin #define argp_fmtstream_set_rmargin line_wrap_set_rmargin #define __argp_fmtstream_wmargin line_wrap_wmargin #define argp_fmtstream_wmargin line_wrap_wmargin #define __argp_fmtstream_set_wmargin line_wrap_set_wmargin #define argp_fmtstream_set_wmargin line_wrap_set_wmargin #define __argp_fmtstream_point line_wrap_point #define argp_fmtstream_point line_wrap_point #else /* !ARGP_FMTSTREAM_USE_LINEWRAP */ /* Guess we have to define our own version. */ #ifndef __const #define __const const #endif struct argp_fmtstream { FILE *stream; /* The stream we're outputting to. */ size_t lmargin, rmargin; /* Left and right margins. */ ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */ /* Point in buffer to which we've processed for wrapping, but not output. */ size_t point_offs; /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */ ssize_t point_col; char *buf; /* Output buffer. */ char *p; /* Current end of text in BUF. */ char *end; /* Absolute end of BUF. */ }; typedef struct argp_fmtstream *argp_fmtstream_t; /* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines written on it with LMARGIN spaces and limits them to RMARGIN columns total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by replacing the whitespace before them with a newline and WMARGIN spaces. Otherwise, chars beyond RMARGIN are simply dropped until a newline. Returns NULL if there was an error. */ extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream, size_t __lmargin, size_t __rmargin, ssize_t __wmargin); extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream, size_t __lmargin, size_t __rmargin, ssize_t __wmargin); /* Flush __FS to its stream, and free it (but don't close the stream). */ extern void __argp_fmtstream_free (argp_fmtstream_t __fs); extern void argp_fmtstream_free (argp_fmtstream_t __fs); extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs, __const char *__fmt, ...) PRINTF_STYLE(2,3); extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs, __const char *__fmt, ...) PRINTF_STYLE(2,3); #if __STDC_VERSION__ - 199900L < 1 extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch); extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch); extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str); extern int argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str); extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs, __const char *__str, size_t __len); extern size_t argp_fmtstream_write (argp_fmtstream_t __fs, __const char *__str, size_t __len); #endif /* __STDC_VERSION__ - 199900L < 1 */ /* Access macros for various bits of state. */ #define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin) #define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin) #define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin) #define __argp_fmtstream_lmargin argp_fmtstream_lmargin #define __argp_fmtstream_rmargin argp_fmtstream_rmargin #define __argp_fmtstream_wmargin argp_fmtstream_wmargin #if __STDC_VERSION__ - 199900L < 1 /* Set __FS's left margin to LMARGIN and return the old value. */ extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin); extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin); /* Set __FS's right margin to __RMARGIN and return the old value. */ extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin); extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin); /* Set __FS's wrap margin to __WMARGIN and return the old value. */ extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin); extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin); /* Return the column number of the current output point in __FS. */ extern size_t argp_fmtstream_point (argp_fmtstream_t __fs); extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs); #endif /* __STDC_VERSION__ - 199900L < 1 */ /* Internal routines. */ extern void _argp_fmtstream_update (argp_fmtstream_t __fs); extern void __argp_fmtstream_update (argp_fmtstream_t __fs); extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); #ifdef __OPTIMIZE__ /* Inline versions of above routines. */ #if !_LIBC #define __argp_fmtstream_putc argp_fmtstream_putc #define __argp_fmtstream_puts argp_fmtstream_puts #define __argp_fmtstream_write argp_fmtstream_write #define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin #define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin #define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin #define __argp_fmtstream_point argp_fmtstream_point #define __argp_fmtstream_update _argp_fmtstream_update #define __argp_fmtstream_ensure _argp_fmtstream_ensure #endif #ifndef ARGP_FS_EI #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) #define ARGP_FS_EI extern inline #else #define ARGP_FS_EI inline #endif #endif ARGP_FS_EI size_t __argp_fmtstream_write (argp_fmtstream_t __fs, __const char *__str, size_t __len) { if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len)) { memcpy (__fs->p, __str, __len); __fs->p += __len; return __len; } else return 0; } ARGP_FS_EI int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str) { size_t __len = strlen (__str); if (__len) { size_t __wrote = __argp_fmtstream_write (__fs, __str, __len); return __wrote == __len ? 0 : -1; } else return 0; } ARGP_FS_EI int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch) { if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1)) return *__fs->p++ = __ch; else return EOF; } /* Set __FS's left margin to __LMARGIN and return the old value. */ ARGP_FS_EI size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->lmargin; __fs->lmargin = __lmargin; return __old; } /* Set __FS's right margin to __RMARGIN and return the old value. */ ARGP_FS_EI size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->rmargin; __fs->rmargin = __rmargin; return __old; } /* Set FS's wrap margin to __WMARGIN and return the old value. */ ARGP_FS_EI size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin) { size_t __old; if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); __old = __fs->wmargin; __fs->wmargin = __wmargin; return __old; } /* Return the column number of the current output point in __FS. */ ARGP_FS_EI size_t __argp_fmtstream_point (argp_fmtstream_t __fs) { if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) __argp_fmtstream_update (__fs); return __fs->point_col >= 0 ? __fs->point_col : 0; } #if !_LIBC #undef __argp_fmtstream_putc #undef __argp_fmtstream_puts #undef __argp_fmtstream_write #undef __argp_fmtstream_set_lmargin #undef __argp_fmtstream_set_rmargin #undef __argp_fmtstream_set_wmargin #undef __argp_fmtstream_point #undef __argp_fmtstream_update #undef __argp_fmtstream_ensure #endif #endif /* __OPTIMIZE__ */ #endif /* ARGP_FMTSTREAM_USE_LINEWRAP */ #endif /* argp-fmtstream.h */ glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-parse.c0000644000076200007630000000013112617742532023455 xustar000000000000000030 mtime=1447019866.024471735 29 atime=1447019866.36646659 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-parse.c0000644000076200007630000010745112617742532023703 0ustar00jenkinsjenkins00000000000000/* Hierarchial argument parsing Copyright (C) 1995, 96, 97, 98, 99, 2000,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif #ifdef HAVE_CONFIG_H #include #endif #if HAVE_ALLOCA_H #include #endif #include #include #if HAVE_UNISTD_H # include #endif #include #include #if HAVE_MALLOC_H /* Needed, for alloca on windows */ # include #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ # if defined HAVE_LIBINTL_H || defined _LIBC # include # ifdef _LIBC # undef dgettext # define dgettext(domain, msgid) __dcgettext (domain, msgid, LC_MESSAGES) # endif # else # define dgettext(domain, msgid) (msgid) # define gettext(msgid) (msgid) # endif #endif #ifndef N_ # define N_(msgid) (msgid) #endif #if _LIBC - 0 #include #else #ifdef HAVE_CTHREADS_H #include #endif #endif /* _LIBC */ #include "argp.h" #include "argp-namefrob.h" /* The meta-argument used to prevent any further arguments being interpreted as options. */ #define QUOTE "--" /* EZ alias for ARGP_ERR_UNKNOWN. */ #define EBADKEY ARGP_ERR_UNKNOWN /* Default options. */ /* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep for one second intervals, decrementing _ARGP_HANG until it's zero. Thus you can force the program to continue by attaching a debugger and setting it to 0 yourself. */ volatile int _argp_hang; #define OPT_PROGNAME -2 #define OPT_USAGE -3 #if HAVE_SLEEP && HAVE_GETPID #define OPT_HANG -4 #endif static const struct argp_option argp_default_options[] = { {"help", '?', 0, 0, N_("Give this help list"), -1}, {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0 }, {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name"), 0}, #if OPT_HANG {"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN, N_("Hang for SECS seconds (default 3600)"), 0 }, #endif {0, 0, 0, 0, 0, 0} }; static error_t argp_default_parser (int key, char *arg, struct argp_state *state) { switch (key) { case '?': __argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP); break; case OPT_USAGE: __argp_state_help (state, state->out_stream, ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK); break; case OPT_PROGNAME: /* Set the program name. */ #if HAVE_DECL_PROGRAM_INVOCATION_NAME program_invocation_name = arg; #endif /* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka __PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined to be that, so we have to be a bit careful here.] */ /* Update what we use for messages. */ state->name = __argp_basename(arg); #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME program_invocation_short_name = state->name; #endif if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS)) == ARGP_PARSE_ARGV0) /* Update what getopt uses too. */ state->argv[0] = arg; break; #if OPT_HANG case OPT_HANG: _argp_hang = atoi (arg ? arg : "3600"); fprintf(state->err_stream, "%s: pid = %ld\n", state->name, (long) getpid()); while (_argp_hang-- > 0) __sleep (1); break; #endif default: return EBADKEY; } return 0; } static const struct argp argp_default_argp = {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"}; static const struct argp_option argp_version_options[] = { {"version", 'V', 0, 0, N_("Print program version"), -1}, {0, 0, 0, 0, 0, 0 } }; static error_t argp_version_parser (int key, char *arg UNUSED, struct argp_state *state) { switch (key) { case 'V': if (argp_program_version_hook) (*argp_program_version_hook) (state->out_stream, state); else if (argp_program_version) fprintf (state->out_stream, "%s\n", argp_program_version); else __argp_error (state, dgettext (state->root_argp->argp_domain, "(PROGRAM ERROR) No version known!?")); if (! (state->flags & ARGP_NO_EXIT)) exit (0); break; default: return EBADKEY; } return 0; } static const struct argp argp_version_argp = {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"}; /* The state of a `group' during parsing. Each group corresponds to a particular argp structure from the tree of such descending from the top level argp passed to argp_parse. */ struct group { /* This group's parsing function. */ argp_parser_t parser; /* Which argp this group is from. */ const struct argp *argp; /* The number of non-option args sucessfully handled by this parser. */ unsigned args_processed; /* This group's parser's parent's group. */ struct group *parent; unsigned parent_index; /* And the our position in the parent. */ /* These fields are swapped into and out of the state structure when calling this group's parser. */ void *input, **child_inputs; void *hook; }; /* Call GROUP's parser with KEY and ARG, swapping any group-specific info from STATE before calling, and back into state afterwards. If GROUP has no parser, EBADKEY is returned. */ static error_t group_parse (struct group *group, struct argp_state *state, int key, char *arg) { if (group->parser) { error_t err; state->hook = group->hook; state->input = group->input; state->child_inputs = group->child_inputs; state->arg_num = group->args_processed; err = (*group->parser)(key, arg, state); group->hook = state->hook; return err; } else return EBADKEY; } struct parser { const struct argp *argp; const char *posixly_correct; /* True if there are only no-option arguments left, which are just passed verbatim with ARGP_KEY_ARG. This is set if we encounter a quote, or the end of the proper options, but may be cleared again if the user moves the next argument pointer backwards. */ int args_only; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. */ enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* A segment of non-option arguments that have been skipped for later processing, after all options. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. If quoted or args_only is non-zero, this segment should be empty. */ /* FIXME: I'd prefer to use unsigned, but it's more consistent to use the same type as for state.next. */ int first_nonopt; int last_nonopt; /* String of all recognized short options. Needed for ARGP_LONG_ONLY. */ /* FIXME: Perhaps change to a pointer to a suitable bitmap instead? */ char *short_opts; /* For parsing combined short options. */ char *nextchar; /* States of the various parsing groups. */ struct group *groups; /* The end of the GROUPS array. */ struct group *egroup; /* An vector containing storage for the CHILD_INPUTS field in all groups. */ void **child_inputs; /* State block supplied to parsing routines. */ struct argp_state state; /* Memory used by this parser. */ void *storage; }; /* Search for a group defining a short option. */ static const struct argp_option * find_short_option(struct parser *parser, int key, struct group **p) { struct group *group; assert(key >= 0); assert(isascii(key)); for (group = parser->groups; group < parser->egroup; group++) { const struct argp_option *opts; for (opts = group->argp->options; !__option_is_end(opts); opts++) if (opts->key == key) { *p = group; return opts; } } return NULL; } enum match_result { MATCH_EXACT, MATCH_PARTIAL, MATCH_NO }; /* If defined, allow complete.el-like abbreviations of long options. */ #ifndef ARGP_COMPLETE #define ARGP_COMPLETE 0 #endif /* Matches an encountern long-option argument ARG against an option NAME. * ARG is terminated by NUL or '='. */ static enum match_result match_option(const char *arg, const char *name) { unsigned i, j; for (i = j = 0;; i++, j++) { switch(arg[i]) { case '\0': case '=': return name[j] ? MATCH_PARTIAL : MATCH_EXACT; #if ARGP_COMPLETE case '-': while (name[j] != '-') if (!name[j++]) return MATCH_NO; break; #endif default: if (arg[i] != name[j]) return MATCH_NO; } } } static const struct argp_option * find_long_option(struct parser *parser, const char *arg, struct group **p) { struct group *group; /* Partial match found so far. */ struct group *matched_group = NULL; const struct argp_option *matched_option = NULL; /* Number of partial matches. */ int num_partial = 0; for (group = parser->groups; group < parser->egroup; group++) { const struct argp_option *opts; for (opts = group->argp->options; !__option_is_end(opts); opts++) { if (!opts->name) continue; switch (match_option(arg, opts->name)) { case MATCH_NO: break; case MATCH_PARTIAL: num_partial++; matched_group = group; matched_option = opts; break; case MATCH_EXACT: /* Exact match. */ *p = group; return opts; } } } if (num_partial == 1) { *p = matched_group; return matched_option; } return NULL; } /* The next usable entries in the various parser tables being filled in by convert_options. */ struct parser_convert_state { struct parser *parser; char *short_end; void **child_inputs_end; }; /* Initialize GROUP from ARGP. If CVT->SHORT_END is non-NULL, short options are recorded in the short options string. Returns the next unused group entry. CVT holds state used during the conversion. */ static struct group * convert_options (const struct argp *argp, struct group *parent, unsigned parent_index, struct group *group, struct parser_convert_state *cvt) { const struct argp_option *opt = argp->options; const struct argp_child *children = argp->children; if (opt || argp->parser) { /* This parser needs a group. */ if (cvt->short_end) { /* Record any short options. */ for ( ; !__option_is_end (opt); opt++) if (__option_is_short(opt)) *cvt->short_end++ = opt->key; } group->parser = argp->parser; group->argp = argp; group->args_processed = 0; group->parent = parent; group->parent_index = parent_index; group->input = 0; group->hook = 0; group->child_inputs = 0; if (children) /* Assign GROUP's CHILD_INPUTS field some space from CVT->child_inputs_end.*/ { unsigned num_children = 0; while (children[num_children].argp) num_children++; group->child_inputs = cvt->child_inputs_end; cvt->child_inputs_end += num_children; } parent = group++; } else parent = 0; if (children) { unsigned index = 0; while (children->argp) group = convert_options (children++->argp, parent, index++, group, cvt); } return group; } /* Allocate and initialize the group structures, so that they are ordered as if by traversing the corresponding argp parser tree in pre-order. Also build the list of short options, if that is needed. */ static void parser_convert (struct parser *parser, const struct argp *argp) { struct parser_convert_state cvt; cvt.parser = parser; cvt.short_end = parser->short_opts; cvt.child_inputs_end = parser->child_inputs; parser->argp = argp; if (argp) parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt); else parser->egroup = parser->groups; /* No parsers at all! */ if (parser->short_opts) *cvt.short_end ='\0'; } /* Lengths of various parser fields which we will allocated. */ struct parser_sizes { /* Needed only ARGP_LONG_ONLY */ size_t short_len; /* Number of short options. */ size_t num_groups; /* Group structures we allocate. */ size_t num_child_inputs; /* Child input slots. */ }; /* For ARGP, increments the NUM_GROUPS field in SZS by the total number of argp structures descended from it, and the SHORT_LEN by the total number of short options. */ static void calc_sizes (const struct argp *argp, struct parser_sizes *szs) { const struct argp_child *child = argp->children; const struct argp_option *opt = argp->options; if (opt || argp->parser) { /* This parser needs a group. */ szs->num_groups++; if (opt) { while (__option_is_short (opt++)) szs->short_len++; } } if (child) while (child->argp) { calc_sizes ((child++)->argp, szs); szs->num_child_inputs++; } } /* Initializes PARSER to parse ARGP in a manner described by FLAGS. */ static error_t parser_init (struct parser *parser, const struct argp *argp, int argc, char **argv, int flags, void *input) { error_t err = 0; struct group *group; struct parser_sizes szs; parser->posixly_correct = getenv ("POSIXLY_CORRECT"); if (flags & ARGP_IN_ORDER) parser->ordering = RETURN_IN_ORDER; else if (flags & ARGP_NO_ARGS) parser->ordering = REQUIRE_ORDER; else if (parser->posixly_correct) parser->ordering = REQUIRE_ORDER; else parser->ordering = PERMUTE; szs.short_len = 0; szs.num_groups = 0; szs.num_child_inputs = 0; if (argp) calc_sizes (argp, &szs); if (!(flags & ARGP_LONG_ONLY)) /* We have no use for the short option array. */ szs.short_len = 0; /* Lengths of the various bits of storage used by PARSER. */ #define GLEN (szs.num_groups + 1) * sizeof (struct group) #define CLEN (szs.num_child_inputs * sizeof (void *)) #define SLEN (szs.short_len + 1) #define STORAGE(offset) ((void *) (((char *) parser->storage) + (offset))) parser->storage = malloc (GLEN + CLEN + SLEN); if (! parser->storage) return ENOMEM; parser->groups = parser->storage; parser->child_inputs = STORAGE(GLEN); memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *)); if (flags & ARGP_LONG_ONLY) parser->short_opts = STORAGE(GLEN + CLEN); else parser->short_opts = NULL; parser_convert (parser, argp); memset (&parser->state, 0, sizeof (struct argp_state)); parser->state.root_argp = parser->argp; parser->state.argc = argc; parser->state.argv = argv; parser->state.flags = flags; parser->state.err_stream = stderr; parser->state.out_stream = stdout; parser->state.pstate = parser; parser->args_only = 0; parser->nextchar = NULL; parser->first_nonopt = parser->last_nonopt = 0; /* Call each parser for the first time, giving it a chance to propagate values to child parsers. */ if (parser->groups < parser->egroup) parser->groups->input = input; for (group = parser->groups; group < parser->egroup && (!err || err == EBADKEY); group++) { if (group->parent) /* If a child parser, get the initial input value from the parent. */ group->input = group->parent->child_inputs[group->parent_index]; if (!group->parser && group->argp->children && group->argp->children->argp) /* For the special case where no parsing function is supplied for an argp, propagate its input to its first child, if any (this just makes very simple wrapper argps more convenient). */ group->child_inputs[0] = group->input; err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0); } if (err == EBADKEY) err = 0; /* Some parser didn't understand. */ if (err) return err; if (argv[0] && !(parser->state.flags & ARGP_PARSE_ARGV0)) /* There's an argv[0]; use it for messages. */ { parser->state.name = __argp_basename(argv[0]); /* Don't parse it as an argument. */ parser->state.next = 1; } else parser->state.name = __argp_short_program_name(NULL); return 0; } /* Free any storage consumed by PARSER (but not PARSER itself). */ static error_t parser_finalize (struct parser *parser, error_t err, int arg_ebadkey, int *end_index) { struct group *group; if (err == EBADKEY && arg_ebadkey) /* Suppress errors generated by unparsed arguments. */ err = 0; if (! err) { if (parser->state.next == parser->state.argc) /* We successfully parsed all arguments! Call all the parsers again, just a few more times... */ { for (group = parser->groups; group < parser->egroup && (!err || err==EBADKEY); group++) if (group->args_processed == 0) err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0); for (group = parser->egroup - 1; group >= parser->groups && (!err || err==EBADKEY); group--) err = group_parse (group, &parser->state, ARGP_KEY_END, 0); if (err == EBADKEY) err = 0; /* Some parser didn't understand. */ /* Tell the user that all arguments are parsed. */ if (end_index) *end_index = parser->state.next; } else if (end_index) /* Return any remaining arguments to the user. */ *end_index = parser->state.next; else /* No way to return the remaining arguments, they must be bogus. */ { if (!(parser->state.flags & ARGP_NO_ERRS) && parser->state.err_stream) fprintf (parser->state.err_stream, dgettext (parser->argp->argp_domain, "%s: Too many arguments\n"), parser->state.name); err = EBADKEY; } } /* Okay, we're all done, with either an error or success; call the parsers to indicate which one. */ if (err) { /* Maybe print an error message. */ if (err == EBADKEY) /* An appropriate message describing what the error was should have been printed earlier. */ __argp_state_help (&parser->state, parser->state.err_stream, ARGP_HELP_STD_ERR); /* Since we didn't exit, give each parser an error indication. */ for (group = parser->groups; group < parser->egroup; group++) group_parse (group, &parser->state, ARGP_KEY_ERROR, 0); } else /* Notify parsers of success, and propagate back values from parsers. */ { /* We pass over the groups in reverse order so that child groups are given a chance to do there processing before passing back a value to the parent. */ for (group = parser->egroup - 1 ; group >= parser->groups && (!err || err == EBADKEY) ; group--) err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0); if (err == EBADKEY) err = 0; /* Some parser didn't understand. */ } /* Call parsers once more, to do any final cleanup. Errors are ignored. */ for (group = parser->egroup - 1; group >= parser->groups; group--) group_parse (group, &parser->state, ARGP_KEY_FINI, 0); if (err == EBADKEY) err = EINVAL; free (parser->storage); return err; } /* Call the user parsers to parse the non-option argument VAL, at the current position, returning any error. The state NEXT pointer should point to the argument; this function will adjust it correctly to reflect however many args actually end up being consumed. */ static error_t parser_parse_arg (struct parser *parser, char *val) { /* Save the starting value of NEXT */ int index = parser->state.next; error_t err = EBADKEY; struct group *group; int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */ /* Try to parse the argument in each parser. */ for (group = parser->groups ; group < parser->egroup && err == EBADKEY ; group++) { parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */ key = ARGP_KEY_ARG; err = group_parse (group, &parser->state, key, val); if (err == EBADKEY) /* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */ { parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */ key = ARGP_KEY_ARGS; err = group_parse (group, &parser->state, key, 0); } } if (! err) { if (key == ARGP_KEY_ARGS) /* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't changed by the user, *all* arguments should be considered consumed. */ parser->state.next = parser->state.argc; if (parser->state.next > index) /* Remember that we successfully processed a non-option argument -- but only if the user hasn't gotten tricky and set the clock back. */ (--group)->args_processed += (parser->state.next - index); else /* The user wants to reparse some args, so try looking for options again. */ parser->args_only = 0; } return err; } /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,next), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (struct parser *parser) { int bottom = parser->first_nonopt; int middle = parser->last_nonopt; int top = parser->state.next; char **argv = parser->state.argv; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ parser->first_nonopt += (parser->state.next - parser->last_nonopt); parser->last_nonopt = parser->state.next; } enum arg_type { ARG_ARG, ARG_SHORT_OPTION, ARG_LONG_OPTION, ARG_LONG_ONLY_OPTION, ARG_QUOTE }; static enum arg_type classify_arg(struct parser *parser, char *arg, char **opt) { if (arg[0] == '-') /* Looks like an option... */ switch (arg[1]) { case '\0': /* "-" is not an option. */ return ARG_ARG; case '-': /* Long option, or quote. */ if (!arg[2]) return ARG_QUOTE; /* A long option. */ if (opt) *opt = arg + 2; return ARG_LONG_OPTION; default: /* Short option. But if ARGP_LONG_ONLY, it can also be a long option. */ if (opt) *opt = arg + 1; if (parser->state.flags & ARGP_LONG_ONLY) { /* Rules from getopt.c: If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ assert(parser->short_opts); if (arg[2] || !strchr(parser->short_opts, arg[1])) return ARG_LONG_ONLY_OPTION; } return ARG_SHORT_OPTION; } else return ARG_ARG; } /* Parse the next argument in PARSER (as indicated by PARSER->state.next). Any error from the parsers is returned, and *ARGP_EBADKEY indicates whether a value of EBADKEY is due to an unrecognized argument (which is generally not fatal). */ static error_t parser_parse_next (struct parser *parser, int *arg_ebadkey) { if (parser->state.quoted && parser->state.next < parser->state.quoted) /* The next argument pointer has been moved to before the quoted region, so pretend we never saw the quoting `--', and start looking for options again. If the `--' is still there we'll just process it one more time. */ parser->state.quoted = parser->args_only = 0; /* Give FIRST_NONOPT & LAST_NONOPT rational values if NEXT has been moved back by the user (who may also have changed the arguments). */ if (parser->last_nonopt > parser->state.next) parser->last_nonopt = parser->state.next; if (parser->first_nonopt > parser->state.next) parser->first_nonopt = parser->state.next; if (parser->nextchar) /* Deal with short options. */ { struct group *group; char c; const struct argp_option *option; char *value = NULL;; assert(!parser->args_only); c = *parser->nextchar++; option = find_short_option(parser, c, &group); if (!option) { if (parser->posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: illegal option -- %c\n"), parser->state.name, c); else fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: invalid option -- %c\n"), parser->state.name, c); *arg_ebadkey = 0; return EBADKEY; } if (!*parser->nextchar) parser->nextchar = NULL; if (option->arg) { value = parser->nextchar; parser->nextchar = NULL; if (!value && !(option->flags & OPTION_ARG_OPTIONAL)) /* We need an mandatory argument. */ { if (parser->state.next == parser->state.argc) /* Missing argument */ { /* 1003.2 specifies the format of this message. */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: option requires an argument -- %c\n"), parser->state.name, c); *arg_ebadkey = 0; return EBADKEY; } value = parser->state.argv[parser->state.next++]; } } return group_parse(group, &parser->state, option->key, value); } else /* Advance to the next ARGV-element. */ { if (parser->args_only) { *arg_ebadkey = 1; if (parser->state.next >= parser->state.argc) /* We're done. */ return EBADKEY; else return parser_parse_arg(parser, parser->state.argv[parser->state.next]); } if (parser->state.next >= parser->state.argc) /* Almost done. If there are non-options that we skipped previously, we should process them now. */ { *arg_ebadkey = 1; if (parser->first_nonopt != parser->last_nonopt) { exchange(parser); /* Start processing the arguments we skipped previously. */ parser->state.next = parser->first_nonopt; parser->first_nonopt = parser->last_nonopt = 0; parser->args_only = 1; return 0; } else /* Indicate that we're really done. */ return EBADKEY; } else /* Look for options. */ { char *arg = parser->state.argv[parser->state.next]; char *optstart; enum arg_type token = classify_arg(parser, arg, &optstart); switch (token) { case ARG_ARG: switch (parser->ordering) { case PERMUTE: if (parser->first_nonopt == parser->last_nonopt) /* Skipped sequence is empty; start a new one. */ parser->first_nonopt = parser->last_nonopt = parser->state.next; else if (parser->last_nonopt != parser->state.next) /* We have a non-empty skipped sequence, and we're not at the end-point, so move it. */ exchange(parser); assert(parser->last_nonopt == parser->state.next); /* Skip this argument for now. */ parser->state.next++; parser->last_nonopt = parser->state.next; return 0; case REQUIRE_ORDER: /* Implicit quote before the first argument. */ parser->args_only = 1; return 0; case RETURN_IN_ORDER: *arg_ebadkey = 1; return parser_parse_arg(parser, arg); default: abort(); } case ARG_QUOTE: /* Skip it, then exchange with any previous non-options. */ parser->state.next++; assert (parser->last_nonopt != parser->state.next); if (parser->first_nonopt != parser->last_nonopt) { exchange(parser); /* Start processing the skipped and the quoted arguments. */ parser->state.quoted = parser->state.next = parser->first_nonopt; /* Also empty the skipped-list, to avoid confusion if the user resets the next pointer. */ parser->first_nonopt = parser->last_nonopt = 0; } else parser->state.quoted = parser->state.next; parser->args_only = 1; return 0; case ARG_LONG_ONLY_OPTION: case ARG_LONG_OPTION: { struct group *group; const struct argp_option *option; char *value; parser->state.next++; option = find_long_option(parser, optstart, &group); if (!option) { /* NOTE: This includes any "=something" in the output. */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: unrecognized option `%s'\n"), parser->state.name, arg); *arg_ebadkey = 0; return EBADKEY; } value = strchr(optstart, '='); if (value) value++; if (value && !option->arg) /* Unexpected argument. */ { if (token == ARG_LONG_OPTION) /* --option */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: option `--%s' doesn't allow an argument\n"), parser->state.name, option->name); else /* +option or -option */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: option `%c%s' doesn't allow an argument\n"), parser->state.name, arg[0], option->name); *arg_ebadkey = 0; return EBADKEY; } if (option->arg && !value && !(option->flags & OPTION_ARG_OPTIONAL)) /* We need an mandatory argument. */ { if (parser->state.next == parser->state.argc) /* Missing argument */ { if (token == ARG_LONG_OPTION) /* --option */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: option `--%s' requires an argument\n"), parser->state.name, option->name); else /* +option or -option */ fprintf (parser->state.err_stream, dgettext(parser->state.root_argp->argp_domain, "%s: option `%c%s' requires an argument\n"), parser->state.name, arg[0], option->name); *arg_ebadkey = 0; return EBADKEY; } value = parser->state.argv[parser->state.next++]; } *arg_ebadkey = 0; return group_parse(group, &parser->state, option->key, value); } case ARG_SHORT_OPTION: parser->state.next++; parser->nextchar = optstart; return 0; default: abort(); } } } } /* Parse the options strings in ARGC & ARGV according to the argp in ARGP. FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the index in ARGV of the first unparsed option is returned in it. If an unknown option is present, EINVAL is returned; if some parser routine returned a non-zero value, it is returned; otherwise 0 is returned. */ error_t __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, int *end_index, void *input) { error_t err; struct parser parser; /* If true, then err == EBADKEY is a result of a non-option argument failing to be parsed (which in some cases isn't actually an error). */ int arg_ebadkey = 0; if (! (flags & ARGP_NO_HELP)) /* Add our own options. */ { struct argp_child *child = alloca (4 * sizeof (struct argp_child)); struct argp *top_argp = alloca (sizeof (struct argp)); /* TOP_ARGP has no options, it just serves to group the user & default argps. */ memset (top_argp, 0, sizeof (*top_argp)); top_argp->children = child; memset (child, 0, 4 * sizeof (struct argp_child)); if (argp) (child++)->argp = argp; (child++)->argp = &argp_default_argp; if (argp_program_version || argp_program_version_hook) (child++)->argp = &argp_version_argp; child->argp = 0; argp = top_argp; } /* Construct a parser for these arguments. */ err = parser_init (&parser, argp, argc, argv, flags, input); if (! err) /* Parse! */ { while (! err) err = parser_parse_next (&parser, &arg_ebadkey); err = parser_finalize (&parser, err, arg_ebadkey, end_index); } return err; } #ifdef weak_alias weak_alias (__argp_parse, argp_parse) #endif /* Return the input field for ARGP in the parser corresponding to STATE; used by the help routines. */ void * __argp_input (const struct argp *argp, const struct argp_state *state) { if (state) { struct group *group; struct parser *parser = state->pstate; for (group = parser->groups; group < parser->egroup; group++) if (group->argp == argp) return group->input; } return 0; } #ifdef weak_alias weak_alias (__argp_input, _argp_input) #endif /* Defined here, in case a user is not inlining the definitions in * argp.h */ void __argp_usage (__const struct argp_state *__state) { __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); } int __option_is_short (__const struct argp_option *__opt) { if (__opt->flags & OPTION_DOC) return 0; else { int __key = __opt->key; /* FIXME: whether or not a particular key implies a short option * ought not to be locale dependent. */ return __key > 0 && isprint (__key); } } int __option_is_end (__const struct argp_option *__opt) { return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; } glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-pvh.c0000644000076200007630000000013012617742532023137 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-pvh.c0000644000076200007630000000275712617742532023371 0ustar00jenkinsjenkins00000000000000/* Default definition for ARGP_PROGRAM_VERSION_HOOK. Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "argp.h" /* If set by the user program to a non-zero value, then a default option --version is added (unless the ARGP_NO_HELP flag is used), which calls this function with a stream to print the version to and a pointer to the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = 0; glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-help.c0000644000076200007630000000013212617742532023274 xustar000000000000000030 mtime=1447019866.024471735 30 atime=1447019866.365466605 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/argp-help.c0000644000076200007630000015331512617742532023521 0ustar00jenkinsjenkins00000000000000/* Hierarchial argument parsing help output Copyright (C) 1995,96,97,98,99,2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif #ifdef HAVE_CONFIG_H #include #endif #if HAVE_ALLOCA_H #include #endif #include #include #include #include #include #include #if HAVE_MALLOC_H /* Needed, for alloca on windows */ # include #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. */ # if defined HAVE_LIBINTL_H || defined _LIBC # include # ifdef _LIBC # undef dgettext # define dgettext(domain, msgid) __dcgettext (domain, msgid, LC_MESSAGES) # endif # else # define dgettext(domain, msgid) (msgid) # endif #endif #include "argp.h" #include "argp-fmtstream.h" #include "argp-namefrob.h" #ifndef _LIBC # ifndef __strchrnul # define __strchrnul strchrnul # endif # ifndef __mempcpy # define __mempcpy mempcpy # endif /* We need to use a different name, as __strndup is likely a macro. */ # define STRNDUP strndup # if HAVE_STRERROR # define STRERROR strerror # else # define STRERROR(x) (sys_errlist[x]) # endif #else /* _LIBC */ # define FLOCKFILE __flockfile # define FUNLOCKFILE __funlockfile # define STRNDUP __strndup # define STRERROR strerror #endif #if !_LIBC # if !HAVE_STRNDUP char *strndup (const char *s, size_t size); # endif /* !HAVE_STRNDUP */ # if !HAVE_MEMPCPY void *mempcpy (void *to, const void *from, size_t size); # endif /* !HAVE_MEMPCPY */ # if !HAVE_STRCHRNUL char *strchrnul(const char *s, int c); # endif /* !HAVE_STRCHRNUL */ # if !HAVE_STRCASECMP int strcasecmp(const char *s1, const char *s2); #endif #endif /* !_LIBC */ /* User-selectable (using an environment variable) formatting parameters. These may be specified in an environment variable called `ARGP_HELP_FMT', with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2 Where VALn must be a positive integer. The list of variables is in the UPARAM_NAMES vector, below. */ /* Default parameters. */ #define DUP_ARGS 0 /* True if option argument can be duplicated. */ #define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */ #define SHORT_OPT_COL 2 /* column in which short options start */ #define LONG_OPT_COL 6 /* column in which long options start */ #define DOC_OPT_COL 2 /* column in which doc options start */ #define OPT_DOC_COL 29 /* column in which option text starts */ #define HEADER_COL 1 /* column in which group headers are printed */ #define USAGE_INDENT 12 /* indentation of wrapped usage lines */ #define RMARGIN 79 /* right margin used for wrapping */ /* User-selectable (using an environment variable) formatting parameters. They must all be of type `int' for the parsing code to work. */ struct uparams { /* If true, arguments for an option are shown with both short and long options, even when a given option has both, e.g. `-x ARG, --longx=ARG'. If false, then if an option has both, the argument is only shown with the long one, e.g., `-x, --longx=ARG', and a message indicating that this really means both is printed below the options. */ int dup_args; /* This is true if when DUP_ARGS is false, and some duplicate arguments have been suppressed, an explanatory message should be printed. */ int dup_args_note; /* Various output columns. */ int short_opt_col; int long_opt_col; int doc_opt_col; int opt_doc_col; int header_col; int usage_indent; int rmargin; int valid; /* True when the values in here are valid. */ }; /* This is a global variable, as user options are only ever read once. */ static struct uparams uparams = { DUP_ARGS, DUP_ARGS_NOTE, SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL, USAGE_INDENT, RMARGIN, 0 }; /* A particular uparam, and what the user name is. */ struct uparam_name { const char *name; /* User name. */ int is_bool; /* Whether it's `boolean'. */ size_t uparams_offs; /* Location of the (int) field in UPARAMS. */ }; /* The name-field mappings we know about. */ static const struct uparam_name uparam_names[] = { { "dup-args", 1, offsetof (struct uparams, dup_args) }, { "dup-args-note", 1, offsetof (struct uparams, dup_args_note) }, { "short-opt-col", 0, offsetof (struct uparams, short_opt_col) }, { "long-opt-col", 0, offsetof (struct uparams, long_opt_col) }, { "doc-opt-col", 0, offsetof (struct uparams, doc_opt_col) }, { "opt-doc-col", 0, offsetof (struct uparams, opt_doc_col) }, { "header-col", 0, offsetof (struct uparams, header_col) }, { "usage-indent", 0, offsetof (struct uparams, usage_indent) }, { "rmargin", 0, offsetof (struct uparams, rmargin) }, { 0, 0, 0 } }; /* Read user options from the environment, and fill in UPARAMS appropiately. */ static void fill_in_uparams (const struct argp_state *state) { const char *var = getenv ("ARGP_HELP_FMT"); #define SKIPWS(p) do { while (isspace (*p)) p++; } while (0); if (var) /* Parse var. */ while (*var) { SKIPWS (var); if (isalpha (*var)) { size_t var_len; const struct uparam_name *un; int unspec = 0, val = 0; const char *arg = var; while (isalnum (*arg) || *arg == '-' || *arg == '_') arg++; var_len = arg - var; SKIPWS (arg); if (*arg == '\0' || *arg == ',') unspec = 1; else if (*arg == '=') { arg++; SKIPWS (arg); } if (unspec) { if (var[0] == 'n' && var[1] == 'o' && var[2] == '-') { val = 0; var += 3; var_len -= 3; } else val = 1; } else if (isdigit (*arg)) { val = atoi (arg); while (isdigit (*arg)) arg++; SKIPWS (arg); } for (un = uparam_names; un->name; un++) if (strlen (un->name) == var_len && strncmp (var, un->name, var_len) == 0) { if (unspec && !un->is_bool) __argp_failure (state, 0, 0, dgettext (state->root_argp->argp_domain, "\ %.*s: ARGP_HELP_FMT parameter requires a value"), (int) var_len, var); else *(int *)((char *)&uparams + un->uparams_offs) = val; break; } if (! un->name) __argp_failure (state, 0, 0, dgettext (state->root_argp->argp_domain, "\ %.*s: Unknown ARGP_HELP_FMT parameter"), (int) var_len, var); var = arg; if (*var == ',') var++; } else if (*var) { __argp_failure (state, 0, 0, dgettext (state->root_argp->argp_domain, "Garbage in ARGP_HELP_FMT: %s"), var); break; } } } /* Returns true if OPT hasn't been marked invisible. Visibility only affects whether OPT is displayed or used in sorting, not option shadowing. */ #define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN)) /* Returns true if OPT is an alias for an earlier option. */ #define oalias(opt) ((opt)->flags & OPTION_ALIAS) /* Returns true if OPT is an documentation-only entry. */ #define odoc(opt) ((opt)->flags & OPTION_DOC) /* Returns true if OPT is the end-of-list marker for a list of options. */ #define oend(opt) __option_is_end (opt) /* Returns true if OPT has a short option. */ #define oshort(opt) __option_is_short (opt) /* The help format for a particular option is like: -xARG, -yARG, --long1=ARG, --long2=ARG Documentation... Where ARG will be omitted if there's no argument, for this option, or will be surrounded by "[" and "]" appropiately if the argument is optional. The documentation string is word-wrapped appropiately, and if the list of options is long enough, it will be started on a separate line. If there are no short options for a given option, the first long option is indented slighly in a way that's supposed to make most long options appear to be in a separate column. For example, the following output (from ps): -p PID, --pid=PID List the process PID --pgrp=PGRP List processes in the process group PGRP -P, -x, --no-parent Include processes without parents -Q, --all-fields Don't elide unusable fields (normally if there's some reason ps can't print a field for any process, it's removed from the output entirely) -r, --reverse, --gratuitously-long-reverse-option Reverse the order of any sort --session[=SID] Add the processes from the session SID (which defaults to the sid of the current process) Here are some more options: -f ZOT, --foonly=ZOT Glork a foonly -z, --zaza Snit a zar -?, --help Give this help list --usage Give a short usage message -V, --version Print program version The struct argp_option array for the above could look like: { {"pid", 'p', "PID", 0, "List the process PID"}, {"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"}, {"no-parent", 'P', 0, 0, "Include processes without parents"}, {0, 'x', 0, OPTION_ALIAS}, {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally" " if there's some reason ps can't" " print a field for any process, it's" " removed from the output entirely)" }, {"reverse", 'r', 0, 0, "Reverse the order of any sort"}, {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS}, {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL, "Add the processes from the session" " SID (which defaults to the sid of" " the current process)" }, {0,0,0,0, "Here are some more options:"}, {"foonly", 'f', "ZOT", 0, "Glork a foonly"}, {"zaza", 'z', 0, 0, "Snit a zar"}, {0} } Note that the last three options are automatically supplied by argp_parse, unless you tell it not to with ARGP_NO_HELP. */ /* Returns true if CH occurs between BEG and END. */ static int find_char (char ch, char *beg, char *end) { while (beg < end) if (*beg == ch) return 1; else beg++; return 0; } struct hol_cluster; /* fwd decl */ struct hol_entry { /* First option. */ const struct argp_option *opt; /* Number of options (including aliases). */ unsigned num; /* A pointers into the HOL's short_options field, to the first short option letter for this entry. The order of the characters following this point corresponds to the order of options pointed to by OPT, and there are at most NUM. A short option recorded in a option following OPT is only valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's probably been shadowed by some other entry). */ char *short_options; /* Entries are sorted by their group first, in the order: 1, 2, ..., n, 0, -m, ..., -2, -1 and then alphabetically within each group. The default is 0. */ int group; /* The cluster of options this entry belongs to, or 0 if none. */ struct hol_cluster *cluster; /* The argp from which this option came. */ const struct argp *argp; }; /* A cluster of entries to reflect the argp tree structure. */ struct hol_cluster { /* A descriptive header printed before options in this cluster. */ const char *header; /* Used to order clusters within the same group with the same parent, according to the order in which they occurred in the parent argp's child list. */ int index; /* How to sort this cluster with respect to options and other clusters at the same depth (clusters always follow options in the same group). */ int group; /* The cluster to which this cluster belongs, or 0 if it's at the base level. */ struct hol_cluster *parent; /* The argp from which this cluster is (eventually) derived. */ const struct argp *argp; /* The distance this cluster is from the root. */ int depth; /* Clusters in a given hol are kept in a linked list, to make freeing them possible. */ struct hol_cluster *next; }; /* A list of options for help. */ struct hol { /* An array of hol_entry's. */ struct hol_entry *entries; /* The number of entries in this hol. If this field is zero, the others are undefined. */ unsigned num_entries; /* A string containing all short options in this HOL. Each entry contains pointers into this string, so the order can't be messed with blindly. */ char *short_options; /* Clusters of entries in this hol. */ struct hol_cluster *clusters; }; /* Create a struct hol from the options in ARGP. CLUSTER is the hol_cluster in which these entries occur, or 0, if at the root. */ static struct hol * make_hol (const struct argp *argp, struct hol_cluster *cluster) { char *so; const struct argp_option *o; const struct argp_option *opts = argp->options; struct hol_entry *entry; unsigned num_short_options = 0; struct hol *hol = malloc (sizeof (struct hol)); assert (hol); hol->num_entries = 0; hol->clusters = 0; if (opts) { int cur_group = 0; /* The first option must not be an alias. */ assert (! oalias (opts)); /* Calculate the space needed. */ for (o = opts; ! oend (o); o++) { if (! oalias (o)) hol->num_entries++; if (oshort (o)) num_short_options++; /* This is an upper bound. */ } hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries); hol->short_options = malloc (num_short_options + 1); assert (hol->entries && hol->short_options); /* Fill in the entries. */ so = hol->short_options; for (o = opts, entry = hol->entries; ! oend (o); entry++) { entry->opt = o; entry->num = 0; entry->short_options = so; entry->group = cur_group = o->group ? o->group : ((!o->name && !o->key) ? cur_group + 1 : cur_group); entry->cluster = cluster; entry->argp = argp; do { entry->num++; if (oshort (o) && ! find_char (o->key, hol->short_options, so)) /* O has a valid short option which hasn't already been used.*/ *so++ = o->key; o++; } while (! oend (o) && oalias (o)); } *so = '\0'; /* null terminated so we can find the length */ } return hol; } /* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the associated argp child list entry), INDEX, and PARENT, and return a pointer to it. ARGP is the argp that this cluster results from. */ static struct hol_cluster * hol_add_cluster (struct hol *hol, int group, const char *header, int index, struct hol_cluster *parent, const struct argp *argp) { struct hol_cluster *cl = malloc (sizeof (struct hol_cluster)); if (cl) { cl->group = group; cl->header = header; cl->index = index; cl->parent = parent; cl->argp = argp; cl->depth = parent ? parent->depth + 1 : 0; cl->next = hol->clusters; hol->clusters = cl; } return cl; } /* Free HOL and any resources it uses. */ static void hol_free (struct hol *hol) { struct hol_cluster *cl = hol->clusters; while (cl) { struct hol_cluster *next = cl->next; free (cl); cl = next; } if (hol->num_entries > 0) { free (hol->entries); free (hol->short_options); } free (hol); } static inline int hol_entry_short_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, const char *domain, void *cookie), const char *domain, void *cookie) { unsigned nopts; int val = 0; const struct argp_option *opt, *real = entry->opt; char *so = entry->short_options; for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--) if (oshort (opt) && *so == opt->key) { if (!oalias (opt)) real = opt; if (ovisible (opt)) val = (*func)(opt, real, domain, cookie); so++; } return val; } static inline int hol_entry_long_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, const char *domain, void *cookie), const char *domain, void *cookie) { unsigned nopts; int val = 0; const struct argp_option *opt, *real = entry->opt; for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--) if (opt->name) { if (!oalias (opt)) real = opt; if (ovisible (opt)) val = (*func)(opt, real, domain, cookie); } return val; } /* Iterator that returns true for the first short option. */ static inline int until_short (const struct argp_option *opt, const struct argp_option *real UNUSED, const char *domain UNUSED, void *cookie UNUSED) { return oshort (opt) ? opt->key : 0; } /* Returns the first valid short option in ENTRY, or 0 if there is none. */ static char hol_entry_first_short (const struct hol_entry *entry) { return hol_entry_short_iterate (entry, until_short, entry->argp->argp_domain, 0); } /* Returns the first valid long option in ENTRY, or 0 if there is none. */ static const char * hol_entry_first_long (const struct hol_entry *entry) { const struct argp_option *opt; unsigned num; for (opt = entry->opt, num = entry->num; num > 0; opt++, num--) if (opt->name && ovisible (opt)) return opt->name; return 0; } /* Returns the entry in HOL with the long option name NAME, or 0 if there is none. */ static struct hol_entry * hol_find_entry (struct hol *hol, const char *name) { struct hol_entry *entry = hol->entries; unsigned num_entries = hol->num_entries; while (num_entries-- > 0) { const struct argp_option *opt = entry->opt; unsigned num_opts = entry->num; while (num_opts-- > 0) if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0) return entry; else opt++; entry++; } return 0; } /* If an entry with the long option NAME occurs in HOL, set it's special sort position to GROUP. */ static void hol_set_group (struct hol *hol, const char *name, int group) { struct hol_entry *entry = hol_find_entry (hol, name); if (entry) entry->group = group; } /* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1. EQ is what to return if GROUP1 and GROUP2 are the same. */ static int group_cmp (int group1, int group2, int eq) { if (group1 == group2) return eq; else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0)) return group1 - group2; else return group2 - group1; } /* Compare clusters CL1 & CL2 by the order that they should appear in output. */ static int hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2) { /* If one cluster is deeper than the other, use its ancestor at the same level, so that finding the common ancestor is straightforward. */ while (cl1->depth < cl2->depth) cl1 = cl1->parent; while (cl2->depth < cl1->depth) cl2 = cl2->parent; /* Now reduce both clusters to their ancestors at the point where both have a common parent; these can be directly compared. */ while (cl1->parent != cl2->parent) cl1 = cl1->parent, cl2 = cl2->parent; return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index); } /* Return the ancestor of CL that's just below the root (i.e., has a parent of 0). */ static struct hol_cluster * hol_cluster_base (struct hol_cluster *cl) { while (cl->parent) cl = cl->parent; return cl; } /* Return true if CL1 is a child of CL2. */ static int hol_cluster_is_child (const struct hol_cluster *cl1, const struct hol_cluster *cl2) { while (cl1 && cl1 != cl2) cl1 = cl1->parent; return cl1 == cl2; } /* Given the name of a OPTION_DOC option, modifies NAME to start at the tail that should be used for comparisons, and returns true iff it should be treated as a non-option. */ /* FIXME: Can we use unsigned char * for the argument? */ static int canon_doc_option (const char **name) { int non_opt; /* Skip initial whitespace. */ while (isspace ( (unsigned char) **name)) (*name)++; /* Decide whether this looks like an option (leading `-') or not. */ non_opt = (**name != '-'); /* Skip until part of name used for sorting. */ while (**name && !isalnum ( (unsigned char) **name)) (*name)++; return non_opt; } /* Order ENTRY1 & ENTRY2 by the order which they should appear in a help listing. */ static int hol_entry_cmp (const struct hol_entry *entry1, const struct hol_entry *entry2) { /* The group numbers by which the entries should be ordered; if either is in a cluster, then this is just the group within the cluster. */ int group1 = entry1->group, group2 = entry2->group; if (entry1->cluster != entry2->cluster) { /* The entries are not within the same cluster, so we can't compare them directly, we have to use the appropiate clustering level too. */ if (! entry1->cluster) /* ENTRY1 is at the `base level', not in a cluster, so we have to compare it's group number with that of the base cluster in which ENTRY2 resides. Note that if they're in the same group, the clustered option always comes laster. */ return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1); else if (! entry2->cluster) /* Likewise, but ENTRY2's not in a cluster. */ return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1); else /* Both entries are in clusters, we can just compare the clusters. */ return hol_cluster_cmp (entry1->cluster, entry2->cluster); } else if (group1 == group2) /* The entries are both in the same cluster and group, so compare them alphabetically. */ { int short1 = hol_entry_first_short (entry1); int short2 = hol_entry_first_short (entry2); int doc1 = odoc (entry1->opt); int doc2 = odoc (entry2->opt); /* FIXME: Can we use unsigned char * instead? */ const char *long1 = hol_entry_first_long (entry1); const char *long2 = hol_entry_first_long (entry2); if (doc1) doc1 = canon_doc_option (&long1); if (doc2) doc2 = canon_doc_option (&long2); if (doc1 != doc2) /* `documentation' options always follow normal options (or documentation options that *look* like normal options). */ return doc1 - doc2; else if (!short1 && !short2 && long1 && long2) /* Only long options. */ return __strcasecmp (long1, long2); else /* Compare short/short, long/short, short/long, using the first character of long options. Entries without *any* valid options (such as options with OPTION_HIDDEN set) will be put first, but as they're not displayed, it doesn't matter where they are. */ { unsigned char first1 = short1 ? short1 : long1 ? *long1 : 0; unsigned char first2 = short2 ? short2 : long2 ? *long2 : 0; #ifdef _tolower int lower_cmp = _tolower (first1) - _tolower (first2); #else int lower_cmp = tolower (first1) - tolower (first2); #endif /* Compare ignoring case, except when the options are both the same letter, in which case lower-case always comes first. */ /* NOTE: The subtraction below does the right thing even with eight-bit chars: first1 and first2 are converted to int *before* the subtraction. */ return lower_cmp ? lower_cmp : first2 - first1; } } else /* Within the same cluster, but not the same group, so just compare groups. */ return group_cmp (group1, group2, 0); } /* Version of hol_entry_cmp with correct signature for qsort. */ static int hol_entry_qcmp (const void *entry1_v, const void *entry2_v) { return hol_entry_cmp (entry1_v, entry2_v); } /* Sort HOL by group and alphabetically by option name (with short options taking precedence over long). Since the sorting is for display purposes only, the shadowing of options isn't effected. */ static void hol_sort (struct hol *hol) { if (hol->num_entries > 0) qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry), hol_entry_qcmp); } /* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow any in MORE with the same name. */ static void hol_append (struct hol *hol, struct hol *more) { struct hol_cluster **cl_end = &hol->clusters; /* Steal MORE's cluster list, and add it to the end of HOL's. */ while (*cl_end) cl_end = &(*cl_end)->next; *cl_end = more->clusters; more->clusters = 0; /* Merge entries. */ if (more->num_entries > 0) { if (hol->num_entries == 0) { hol->num_entries = more->num_entries; hol->entries = more->entries; hol->short_options = more->short_options; more->num_entries = 0; /* Mark MORE's fields as invalid. */ } else /* Append the entries in MORE to those in HOL, taking care to only add non-shadowed SHORT_OPTIONS values. */ { unsigned left; char *so, *more_so; struct hol_entry *e; unsigned num_entries = hol->num_entries + more->num_entries; struct hol_entry *entries = malloc (num_entries * sizeof (struct hol_entry)); unsigned hol_so_len = strlen (hol->short_options); char *short_options = malloc (hol_so_len + strlen (more->short_options) + 1); __mempcpy (__mempcpy (entries, hol->entries, hol->num_entries * sizeof (struct hol_entry)), more->entries, more->num_entries * sizeof (struct hol_entry)); __mempcpy (short_options, hol->short_options, hol_so_len); /* Fix up the short options pointers from HOL. */ for (e = entries, left = hol->num_entries; left > 0; e++, left--) e->short_options += (short_options - hol->short_options); /* Now add the short options from MORE, fixing up its entries too. */ so = short_options + hol_so_len; more_so = more->short_options; for (left = more->num_entries; left > 0; e++, left--) { int opts_left; const struct argp_option *opt; e->short_options = so; for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--) { int ch = *more_so; if (oshort (opt) && ch == opt->key) /* The next short option in MORE_SO, CH, is from OPT. */ { if (! find_char (ch, short_options, short_options + hol_so_len)) /* The short option CH isn't shadowed by HOL's options, so add it to the sum. */ *so++ = ch; more_so++; } } } *so = '\0'; free (hol->entries); free (hol->short_options); hol->entries = entries; hol->num_entries = num_entries; hol->short_options = short_options; } } hol_free (more); } /* Inserts enough spaces to make sure STREAM is at column COL. */ static void indent_to (argp_fmtstream_t stream, unsigned col) { int needed = col - __argp_fmtstream_point (stream); while (needed-- > 0) __argp_fmtstream_putc (stream, ' '); } /* Output to STREAM either a space, or a newline if there isn't room for at least ENSURE characters before the right margin. */ static void space (argp_fmtstream_t stream, size_t ensure) { if (__argp_fmtstream_point (stream) + ensure >= __argp_fmtstream_rmargin (stream)) __argp_fmtstream_putc (stream, '\n'); else __argp_fmtstream_putc (stream, ' '); } /* If the option REAL has an argument, we print it in using the printf format REQ_FMT or OPT_FMT depending on whether it's a required or optional argument. */ static void arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt, const char *domain UNUSED, argp_fmtstream_t stream) { if (real->arg) { if (real->flags & OPTION_ARG_OPTIONAL) __argp_fmtstream_printf (stream, opt_fmt, dgettext (domain, real->arg)); else __argp_fmtstream_printf (stream, req_fmt, dgettext (domain, real->arg)); } } /* Helper functions for hol_entry_help. */ /* State used during the execution of hol_help. */ struct hol_help_state { /* PREV_ENTRY should contain the previous entry printed, or 0. */ struct hol_entry *prev_entry; /* If an entry is in a different group from the previous one, and SEP_GROUPS is true, then a blank line will be printed before any output. */ int sep_groups; /* True if a duplicate option argument was suppressed (only ever set if UPARAMS.dup_args is false). */ int suppressed_dup_arg; }; /* Some state used while printing a help entry (used to communicate with helper functions). See the doc for hol_entry_help for more info, as most of the fields are copied from its arguments. */ struct pentry_state { const struct hol_entry *entry; argp_fmtstream_t stream; struct hol_help_state *hhstate; /* True if nothing's been printed so far. */ int first; /* If non-zero, the state that was used to print this help. */ const struct argp_state *state; }; /* If a user doc filter should be applied to DOC, do so. */ static const char * filter_doc (const char *doc, int key, const struct argp *argp, const struct argp_state *state) { if (argp->help_filter) /* We must apply a user filter to this output. */ { void *input = __argp_input (argp, state); return (*argp->help_filter) (key, doc, input); } else /* No filter. */ return doc; } /* Prints STR as a header line, with the margin lines set appropiately, and notes the fact that groups should be separated with a blank line. ARGP is the argp that should dictate any user doc filtering to take place. Note that the previous wrap margin isn't restored, but the left margin is reset to 0. */ static void print_header (const char *str, const struct argp *argp, struct pentry_state *pest) { const char *tstr = dgettext (argp->argp_domain, str); const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state); if (fstr) { if (*fstr) { if (pest->hhstate->prev_entry) /* Precede with a blank line. */ __argp_fmtstream_putc (pest->stream, '\n'); indent_to (pest->stream, uparams.header_col); __argp_fmtstream_set_lmargin (pest->stream, uparams.header_col); __argp_fmtstream_set_wmargin (pest->stream, uparams.header_col); __argp_fmtstream_puts (pest->stream, fstr); __argp_fmtstream_set_lmargin (pest->stream, 0); __argp_fmtstream_putc (pest->stream, '\n'); } pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */ } if (fstr != tstr) free ((char *) fstr); } /* Inserts a comma if this isn't the first item on the line, and then makes sure we're at least to column COL. If this *is* the first item on a line, prints any pending whitespace/headers that should precede this line. Also clears FIRST. */ static void comma (unsigned col, struct pentry_state *pest) { if (pest->first) { const struct hol_entry *pe = pest->hhstate->prev_entry; const struct hol_cluster *cl = pest->entry->cluster; if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group) __argp_fmtstream_putc (pest->stream, '\n'); if (cl && cl->header && *cl->header && (!pe || (pe->cluster != cl && !hol_cluster_is_child (pe->cluster, cl)))) /* If we're changing clusters, then this must be the start of the ENTRY's cluster unless that is an ancestor of the previous one (in which case we had just popped into a sub-cluster for a bit). If so, then print the cluster's header line. */ { int old_wm = __argp_fmtstream_wmargin (pest->stream); print_header (cl->header, cl->argp, pest); __argp_fmtstream_set_wmargin (pest->stream, old_wm); } pest->first = 0; } else __argp_fmtstream_puts (pest->stream, ", "); indent_to (pest->stream, col); } /* Print help for ENTRY to STREAM. */ static void hol_entry_help (struct hol_entry *entry, const struct argp_state *state, argp_fmtstream_t stream, struct hol_help_state *hhstate) { unsigned num; const struct argp_option *real = entry->opt, *opt; char *so = entry->short_options; int have_long_opt = 0; /* We have any long options. */ /* Saved margins. */ int old_lm = __argp_fmtstream_set_lmargin (stream, 0); int old_wm = __argp_fmtstream_wmargin (stream); /* PEST is a state block holding some of our variables that we'd like to share with helper functions. */ /* Decent initializers are a GNU extension, so don't use it here. */ struct pentry_state pest; pest.entry = entry; pest.stream = stream; pest.hhstate = hhstate; pest.first = 1; pest.state = state; if (! odoc (real)) for (opt = real, num = entry->num; num > 0; opt++, num--) if (opt->name && ovisible (opt)) { have_long_opt = 1; break; } /* First emit short options. */ __argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */ for (opt = real, num = entry->num; num > 0; opt++, num--) if (oshort (opt) && opt->key == *so) /* OPT has a valid (non shadowed) short option. */ { if (ovisible (opt)) { comma (uparams.short_opt_col, &pest); __argp_fmtstream_putc (stream, '-'); __argp_fmtstream_putc (stream, *so); if (!have_long_opt || uparams.dup_args) arg (real, " %s", "[%s]", state->root_argp->argp_domain, stream); else if (real->arg) hhstate->suppressed_dup_arg = 1; } so++; } /* Now, long options. */ if (odoc (real)) /* A `documentation' option. */ { __argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col); for (opt = real, num = entry->num; num > 0; opt++, num--) if (opt->name && ovisible (opt)) { comma (uparams.doc_opt_col, &pest); /* Calling gettext here isn't quite right, since sorting will have been done on the original; but documentation options should be pretty rare anyway... */ __argp_fmtstream_puts (stream, dgettext (state->root_argp->argp_domain, opt->name)); } } else /* A real long option. */ { int first_long_opt = 1; __argp_fmtstream_set_wmargin (stream, uparams.long_opt_col); for (opt = real, num = entry->num; num > 0; opt++, num--) if (opt->name && ovisible (opt)) { comma (uparams.long_opt_col, &pest); __argp_fmtstream_printf (stream, "--%s", opt->name); if (first_long_opt || uparams.dup_args) arg (real, "=%s", "[=%s]", state->root_argp->argp_domain, stream); else if (real->arg) hhstate->suppressed_dup_arg = 1; } } /* Next, documentation strings. */ __argp_fmtstream_set_lmargin (stream, 0); if (pest.first) { /* Didn't print any switches, what's up? */ if (!oshort (real) && !real->name) /* This is a group header, print it nicely. */ print_header (real->doc, entry->argp, &pest); else /* Just a totally shadowed option or null header; print nothing. */ goto cleanup; /* Just return, after cleaning up. */ } else { const char *tstr = real->doc ? dgettext (state->root_argp->argp_domain, real->doc) : 0; const char *fstr = filter_doc (tstr, real->key, entry->argp, state); if (fstr && *fstr) { unsigned int col = __argp_fmtstream_point (stream); __argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col); __argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col); if (col > (unsigned int) (uparams.opt_doc_col + 3)) __argp_fmtstream_putc (stream, '\n'); else if (col >= (unsigned int) uparams.opt_doc_col) __argp_fmtstream_puts (stream, " "); else indent_to (stream, uparams.opt_doc_col); __argp_fmtstream_puts (stream, fstr); } if (fstr && fstr != tstr) free ((char *) fstr); /* Reset the left margin. */ __argp_fmtstream_set_lmargin (stream, 0); __argp_fmtstream_putc (stream, '\n'); } hhstate->prev_entry = entry; cleanup: __argp_fmtstream_set_lmargin (stream, old_lm); __argp_fmtstream_set_wmargin (stream, old_wm); } /* Output a long help message about the options in HOL to STREAM. */ static void hol_help (struct hol *hol, const struct argp_state *state, argp_fmtstream_t stream) { unsigned num; struct hol_entry *entry; struct hol_help_state hhstate = { 0, 0, 0 }; for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--) hol_entry_help (entry, state, stream, &hhstate); if (hhstate.suppressed_dup_arg && uparams.dup_args_note) { const char *tstr = dgettext (state->root_argp->argp_domain, "\ Mandatory or optional arguments to long options are also mandatory or \ optional for any corresponding short options."); const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE, state ? state->root_argp : 0, state); if (fstr && *fstr) { __argp_fmtstream_putc (stream, '\n'); __argp_fmtstream_puts (stream, fstr); __argp_fmtstream_putc (stream, '\n'); } if (fstr && fstr != tstr) free ((char *) fstr); } } /* Helper functions for hol_usage. */ /* If OPT is a short option without an arg, append its key to the string pointer pointer to by COOKIE, and advance the pointer. */ static int add_argless_short_opt (const struct argp_option *opt, const struct argp_option *real, const char *domain UNUSED, void *cookie) { char **snao_end = cookie; if (!(opt->arg || real->arg) && !((opt->flags | real->flags) & OPTION_NO_USAGE)) *(*snao_end)++ = opt->key; return 0; } /* If OPT is a short option with an arg, output a usage entry for it to the stream pointed at by COOKIE. */ static int usage_argful_short_opt (const struct argp_option *opt, const struct argp_option *real, const char *domain UNUSED, void *cookie) { argp_fmtstream_t stream = cookie; const char *arg = opt->arg; int flags = opt->flags | real->flags; if (! arg) arg = real->arg; if (arg && !(flags & OPTION_NO_USAGE)) { arg = dgettext (domain, arg); if (flags & OPTION_ARG_OPTIONAL) __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg); else { /* Manually do line wrapping so that it (probably) won't get wrapped at the embedded space. */ space (stream, 6 + strlen (arg)); __argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg); } } return 0; } /* Output a usage entry for the long option opt to the stream pointed at by COOKIE. */ static int usage_long_opt (const struct argp_option *opt, const struct argp_option *real, const char *domain UNUSED, void *cookie) { argp_fmtstream_t stream = cookie; const char *arg = opt->arg; int flags = opt->flags | real->flags; if (! arg) arg = real->arg; if (! (flags & OPTION_NO_USAGE)) { if (arg) { arg = dgettext (domain, arg); if (flags & OPTION_ARG_OPTIONAL) __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg); else __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg); } else __argp_fmtstream_printf (stream, " [--%s]", opt->name); } return 0; } /* Print a short usage description for the arguments in HOL to STREAM. */ static void hol_usage (struct hol *hol, argp_fmtstream_t stream) { if (hol->num_entries > 0) { unsigned nentries; struct hol_entry *entry; char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1); char *snao_end = short_no_arg_opts; /* First we put a list of short options without arguments. */ for (entry = hol->entries, nentries = hol->num_entries ; nentries > 0 ; entry++, nentries--) hol_entry_short_iterate (entry, add_argless_short_opt, entry->argp->argp_domain, &snao_end); if (snao_end > short_no_arg_opts) { *snao_end++ = 0; __argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts); } /* Now a list of short options *with* arguments. */ for (entry = hol->entries, nentries = hol->num_entries ; nentries > 0 ; entry++, nentries--) hol_entry_short_iterate (entry, usage_argful_short_opt, entry->argp->argp_domain, stream); /* Finally, a list of long options (whew!). */ for (entry = hol->entries, nentries = hol->num_entries ; nentries > 0 ; entry++, nentries--) hol_entry_long_iterate (entry, usage_long_opt, entry->argp->argp_domain, stream); } } /* Make a HOL containing all levels of options in ARGP. CLUSTER is the cluster in which ARGP's entries should be clustered, or 0. */ static struct hol * argp_hol (const struct argp *argp, struct hol_cluster *cluster) { const struct argp_child *child = argp->children; struct hol *hol = make_hol (argp, cluster); if (child) while (child->argp) { struct hol_cluster *child_cluster = ((child->group || child->header) /* Put CHILD->argp within its own cluster. */ ? hol_add_cluster (hol, child->group, child->header, child - argp->children, cluster, argp) /* Just merge it into the parent's cluster. */ : cluster); hol_append (hol, argp_hol (child->argp, child_cluster)) ; child++; } return hol; } /* Calculate how many different levels with alternative args strings exist in ARGP. */ static size_t argp_args_levels (const struct argp *argp) { size_t levels = 0; const struct argp_child *child = argp->children; if (argp->args_doc && strchr (argp->args_doc, '\n')) levels++; if (child) while (child->argp) levels += argp_args_levels ((child++)->argp); return levels; } /* Print all the non-option args documented in ARGP to STREAM. Any output is preceded by a space. LEVELS is a pointer to a byte vector the length returned by argp_args_levels; it should be initialized to zero, and updated by this routine for the next call if ADVANCE is true. True is returned as long as there are more patterns to output. */ static int argp_args_usage (const struct argp *argp, const struct argp_state *state, char **levels, int advance, argp_fmtstream_t stream) { char *our_level = *levels; int multiple = 0; const struct argp_child *child = argp->children; const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0; const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state); if (fdoc) { const char *cp = fdoc; nl = __strchrnul (cp, '\n'); if (*nl != '\0') /* This is a `multi-level' args doc; advance to the correct position as determined by our state in LEVELS, and update LEVELS. */ { int i; multiple = 1; for (i = 0; i < *our_level; i++) cp = nl + 1, nl = __strchrnul (cp, '\n'); (*levels)++; } /* Manually do line wrapping so that it (probably) won't get wrapped at any embedded spaces. */ space (stream, 1 + nl - cp); __argp_fmtstream_write (stream, cp, nl - cp); } if (fdoc && fdoc != tdoc) free ((char *)fdoc); /* Free user's modified doc string. */ if (child) while (child->argp) advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream); if (advance && multiple) { /* Need to increment our level. */ if (*nl) /* There's more we can do here. */ { (*our_level)++; advance = 0; /* Our parent shouldn't advance also. */ } else if (*our_level > 0) /* We had multiple levels, but used them up; reset to zero. */ *our_level = 0; } return !advance; } /* Print the documentation for ARGP to STREAM; if POST is false, then everything preceeding a `\v' character in the documentation strings (or the whole string, for those with none) is printed, otherwise, everything following the `\v' character (nothing for strings without). Each separate bit of documentation is separated a blank line, and if PRE_BLANK is true, then the first is as well. If FIRST_ONLY is true, only the first occurrence is output. Returns true if anything was output. */ static int argp_doc (const struct argp *argp, const struct argp_state *state, int post, int pre_blank, int first_only, argp_fmtstream_t stream) { const char *text; const char *inp_text; void *input = 0; int anything = 0; size_t inp_text_limit = 0; const char *doc = dgettext (argp->argp_domain, argp->doc); const struct argp_child *child = argp->children; if (doc) { char *vt = strchr (doc, '\v'); inp_text = post ? (vt ? vt + 1 : 0) : doc; inp_text_limit = (!post && vt) ? (vt - doc) : 0; } else inp_text = 0; if (argp->help_filter) /* We have to filter the doc strings. */ { if (inp_text_limit) /* Copy INP_TEXT so that it's nul-terminated. */ inp_text = STRNDUP (inp_text, inp_text_limit); input = __argp_input (argp, state); text = (*argp->help_filter) (post ? ARGP_KEY_HELP_POST_DOC : ARGP_KEY_HELP_PRE_DOC, inp_text, input); } else text = (const char *) inp_text; if (text) { if (pre_blank) __argp_fmtstream_putc (stream, '\n'); if (text == inp_text && inp_text_limit) __argp_fmtstream_write (stream, inp_text, inp_text_limit); else __argp_fmtstream_puts (stream, text); if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) __argp_fmtstream_putc (stream, '\n'); anything = 1; } if (text && text != inp_text) free ((char *) text); /* Free TEXT returned from the help filter. */ if (inp_text && inp_text_limit && argp->help_filter) free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */ if (post && argp->help_filter) /* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */ { text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input); if (text) { if (anything || pre_blank) __argp_fmtstream_putc (stream, '\n'); __argp_fmtstream_puts (stream, text); free ((char *) text); if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) __argp_fmtstream_putc (stream, '\n'); anything = 1; } } if (child) while (child->argp && !(first_only && anything)) anything |= argp_doc ((child++)->argp, state, post, anything || pre_blank, first_only, stream); return anything; } /* Output a usage message for ARGP to STREAM. If called from argp_state_help, STATE is the relevent parsing state. FLAGS are from the set ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */ static void _help (const struct argp *argp, const struct argp_state *state, FILE *stream, unsigned flags, const char *name) { int anything = 0; /* Whether we've output anything. */ struct hol *hol = 0; argp_fmtstream_t fs; if (! stream) return; FLOCKFILE (stream); if (! uparams.valid) fill_in_uparams (state); fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0); if (! fs) { FUNLOCKFILE (stream); return; } if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG)) { hol = argp_hol (argp, 0); /* If present, these options always come last. */ hol_set_group (hol, "help", -1); hol_set_group (hol, "version", -1); hol_sort (hol); } if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE)) /* Print a short `Usage:' message. */ { int first_pattern = 1, more_patterns; size_t num_pattern_levels = argp_args_levels (argp); char *pattern_levels = alloca (num_pattern_levels); memset (pattern_levels, 0, num_pattern_levels); do { int old_lm; int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent); char *levels = pattern_levels; if (first_pattern) __argp_fmtstream_printf (fs, "%s %s", dgettext (argp->argp_domain, "Usage:"), name); else __argp_fmtstream_printf (fs, "%s %s", dgettext (argp->argp_domain, " or: "), name); /* We set the lmargin as well as the wmargin, because hol_usage manually wraps options with newline to avoid annoying breaks. */ old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent); if (flags & ARGP_HELP_SHORT_USAGE) /* Just show where the options go. */ { if (hol->num_entries > 0) __argp_fmtstream_puts (fs, dgettext (argp->argp_domain, " [OPTION...]")); } else /* Actually print the options. */ { hol_usage (hol, fs); flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */ } more_patterns = argp_args_usage (argp, state, &levels, 1, fs); __argp_fmtstream_set_wmargin (fs, old_wm); __argp_fmtstream_set_lmargin (fs, old_lm); __argp_fmtstream_putc (fs, '\n'); anything = 1; first_pattern = 0; } while (more_patterns); } if (flags & ARGP_HELP_PRE_DOC) anything |= argp_doc (argp, state, 0, 0, 1, fs); if (flags & ARGP_HELP_SEE) { __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\ Try `%s --help' or `%s --usage' for more information.\n"), name, name); anything = 1; } if (flags & ARGP_HELP_LONG) /* Print a long, detailed help message. */ { /* Print info about all the options. */ if (hol->num_entries > 0) { if (anything) __argp_fmtstream_putc (fs, '\n'); hol_help (hol, state, fs); anything = 1; } } if (flags & ARGP_HELP_POST_DOC) /* Print any documentation strings at the end. */ anything |= argp_doc (argp, state, 1, anything, 0, fs); if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address) { if (anything) __argp_fmtstream_putc (fs, '\n'); __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "Report bugs to %s.\n"), argp_program_bug_address); anything = 1; } FUNLOCKFILE (stream); if (hol) hol_free (hol); __argp_fmtstream_free (fs); } /* Output a usage message for ARGP to STREAM. FLAGS are from the set ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */ void __argp_help (const struct argp *argp, FILE *stream, unsigned flags, char *name) { _help (argp, 0, stream, flags, name); } #ifdef weak_alias weak_alias (__argp_help, argp_help) #endif char *__argp_basename(char *name) { char *short_name = strrchr(name, '/'); return short_name ? short_name + 1 : name; } char * __argp_short_program_name(const struct argp_state *state) { if (state) return state->name; #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME return program_invocation_short_name; #elif HAVE_DECL_PROGRAM_INVOCATION_NAME return __argp_basename(program_invocation_name); #else /* !HAVE_DECL_PROGRAM_INVOCATION_NAME */ /* FIXME: What now? Miles suggests that it is better to use NULL, but currently the value is passed on directly to fputs_unlocked, so that requires more changes. */ # if __GNUC__ return ""; # endif /* __GNUC__ */ #endif /* !HAVE_DECL_PROGRAM_INVOCATION_NAME */ } /* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are from the set ARGP_HELP_*. */ void __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags) { if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream) { if (state && (state->flags & ARGP_LONG_ONLY)) flags |= ARGP_HELP_LONG_ONLY; _help (state ? state->root_argp : 0, state, stream, flags, __argp_short_program_name(state)); if (!state || ! (state->flags & ARGP_NO_EXIT)) { if (flags & ARGP_HELP_EXIT_ERR) exit (argp_err_exit_status); if (flags & ARGP_HELP_EXIT_OK) exit (0); } } } #ifdef weak_alias weak_alias (__argp_state_help, argp_state_help) #endif /* If appropriate, print the printf string FMT and following args, preceded by the program name and `:', to stderr, and followed by a `Try ... --help' message, then exit (1). */ void __argp_error (const struct argp_state *state, const char *fmt, ...) { if (!state || !(state->flags & ARGP_NO_ERRS)) { FILE *stream = state ? state->err_stream : stderr; if (stream) { va_list ap; FLOCKFILE (stream); FPUTS_UNLOCKED (__argp_short_program_name(state), stream); PUTC_UNLOCKED (':', stream); PUTC_UNLOCKED (' ', stream); va_start (ap, fmt); vfprintf (stream, fmt, ap); va_end (ap); PUTC_UNLOCKED ('\n', stream); __argp_state_help (state, stream, ARGP_HELP_STD_ERR); FUNLOCKFILE (stream); } } } #ifdef weak_alias weak_alias (__argp_error, argp_error) #endif /* Similar to the standard gnu error-reporting function error(), but will respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print to STATE->err_stream. This is useful for argument parsing code that is shared between program startup (when exiting is desired) and runtime option parsing (when typically an error code is returned instead). The difference between this function and argp_error is that the latter is for *parsing errors*, and the former is for other problems that occur during parsing but don't reflect a (syntactic) problem with the input. */ void __argp_failure (const struct argp_state *state, int status, int errnum, const char *fmt, ...) { if (!state || !(state->flags & ARGP_NO_ERRS)) { FILE *stream = state ? state->err_stream : stderr; if (stream) { FLOCKFILE (stream); FPUTS_UNLOCKED (__argp_short_program_name(state), stream); if (fmt) { va_list ap; PUTC_UNLOCKED (':', stream); PUTC_UNLOCKED (' ', stream); va_start (ap, fmt); vfprintf (stream, fmt, ap); va_end (ap); } if (errnum) { PUTC_UNLOCKED (':', stream); PUTC_UNLOCKED (' ', stream); fputs (STRERROR (errnum), stream); } PUTC_UNLOCKED ('\n', stream); FUNLOCKFILE (stream); if (status && (!state || !(state->flags & ARGP_NO_EXIT))) exit (status); } } } #ifdef weak_alias weak_alias (__argp_failure, argp_failure) #endif glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/missing0000644000076200007630000000013212617742566022654 xustar000000000000000030 mtime=1447019894.180048146 30 atime=1447019894.180048146 30 ctime=1447019929.880511058 glusterfs-3.7.6/contrib/argp-standalone/missing0000755000076200007630000002623312617742566023102 0ustar00jenkinsjenkins00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/strchrnul.c0000644000076200007630000000013012617742532023437 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.881511043 glusterfs-3.7.6/contrib/argp-standalone/strchrnul.c0000644000076200007630000000073712617742532023665 0ustar00jenkinsjenkins00000000000000/* strchrnul.c * */ /* Written by Niels Möller * * This file is hereby placed in the public domain. */ /* FIXME: What is this function supposed to do? My guess is that it is * like strchr, but returns a pointer to the NUL character, not a NULL * pointer, if the character isn't found. */ char *strchrnul(const char *, int ); char *strchrnul(const char *s, int c) { const char *p = s; while (*p && (*p != c)) p++; return (char *) p; } glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/acinclude.m40000644000076200007630000000013112617742532023441 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.881511043 glusterfs-3.7.6/contrib/argp-standalone/acinclude.m40000644000076200007630000007430112617742532023664 0ustar00jenkinsjenkins00000000000000dnl Try to detect the type of the third arg to getsockname() et al AC_DEFUN([LSH_TYPE_SOCKLEN_T], [AH_TEMPLATE([socklen_t], [Length type used by getsockopt]) AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t, [AC_EGREP_HEADER(socklen_t, sys/socket.h, [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])]) if test $ac_cv_type_socklen_t = no; then AC_MSG_CHECKING(for AIX) AC_EGREP_CPP(yes, [ #ifdef _AIX yes #endif ],[ AC_MSG_RESULT(yes) AC_DEFINE(socklen_t, size_t) ],[ AC_MSG_RESULT(no) AC_DEFINE(socklen_t, int) ]) fi ]) dnl Choose cc flags for compiling position independent code AC_DEFUN([LSH_CCPIC], [AC_MSG_CHECKING(CCPIC) AC_CACHE_VAL(lsh_cv_sys_ccpic,[ if test -z "$CCPIC" ; then if test "$GCC" = yes ; then case `uname -sr` in BSD/OS*) case `uname -r` in 4.*) CCPIC="-fPIC";; *) CCPIC="";; esac ;; Darwin*) CCPIC="-fPIC" ;; SunOS\ 5.*) # Could also use -fPIC, if there are a large number of symbol reference CCPIC="-fPIC" ;; CYGWIN*) CCPIC="" ;; *) CCPIC="-fpic" ;; esac else case `uname -sr` in Darwin*) CCPIC="-fPIC" ;; IRIX*) CCPIC="-share" ;; hp*|HP*) CCPIC="+z"; ;; FreeBSD*) CCPIC="-fpic";; SCO_SV*) CCPIC="-KPIC -dy -Bdynamic";; UnixWare*|OpenUNIX*) CCPIC="-KPIC -dy -Bdynamic";; Solaris*) CCPIC="-KPIC -Bdynamic";; Windows_NT*) CCPIC="-shared" ;; esac fi fi OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $CCPIC" AC_TRY_COMPILE([], [exit(0);], lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='') CFLAGS="$OLD_CFLAGS" ]) CCPIC="$lsh_cv_sys_ccpic" AC_MSG_RESULT($CCPIC) AC_SUBST([CCPIC])]) dnl LSH_PATH_ADD(path-id, directory) AC_DEFUN([LSH_PATH_ADD], [AC_MSG_CHECKING($2) ac_exists=no if test -d "$2/." ; then ac_real_dir=`cd $2 && pwd` if test -n "$ac_real_dir" ; then ac_exists=yes for old in $1_REAL_DIRS ; do ac_found=no if test x$ac_real_dir = x$old ; then ac_found=yes; break; fi done if test $ac_found = yes ; then AC_MSG_RESULT(already added) else AC_MSG_RESULT(added) # LDFLAGS="$LDFLAGS -L $2" $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS" $1_DIRS="$2 [$]$1_DIRS" fi fi fi if test $ac_exists = no ; then AC_MSG_RESULT(not found) fi ]) dnl LSH_RPATH_ADD(dir) AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)]) dnl LSH_RPATH_INIT(candidates) AC_DEFUN([LSH_RPATH_INIT], [AC_MSG_CHECKING([for -R flag]) RPATHFLAG='' case `uname -sr` in OSF1\ V4.*) RPATHFLAG="-rpath " ;; IRIX\ 6.*) RPATHFLAG="-rpath " ;; IRIX\ 5.*) RPATHFLAG="-rpath " ;; SunOS\ 5.*) if test "$TCC" = "yes"; then # tcc doesn't know about -R RPATHFLAG="-Wl,-R," else RPATHFLAG=-R fi ;; Linux\ 2.*) RPATHFLAG="-Wl,-rpath," ;; *) : ;; esac if test x$RPATHFLAG = x ; then AC_MSG_RESULT(none) else AC_MSG_RESULT([using $RPATHFLAG]) fi RPATH_CANDIDATE_REAL_DIRS='' RPATH_CANDIDATE_DIRS='' AC_MSG_RESULT([Searching for libraries]) for d in $1 ; do LSH_RPATH_ADD($d) done ]) dnl Try to execute a main program, and if it fails, try adding some dnl -R flag. dnl LSH_RPATH_FIX AC_DEFUN([LSH_RPATH_FIX], [if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then ac_success=no AC_TRY_RUN([int main(int argc, char **argv) { return 0; }], ac_success=yes, ac_success=no, :) if test $ac_success = no ; then AC_MSG_CHECKING([Running simple test program failed. Trying -R flags]) dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS ac_remaining_dirs='' ac_rpath_save_LDFLAGS="$LDFLAGS" for d in $RPATH_CANDIDATE_DIRS ; do if test $ac_success = yes ; then ac_remaining_dirs="$ac_remaining_dirs $d" else LDFLAGS="$RPATHFLAG$d $LDFLAGS" dnl echo LDFLAGS = $LDFLAGS AC_TRY_RUN([int main(int argc, char **argv) { return 0; }], [ac_success=yes ac_rpath_save_LDFLAGS="$LDFLAGS" AC_MSG_RESULT([adding $RPATHFLAG$d]) ], [ac_remaining_dirs="$ac_remaining_dirs $d"], :) LDFLAGS="$ac_rpath_save_LDFLAGS" fi done RPATH_CANDIDATE_DIRS=$ac_remaining_dirs fi if test $ac_success = no ; then AC_MSG_RESULT(failed) fi fi ]) dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS. dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [, dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) AC_DEFUN([LSH_CHECK_KRB_LIB], [AC_CHECK_LIB([$1], [$2], ifelse([$3], , [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` AC_DEFINE_UNQUOTED($ac_tr_lib) KRB_LIBS="-l$1 $KRB_LIBS" ]], [$3]), ifelse([$4], , , [$4 ])dnl , [$5 $KRB_LIBS]) ]) dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD) AC_DEFUN([LSH_LIB_ARGP], [ ac_argp_save_LIBS="$LIBS" ac_argp_save_LDFLAGS="$LDFLAGS" ac_argp_ok=no # First check if we can link with argp. AC_SEARCH_LIBS(argp_parse, argp, [ LSH_RPATH_FIX AC_CACHE_CHECK([for working argp], lsh_cv_lib_argp_works, [ AC_TRY_RUN( [#include #include static const struct argp_option options[] = { { NULL, 0, NULL, 0, NULL, 0 } }; struct child_state { int n; }; static error_t child_parser(int key, char *arg, struct argp_state *state) { struct child_state *input = (struct child_state *) state->input; switch(key) { default: return ARGP_ERR_UNKNOWN; case ARGP_KEY_END: if (!input->n) input->n = 1; break; } return 0; } const struct argp child_argp = { options, child_parser, NULL, NULL, NULL, NULL, NULL }; struct main_state { struct child_state child; int m; }; static error_t main_parser(int key, char *arg, struct argp_state *state) { struct main_state *input = (struct main_state *) state->input; switch(key) { default: return ARGP_ERR_UNKNOWN; case ARGP_KEY_INIT: state->child_inputs[0] = &input->child; break; case ARGP_KEY_END: if (!input->m) input->m = input->child.n; break; } return 0; } static const struct argp_child main_children[] = { { &child_argp, 0, "", 0 }, { NULL, 0, NULL, 0} }; static const struct argp main_argp = { options, main_parser, NULL, NULL, main_children, NULL, NULL }; int main(int argc, char **argv) { struct main_state input = { { 0 }, 0 }; char *v[2] = { "foo", NULL }; argp_parse(&main_argp, 1, v, 0, NULL, &input); if ( (input.m == 1) && (input.child.n == 1) ) return 0; else return 1; } ], lsh_cv_lib_argp_works=yes, lsh_cv_lib_argp_works=no, lsh_cv_lib_argp_works=no)]) if test x$lsh_cv_lib_argp_works = xyes ; then ac_argp_ok=yes else # Reset link flags LIBS="$ac_argp_save_LIBS" LDFLAGS="$ac_argp_save_LDFLAGS" fi]) if test x$ac_argp_ok = xyes ; then ifelse([$1],, true, [$1]) else ifelse([$2],, true, [$2]) fi ]) dnl LSH_GCC_ATTRIBUTES dnl Check for gcc's __attribute__ construction AC_DEFUN([LSH_GCC_ATTRIBUTES], [AC_CACHE_CHECK(for __attribute__, lsh_cv_c_attribute, [ AC_TRY_COMPILE([ #include ], [ static void foo(void) __attribute__ ((noreturn)); static void __attribute__ ((noreturn)) foo(void) { exit(1); } ], lsh_cv_c_attribute=yes, lsh_cv_c_attribute=no)]) AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__]) if test "x$lsh_cv_c_attribute" = "xyes"; then AC_DEFINE(HAVE_GCC_ATTRIBUTE) fi AH_BOTTOM( [#if __GNUC__ || HAVE_GCC_ATTRIBUTE # define NORETURN __attribute__ ((__noreturn__)) # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a))) # define UNUSED __attribute__ ((__unused__)) #else # define NORETURN # define PRINTF_STYLE(f, a) # define UNUSED #endif ])]) AC_DEFUN([LSH_GCC_FUNCTION_NAME], [# Check for gcc's __FUNCTION__ variable AH_TEMPLATE([HAVE_GCC_FUNCTION], [Define if the compiler understands __FUNCTION__]) AH_BOTTOM( [#if HAVE_GCC_FUNCTION # define FUNCTION_NAME __FUNCTION__ #else # define FUNCTION_NAME "Unknown" #endif ]) AC_CACHE_CHECK(for __FUNCTION__, lsh_cv_c_FUNCTION, [ AC_TRY_COMPILE(, [ #if __GNUC__ == 3 # error __FUNCTION__ is broken in gcc-3 #endif void foo(void) { char c = __FUNCTION__[0]; } ], lsh_cv_c_FUNCTION=yes, lsh_cv_c_FUNCTION=no)]) if test "x$lsh_cv_c_FUNCTION" = "xyes"; then AC_DEFINE(HAVE_GCC_FUNCTION) fi ]) # Check for alloca, and include the standard blurb in config.h AC_DEFUN([LSH_FUNC_ALLOCA], [AC_FUNC_ALLOCA AC_CHECK_HEADERS([malloc.h]) AH_BOTTOM( [/* AIX requires this to be the first thing in the file. */ #ifndef __GNUC__ # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #else /* defined __GNUC__ */ # if HAVE_ALLOCA_H # include # endif #endif /* Needed for alloca on windows */ #if HAVE_MALLOC_H # include #endif ])]) AC_DEFUN([LSH_FUNC_STRERROR], [AC_CHECK_FUNCS(strerror) AH_BOTTOM( [#if HAVE_STRERROR #define STRERROR strerror #else #define STRERROR(x) (sys_errlist[x]) #endif ])]) AC_DEFUN([LSH_FUNC_STRSIGNAL], [AC_CHECK_FUNCS(strsignal) AC_CHECK_DECLS([sys_siglist, _sys_siglist]) AH_BOTTOM( [#if HAVE_STRSIGNAL # define STRSIGNAL strsignal #else /* !HAVE_STRSIGNAL */ # if HAVE_DECL_SYS_SIGLIST # define STRSIGNAL(x) (sys_siglist[x]) # else # if HAVE_DECL__SYS_SIGLIST # define STRSIGNAL(x) (_sys_siglist[x]) # else # define STRSIGNAL(x) "Unknown signal" # if __GNUC__ # warning Using dummy STRSIGNAL # endif # endif # endif #endif /* !HAVE_STRSIGNAL */ ])]) dnl LSH_MAKE_CONDITIONAL(symbol, test) AC_DEFUN([LSH_MAKE_CONDITIONAL], [if $2 ; then IF_$1='' UNLESS_$1='# ' else IF_$1='# ' UNLESS_$1='' fi AC_SUBST(IF_$1) AC_SUBST(UNLESS_$1)]) dnl LSH_DEPENDENCY_TRACKING dnl Defines compiler flags DEP_FLAGS to generate dependency dnl information, and DEP_PROCESS that is any shell commands needed for dnl massaging the dependency information further. Dependencies are dnl generated as a side effect of compilation. Dependency files dnl themselves are not treated as targets. AC_DEFUN([LSH_DEPENDENCY_TRACKING], [AC_ARG_ENABLE(dependency_tracking, AC_HELP_STRING([--disable-dependency-tracking], [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),, [enable_dependency_tracking=yes]) DEP_FLAGS='' DEP_PROCESS='true' if test x$enable_dependency_tracking = xyes ; then if test x$GCC = xyes ; then gcc_version=`gcc --version | head -1` case "$gcc_version" in 2.*|*[[!0-9.]]2.*) enable_dependency_tracking=no AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed]) ;; *) DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d' DEP_PROCESS='true' ;; esac else enable_dependency_tracking=no AC_MSG_WARN([Dependency tracking disabled]) fi fi if test x$enable_dependency_tracking = xyes ; then DEP_INCLUDE='include ' else DEP_INCLUDE='# ' fi AC_SUBST([DEP_INCLUDE]) AC_SUBST([DEP_FLAGS]) AC_SUBST([DEP_PROCESS])]) dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])] dnl dnl the "ISO C9X: 7.18 Integer types " section requires the dnl existence of an include file that defines a set of dnl typedefs, especially uint8_t,int32_t,uintptr_t. dnl Many older installations will not provide this file, but some will dnl have the very same definitions in . In other enviroments dnl we can use the inet-types in which would define the dnl typedefs int8_t and u_int8_t respectivly. dnl dnl This macros will create a local "_stdint.h" or the headerfile given as dnl an argument. In many cases that file will just "#include " dnl or "#include ", while in other environments it will provide dnl the set of basic 'stdint's definitions/typedefs: dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t dnl int_least32_t.. int_fast32_t.. intmax_t dnl which may or may not rely on the definitions of other files, dnl or using the AC_CHECK_SIZEOF macro to determine the actual dnl sizeof each type. dnl dnl if your header files require the stdint-types you will want to create an dnl installable file mylib-int.h that all your other installable header dnl may include. So if you have a library package named "mylib", just use dnl AX_CREATE_STDINT_H(mylib-int.h) dnl in configure.ac and go to install that very header file in Makefile.am dnl along with the other headers (mylib.h) - and the mylib-specific headers dnl can simply use "#include " to obtain the stdint-types. dnl dnl Remember, if the system already had a valid , the generated dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things... dnl dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/) dnl @version $Id: acinclude.m4,v 1.27 2004/11/23 21:27:35 nisse Exp $ dnl @author Guido Draheim AC_DEFUN([AX_CREATE_STDINT_H], [# ------ AX CREATE STDINT H ------------------------------------- AC_MSG_CHECKING([for stdint types]) ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)` # try to shortcircuit - if the default include path of the compiler # can find a "stdint.h" header then we assume that all compilers can. AC_CACHE_VAL([ac_cv_header_stdint_t],[ old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS="" old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="" old_CFLAGS="$CFLAGS" ; CFLAGS="" AC_TRY_COMPILE([#include ],[int_least32_t v = 0;], [ac_cv_stdint_result="(assuming C99 compatible system)" ac_cv_header_stdint_t="stdint.h"; ], [ac_cv_header_stdint_t=""]) CXXFLAGS="$old_CXXFLAGS" CPPFLAGS="$old_CPPFLAGS" CFLAGS="$old_CFLAGS" ]) v="... $ac_cv_header_stdint_h" if test "$ac_stdint_h" = "stdint.h" ; then AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)]) elif test "$ac_stdint_h" = "inttypes.h" ; then AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)]) elif test "_$ac_cv_header_stdint_t" = "_" ; then AC_MSG_RESULT([(putting them into $ac_stdint_h)$v]) else ac_cv_header_stdint="$ac_cv_header_stdint_t" AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)]) fi if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit.. dnl .....intro message done, now do a few system checks..... dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead inttype_headers=`echo $2 | sed -e 's/,/ /g'` ac_cv_stdint_result="(no helpful system typedefs seen)" AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h) AC_MSG_RESULT([(..)]) for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do unset ac_cv_type_uintptr_t unset ac_cv_type_uint64_t _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) ac_cv_stdint_result="(seen uintptr_t$and64 in $i)" break; done AC_MSG_CHECKING([for stdint uintptr_t]) ]) if test "_$ac_cv_header_stdint_x" = "_" ; then AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h) AC_MSG_RESULT([(..)]) for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) ac_cv_stdint_result="(seen uint32_t$and64 in $i)" break; done AC_MSG_CHECKING([for stdint uint32_t]) ]) fi if test "_$ac_cv_header_stdint_x" = "_" ; then if test "_$ac_cv_header_stdint_o" = "_" ; then AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h) AC_MSG_RESULT([(..)]) for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl continue,[#include <$i>]) AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>]) ac_cv_stdint_result="(seen u_int32_t$and64 in $i)" break; done AC_MSG_CHECKING([for stdint u_int32_t]) ]) fi fi dnl if there was no good C99 header file, do some typedef checks... if test "_$ac_cv_header_stdint_x" = "_" ; then AC_MSG_CHECKING([for stdint datatype model]) AC_MSG_RESULT([(..)]) AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void*) ac_cv_stdint_char_model="" ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char" ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short" ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int" ac_cv_stdint_long_model="" ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int" ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long" ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp" name="$ac_cv_stdint_long_model" case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in 122/242) name="$name, IP16 (standard 16bit machine)" ;; 122/244) name="$name, LP32 (standard 32bit mac/win)" ;; 122/*) name="$name (unusual int16 model)" ;; 124/444) name="$name, ILP32 (standard 32bit unixish)" ;; 124/488) name="$name, LP64 (standard 64bit unixish)" ;; 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;; 124/*) name="$name (unusual int32 model)" ;; 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;; 128/*) name="$name (unusual int64 model)" ;; 222/*|444/*) name="$name (unusual dsptype)" ;; *) name="$name (very unusal model)" ;; esac AC_MSG_RESULT([combined for stdint datatype model... $name]) fi if test "_$ac_cv_header_stdint_x" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_x" elif test "_$ac_cv_header_stdint_o" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_o" elif test "_$ac_cv_header_stdint_u" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_u" else ac_cv_header_stdint="stddef.h" fi AC_MSG_CHECKING([for extra inttypes in chosen header]) AC_MSG_RESULT([($ac_cv_header_stdint)]) dnl see if int_least and int_fast types are present in _this_ header. unset ac_cv_type_int_least32_t unset ac_cv_type_int_fast32_t AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>]) AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>]) AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>]) fi # shortcircut to system "stdint.h" # ------------------ PREPARE VARIABLES ------------------------------ if test "$GCC" = "yes" ; then ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` else ac_cv_stdint_message="using $CC" fi AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl $ac_cv_stdint_result]) # ----------------- DONE inttypes.h checks START header ------------- AC_CONFIG_COMMANDS([$ac_stdint_h],[ AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h) ac_stdint=$tmp/_stdint.h echo "#ifndef" $_ac_stdint_h >$ac_stdint echo "#define" $_ac_stdint_h "1" >>$ac_stdint echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint if test "_$ac_cv_header_stdint_t" != "_" ; then echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint fi cat >>$ac_stdint < #else #include /* .................... configured part ............................ */ STDINT_EOF echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_x" != "_" ; then ac_header="$ac_cv_header_stdint_x" echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint fi echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_o" != "_" ; then ac_header="$ac_cv_header_stdint_o" echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint fi echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint if test "_$ac_cv_header_stdint_u" != "_" ; then ac_header="$ac_cv_header_stdint_u" echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint fi echo "" >>$ac_stdint if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then echo "#include <$ac_header>" >>$ac_stdint echo "" >>$ac_stdint fi fi echo "/* which 64bit typedef has been found */" >>$ac_stdint if test "$ac_cv_type_uint64_t" = "yes" ; then echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint fi if test "$ac_cv_type_u_int64_t" = "yes" ; then echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* which type model has been detected */" >>$ac_stdint if test "_$ac_cv_stdint_char_model" != "_" ; then echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint else echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* whether int_least types were detected */" >>$ac_stdint if test "$ac_cv_type_int_least32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint fi echo "/* whether int_fast types were detected */" >>$ac_stdint if test "$ac_cv_type_int_fast32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint fi echo "/* whether intmax_t type was detected */" >>$ac_stdint if test "$ac_cv_type_intmax_t" = "yes"; then echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint fi echo "" >>$ac_stdint cat >>$ac_stdint <= 199901L #define _HAVE_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #elif !defined __STRICT_ANSI__ #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ #define _HAVE_UINT64_T typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__ /* note: all ELF-systems seem to have loff-support which needs 64-bit */ #if !defined _NO_LONGLONG #define _HAVE_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #endif #elif defined __alpha || (defined __mips && defined _ABIN32) #if !defined _NO_LONGLONG typedef long int64_t; typedef unsigned long uint64_t; #endif /* compiler/cpu type to define int64_t */ #endif #endif #endif #if defined _STDINT_HAVE_U_INT_TYPES /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */ typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; /* glibc compatibility */ #ifndef __int8_t_defined #define __int8_t_defined #endif #endif #ifdef _STDINT_NEED_INT_MODEL_T /* we must guess all the basic types. Apart from byte-adressable system, */ /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */ /* (btw, those nibble-addressable systems are way off, or so we assume) */ dnl /* have a look at "64bit and data size neutrality" at */ dnl /* http://unix.org/version2/whatsnew/login_64bit.html */ dnl /* (the shorthand "ILP" types always have a "P" part) */ #if defined _STDINT_BYTE_MODEL #if _STDINT_LONG_MODEL+0 == 242 /* 2:4:2 = IP16 = a normal 16-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef long int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */ /* 4:4:4 = ILP32 = a normal 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */ /* 4:8:8 = LP64 = a normal 64-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* this system has a "long" of 64bit */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T typedef unsigned long uint64_t; typedef long int64_t; #endif #elif _STDINT_LONG_MODEL+0 == 448 /* LLP64 a 64-bit system derived from a 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* assuming the system has a "long long" */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T typedef unsigned long long uint64_t; typedef long long int64_t; #endif #else #define _STDINT_NO_INT32_T #endif #else #define _STDINT_NO_INT8_T #define _STDINT_NO_INT32_T #endif #endif /* * quote from SunOS-5.8 sys/inttypes.h: * Use at your own risk. As of February 1996, the committee is squarely * behind the fixed sized types; the "least" and "fast" types are still being * discussed. The probability that the "fast" types may be removed before * the standard is finalized is high enough that they are not currently * implemented. */ #if defined _STDINT_NEED_INT_LEAST_T typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_least64_t; #endif typedef uint8_t uint_least8_t; typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_least64_t; #endif /* least types */ #endif #if defined _STDINT_NEED_INT_FAST_T typedef int8_t int_fast8_t; typedef int int_fast16_t; typedef int32_t int_fast32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_fast64_t; #endif typedef uint8_t uint_fast8_t; typedef unsigned uint_fast16_t; typedef uint32_t uint_fast32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_fast64_t; #endif /* fast types */ #endif #ifdef _STDINT_NEED_INTMAX_T #ifdef _HAVE_UINT64_T typedef int64_t intmax_t; typedef uint64_t uintmax_t; #else typedef long intmax_t; typedef unsigned long uintmax_t; #endif #endif #ifdef _STDINT_NEED_INTPTR_T #ifndef __intptr_t_defined #define __intptr_t_defined /* we encourage using "long" to store pointer values, never use "int" ! */ #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484 typedef unsinged int uintptr_t; typedef int intptr_t; #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444 typedef unsigned long uintptr_t; typedef long intptr_t; #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T typedef uint64_t uintptr_t; typedef int64_t intptr_t; #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */ typedef unsigned long uintptr_t; typedef long intptr_t; #endif #endif #endif /* shortcircuit*/ #endif /* once */ #endif #endif STDINT_EOF if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then AC_MSG_NOTICE([$ac_stdint_h is unchanged]) else ac_dir=`AS_DIRNAME(["$ac_stdint_h"])` AS_MKDIR_P(["$ac_dir"]) rm -f $ac_stdint_h mv $ac_stdint $ac_stdint_h fi ],[# variables for create stdint.h replacement PACKAGE="$PACKAGE" VERSION="$VERSION" ac_stdint_h="$ac_stdint_h" _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h) ac_cv_stdint_message="$ac_cv_stdint_message" ac_cv_header_stdint_t="$ac_cv_header_stdint_t" ac_cv_header_stdint_x="$ac_cv_header_stdint_x" ac_cv_header_stdint_o="$ac_cv_header_stdint_o" ac_cv_header_stdint_u="$ac_cv_header_stdint_u" ac_cv_type_uint64_t="$ac_cv_type_uint64_t" ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" ac_cv_stdint_char_model="$ac_cv_stdint_char_model" ac_cv_stdint_long_model="$ac_cv_stdint_long_model" ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" ac_cv_type_intmax_t="$ac_cv_type_intmax_t" ]) ]) glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/config.h.in0000644000076200007630000000013212617742563023300 xustar000000000000000030 mtime=1447019891.886082659 30 atime=1447019891.887082643 30 ctime=1447019929.881511043 glusterfs-3.7.6/contrib/argp-standalone/config.h.in0000644000076200007630000001307112617742563023517 0ustar00jenkinsjenkins00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF /* Define to 1 if you have the declaration of `program_invocation_name', and to 0 if you don't. */ #undef HAVE_DECL_PROGRAM_INVOCATION_NAME /* Define to 1 if you have the declaration of `program_invocation_short_name', and to 0 if you don't. */ #undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the `flockfile' function. */ #undef HAVE_FLOCKFILE /* Define to 1 if you have the `fputs_unlocked' function. */ #undef HAVE_FPUTS_UNLOCKED /* Define to 1 if you have the `fwrite_unlocked' function. */ #undef HAVE_FWRITE_UNLOCKED /* Define if the compiler understands __attribute__ */ #undef HAVE_GCC_ATTRIBUTE /* Define to 1 if you have the `getpid' function. */ #undef HAVE_GETPID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mempcpy' function. */ #undef HAVE_MEMPCPY /* Define to 1 if you have the `putc_unlocked' function. */ #undef HAVE_PUTC_UNLOCKED /* Define to 1 if you have the `sleep' function. */ #undef HAVE_SLEEP /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strchrnul' function. */ #undef HAVE_STRCHRNUL /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the header file. */ #undef HAVE_SYSEXITS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Version number of package */ #undef VERSION /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `unsigned int' if does not define. */ #undef size_t #if __GNUC__ || HAVE_GCC_ATTRIBUTE # define NORETURN __attribute__ ((__noreturn__)) # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a))) # define UNUSED __attribute__ ((__unused__)) #else # define NORETURN # define PRINTF_STYLE(f, a) # define UNUSED #endif glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/strcasecmp.c0000644000076200007630000000013012617742532023557 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.881511043 glusterfs-3.7.6/contrib/argp-standalone/strcasecmp.c0000644000076200007630000000101412617742532023772 0ustar00jenkinsjenkins00000000000000/* strcasecmp.c * */ /* Written by Niels Möller * * This file is hereby placed in the public domain. */ #include int strcasecmp(const char *, const char *); int strcasecmp(const char *s1, const char *s2) { unsigned i; for (i = 0; s1[i] && s2[i]; i++) { unsigned char c1 = tolower( (unsigned char) s1[i]); unsigned char c2 = tolower( (unsigned char) s2[i]); if (c1 < c2) return -1; else if (c1 > c2) return 1; } return !s2[i] - !s1[i]; } glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/Makefile.in0000644000076200007630000000013212617742566023325 xustar000000000000000030 mtime=1447019894.279046655 30 atime=1447019894.279046655 30 ctime=1447019929.881511043 glusterfs-3.7.6/contrib/argp-standalone/Makefile.in0000644000076200007630000006355012617742566023553 0ustar00jenkinsjenkins00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # From glibc # Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C 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. # The GNU C 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. VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = . DIST_COMMON = $(am__configure_deps) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/config.h.in $(top_srcdir)/configure depcomp \ install-sh mempcpy.c missing strcasecmp.c strchrnul.c \ strndup.c vsnprintf.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru AM_V_AR = $(am__v_AR_$(V)) am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) am__v_AR_0 = @echo " AR " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ libargp_a_AR = $(AR) $(ARFLAGS) libargp_a_DEPENDENCIES = $(LIBOBJS) am_libargp_a_OBJECTS = argp-ba.$(OBJEXT) argp-eexst.$(OBJEXT) \ argp-fmtstream.$(OBJEXT) argp-help.$(OBJEXT) \ argp-parse.$(OBJEXT) argp-pv.$(OBJEXT) argp-pvh.$(OBJEXT) libargp_a_OBJECTS = $(am_libargp_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libargp_a_SOURCES) DIST_SOURCES = $(libargp_a_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive HEADERS = $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # You should have received a copy of the GNU Library General Public # License along with the GNU C Library; see the file COPYING.LIB. If # not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AUTOMAKE_OPTIONS = foreign SUBDIRS = . noinst_LIBRARIES = libargp.a noinst_HEADERS = argp.h argp-fmtstream.h argp-namefrob.h EXTRA_DIST = mempcpy.c strchrnul.c strndup.c strcasecmp.c vsnprintf.c autogen.sh # Leaves out argp-fs-xinl.c and argp-xinl.c libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c \ argp-help.c argp-parse.c argp-pv.c \ argp-pvh.c libargp_a_LIBADD = $(LIBOBJS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libargp.a: $(libargp_a_OBJECTS) $(libargp_a_DEPENDENCIES) $(AM_V_at)-rm -f libargp.a $(AM_V_AR)$(libargp_a_AR) libargp.a $(libargp_a_OBJECTS) $(libargp_a_LIBADD) $(AM_V_at)$(RANLIB) libargp.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mempcpy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strchrnul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strndup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vsnprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-ba.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-eexst.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-fmtstream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-pv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-pvh.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(LIBRARIES) $(HEADERS) config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(DEPDIR) ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf $(DEPDIR) ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-noinstLIBRARIES ctags ctags-recursive dist dist-all \ dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/configure0000644000076200007630000000013212617742564023162 xustar000000000000000030 mtime=1447019892.556072577 30 atime=1447019892.370075374 30 ctime=1447019929.882511028 glusterfs-3.7.6/contrib/argp-standalone/configure0000755000076200007630000101462712617742564023415 0ustar00jenkinsjenkins00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.63 for argp standalone-1.3. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell bug-autoconf@gnu.org about your system, echo including any error possibly output before this message. echo This can help us improve future autoconf versions. echo Configuration will now proceed without shell functions. } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='argp' PACKAGE_TARNAME='argp' PACKAGE_VERSION='standalone-1.3' PACKAGE_STRING='argp standalone-1.3' PACKAGE_BUGREPORT='' ac_unique_file="argp-ba.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS ALLOCA RANLIB EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { $as_echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { $as_echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 { (exit 1); exit 1; }; } ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { $as_echo "$as_me: error: working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures argp standalone-1.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/argp] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of argp standalone-1.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF argp configure standalone-1.3 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by argp $as_me standalone-1.3, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 $as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Needed to stop autoconf from looking for files in parent directories. ac_aux_dir= for ac_dir in . "$srcdir"/.; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in . \"$srcdir\"/." >&5 $as_echo "$as_me: error: cannot find install-sh or install.sh in . \"$srcdir\"/." >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) { { $as_echo "$as_me:$LINENO: error: unsafe absolute working directory name" >&5 $as_echo "$as_me: error: unsafe absolute working directory name" >&2;} { (exit 1); exit 1; }; };; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) { { $as_echo "$as_me:$LINENO: error: unsafe srcdir value: \`$srcdir'" >&5 $as_echo "$as_me: error: unsafe srcdir value: \`$srcdir'" >&2;} { (exit 1); exit 1; }; };; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 $as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftest.file ) then # Ok. : else { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 $as_echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. test -d ./--version && rmdir ./--version MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AWK+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:$LINENO: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 $as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='argp' VERSION='standalone-1.3' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac AM_BACKSLASH='\' # GNU libc defaults to supplying the ISO C library functions only. The # _GNU_SOURCE define enables these extensions, in particular we want # errno.h to declare program_invocation_name. Enable it on all # systems; no problems have been reported with it so far. DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:$LINENO: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } # Provide some information about the compiler. $as_echo "$as_me:$LINENO: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { $as_echo "$as_me:$LINENO: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } if test -z "$ac_file"; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 $as_echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi fi fi { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } { $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } { $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi rm -f conftest$ac_cv_exeext { $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 $as_echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:$LINENO: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:$LINENO: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 $as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 $as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:$LINENO: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 $as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test "${ac_cv_header_minix_config_h+set}" = set; then { $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5 $as_echo_n "checking for minix/config.h... " >&6; } if test "${ac_cv_header_minix_config_h+set}" = set; then $as_echo_n "(cached) " >&6 fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 $as_echo "$ac_cv_header_minix_config_h" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking minix/config.h usability" >&5 $as_echo_n "checking minix/config.h usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking minix/config.h presence" >&5 $as_echo_n "checking minix/config.h presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: minix/config.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: minix/config.h: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: minix/config.h: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5 $as_echo_n "checking for minix/config.h... " >&6; } if test "${ac_cv_header_minix_config_h+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_header_minix_config_h=$ac_header_preproc fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 $as_echo "$ac_cv_header_minix_config_h" >&6; } fi if test "x$ac_cv_header_minix_config_h" = x""yes; then MINIX=yes else MINIX= fi if test "$MINIX" = yes; then cat >>confdefs.h <<\_ACEOF #define _POSIX_SOURCE 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _POSIX_1_SOURCE 2 _ACEOF cat >>confdefs.h <<\_ACEOF #define _MINIX 1 _ACEOF fi { $as_echo "$as_me:$LINENO: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if test "${ac_cv_safe_to_define___extensions__+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_safe_to_define___extensions__=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && cat >>confdefs.h <<\_ACEOF #define __EXTENSIONS__ 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _ALL_SOURCE 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _GNU_SOURCE 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _POSIX_PTHREAD_SEMANTICS 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _TANDEM_SOURCE 1 _ACEOF # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } # Provide some information about the compiler. $as_echo "$as_me:$LINENO: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:$LINENO: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; }; } # Provide some information about the compiler. $as_echo "$as_me:$LINENO: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:$LINENO: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test "x$am_cv_prog_cc_stdc" = xno ; then { { $as_echo "$as_me:$LINENO: error: the C compiler doesn't handle ANSI-C" >&5 $as_echo "$as_me: error: the C compiler doesn't handle ANSI-C" >&2;} { (exit 1); exit 1; }; } fi # Checks for libraries. # Checks for header files. { $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi for ac_header in libintl.h limits.h malloc.h unistd.h sysexits.h stdarg.h do as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 $as_echo_n "checking $ac_header usability... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 $as_echo_n "checking $ac_header presence... " >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 $as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 $as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 $as_echo_n "checking for $ac_header... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi as_val=`eval 'as_val=${'$as_ac_Header'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if test "${ac_cv_c_const+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const /**/ _ACEOF fi { $as_echo "$as_me:$LINENO: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if test "${ac_cv_c_inline+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:$LINENO: checking for size_t" >&5 $as_echo_n "checking for size_t... " >&6; } if test "${ac_cv_type_size_t+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_type_size_t=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if (sizeof (size_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if (sizeof ((size_t))) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 $as_echo "$ac_cv_type_size_t" >&6; } if test "x$ac_cv_type_size_t" = x""yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { $as_echo "$as_me:$LINENO: checking for __attribute__" >&5 $as_echo_n "checking for __attribute__... " >&6; } if test "${lsh_cv_c_attribute+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { static void foo(void) __attribute__ ((noreturn)); static void __attribute__ ((noreturn)) foo(void) { exit(1); } ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then lsh_cv_c_attribute=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 lsh_cv_c_attribute=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $lsh_cv_c_attribute" >&5 $as_echo "$lsh_cv_c_attribute" >&6; } if test "x$lsh_cv_c_attribute" = "xyes"; then cat >>confdefs.h <<\_ACEOF #define HAVE_GCC_ATTRIBUTE 1 _ACEOF fi # Checks for library functions. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:$LINENO: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if test "${ac_cv_working_alloca_h+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_working_alloca_h=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_working_alloca_h=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_ALLOCA_H 1 _ACEOF fi { $as_echo "$as_me:$LINENO: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if test "${ac_cv_func_alloca_works+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_func_alloca_works=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_alloca_works=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_ALLOCA 1 _ACEOF else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext cat >>confdefs.h <<\_ACEOF #define C_ALLOCA 1 _ACEOF { $as_echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if test "${ac_cv_os_cray+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if test "${ac_cv_c_stack_direction+set}" = set; then $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then ac_cv_c_stack_direction=0 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int find_stack_direction () { static char *addr = 0; auto char dummy; if (addr == 0) { addr = &dummy; return find_stack_direction (); } else return (&dummy > addr) ? 1 : -1; } int main () { return find_stack_direction () < 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_stack_direction=1 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_stack_direction=-1 fi rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { $as_echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi for ac_func in vprintf do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF { $as_echo "$as_me:$LINENO: checking for _doprnt" >&5 $as_echo_n "checking for _doprnt... " >&6; } if test "${ac_cv_func__doprnt+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define _doprnt to an innocuous variant, in case declares _doprnt. For example, HP-UX 11i declares gettimeofday. */ #define _doprnt innocuous__doprnt /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef _doprnt /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub__doprnt || defined __stub____doprnt choke me #endif int main () { return _doprnt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_func__doprnt=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 $as_echo "$ac_cv_func__doprnt" >&6; } if test "x$ac_cv_func__doprnt" = x""yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done for ac_func in strerror sleep getpid snprintf do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in mempcpy strndup strchrnul strcasecmp vsnprintf do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else case " $LIBOBJS " in *" $ac_func.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; esac fi done # At least on freebsd, putc_unlocked is a macro, so the standard # AC_CHECK_FUNCS doesn't work well. { $as_echo "$as_me:$LINENO: checking for putc_unlocked('x', stdout)" >&5 $as_echo_n "checking for putc_unlocked('x', stdout)... " >&6; } if test "${ac_cv_func_call_putc_unlocked+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { putc_unlocked('x', stdout) ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then ac_cv_func_call_putc_unlocked=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_call_putc_unlocked=no fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_func_call_putc_unlocked" >&5 $as_echo "$ac_cv_func_call_putc_unlocked" >&6; } if test $ac_cv_func_call_putc_unlocked = yes ; then cat >>confdefs.h <<_ACEOF #define HAVE_PUTC_UNLOCKED 1 _ACEOF else true fi for ac_func in flockfile do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in fputs_unlocked fwrite_unlocked do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Used only by argp-test.c, so don't use AC_REPLACE_FUNCS. for ac_func in strdup asprintf do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 $as_echo_n "checking for $ac_func... " >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then eval "$as_ac_var=yes" else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } as_val=`eval 'as_val=${'$as_ac_var'} $as_echo "$as_val"'` if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:$LINENO: checking whether program_invocation_name is declared" >&5 $as_echo_n "checking whether program_invocation_name is declared... " >&6; } if test "${ac_cv_have_decl_program_invocation_name+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { #ifndef program_invocation_name (void) program_invocation_name; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_have_decl_program_invocation_name=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_have_decl_program_invocation_name=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_program_invocation_name" >&5 $as_echo "$ac_cv_have_decl_program_invocation_name" >&6; } if test "x$ac_cv_have_decl_program_invocation_name" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_DECL_PROGRAM_INVOCATION_NAME 1 _ACEOF else cat >>confdefs.h <<_ACEOF #define HAVE_DECL_PROGRAM_INVOCATION_NAME 0 _ACEOF fi { $as_echo "$as_me:$LINENO: checking whether program_invocation_short_name is declared" >&5 $as_echo_n "checking whether program_invocation_short_name is declared... " >&6; } if test "${ac_cv_have_decl_program_invocation_short_name+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { #ifndef program_invocation_short_name (void) program_invocation_short_name; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_have_decl_program_invocation_short_name=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_have_decl_program_invocation_short_name=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_program_invocation_short_name" >&5 $as_echo "$ac_cv_have_decl_program_invocation_short_name" >&6; } if test "x$ac_cv_have_decl_program_invocation_short_name" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1 _ACEOF else cat >>confdefs.h <<_ACEOF #define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 0 _ACEOF fi # Set these flags *last*, or else the test programs won't compile if test x$GCC = xyes ; then # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then true else CFLAGS="$CFLAGS -ggdb3" fi CFLAGS="$CFLAGS -Wall -W \ -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \ -Waggregate-return \ -Wpointer-arith -Wbad-function-cast -Wnested-externs" fi CPPFLAGS="$CPPFLAGS -I$srcdir" CFLAGS="$CFLAGS -std=gnu89 -static" ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&5 $as_echo "$as_me: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 $as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 $as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 $as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by argp $as_me standalone-1.3, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTION]... [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ argp config.status standalone-1.3 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2008 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { $as_echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { $as_echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { $as_echo "$as_me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=' ' ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\).*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\).*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 $as_echo "$as_me: error: could not setup config files machinery" >&2;} { (exit 1); exit 1; }; } _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 $as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 $as_echo "$as_me: error: could not setup config headers machinery" >&2;} { (exit 1); exit 1; }; } fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac ac_file_inputs="$ac_file_inputs '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 $as_echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 $as_echo "$as_me: error: could not create $ac_file" >&2;} { (exit 1); exit 1; }; } fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 $as_echo "$as_me: error: could not create -" >&2;} { (exit 1); exit 1; }; } fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir=$dirpart/$fdir case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 $as_echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 $as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-namefrob.h0000644000076200007630000000013112617742532024141 xustar000000000000000030 mtime=1447019866.024471735 29 atime=1447019866.36646659 30 ctime=1447019929.882511028 glusterfs-3.7.6/contrib/argp-standalone/argp-namefrob.h0000644000076200007630000000666612617742532024375 0ustar00jenkinsjenkins00000000000000/* Name frobnication for compiling argp outside of glibc Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if !_LIBC /* This code is written for inclusion in gnu-libc, and uses names in the namespace reserved for libc. If we're not compiling in libc, define those names to be the normal ones instead. */ /* argp-parse functions */ #undef __argp_parse #define __argp_parse argp_parse #undef __option_is_end #define __option_is_end _option_is_end #undef __option_is_short #define __option_is_short _option_is_short #undef __argp_input #define __argp_input _argp_input /* argp-help functions */ #undef __argp_help #define __argp_help argp_help #undef __argp_error #define __argp_error argp_error #undef __argp_failure #define __argp_failure argp_failure #undef __argp_state_help #define __argp_state_help argp_state_help #undef __argp_usage #define __argp_usage argp_usage #undef __argp_basename #define __argp_basename _argp_basename #undef __argp_short_program_name #define __argp_short_program_name _argp_short_program_name /* argp-fmtstream functions */ #undef __argp_make_fmtstream #define __argp_make_fmtstream argp_make_fmtstream #undef __argp_fmtstream_free #define __argp_fmtstream_free argp_fmtstream_free #undef __argp_fmtstream_putc #define __argp_fmtstream_putc argp_fmtstream_putc #undef __argp_fmtstream_puts #define __argp_fmtstream_puts argp_fmtstream_puts #undef __argp_fmtstream_write #define __argp_fmtstream_write argp_fmtstream_write #undef __argp_fmtstream_printf #define __argp_fmtstream_printf argp_fmtstream_printf #undef __argp_fmtstream_set_lmargin #define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin #undef __argp_fmtstream_set_rmargin #define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin #undef __argp_fmtstream_set_wmargin #define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin #undef __argp_fmtstream_point #define __argp_fmtstream_point argp_fmtstream_point #undef __argp_fmtstream_update #define __argp_fmtstream_update _argp_fmtstream_update #undef __argp_fmtstream_ensure #define __argp_fmtstream_ensure _argp_fmtstream_ensure #undef __argp_fmtstream_lmargin #define __argp_fmtstream_lmargin argp_fmtstream_lmargin #undef __argp_fmtstream_rmargin #define __argp_fmtstream_rmargin argp_fmtstream_rmargin #undef __argp_fmtstream_wmargin #define __argp_fmtstream_wmargin argp_fmtstream_wmargin /* normal libc functions we call */ #undef __sleep #define __sleep sleep #undef __strcasecmp #define __strcasecmp strcasecmp #undef __vsnprintf #define __vsnprintf vsnprintf #endif /* !_LIBC */ #ifndef __set_errno #define __set_errno(e) (errno = (e)) #endif glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/aclocal.m40000644000076200007630000000013212617742562023114 xustar000000000000000030 mtime=1447019890.809098859 30 atime=1447019891.077094827 30 ctime=1447019929.882511028 glusterfs-3.7.6/contrib/argp-standalone/aclocal.m40000644000076200007630000010535412617742562023341 0ustar00jenkinsjenkins00000000000000# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],, [m4_warning([this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/argp-eexst.c0000644000076200007630000000013112617742532023473 xustar000000000000000029 mtime=1447019866.02347175 30 atime=1447019866.365466605 30 ctime=1447019929.882511028 glusterfs-3.7.6/contrib/argp-standalone/argp-eexst.c0000644000076200007630000000247212617742532023716 0ustar00jenkinsjenkins00000000000000/* Default definition for ARGP_ERR_EXIT_STATUS Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . The GNU C 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. The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #if HAVE_SYSEXITS_H # include #else # define EX_USAGE 64 #endif #include "argp.h" /* The exit status that argp will use when exiting due to a parsing error. If not defined or set by the user program, this defaults to EX_USAGE from . */ error_t argp_err_exit_status = EX_USAGE; glusterfs-3.7.6/contrib/argp-standalone/PaxHeaders.7244/mempcpy.c0000644000076200007630000000013012617742532023065 xustar000000000000000029 mtime=1447019866.02547172 29 atime=1447019866.36646659 30 ctime=1447019929.882511028 glusterfs-3.7.6/contrib/argp-standalone/mempcpy.c0000644000076200007630000000047612617742532023313 0ustar00jenkinsjenkins00000000000000/* strndup.c * */ /* Written by Niels Möller * * This file is hereby placed in the public domain. */ #include void * mempcpy (void *, const void *, size_t) ; void * mempcpy (void *to, const void *from, size_t size) { memcpy(to, from, size); return (char *) to + size; } glusterfs-3.7.6/contrib/PaxHeaders.7244/libexecinfo0000644000076200007630000000012612617742634020412 xustar000000000000000029 mtime=1447019932.24747545 28 atime=1447019949.3342184 29 ctime=1447019932.24747545 glusterfs-3.7.6/contrib/libexecinfo/0000755000076200007630000000000012617742634020701 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/libexecinfo/PaxHeaders.7244/execinfo.c0000644000076200007630000000012712617742532022431 xustar000000000000000029 mtime=1447019866.02947166 29 atime=1447019866.36846656 29 ctime=1447019932.24747545 glusterfs-3.7.6/contrib/libexecinfo/execinfo.c0000644000076200007630000005026112617742532022646 0ustar00jenkinsjenkins00000000000000/* * Copyright (c) 2003 Maxim Sobolev * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. * * $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $ */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #ifndef HAVE_BACKTRACE #include #include #include #include #include #include #include #include #include #include #include "execinfo_compat.h" #define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1))) static void * getreturnaddr(int level) { switch (level) { case 0: return __builtin_return_address(1); case 1: return __builtin_return_address(2); case 2: return __builtin_return_address(3); case 3: return __builtin_return_address(4); case 4: return __builtin_return_address(5); case 5: return __builtin_return_address(6); case 6: return __builtin_return_address(7); case 7: return __builtin_return_address(8); case 8: return __builtin_return_address(9); case 9: return __builtin_return_address(10); case 10: return __builtin_return_address(11); case 11: return __builtin_return_address(12); case 12: return __builtin_return_address(13); case 13: return __builtin_return_address(14); case 14: return __builtin_return_address(15); case 15: return __builtin_return_address(16); case 16: return __builtin_return_address(17); case 17: return __builtin_return_address(18); case 18: return __builtin_return_address(19); case 19: return __builtin_return_address(20); case 20: return __builtin_return_address(21); case 21: return __builtin_return_address(22); case 22: return __builtin_return_address(23); case 23: return __builtin_return_address(24); case 24: return __builtin_return_address(25); case 25: return __builtin_return_address(26); case 26: return __builtin_return_address(27); case 27: return __builtin_return_address(28); case 28: return __builtin_return_address(29); case 29: return __builtin_return_address(30); case 30: return __builtin_return_address(31); case 31: return __builtin_return_address(32); case 32: return __builtin_return_address(33); case 33: return __builtin_return_address(34); case 34: return __builtin_return_address(35); case 35: return __builtin_return_address(36); case 36: return __builtin_return_address(37); case 37: return __builtin_return_address(38); case 38: return __builtin_return_address(39); case 39: return __builtin_return_address(40); case 40: return __builtin_return_address(41); case 41: return __builtin_return_address(42); case 42: return __builtin_return_address(43); case 43: return __builtin_return_address(44); case 44: return __builtin_return_address(45); case 45: return __builtin_return_address(46); case 46: return __builtin_return_address(47); case 47: return __builtin_return_address(48); case 48: return __builtin_return_address(49); case 49: return __builtin_return_address(50); case 50: return __builtin_return_address(51); case 51: return __builtin_return_address(52); case 52: return __builtin_return_address(53); case 53: return __builtin_return_address(54); case 54: return __builtin_return_address(55); case 55: return __builtin_return_address(56); case 56: return __builtin_return_address(57); case 57: return __builtin_return_address(58); case 58: return __builtin_return_address(59); case 59: return __builtin_return_address(60); case 60: return __builtin_return_address(61); case 61: return __builtin_return_address(62); case 62: return __builtin_return_address(63); case 63: return __builtin_return_address(64); case 64: return __builtin_return_address(65); case 65: return __builtin_return_address(66); case 66: return __builtin_return_address(67); case 67: return __builtin_return_address(68); case 68: return __builtin_return_address(69); case 69: return __builtin_return_address(70); case 70: return __builtin_return_address(71); case 71: return __builtin_return_address(72); case 72: return __builtin_return_address(73); case 73: return __builtin_return_address(74); case 74: return __builtin_return_address(75); case 75: return __builtin_return_address(76); case 76: return __builtin_return_address(77); case 77: return __builtin_return_address(78); case 78: return __builtin_return_address(79); case 79: return __builtin_return_address(80); case 80: return __builtin_return_address(81); case 81: return __builtin_return_address(82); case 82: return __builtin_return_address(83); case 83: return __builtin_return_address(84); case 84: return __builtin_return_address(85); case 85: return __builtin_return_address(86); case 86: return __builtin_return_address(87); case 87: return __builtin_return_address(88); case 88: return __builtin_return_address(89); case 89: return __builtin_return_address(90); case 90: return __builtin_return_address(91); case 91: return __builtin_return_address(92); case 92: return __builtin_return_address(93); case 93: return __builtin_return_address(94); case 94: return __builtin_return_address(95); case 95: return __builtin_return_address(96); case 96: return __builtin_return_address(97); case 97: return __builtin_return_address(98); case 98: return __builtin_return_address(99); case 99: return __builtin_return_address(100); case 100: return __builtin_return_address(101); case 101: return __builtin_return_address(102); case 102: return __builtin_return_address(103); case 103: return __builtin_return_address(104); case 104: return __builtin_return_address(105); case 105: return __builtin_return_address(106); case 106: return __builtin_return_address(107); case 107: return __builtin_return_address(108); case 108: return __builtin_return_address(109); case 109: return __builtin_return_address(110); case 110: return __builtin_return_address(111); case 111: return __builtin_return_address(112); case 112: return __builtin_return_address(113); case 113: return __builtin_return_address(114); case 114: return __builtin_return_address(115); case 115: return __builtin_return_address(116); case 116: return __builtin_return_address(117); case 117: return __builtin_return_address(118); case 118: return __builtin_return_address(119); case 119: return __builtin_return_address(120); case 120: return __builtin_return_address(121); case 121: return __builtin_return_address(122); case 122: return __builtin_return_address(123); case 123: return __builtin_return_address(124); case 124: return __builtin_return_address(125); case 125: return __builtin_return_address(126); case 126: return __builtin_return_address(127); case 127: return __builtin_return_address(128); default: return NULL; } } static void * getframeaddr(int level) { switch (level) { case 0: return __builtin_frame_address(1); case 1: return __builtin_frame_address(2); case 2: return __builtin_frame_address(3); case 3: return __builtin_frame_address(4); case 4: return __builtin_frame_address(5); case 5: return __builtin_frame_address(6); case 6: return __builtin_frame_address(7); case 7: return __builtin_frame_address(8); case 8: return __builtin_frame_address(9); case 9: return __builtin_frame_address(10); case 10: return __builtin_frame_address(11); case 11: return __builtin_frame_address(12); case 12: return __builtin_frame_address(13); case 13: return __builtin_frame_address(14); case 14: return __builtin_frame_address(15); case 15: return __builtin_frame_address(16); case 16: return __builtin_frame_address(17); case 17: return __builtin_frame_address(18); case 18: return __builtin_frame_address(19); case 19: return __builtin_frame_address(20); case 20: return __builtin_frame_address(21); case 21: return __builtin_frame_address(22); case 22: return __builtin_frame_address(23); case 23: return __builtin_frame_address(24); case 24: return __builtin_frame_address(25); case 25: return __builtin_frame_address(26); case 26: return __builtin_frame_address(27); case 27: return __builtin_frame_address(28); case 28: return __builtin_frame_address(29); case 29: return __builtin_frame_address(30); case 30: return __builtin_frame_address(31); case 31: return __builtin_frame_address(32); case 32: return __builtin_frame_address(33); case 33: return __builtin_frame_address(34); case 34: return __builtin_frame_address(35); case 35: return __builtin_frame_address(36); case 36: return __builtin_frame_address(37); case 37: return __builtin_frame_address(38); case 38: return __builtin_frame_address(39); case 39: return __builtin_frame_address(40); case 40: return __builtin_frame_address(41); case 41: return __builtin_frame_address(42); case 42: return __builtin_frame_address(43); case 43: return __builtin_frame_address(44); case 44: return __builtin_frame_address(45); case 45: return __builtin_frame_address(46); case 46: return __builtin_frame_address(47); case 47: return __builtin_frame_address(48); case 48: return __builtin_frame_address(49); case 49: return __builtin_frame_address(50); case 50: return __builtin_frame_address(51); case 51: return __builtin_frame_address(52); case 52: return __builtin_frame_address(53); case 53: return __builtin_frame_address(54); case 54: return __builtin_frame_address(55); case 55: return __builtin_frame_address(56); case 56: return __builtin_frame_address(57); case 57: return __builtin_frame_address(58); case 58: return __builtin_frame_address(59); case 59: return __builtin_frame_address(60); case 60: return __builtin_frame_address(61); case 61: return __builtin_frame_address(62); case 62: return __builtin_frame_address(63); case 63: return __builtin_frame_address(64); case 64: return __builtin_frame_address(65); case 65: return __builtin_frame_address(66); case 66: return __builtin_frame_address(67); case 67: return __builtin_frame_address(68); case 68: return __builtin_frame_address(69); case 69: return __builtin_frame_address(70); case 70: return __builtin_frame_address(71); case 71: return __builtin_frame_address(72); case 72: return __builtin_frame_address(73); case 73: return __builtin_frame_address(74); case 74: return __builtin_frame_address(75); case 75: return __builtin_frame_address(76); case 76: return __builtin_frame_address(77); case 77: return __builtin_frame_address(78); case 78: return __builtin_frame_address(79); case 79: return __builtin_frame_address(80); case 80: return __builtin_frame_address(81); case 81: return __builtin_frame_address(82); case 82: return __builtin_frame_address(83); case 83: return __builtin_frame_address(84); case 84: return __builtin_frame_address(85); case 85: return __builtin_frame_address(86); case 86: return __builtin_frame_address(87); case 87: return __builtin_frame_address(88); case 88: return __builtin_frame_address(89); case 89: return __builtin_frame_address(90); case 90: return __builtin_frame_address(91); case 91: return __builtin_frame_address(92); case 92: return __builtin_frame_address(93); case 93: return __builtin_frame_address(94); case 94: return __builtin_frame_address(95); case 95: return __builtin_frame_address(96); case 96: return __builtin_frame_address(97); case 97: return __builtin_frame_address(98); case 98: return __builtin_frame_address(99); case 99: return __builtin_frame_address(100); case 100: return __builtin_frame_address(101); case 101: return __builtin_frame_address(102); case 102: return __builtin_frame_address(103); case 103: return __builtin_frame_address(104); case 104: return __builtin_frame_address(105); case 105: return __builtin_frame_address(106); case 106: return __builtin_frame_address(107); case 107: return __builtin_frame_address(108); case 108: return __builtin_frame_address(109); case 109: return __builtin_frame_address(110); case 110: return __builtin_frame_address(111); case 111: return __builtin_frame_address(112); case 112: return __builtin_frame_address(113); case 113: return __builtin_frame_address(114); case 114: return __builtin_frame_address(115); case 115: return __builtin_frame_address(116); case 116: return __builtin_frame_address(117); case 117: return __builtin_frame_address(118); case 118: return __builtin_frame_address(119); case 119: return __builtin_frame_address(120); case 120: return __builtin_frame_address(121); case 121: return __builtin_frame_address(122); case 122: return __builtin_frame_address(123); case 123: return __builtin_frame_address(124); case 124: return __builtin_frame_address(125); case 125: return __builtin_frame_address(126); case 126: return __builtin_frame_address(127); case 127: return __builtin_frame_address(128); default: return NULL; } } static inline void * realloc_safe(void *ptr, size_t size) { void *nptr; nptr = realloc (ptr, size); if (nptr == NULL) free (ptr); return nptr; } int backtrace(void **buffer, int size) { int i; for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) { buffer[i - 1] = getreturnaddr(i); if (buffer[i - 1] == NULL) break; } return i - 1; } char ** backtrace_symbols(void *const *buffer, int size) { size_t clen, alen; int i, offset; char **rval; Dl_info info; clen = size * sizeof(char *); rval = malloc(clen); if (rval == NULL) return NULL; for (i = 0; i < size; i++) { if (dladdr(buffer[i], &info) != 0) { if (info.dli_sname == NULL) info.dli_sname = "???"; if (info.dli_saddr == NULL) info.dli_saddr = buffer[i]; offset = buffer[i] - info.dli_saddr; /* "0x01234567 at filename" */ alen = 2 + /* "0x" */ (sizeof(void *) * 2) + /* "01234567" */ 2 + /* " <" */ strlen(info.dli_sname) + /* "function" */ 1 + /* "+" */ 10 + /* "offset */ 5 + /* "> at " */ strlen(info.dli_fname) + /* "filename" */ 1; /* "\0" */ rval = realloc_safe(rval, clen + alen); if (rval == NULL) return NULL; snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s", buffer[i], info.dli_sname, offset, info.dli_fname); } else { alen = 2 + /* "0x" */ (sizeof(void *) * 2) + /* "01234567" */ 1; /* "\0" */ rval = realloc_safe(rval, clen + alen); if (rval == NULL) return NULL; snprintf((char *) rval + clen, alen, "%p", buffer[i]); } rval[i] = (char *) clen; clen += alen; } for (i = 0; i < size; i++) rval[i] += (long) rval; return rval; } void backtrace_symbols_fd(void *const *buffer, int size, int fd) { int i, len, offset; char *buf; Dl_info info; for (i = 0; i < size; i++) { if (dladdr(buffer[i], &info) != 0) { if (info.dli_sname == NULL) info.dli_sname = "???"; if (info.dli_saddr == NULL) info.dli_saddr = buffer[i]; offset = buffer[i] - info.dli_saddr; /* "0x01234567 at filename" */ len = 2 + /* "0x" */ (sizeof(void *) * 2) + /* "01234567" */ 2 + /* " <" */ strlen(info.dli_sname) + /* "function" */ 1 + /* "+" */ D10(offset) + /* "offset */ 5 + /* "> at " */ strlen(info.dli_fname) + /* "filename" */ 2; /* "\n\0" */ buf = alloca(len); if (buf == NULL) return; snprintf(buf, len, "%p <%s+%d> at %s\n", buffer[i], info.dli_sname, offset, info.dli_fname); } else { len = 2 + /* "0x" */ (sizeof(void *) * 2) + /* "01234567" */ 2; /* "\n\0" */ buf = alloca(len); if (buf == NULL) return; snprintf(buf, len, "%p\n", buffer[i]); } if (write(fd, buf, strlen(buf)) == -1) return; } } #endif glusterfs-3.7.6/contrib/libexecinfo/PaxHeaders.7244/execinfo_compat.h0000644000076200007630000000013012617742532023773 xustar000000000000000029 mtime=1447019866.02947166 29 atime=1447019866.36846656 30 ctime=1447019932.052478383 glusterfs-3.7.6/contrib/libexecinfo/execinfo_compat.h0000644000076200007630000000344012617742532024213 0ustar00jenkinsjenkins00000000000000/* * Copyright (c) 2003 Maxim Sobolev * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. * * $Id: execinfo.h,v 1.2 2004/07/19 05:20:29 sobomax Exp $ */ #ifndef _EXECINFO_H_ #define _EXECINFO_H_ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #ifndef HAVE_BACKTRACE #ifdef __cplusplus extern "C" { #endif extern int backtrace(void **, int); extern char **backtrace_symbols(void *const *, int); extern void backtrace_symbols_fd(void *const *, int, int); #ifdef __cplusplus } #endif #endif #endif /* _EXECINFO_H_ */ glusterfs-3.7.6/contrib/PaxHeaders.7244/aclocal0000644000076200007630000000013012617742631017511 xustar000000000000000030 mtime=1447019929.751512999 28 atime=1447019949.3342184 30 ctime=1447019929.751512999 glusterfs-3.7.6/contrib/aclocal/0000755000076200007630000000000012617742631020005 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/aclocal/PaxHeaders.7244/python.m40000644000076200007630000000013212617742532021353 xustar000000000000000030 mtime=1447019866.022471765 30 atime=1447019866.365466605 30 ctime=1447019929.751512999 glusterfs-3.7.6/contrib/aclocal/python.m40000644000076200007630000002051312617742532021571 0ustar00jenkinsjenkins00000000000000## ------------------------ -*- Autoconf -*- ## Python file handling ## From Andrew Dalke ## Updated by James Henstridge ## ------------------------ # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON # automake variable. To install a package with the same name as the # automake package, install to $(pkgpythondir), or use the # pkgpython_PYTHON automake variable. # # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as # locations to install python extension modules (shared libraries). # Another macro is required to find the appropriate flags to compile # extension modules. # # If your package is configured with a different prefix to python, # users will have to add the install directory to the PYTHONPATH # environment variable, or create a .pth file (see the python # documentation for details). # # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system # doesn't meet the requirement. MINIMUM-VERSION should consist of # numbers and dots only. AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported. (2.0 was released on October 16, 2000). m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [python python2 python3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 dnl python2.1 python2.0]) m4_if([$1],[],[ dnl No version check is needed. # Find any Python interpreter. if test -z "$PYTHON"; then AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) fi am_display_PYTHON=python ], [ dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version >= $1]) AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. AC_CACHE_CHECK([for a Python interpreter with version >= $1], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then PYTHON=: else AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) fi am_display_PYTHON=$am_cv_pathless_PYTHON fi ]) if test "$PYTHON" = :; then dnl Run any user-specified action, or abort. m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) else dnl Query Python for its version number. Getting [:3] seems to be dnl the best way to do this; it's what "site.py" does in the standard dnl library. AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) dnl Use the values of $prefix and $exec_prefix for the corresponding dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made dnl distinct variables so they can be overridden if need be. However, dnl general consensus is that you shouldn't need this ability. AC_SUBST([PYTHON_PREFIX], ['${prefix}']) AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) dnl At times (like when building shared libraries) you may want dnl to know which OS platform Python thinks this is. AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) dnl Set up 4 directories: dnl pythondir -- where to install python scripts. This is the dnl site-packages directory, not the python standard library dnl directory like in previous automake betas. This behavior dnl is more consistent with lispdir.m4 for example. dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON script directory], [am_cv_python_pythondir], [if test "x$prefix" = xNONE then am_py_prefix=$ac_default_prefix else am_py_prefix=$prefix fi am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null || echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` ;; *) case $am_py_prefix in /usr|/System*) ;; *) am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pythondir], [$am_cv_python_pythondir]) dnl pkgpythondir -- $PACKAGE directory under pythondir. Was dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is dnl more consistent with the rest of automake. AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) dnl pyexecdir -- directory for installing python extension modules dnl (shared libraries) dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], [am_cv_python_pyexecdir], [if test "x$exec_prefix" = xNONE then am_py_exec_prefix=$am_py_prefix else am_py_exec_prefix=$exec_prefix fi am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null || echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` ;; *) case $am_py_exec_prefix in /usr|/System*) ;; *) am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) dnl Run any user-specified action. $2 fi ]) # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) glusterfs-3.7.6/contrib/aclocal/PaxHeaders.7244/mkdirp.m40000644000076200007630000000013212617742532021320 xustar000000000000000030 mtime=1447019866.022471765 30 atime=1447019866.365466605 30 ctime=1447019929.748513044 glusterfs-3.7.6/contrib/aclocal/mkdirp.m40000644000076200007630000001411112617742532021533 0ustar00jenkinsjenkins00000000000000# Excerpt from autoconf/autoconf/programs.m4 # This file is part of Autoconf. -*- Autoconf -*- # Checking for programs. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # This file is part of Autoconf. 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 3 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. # # Under Section 7 of GPL version 3, you are granted additional # permissions described in the Autoconf Configure Script Exception, # version 3.0, as published by the Free Software Foundation. # # You should have received a copy of the GNU General Public License # and a copy of the Autoconf Configure Script Exception along with # this program; see the files COPYINGv3 and COPYING.EXCEPTION # respectively. If not, see . # Written by David MacKenzie, with help from # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, # Roland McGrath, Noah Friedman, david d zuhn, and many others. # AC_PROG_MKDIR_P # --------------- # Check whether `mkdir -p' is known to be thread-safe, and fall back to # install-sh -d otherwise. # # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories # created by `make install' are always world readable, even if the # installer happens to have an overly restrictive umask (e.g. 077). # This was a mistake. There are at least two reasons why we must not # use `-m 0755': # - it causes special bits like SGID to be ignored, # - it may be too restrictive (some setups expect 775 directories). # # Do not use -m 0755 and let people choose whatever they expect by # setting umask. # # We cannot accept any implementation of `mkdir' that recognizes `-p'. # Some implementations (such as Solaris 8's) are vulnerable to race conditions: # if a parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' # concurrently, both version can detect that a/ is missing, but only # one can create it and the other will error out. Consequently we # restrict ourselves to known race-free implementations. # # Automake used to define mkdir_p as `mkdir -p .', in order to # allow $(mkdir_p) to be used without argument. As in # $(mkdir_p) $(somedir) # where $(somedir) is conditionally defined. However we don't do # that for MKDIR_P. # 1. before we restricted the check to GNU mkdir, `mkdir -p .' was # reported to fail in read-only directories. The system where this # happened has been forgotten. # 2. in practice we call $(MKDIR_P) on directories such as # $(MKDIR_P) "$(DESTDIR)$(somedir)" # and we don't want to create $(DESTDIR) if $(somedir) is empty. # To support the latter case, we have to write # test -z "$(somedir)" || $(MKDIR_P) "$(DESTDIR)$(somedir)" # so $(MKDIR_P) always has an argument. # We will have better chances of detecting a missing test if # $(MKDIR_P) complains about missing arguments. # 3. $(MKDIR_P) is named after `mkdir -p' and we don't expect this # to accept no argument. # 4. having something like `mkdir .' in the output is unsightly. # # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create. AN_MAKEVAR([MKDIR_P], [AC_PROG_MKDIR_P]) AC_DEFUN_ONCE([AC_PROG_MKDIR_P], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_MSG_CHECKING([for a thread-safe mkdir -p]) if test -z "$MKDIR_P"; then AC_CACHE_VAL([ac_cv_path_mkdir], [_AS_PATH_WALK([$PATH$PATH_SEPARATOR/opt/sfw/bin], [for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do AS_EXECUTABLE_P(["$as_dir/$ac_prog$ac_exec_ext"]) || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done])]) test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi dnl status.m4 does special magic for MKDIR_P instead of AC_SUBST, dnl to get relative names right. However, also AC_SUBST here so dnl that Automake versions before 1.10 will pick it up (they do not dnl trace AC_SUBST_TRACE). dnl FIXME: Remove this once we drop support for Automake < 1.10. AC_SUBST([MKDIR_P])dnl AC_MSG_RESULT([$MKDIR_P]) ])# AC_PROG_MKDIR_P # From automake/m4/mkdirp.m4 ## -*- Autoconf -*- # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [ AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) glusterfs-3.7.6/contrib/PaxHeaders.7244/fuse-lib0000644000076200007630000000013012617742647017630 xustar000000000000000030 mtime=1447019943.502306133 28 atime=1447019949.3342184 30 ctime=1447019943.502306133 glusterfs-3.7.6/contrib/fuse-lib/0000755000076200007630000000000012617742647020124 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/fuse-lib/PaxHeaders.7244/mount-gluster-compat.h0000644000076200007630000000013012617742532024155 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 29 ctime=1447019943.46330672 glusterfs-3.7.6/contrib/fuse-lib/mount-gluster-compat.h0000644000076200007630000000300712617742532024374 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi Copyright (c) 2010 Gluster, Inc. This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #if defined(GF_LINUX_HOST_OS) #include #endif /* GF_LINUX_HOST_OS */ #include #include #include #include #include #if defined(__NetBSD__) #include #define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0) #define MS_RDONLY MNT_RDONLY #endif #if defined(GF_DARWIN_HOST_OS) || defined(__FreeBSD__) #include #include #define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0) #define MS_RDONLY MNT_RDONLY #endif #ifdef GF_LINUX_HOST_OS #define _PATH_MOUNT "/bin/mount" #else /* FreeBSD, NetBSD, MacOS X */ #define _PATH_MOUNT "/sbin/mount" #endif #ifdef FUSE_UTIL #define MALLOC(size) malloc (size) #define FREE(ptr) free (ptr) #define GFFUSE_LOGERR(...) fprintf (stderr, ## __VA_ARGS__) #else /* FUSE_UTIL */ #include "glusterfs.h" #include "logging.h" #include "common-utils.h" #define GFFUSE_LOGERR(...) \ gf_log ("glusterfs-fuse", GF_LOG_ERROR, ## __VA_ARGS__) #endif /* !FUSE_UTIL */ glusterfs-3.7.6/contrib/fuse-lib/PaxHeaders.7244/misc.c0000644000076200007630000000013112617742532020776 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 30 ctime=1447019943.496306224 glusterfs-3.7.6/contrib/fuse-lib/misc.c0000644000076200007630000000253112617742532021215 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB */ #include #include #include #include #include "glusterfs.h" #include "fuse_kernel.h" #include "fuse-misc.h" unsigned long calc_timeout_sec (double t) { if (t > (double) ULONG_MAX) return ULONG_MAX; else if (t < 0.0) return 0; else return (unsigned long) t; } unsigned int calc_timeout_nsec (double t) { double f = t - (double) calc_timeout_sec (t); if (f < 0.0) return 0; else if (f >= 0.999999999) return 999999999; else return (unsigned int) (f * 1.0e9); } void convert_fuse_file_lock (struct fuse_file_lock *fl, struct gf_flock *flock, uint64_t lk_owner) { memset (flock, 0, sizeof (struct flock)); flock->l_type = fl->type; flock->l_whence = SEEK_SET; flock->l_start = fl->start; if (fl->end == OFFSET_MAX) flock->l_len = 0; else flock->l_len = fl->end - fl->start + 1; flock->l_pid = fl->pid; set_lk_owner_from_uint64 (&flock->l_owner, lk_owner); } glusterfs-3.7.6/contrib/fuse-lib/PaxHeaders.7244/mount-common.c0000644000076200007630000000013112617742532022473 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 30 ctime=1447019943.502306133 glusterfs-3.7.6/contrib/fuse-lib/mount-common.c0000644000076200007630000002203412617742532022712 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi Copyright (c) 2010 Gluster, Inc. This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ #include "mount-gluster-compat.h" /* * These functions (and gf_fuse_umount() in mount.c) * were originally taken from libfuse as of commit 7960e99e * (http://fuse.git.sourceforge.net/git/gitweb.cgi?p=fuse/fuse;a=commit;h=7960e99e) * almost verbatim. What has been changed upon adoption: * - style adopted to that of glusterfs * - s/fprintf/gf_log/ * - s/free/FREE/, s/malloc/MALLOC/ * - there are some other minor things * * For changes that were made later and syncs with upstream, * see the commit log and per-function comments. */ #ifdef GF_LINUX_HOST_OS /* FUSE: cherry-picked bd99f9cf */ static int mtab_needs_update (const char *mnt) { int res; struct stat stbuf; /* If mtab is within new mount, don't touch it */ if (strncmp (mnt, _PATH_MOUNTED, strlen (mnt)) == 0 && _PATH_MOUNTED[strlen (mnt)] == '/') return 0; /* * Skip mtab update if /etc/mtab: * * - doesn't exist, * - is a symlink, * - is on a read-only filesystem. */ res = lstat (_PATH_MOUNTED, &stbuf); if (res == -1) { if (errno == ENOENT) return 0; } else { uid_t ruid; int err; if (S_ISLNK (stbuf.st_mode)) return 0; ruid = getuid (); if (ruid != 0) setreuid (0, -1); res = access (_PATH_MOUNTED, W_OK); err = (res == -1) ? errno : 0; if (ruid != 0) setreuid (ruid, -1); if (err == EROFS) return 0; } return 1; } #else /* GF_LINUX_HOST_OS */ #define mtab_needs_update(x) 1 #endif /* GF_LINUX_HOST_OS */ /* FUSE: called add_mount_legacy(); R.I.P. as of cbd3a2a8 */ int fuse_mnt_add_mount (const char *progname, const char *fsname, const char *mnt, const char *type, const char *opts) { int res; int status; sigset_t blockmask; sigset_t oldmask; if (!mtab_needs_update (mnt)) return 0; sigemptyset (&blockmask); sigaddset (&blockmask, SIGCHLD); res = sigprocmask (SIG_BLOCK, &blockmask, &oldmask); if (res == -1) { GFFUSE_LOGERR ("%s: sigprocmask: %s", progname, strerror (errno)); return -1; } res = fork (); if (res == -1) { GFFUSE_LOGERR ("%s: fork: %s", progname, strerror (errno)); goto out_restore; } if (res == 0) { char templ[] = "/tmp/fusermountXXXXXX"; char *tmp; sigprocmask (SIG_SETMASK, &oldmask, NULL); res = setuid (geteuid ()); if (res != 0) { GFFUSE_LOGERR ("%s: setuid: %s", progname, strerror (errno)); exit (1); } /* * hide in a directory, where mount isn't able to resolve * fsname as a valid path */ tmp = mkdtemp (templ); if (!tmp) { GFFUSE_LOGERR ("%s: failed to create temporary directory", progname); exit (1); } if (chdir (tmp)) { GFFUSE_LOGERR ("%s: failed to chdir to %s: %s", progname, tmp, strerror (errno)); exit (1); } rmdir (tmp); execl (_PATH_MOUNT, _PATH_MOUNT, "-i", "-f", "-t", type, "-o", opts, fsname, mnt, NULL); GFFUSE_LOGERR ("%s: failed to execute %s: %s", progname, _PATH_MOUNT, strerror (errno)); exit (1); } res = waitpid (res, &status, 0); if (res == -1) GFFUSE_LOGERR ("%s: waitpid: %s", progname, strerror (errno)); res = (res != -1 && status == 0) ? 0 : -1; out_restore: sigprocmask (SIG_SETMASK, &oldmask, NULL); return res; } char * fuse_mnt_resolve_path (const char *progname, const char *orig) { char buf[PATH_MAX]; char *copy; char *dst; char *end; char *lastcomp; const char *toresolv; if (!orig[0]) { GFFUSE_LOGERR ("%s: invalid mountpoint '%s'", progname, orig); return NULL; } copy = strdup (orig); if (copy == NULL) { GFFUSE_LOGERR ("%s: failed to allocate memory", progname); return NULL; } toresolv = copy; lastcomp = NULL; for (end = copy + strlen (copy) - 1; end > copy && *end == '/'; end --); if (end[0] != '/') { char *tmp; end[1] = '\0'; tmp = strrchr (copy, '/'); if (tmp == NULL) { lastcomp = copy; toresolv = "."; } else { lastcomp = tmp + 1; if (tmp == copy) toresolv = "/"; } if (strcmp (lastcomp, ".") == 0 || strcmp (lastcomp, "..") == 0) { lastcomp = NULL; toresolv = copy; } else if (tmp) tmp[0] = '\0'; } if (realpath (toresolv, buf) == NULL) { GFFUSE_LOGERR ("%s: bad mount point %s: %s", progname, orig, strerror (errno)); FREE (copy); return NULL; } if (lastcomp == NULL) dst = strdup (buf); else { dst = (char *) MALLOC (strlen (buf) + 1 + strlen (lastcomp) + 1); if (dst) { unsigned buflen = strlen (buf); if (buflen && buf[buflen-1] == '/') sprintf (dst, "%s%s", buf, lastcomp); else sprintf (dst, "%s/%s", buf, lastcomp); } } FREE (copy); if (dst == NULL) GFFUSE_LOGERR ("%s: failed to allocate memory", progname); return dst; } /* FUSE: to support some changes that were reverted since * then, it was split in two (fuse_mnt_umount() and * exec_umount()); however the actual code is same as here * since 0197ce40 */ int fuse_mnt_umount (const char *progname, const char *abs_mnt, const char *rel_mnt, int lazy) { int res; int status; sigset_t blockmask; sigset_t oldmask; if (!mtab_needs_update (abs_mnt)) { res = umount2 (rel_mnt, lazy ? 2 : 0); if (res == -1) GFFUSE_LOGERR ("%s: failed to unmount %s: %s", progname, abs_mnt, strerror (errno)); return res; } sigemptyset (&blockmask); sigaddset (&blockmask, SIGCHLD); res = sigprocmask (SIG_BLOCK, &blockmask, &oldmask); if (res == -1) { GFFUSE_LOGERR ("%s: sigprocmask: %s", progname, strerror (errno)); return -1; } res = fork (); if (res == -1) { GFFUSE_LOGERR ("%s: fork: %s", progname, strerror (errno)); goto out_restore; } if (res == 0) { sigprocmask (SIG_SETMASK, &oldmask, NULL); res = setuid (geteuid ()); if (res != 0) { GFFUSE_LOGERR ("%s: setuid: %s", progname, strerror (errno)); exit (1); } #ifdef GF_LINUX_HOST_OS execl ("/bin/umount", "/bin/umount", "-i", rel_mnt, lazy ? "-l" : NULL, NULL); GFFUSE_LOGERR ("%s: failed to execute /bin/umount: %s", progname, strerror (errno)); #elif __NetBSD__ /* exitting the filesystem causes the umount */ exit (0); #else execl ("/sbin/umount", "/sbin/umount", "-f", rel_mnt, NULL); GFFUSE_LOGERR ("%s: failed to execute /sbin/umount: %s", progname, strerror (errno)); #endif /* GF_LINUX_HOST_OS */ exit (1); } res = waitpid (res, &status, 0); if (res == -1) GFFUSE_LOGERR ("%s: waitpid: %s", progname, strerror (errno)); if (status != 0) res = -1; out_restore: sigprocmask (SIG_SETMASK, &oldmask, NULL); return res; } glusterfs-3.7.6/contrib/fuse-lib/PaxHeaders.7244/mount.c0000644000076200007630000000013112617742532021205 xustar000000000000000029 mtime=1447019866.02747169 30 atime=1447019866.367466575 30 ctime=1447019943.499306179 glusterfs-3.7.6/contrib/fuse-lib/mount.c0000644000076200007630000002574312617742532021436 0ustar00jenkinsjenkins00000000000000/* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi Copyright (c) 2010 Gluster, Inc. This program can be distributed under the terms of the GNU LGPLv2. See the file COPYING.LIB. */ #include "mount_util.h" #include "mount-gluster-compat.h" #ifdef GF_FUSERMOUNT #define FUSERMOUNT_PROG FUSERMOUNT_DIR "/fusermount-glusterfs" #else #define FUSERMOUNT_PROG "fusermount" #endif #define FUSE_DEVFD_ENV "_FUSE_DEVFD" #ifdef __FreeBSD__ #include #include #include #endif /* __FreeBSD__ */ /* FUSE: function is called fuse_kern_unmount() */ void gf_fuse_unmount (const char *mountpoint, int fd) { int res; int pid; if (!mountpoint) return; if (fd != -1) { struct pollfd pfd; pfd.fd = fd; pfd.events = 0; res = poll (&pfd, 1, 0); /* If file poll returns POLLERR on the device file descriptor, then the filesystem is already unmounted */ if (res == 1 && (pfd.revents & POLLERR)) return; /* Need to close file descriptor, otherwise synchronous umount would recurse into filesystem, and deadlock */ close (fd); } if (geteuid () == 0) { fuse_mnt_umount ("fuse", mountpoint, mountpoint, 1); return; } res = umount2 (mountpoint, 2); if (res == 0) return; pid = fork (); if (pid == -1) return; if (pid == 0) { const char *argv[] = { FUSERMOUNT_PROG, "-u", "-q", "-z", "--", mountpoint, NULL }; execvp (FUSERMOUNT_PROG, (char **)argv); _exit (1); } waitpid (pid, NULL, 0); } /* gluster-specific routines */ static char * escape (char *s) { size_t len = 0; char *p = NULL; char *q = NULL; char *e = NULL; for (p = s; *p; p++) { if (*p == ',') len++; len++; } e = CALLOC (1, len + 1); if (!e) return NULL; for (p = s, q = e; *p; p++, q++) { if (*p == ',') { *q = '\\'; q++; } *q = *p; } return e; } static int fuse_mount_fusermount (const char *mountpoint, char *fsname, unsigned long mountflags, char *mnt_param, int fd) { int pid = -1; int res = 0; int ret = -1; char *fm_mnt_params = NULL; char *efsname = NULL; #ifndef GF_FUSERMOUNT GFFUSE_LOGERR ("Mounting via helper utility " "(unprivileged mounting) is supported " "only if glusterfs is compiled with " "--enable-fusermount"); return -1; #endif efsname = escape (fsname); if (!efsname) { GFFUSE_LOGERR ("Out of memory"); return -1; } ret = asprintf (&fm_mnt_params, "%s%s,fsname=%s,nonempty,subtype=glusterfs", (mountflags & MS_RDONLY) ? "ro," : "", mnt_param, efsname); FREE (efsname); if (ret == -1) { GFFUSE_LOGERR ("Out of memory"); goto out; } /* fork to exec fusermount */ pid = fork (); if (pid == -1) { GFFUSE_LOGERR ("fork() failed: %s", strerror (errno)); ret = -1; goto out; } if (pid == 0) { char env[10]; const char *argv[32]; int a = 0; argv[a++] = FUSERMOUNT_PROG; argv[a++] = "-o"; argv[a++] = fm_mnt_params; argv[a++] = "--"; argv[a++] = mountpoint; argv[a++] = NULL; snprintf (env, sizeof (env), "%i", fd); setenv (FUSE_DEVFD_ENV, env, 1); execvp (FUSERMOUNT_PROG, (char **)argv); GFFUSE_LOGERR ("failed to exec fusermount: %s", strerror (errno)); _exit (1); } ret = waitpid (pid, &res, 0); ret = (ret == pid && res == 0) ? 0 : -1; out: FREE (fm_mnt_params); return ret; } #if defined(__FreeBSD__) void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len) { int i; if (*iovlen < 0) return; i = *iovlen; *iov = realloc(*iov, sizeof **iov * (i + 2)); if (*iov == NULL) { *iovlen = -1; return; } (*iov)[i].iov_base = strdup(name); (*iov)[i].iov_len = strlen(name) + 1; i++; (*iov)[i].iov_base = val; if (len == (size_t) -1) { if (val != NULL) len = strlen(val) + 1; else len = 0; } (*iov)[i].iov_len = (int)len; *iovlen = ++i; } /* * This function is needed for compatibility with parameters * which used to use the mount_argf() command for the old mount() syscall. */ void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...) { va_list ap; char val[255] = { 0 }; va_start(ap, fmt); vsnprintf(val, sizeof(val), fmt, ap); va_end(ap); build_iovec(iov, iovlen, name, strdup(val), (size_t)-1); } #endif /* __FreeBSD__ */ static int fuse_mount_sys (const char *mountpoint, char *fsname, unsigned long mountflags, char *mnt_param, int fd) { int ret = -1; unsigned mounted = 0; char *mnt_param_mnt = NULL; char *fstype = "fuse.glusterfs"; char *source = fsname; ret = asprintf (&mnt_param_mnt, "%s,fd=%i,rootmode=%o,user_id=%i,group_id=%i", mnt_param, fd, S_IFDIR, getuid (), getgid ()); if (ret == -1) { GFFUSE_LOGERR ("Out of memory"); goto out; } #ifdef __FreeBSD__ struct iovec *iov = NULL; int iovlen = 0; char fdstr[15]; sprintf (fdstr, "%d", fd); build_iovec (&iov, &iovlen, "fstype", "fusefs", -1); build_iovec (&iov, &iovlen, "subtype", "glusterfs", -1); build_iovec (&iov, &iovlen, "fspath", __DECONST(void *, mountpoint), -1); build_iovec (&iov, &iovlen, "from", "/dev/fuse", -1); build_iovec (&iov, &iovlen, "volname", source, -1); build_iovec (&iov, &iovlen, "fd", fdstr, -1); ret = nmount (iov, iovlen, mountflags); #else ret = mount (source, mountpoint, fstype, mountflags, mnt_param_mnt); #endif /* __FreeBSD__ */ #ifdef GF_LINUX_HOST_OS if (ret == -1 && errno == ENODEV) { /* fs subtype support was added by 79c0b2df aka v2.6.21-3159-g79c0b2d. Probably we have an older kernel ... */ fstype = "fuse"; ret = asprintf (&source, "glusterfs#%s", fsname); if (ret == -1) { GFFUSE_LOGERR ("Out of memory"); goto out; } ret = mount (source, mountpoint, fstype, mountflags, mnt_param_mnt); } #endif /* GF_LINUX_HOST_OS */ if (ret == -1) goto out; else mounted = 1; #ifdef GF_LINUX_HOST_OS if (geteuid () == 0) { char *newmnt = fuse_mnt_resolve_path ("fuse", mountpoint); char *mnt_param_mtab = NULL; if (!newmnt) { ret = -1; goto out; } ret = asprintf (&mnt_param_mtab, "%s%s", mountflags & MS_RDONLY ? "ro," : "", mnt_param); if (ret == -1) GFFUSE_LOGERR ("Out of memory"); else { ret = fuse_mnt_add_mount ("fuse", source, newmnt, fstype, mnt_param_mtab); FREE (mnt_param_mtab); } FREE (newmnt); if (ret == -1) { GFFUSE_LOGERR ("failed to add mtab entry"); goto out; } } #endif /* GF_LINUX_HOST_OS */ out: if (ret == -1) { GFFUSE_LOGERR("ret = -1\n"); if (mounted) umount2 (mountpoint, 2); /* lazy umount */ } FREE (mnt_param_mnt); if (source != fsname) FREE (source); return ret; } int gf_fuse_mount (const char *mountpoint, char *fsname, unsigned long mountflags, char *mnt_param, pid_t *mnt_pid, int status_fd) { int fd = -1; pid_t pid = -1; int ret = -1; fd = open ("/dev/fuse", O_RDWR); if (fd == -1) { GFFUSE_LOGERR ("cannot open /dev/fuse (%s)", strerror (errno)); return -1; } /* start mount agent */ pid = fork(); switch (pid) { case 0: /* hello it's mount agent */ if (!mnt_pid) { /* daemonize mount agent, caller is * not interested in waiting for it */ pid = fork (); if (pid) exit (pid == -1 ? 1 : 0); } ret = fuse_mount_sys (mountpoint, fsname, mountflags, mnt_param, fd); if (ret == -1) { gf_log ("glusterfs-fuse", GF_LOG_INFO, "direct mount failed (%s) errno %d, " "retry to mount via fusermount", strerror (errno), errno); ret = fuse_mount_fusermount (mountpoint, fsname, mountflags, mnt_param, fd); } if (ret == -1) GFFUSE_LOGERR ("mount of %s to %s (%s) failed", fsname, mountpoint, mnt_param); if (status_fd >= 0) (void)write (status_fd, &ret, sizeof (ret)); exit (!!ret); /* bye mount agent */ case -1: close (fd); fd = -1; } if (mnt_pid) *mnt_pid = pid; return fd; } glusterfs-3.7.6/contrib/PaxHeaders.7244/macfuse0000644000076200007630000000013012617742647017545 xustar000000000000000030 mtime=1447019943.505306088 28 atime=1447019949.3342184 30 ctime=1447019943.505306088 glusterfs-3.7.6/contrib/macfuse/0000755000076200007630000000000012617742647020041 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/macfuse/PaxHeaders.7244/fuse_param.h0000644000076200007630000000013112617742532022107 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019943.470306615 glusterfs-3.7.6/contrib/macfuse/fuse_param.h0000644000076200007630000001320212617742532022323 0ustar00jenkinsjenkins00000000000000/* * 'rebel' branch modifications: * Copyright (C) 2010 Tuxera. All Rights Reserved. */ /* * Copyright (C) 2006-2008 Google. All Rights Reserved. * Amit Singh */ #ifndef _FUSE_PARAM_H_ #define _FUSE_PARAM_H_ #include /* Compile-time tunables (M_OSXFUSE*) */ #define M_OSXFUSE_ENABLE_FIFOFS 0 #define M_OSXFUSE_ENABLE_INTERRUPT 1 #define M_OSXFUSE_ENABLE_SPECFS 0 #define M_OSXFUSE_ENABLE_TSLOCKING 1 #define M_OSXFUSE_ENABLE_UNSUPPORTED 1 #define M_OSXFUSE_ENABLE_XATTR 1 #define M_OSXFUSE_ENABLE_DSELECT 1 #if M_OSXFUSE_ENABLE_UNSUPPORTED # define M_OSXFUSE_ENABLE_EXCHANGE 1 # define M_OSXFUSE_ENABLE_KUNC 0 # define M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK 1 #endif /* M_OSXFUSE_ENABLE_UNSUPPORTED */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 # if M_OSXFUSE_ENABLE_UNSUPPORTED /* * In Mac OS X 10.5 the file system implementation is responsible for * posting kqueue events. Starting with Mac OS X 10.6 VFS took over that * job. */ # define M_OSXFUSE_ENABLE_KQUEUE 1 # endif #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ #if M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK # define M_OSXFUSE_ENABLE_HUGE_LOCK 0 # define M_OSXFUSE_ENABLE_LOCK_LOGGING 0 # define FUSE_VNOP_EXPORT __private_extern__ #else # define FUSE_VNOP_EXPORT static #endif /* M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK */ /* User Control */ #define OSXFUSE_POSTUNMOUNT_SIGNAL SIGKILL #define MACOSX_ADMIN_GROUP_NAME "admin" #define SYSCTL_OSXFUSE_TUNABLES_ADMIN "osxfuse.tunables.admin_group" #define SYSCTL_OSXFUSE_VERSION_NUMBER "osxfuse.version.number" /* Paths */ #define OSXFUSE_BUNDLE_PATH "/Library/Filesystems/osxfusefs.fs" #define OSXFUSE_KEXT OSXFUSE_BUNDLE_PATH "/Support/osxfusefs.kext" #define OSXFUSE_LOAD_PROG OSXFUSE_BUNDLE_PATH "/Support/load_osxfusefs" #define OSXFUSE_MOUNT_PROG OSXFUSE_BUNDLE_PATH "/Support/mount_osxfusefs" #define SYSTEM_KEXTLOAD "/sbin/kextload" #define SYSTEM_KEXTUNLOAD "/sbin/kextunload" /* Compatible API version */ #define OSXFUSE_MIN_USER_VERSION_MAJOR 7 #define OSXFUSE_MIN_USER_VERSION_MINOR 5 /* Device Interface */ /* * This is the prefix ("osxfuse" by default) of the name of a FUSE device node * in devfs. The suffix is the device number. "/dev/osxfuse0" is the first FUSE * device by default. If you change the prefix from the default to something * else, the user-space FUSE library will need to know about it too. */ #define OSXFUSE_DEVICE_BASENAME "osxfuse" /* * This is the number of /dev/osxfuse nodes we will create. goes from * 0 to (OSXFUSE_NDEVICES - 1). */ #define OSXFUSE_NDEVICES 24 /* * This is the default block size of the virtual storage devices that are * implicitly implemented by the FUSE kernel extension. This can be changed * on a per-mount basis (there's one such virtual device for each mount). */ #define FUSE_DEFAULT_BLOCKSIZE 4096 #define FUSE_MIN_BLOCKSIZE 512 #define FUSE_MAX_BLOCKSIZE MAXPHYS #ifndef MAX_UPL_TRANSFER #define MAX_UPL_TRANSFER 256 #endif /* * This is default I/O size used while accessing the virtual storage devices. * This can be changed on a per-mount basis. * * Nevertheless, the I/O size must be at least as big as the block size. */ #define FUSE_DEFAULT_IOSIZE (16 * PAGE_SIZE) #define FUSE_MIN_IOSIZE 512 #define FUSE_MAX_IOSIZE (MAX_UPL_TRANSFER * PAGE_SIZE) #define FUSE_DEFAULT_INIT_TIMEOUT 10 /* s */ #define FUSE_MIN_INIT_TIMEOUT 1 /* s */ #define FUSE_MAX_INIT_TIMEOUT 300 /* s */ #define FUSE_INIT_WAIT_INTERVAL 100000 /* us */ #define FUSE_INIT_TIMEOUT_DEFAULT_BUTTON_TITLE "OK" #define FUSE_INIT_TIMEOUT_NOTICE_MESSAGE \ "Timed out waiting for the file system to initialize. The volume has " \ "been ejected. You can use the init_timeout mount option to wait longer." #define FUSE_DEFAULT_DAEMON_TIMEOUT 60 /* s */ #define FUSE_MIN_DAEMON_TIMEOUT 0 /* s */ #define FUSE_MAX_DAEMON_TIMEOUT 600 /* s */ #define FUSE_DAEMON_TIMEOUT_DEFAULT_BUTTON_TITLE "Keep Trying" #define FUSE_DAEMON_TIMEOUT_OTHER_BUTTON_TITLE "Force Eject" #define FUSE_DAEMON_TIMEOUT_ALTERNATE_BUTTON_TITLE "Don't Warn Again" #define FUSE_DAEMON_TIMEOUT_ALERT_MESSAGE \ "There was a timeout waiting for the file system to respond. You can " \ "eject this volume immediately, but unsaved changes may be lost." #define FUSE_DAEMON_TIMEOUT_ALERT_TIMEOUT 120 /* s */ #ifdef KERNEL /* * This is the soft upper limit on the number of "request tickets" FUSE's * user-kernel IPC layer can have for a given mount. This can be modified * through the fuse.* sysctl interface. */ #define FUSE_DEFAULT_MAX_FREE_TICKETS 1024 #define FUSE_DEFAULT_IOV_PERMANENT_BUFSIZE (1 << 19) #define FUSE_DEFAULT_IOV_CREDIT 16 /* User-Kernel IPC Buffer */ #define FUSE_MIN_USERKERNEL_BUFSIZE (128 * 1024) #define FUSE_MAX_USERKERNEL_BUFSIZE (16 * 1024 * 1024) #define FUSE_REASONABLE_XATTRSIZE FUSE_MIN_USERKERNEL_BUFSIZE #endif /* KERNEL */ #define FUSE_DEFAULT_USERKERNEL_BUFSIZE (16 * 1024 * 1024) #define FUSE_LINK_MAX LINK_MAX #define FUSE_UIO_BACKUP_MAX 8 #define FUSE_MAXNAMLEN 255 #endif /* _FUSE_PARAM_H_ */ glusterfs-3.7.6/contrib/macfuse/PaxHeaders.7244/fuse_ioctl.h0000644000076200007630000000013112617742532022121 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019943.474306555 glusterfs-3.7.6/contrib/macfuse/fuse_ioctl.h0000644000076200007630000000373112617742532022343 0ustar00jenkinsjenkins00000000000000/* * Copyright (C) 2006-2008 Google. All Rights Reserved. * Amit Singh */ #ifndef _FUSE_IOCTL_H_ #define _FUSE_IOCTL_H_ #include #include /* FUSEDEVIOCxxx */ /* Get mounter's pid. */ #define FUSEDEVGETMOUNTERPID _IOR('F', 1, u_int32_t) /* Check if FUSE_INIT kernel-user handshake is complete. */ #define FUSEDEVIOCGETHANDSHAKECOMPLETE _IOR('F', 2, u_int32_t) /* Mark the daemon as dead. */ #define FUSEDEVIOCSETDAEMONDEAD _IOW('F', 3, u_int32_t) /* Tell the kernel which operations the daemon implements. */ #define FUSEDEVIOCSETIMPLEMENTEDBITS _IOW('F', 4, u_int64_t) /* Get device's random "secret". */ #define FUSEDEVIOCGETRANDOM _IOR('F', 5, u_int32_t) /* * The 'AVFI' (alter-vnode-for-inode) ioctls all require an inode number * as an argument. In the user-space library, you can get the inode number * from a path by using fuse_lookup_inode_by_path_np() [lib/fuse.c]. * * To see an example of using this, see the implementation of * fuse_purge_path_np() in lib/fuse_darwin.c. */ struct fuse_avfi_ioctl { uint64_t inode; uint64_t cmd; uint32_t ubc_flags; uint32_t note; off_t size; }; /* Alter the vnode (if any) specified by the given inode. */ #define FUSEDEVIOCALTERVNODEFORINODE _IOW('F', 6, struct fuse_avfi_ioctl) #define FSCTLALTERVNODEFORINODE IOCBASECMD(FUSEDEVIOCALTERVNODEFORINODE) /* * Possible cmd values for AVFI. */ #define FUSE_AVFI_MARKGONE 0x00000001 /* no ubc_flags */ #define FUSE_AVFI_PURGEATTRCACHE 0x00000002 /* no ubc_flags */ #define FUSE_AVFI_PURGEVNCACHE 0x00000004 /* no ubc_flags */ #define FUSE_AVFI_UBC 0x00000008 /* uses ubc_flags */ #define FUSE_AVFI_UBC_SETSIZE 0x00000010 /* uses ubc_flags, size */ #define FUSE_AVFI_KNOTE 0x00000020 /* uses note */ #define FUSE_SETACLSTATE _IOW('h', 10, int32_t) #define FSCTLSETACLSTATE IOCBASECMD(FUSE_SETACLSTATE) #endif /* _FUSE_IOCTL_H_ */ glusterfs-3.7.6/contrib/macfuse/PaxHeaders.7244/mount_darwin.c0000644000076200007630000000013112617742532022466 xustar000000000000000030 mtime=1447019866.030471645 29 atime=1447019866.36846656 30 ctime=1447019943.505306088 glusterfs-3.7.6/contrib/macfuse/mount_darwin.c0000644000076200007630000002004112617742532022701 0ustar00jenkinsjenkins00000000000000/* * Derived from mount_bsd.c from the fuse distribution. * * FUSE: Filesystem in Userspace * Copyright (C) 2005-2006 Csaba Henk * Copyright (C) 2007-2009 Amit Singh * Copyright (c) 2010 Gluster, Inc. * * This program can be distributed under the terms of the GNU LGPLv2. * See the file COPYING.LIB. */ #undef _POSIX_C_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fuse_param.h" #include "fuse_ioctl.h" #include "glusterfs.h" #include "logging.h" #include "common-utils.h" #define GFFUSE_LOGERR(...) \ gf_log ("glusterfs-fuse", GF_LOG_ERROR, ## __VA_ARGS__) int gf_fuse_mount (const char *mountpoint, char *fsname, unsigned long mountflags, char *mnt_param, pid_t *mnt_pid, int status_fd) /* Not used on OS X */ { int fd = 0; int pid = 0; int ret = 0; char *fdnam = NULL; char *dev = NULL; char vstr[4]; unsigned vval = 0; int i = 0; const char *mountprog = OSXFUSE_MOUNT_PROG; sig_t chldf = SIG_ERR; char version[MAXHOSTNAMELEN + 1] = { 0 }; size_t version_len = MAXHOSTNAMELEN; size_t version_len_desired = 0; int r = 0; char devpath[MAXPATHLEN] = { 0 };; if (!mountpoint) { gf_log ("glustefs-fuse", GF_LOG_ERROR, "missing or invalid mount point"); goto err; } /* mount_fusefs should not try to spawn the daemon */ setenv("MOUNT_FUSEFS_SAFE", "1", 1); /* to notify mount_fusefs it's called from lib */ setenv("MOUNT_FUSEFS_CALL_BY_LIB", "1", 1); chldf = signal(SIGCHLD, SIG_DFL); /* So that we can wait4() below. */ if (chldf == SIG_ERR) { gf_log ("glusterfs-fuse", GF_LOG_ERROR, "signal() returned SIG_ERR: %s", strerror(errno)); goto err; } /* check for user<->kernel match. */ ret = sysctlbyname(SYSCTL_OSXFUSE_VERSION_NUMBER, version, &version_len, NULL, (size_t)0); if (ret != 0) { gf_log ("glustefs-fuse", GF_LOG_ERROR, "sysctlbyname() returned error: %s", strerror(errno)); goto err; } /* sysctlbyname() includes the trailing '\0' in version_len */ version_len_desired = strlen("2.x.y") + 1; if (version_len != version_len_desired) { gf_log ("glusterfs-fuse", GF_LOG_ERROR, "version length mismatch for OSXFUSE %s", version); ret = -1; goto err; } for (i = 0; i < 3; i++) vstr[i] = version[2*i]; vstr[3] = '\0'; vval = strtoul(vstr, NULL, 10); if (vval < 264) { GFFUSE_LOGERR("OSXFUSE version %s is not supported", version); ret = -1; goto err; } gf_log("glusterfs-fuse", GF_LOG_INFO, "OSXFUSE kext version supported %s", version); fdnam = getenv("FUSE_DEV_FD"); if (fdnam) { fd = strtol(fdnam, NULL, 10); if (fd < 0) { GFFUSE_LOGERR("invalid value given in FUSE_DEV_FD"); ret = -1; goto err; } goto mount; } dev = getenv("FUSE_DEV_NAME"); if (!dev) { for (r = 0; r < OSXFUSE_NDEVICES; r++) { snprintf(devpath, MAXPATHLEN - 1, _PATH_DEV OSXFUSE_DEVICE_BASENAME "%d", r); if ((fd = open(devpath, O_RDWR)) < 0) { GFFUSE_LOGERR("failed to open device %s (%s)", devpath, strerror(errno)); goto err; } dev = devpath; goto mount; } } fd = open(dev, O_RDWR); if (fd < 0) { GFFUSE_LOGERR("failed to open device %s (%s)", dev, strerror(errno)); ret = -1; goto err; } mount: signal(SIGCHLD, chldf); pid = fork(); if (pid == -1) { GFFUSE_LOGERR("fork() failed (%s)", strerror(errno)); ret = -1; goto err; } if (pid == 0) { pid = fork(); if (pid == -1) { GFFUSE_LOGERR("fork() failed (%s)", strerror(errno)); ret = -1; goto err; } if (pid == 0) { const char *argv[32]; int a = 0; char *opts = NULL; if (asprintf(&opts, "%s,fssubtype=glusterfs", mnt_param) == -1) { GFFUSE_LOGERR("asprintf() error: %s", strerror(errno)); ret = -1; goto err; } if (!fdnam) asprintf(&fdnam, "%d", fd); argv[a++] = mountprog; if (opts) { argv[a++] = "-o"; argv[a++] = opts; } argv[a++] = fdnam; argv[a++] = mountpoint; argv[a++] = NULL; { char title[MAXPATHLEN + 1] = { 0 }; u_int32_t len = MAXPATHLEN; int ret = proc_pidpath(getpid(), title, len); if (ret) { setenv("MOUNT_FUSEFS_DAEMON_PATH", title, 1); } } execvp(mountprog, (char **) argv); GFFUSE_LOGERR("OSXFUSE: failed to exec mount" " program (%s)", strerror(errno)); _exit(1); } _exit(0); } ret = fd; err: if (ret == -1) { if (fd > 0) { close(fd); } } return ret; } void gf_fuse_unmount(const char *mountpoint, int fd) { int ret; struct stat sbuf; char dev[128]; char resolved_path[PATH_MAX]; char *ep, *rp = NULL; unsigned int hs_complete = 0; ret = ioctl(fd, FUSEDEVIOCGETHANDSHAKECOMPLETE, &hs_complete); if (ret || !hs_complete) { return; } if (fstat(fd, &sbuf) == -1) { return; } devname_r(sbuf.st_rdev, S_IFCHR, dev, 128); if (strncmp(dev, OSXFUSE_DEVICE_BASENAME, sizeof(OSXFUSE_DEVICE_BASENAME) - 1)) { return; } strtol(dev + sizeof(OSXFUSE_DEVICE_BASENAME) - 1, &ep, 10); if (*ep != '\0') { return; } rp = realpath(mountpoint, resolved_path); if (rp) { ret = unmount(resolved_path, 0); } close(fd); return; } glusterfs-3.7.6/contrib/PaxHeaders.7244/userspace-rcu0000644000076200007630000000013012617742650020675 xustar000000000000000030 mtime=1447019944.212295453 28 atime=1447019949.3342184 30 ctime=1447019944.212295453 glusterfs-3.7.6/contrib/userspace-rcu/0000755000076200007630000000000012617742650021171 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/userspace-rcu/PaxHeaders.7244/rculist-extra.h0000644000076200007630000000013112617742532023731 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019944.212295453 glusterfs-3.7.6/contrib/userspace-rcu/rculist-extra.h0000644000076200007630000000276712617742532024163 0ustar00jenkinsjenkins00000000000000/* * Copyright (C) 2002 Free Software Foundation, Inc. * (originally part of the GNU C Library) * Contributed by Ulrich Drepper , 2002. * * Copyright (C) 2009 Pierre-Marc Fournier * Conversion to RCU list. * Copyright (C) 2010 Mathieu Desnoyers * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef URCU_RCULIST_EXTRA_H #define URCU_RCULIST_EXTRA_H /* Copying this definition from liburcu-0.8 as liburcu-0.7 does not have this * particular list api */ /* Add new element at the tail of the list. */ static inline void cds_list_add_tail_rcu(struct cds_list_head *newp, struct cds_list_head *head) { newp->next = head; newp->prev = head->prev; rcu_assign_pointer(head->prev->next, newp); head->prev = newp; } #endif glusterfs-3.7.6/contrib/PaxHeaders.7244/uuid0000644000076200007630000000013012617742617017065 xustar000000000000000030 mtime=1447019919.173672132 28 atime=1447019949.3342184 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/0000755000076200007630000000000012617742617017361 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/gen_uuid_nt.c0000644000076200007630000000013112617742532021603 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/gen_uuid_nt.c0000644000076200007630000000313712617742532022025 0ustar00jenkinsjenkins00000000000000/* * gen_uuid_nt.c -- Use NT api to generate uuid * * Written by Andrey Shedel (andreys@ns.cr.cyco.com) */ #include "uuidP.h" #pragma warning(push,4) #pragma comment(lib, "ntdll.lib") // // Here is a nice example why it's not a good idea // to use native API in ordinary applications. // Number of parameters in function below was changed from 3 to 4 // for NT5. // // // NTSYSAPI // NTSTATUS // NTAPI // NtAllocateUuids( // OUT PULONG p1, // OUT PULONG p2, // OUT PULONG p3, // OUT PUCHAR Seed // 6 bytes // ); // // unsigned long __stdcall NtAllocateUuids( void* p1, // 8 bytes void* p2, // 4 bytes void* p3 // 4 bytes ); typedef unsigned long (__stdcall* NtAllocateUuids_2000)( void* p1, // 8 bytes void* p2, // 4 bytes void* p3, // 4 bytes void* seed // 6 bytes ); // // Nice, but instead of including ntddk.h ot winnt.h // I should define it here because they MISSED __stdcall in those headers. // __declspec(dllimport) struct _TEB* __stdcall NtCurrentTeb(void); // // The only way to get version information from the system is to examine // one stored in PEB. But it's pretty dangerouse because this value could // be altered in image header. // static int Nt5(void) { //return NtCuttentTeb()->Peb->OSMajorVersion >= 5; return (int)*(int*)((char*)(int)(*(int*)((char*)NtCurrentTeb() + 0x30)) + 0xA4) >= 5; } void gf_uuid_generate(uuid_t out) { if(Nt5()) { unsigned char seed[6]; ((NtAllocateUuids_2000)NtAllocateUuids)(out, ((char*)out)+8, ((char*)out)+12, &seed[0] ); } else { NtAllocateUuids(out, ((char*)out)+8, ((char*)out)+12); } } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/clear.c0000644000076200007630000000013112617742532020371 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/clear.c0000644000076200007630000000321712617742532020612 0ustar00jenkinsjenkins00000000000000/* * clear.c -- Clear a UUID * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include "string.h" #include "uuidP.h" void gf_uuid_clear(uuid_t uu) { memset(uu, 0, 16); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/parse.c0000644000076200007630000000013112617742532020415 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/parse.c0000644000076200007630000000457012617742532020641 0ustar00jenkinsjenkins00000000000000/* * parse.c --- UUID parsing * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include #include #include #include #include "uuidP.h" int gf_uuid_parse(const char *in, uuid_t uu) { struct uuid uuid; int i; const char *cp; char buf[3]; if (strlen(in) != 36) return -1; for (i=0, cp = in; i <= 36; i++,cp++) { if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) { if (*cp == '-') continue; else return -1; } if (i== 36) if (*cp == 0) continue; if (!isxdigit(*cp)) return -1; } uuid.time_low = strtoul(in, NULL, 16); uuid.time_mid = strtoul(in+9, NULL, 16); uuid.time_hi_and_version = strtoul(in+14, NULL, 16); uuid.clock_seq = strtoul(in+19, NULL, 16); cp = in+24; buf[2] = 0; for (i=0; i < 6; i++) { buf[0] = *cp++; buf[1] = *cp++; uuid.node[i] = strtoul(buf, NULL, 16); } uuid_pack(&uuid, uu); return 0; } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuid_types.h.in0000644000076200007630000000013112617742532022107 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/uuid_types.h.in0000644000076200007630000000223212617742532022324 0ustar00jenkinsjenkins00000000000000/* * If linux/types.h is already been included, assume it has defined * everything we need. (cross fingers) Other header files may have * also defined the types that we need. */ #if (!defined(_STDINT_H) && !defined(_UUID_STDINT_H)) #define _UUID_STDINT_H typedef unsigned char uint8_t; typedef signed char int8_t; #if (@SIZEOF_INT@ == 8) typedef int int64_t; typedef unsigned int uint64_t; #elif (@SIZEOF_LONG@ == 8) typedef long int64_t; typedef unsigned long uint64_t; #elif (@SIZEOF_LONG_LONG@ == 8) #if defined(__GNUC__) typedef __signed__ long long int64_t; #else typedef signed long long int64_t; #endif typedef unsigned long long uint64_t; #endif #if (@SIZEOF_INT@ == 2) typedef int int16_t; typedef unsigned int uint16_t; #elif (@SIZEOF_SHORT@ == 2) typedef short int16_t; typedef unsigned short uint16_t; #else ?==error: undefined 16 bit type #endif #if (@SIZEOF_INT@ == 4) typedef int int32_t; typedef unsigned int uint32_t; #elif (@SIZEOF_LONG@ == 4) typedef long int32_t; typedef unsigned long uint32_t; #elif (@SIZEOF_SHORT@ == 4) typedef short int32_t; typedef unsigned short uint32_t; #else ?== error: undefined 32 bit type #endif #endif glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/isnull.c0000644000076200007630000000013112617742532020611 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/isnull.c0000644000076200007630000000344112617742532021031 0ustar00jenkinsjenkins00000000000000/* * isnull.c --- Check whether or not the UUID is null * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include "uuidP.h" /* Returns 1 if the uuid is the NULL uuid */ int gf_uuid_is_null(const uuid_t uu) { const unsigned char *cp; int i; for (i=0, cp = uu; i < 16; i++) if (*cp++) return 0; return 1; } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/pack.c0000644000076200007630000000013112617742532020221 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/pack.c0000644000076200007630000000430512617742532020441 0ustar00jenkinsjenkins00000000000000/* * Internal routine for packing UUID's * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include #include "uuidP.h" void uuid_pack(const struct uuid *uu, uuid_t ptr) { uint32_t tmp; unsigned char *out = ptr; tmp = uu->time_low; out[3] = (unsigned char) tmp; tmp >>= 8; out[2] = (unsigned char) tmp; tmp >>= 8; out[1] = (unsigned char) tmp; tmp >>= 8; out[0] = (unsigned char) tmp; tmp = uu->time_mid; out[5] = (unsigned char) tmp; tmp >>= 8; out[4] = (unsigned char) tmp; tmp = uu->time_hi_and_version; out[7] = (unsigned char) tmp; tmp >>= 8; out[6] = (unsigned char) tmp; tmp = uu->clock_seq; out[9] = (unsigned char) tmp; tmp >>= 8; out[8] = (unsigned char) tmp; memcpy(out+10, uu->node, 6); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuid.h0000644000076200007630000000013112617742532020256 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/uuid.h0000644000076200007630000000637012617742532020502 0ustar00jenkinsjenkins00000000000000/* * Public include file for the UUID library * * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #ifndef _UUID_UUID_H #define _UUID_UUID_H #include "config.h" #include #ifndef _WIN32 #include #endif #include typedef unsigned char uuid_t[16]; /* UUID Variant definitions */ #define UUID_VARIANT_NCS 0 #define UUID_VARIANT_DCE 1 #define UUID_VARIANT_MICROSOFT 2 #define UUID_VARIANT_OTHER 3 /* UUID Type definitions */ #define UUID_TYPE_DCE_TIME 1 #define UUID_TYPE_DCE_RANDOM 4 /* Allow UUID constants to be defined */ #ifdef __GNUC__ #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} #else #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} #endif #ifdef __cplusplus extern "C" { #endif /* clear.c */ void gf_uuid_clear(uuid_t uu); /* compare.c */ int gf_uuid_compare(const uuid_t uu1, const uuid_t uu2); /* copy.c */ void gf_uuid_copy(uuid_t dst, const uuid_t src); /* gen_uuid.c */ void gf_uuid_generate(uuid_t out); void gf_uuid_generate_random(uuid_t out); void gf_uuid_generate_time(uuid_t out); /* isnull.c */ int gf_uuid_is_null(const uuid_t uu); /* parse.c */ int gf_uuid_parse(const char *in, uuid_t uu); /* unparse.c */ void gf_uuid_unparse(const uuid_t uu, char *out); void gf_uuid_unparse_lower(const uuid_t uu, char *out); void gf_uuid_unparse_upper(const uuid_t uu, char *out); /* uuid_time.c */ time_t gf_uuid_time(const uuid_t uu, struct timeval *ret_tv); int gf_uuid_type(const uuid_t uu); int gf_uuid_variant(const uuid_t uu); #ifdef __cplusplus } #endif #endif /* _UUID_UUID_H */ glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/compare.c0000644000076200007630000000013112617742532020731 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.996509317 glusterfs-3.7.6/contrib/uuid/compare.c0000644000076200007630000000417412617742532021155 0ustar00jenkinsjenkins00000000000000/* * compare.c --- compare whether or not two UUID's are the same * * Returns 0 if the two UUID's are different, and 1 if they are the same. * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include "uuidP.h" #include #define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); int gf_uuid_compare(const uuid_t uu1, const uuid_t uu2) { struct uuid uuid1, uuid2; uuid_unpack(uu1, &uuid1); uuid_unpack(uu2, &uuid2); UUCMP(uuid1.time_low, uuid2.time_low); UUCMP(uuid1.time_mid, uuid2.time_mid); UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); UUCMP(uuid1.clock_seq, uuid2.clock_seq); return memcmp(uuid1.node, uuid2.node, 6); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuid_time.c0000644000076200007630000000013112617742532021267 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/uuid_time.c0000644000076200007630000001045012617742532021505 0ustar00jenkinsjenkins00000000000000/* * uuid_time.c --- Interpret the time field from a uuid. This program * violates the UUID abstraction barrier by reaching into the guts * of a UUID and interpreting it. * * Copyright (C) 1998, 1999 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #ifdef _WIN32 #define _WIN32_WINNT 0x0500 #include #define UUID MYUUID #endif #include #ifdef HAVE_UNISTD_H #include #endif #include #include #ifdef HAVE_SYS_TIME_H #include #endif #include #include "uuidP.h" #include "logging.h" time_t gf_uuid_time(const uuid_t uu, struct timeval *ret_tv) { struct timeval tv; struct uuid uuid; uint32_t high; uint64_t clock_reg; uuid_unpack(uu, &uuid); high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16); clock_reg = uuid.time_low | ((uint64_t) high << 32); clock_reg -= (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; tv.tv_sec = clock_reg / 10000000; tv.tv_usec = (clock_reg % 10000000) / 10; if (ret_tv) *ret_tv = tv; return tv.tv_sec; } int gf_uuid_type(const uuid_t uu) { struct uuid uuid; uuid_unpack(uu, &uuid); return ((uuid.time_hi_and_version >> 12) & 0xF); } int gf_uuid_variant(const uuid_t uu) { struct uuid uuid; int var; uuid_unpack(uu, &uuid); var = uuid.clock_seq; if ((var & 0x8000) == 0) return UUID_VARIANT_NCS; if ((var & 0x4000) == 0) return UUID_VARIANT_DCE; if ((var & 0x2000) == 0) return UUID_VARIANT_MICROSOFT; return UUID_VARIANT_OTHER; } #ifdef DEBUG static const char *variant_string(int variant) { switch (variant) { case UUID_VARIANT_NCS: return "NCS"; case UUID_VARIANT_DCE: return "DCE"; case UUID_VARIANT_MICROSOFT: return "Microsoft"; default: return "Other"; } } int main(int argc, char **argv) { uuid_t buf; time_t time_reg; struct timeval tv; int type, variant; if (argc != 2) { fprintf(stderr, "Usage: %s uuid\n", argv[0]); exit(1); } if (gf_uuid_parse(argv[1], buf)) { fprintf(stderr, "Invalid UUID: %s\n", argv[1]); exit(1); } variant = gf_uuid_variant(buf); type = gf_uuid_type(buf); time_reg = gf_uuid_time(buf, &tv); printf("UUID variant is %d (%s)\n", variant, variant_string(variant)); if (variant != UUID_VARIANT_DCE) { printf("Warning: This program only knows how to interpret " "DCE UUIDs.\n\tThe rest of the output is likely " "to be incorrect!!\n"); } printf("UUID type is %d", type); switch (type) { case 1: printf(" (time based)\n"); break; case 2: printf(" (DCE)\n"); break; case 3: printf(" (name-based)\n"); break; case 4: printf(" (random)\n"); break; default: printf("\n"); } if (type != 1) { printf("Warning: not a time-based UUID, so UUID time " "decoding will likely not work!\n"); } printf("UUID time is: (%" GF_PRI_SECOND ", %" GF_PRI_USEC "): %s\n", tv.tv_sec, tv.tv_usec, ctime(&time_reg)); return 0; } #endif glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuidP.h0000644000076200007630000000013112617742532020376 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/uuidP.h0000644000076200007630000000406412617742532020620 0ustar00jenkinsjenkins00000000000000/* * uuid.h -- private header file for uuids * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include "uuid.h" #ifdef HAVE_INTTYPES_H #include #else #include "uuid_types.h" #endif #include /* * Offset between 15-Oct-1582 and 1-Jan-70 */ #define TIME_OFFSET_HIGH 0x01B21DD2 #define TIME_OFFSET_LOW 0x13814000 struct uuid { uint32_t time_low; uint16_t time_mid; uint16_t time_hi_and_version; uint16_t clock_seq; uint8_t node[6]; }; /* * prototypes */ void uuid_pack(const struct uuid *uu, uuid_t ptr); void uuid_unpack(const uuid_t in, struct uuid *uu); glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/tst_uuid.c0000644000076200007630000000013112617742532021143 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/tst_uuid.c0000644000076200007630000001257312617742532021371 0ustar00jenkinsjenkins00000000000000/* * tst_uuid.c --- test program from the UUID library * * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #ifdef _WIN32 #define _WIN32_WINNT 0x0500 #include #define UUID MYUUID #endif #include #include #include "uuid.h" static int test_uuid(const char * uuid, int isValid) { static const char * validStr[2] = {"invalid", "valid"}; uuid_t uuidBits; int parsedOk; parsedOk = gf_uuid_parse(uuid, uuidBits) == 0; printf("%s is %s", uuid, validStr[isValid]); if (parsedOk != isValid) { printf(" but gf_uuid_parse says %s\n", validStr[parsedOk]); return 1; } printf(", OK\n"); return 0; } #ifdef __GNUC__ #define ATTR(x) __attribute__(x) #else #define ATTR(x) #endif int main(int argc ATTR((unused)) , char **argv ATTR((unused))) { uuid_t buf, tst; char str[100]; struct timeval tv; time_t time_reg; unsigned char *cp; int i; int failed = 0; int type, variant; gf_uuid_generate(buf); gf_uuid_unparse(buf, str); printf("UUID generate = %s\n", str); printf("UUID: "); for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { printf("%02x", *cp++); } printf("\n"); type = gf_uuid_type(buf); variant = gf_uuid_variant(buf); printf("UUID type = %d, UUID variant = %d\n", type, variant); if (variant != UUID_VARIANT_DCE) { printf("Incorrect UUID Variant; was expecting DCE!\n"); failed++; } printf("\n"); gf_uuid_generate_random(buf); gf_uuid_unparse(buf, str); printf("UUID random string = %s\n", str); printf("UUID: "); for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { printf("%02x", *cp++); } printf("\n"); type = gf_uuid_type(buf); variant = gf_uuid_variant(buf); printf("UUID type = %d, UUID variant = %d\n", type, variant); if (variant != UUID_VARIANT_DCE) { printf("Incorrect UUID Variant; was expecting DCE!\n"); failed++; } if (type != 4) { printf("Incorrect UUID type; was expecting " "4 (random type)!\n"); failed++; } printf("\n"); gf_uuid_generate_time(buf); gf_uuid_unparse(buf, str); printf("UUID string = %s\n", str); printf("UUID time: "); for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { printf("%02x", *cp++); } printf("\n"); type = gf_uuid_type(buf); variant = gf_uuid_variant(buf); printf("UUID type = %d, UUID variant = %d\n", type, variant); if (variant != UUID_VARIANT_DCE) { printf("Incorrect UUID Variant; was expecting DCE!\n"); failed++; } if (type != 1) { printf("Incorrect UUID type; was expecting " "1 (time-based type)!\\n"); failed++; } tv.tv_sec = 0; tv.tv_usec = 0; time_reg = gf_uuid_time(buf, &tv); printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, ctime(&time_reg)); gf_uuid_parse(str, tst); if (!gf_uuid_compare(buf, tst)) printf("UUID parse and compare succeeded.\n"); else { printf("UUID parse and compare failed!\n"); failed++; } gf_uuid_clear(tst); if (gf_uuid_is_null(tst)) printf("UUID clear and is null succeeded.\n"); else { printf("UUID clear and is null failed!\n"); failed++; } gf_uuid_copy(buf, tst); if (!gf_uuid_compare(buf, tst)) printf("UUID copy and compare succeeded.\n"); else { printf("UUID copy and compare failed!\n"); failed++; } failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1); failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1); failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0); failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981", 0); failed += test_uuid("84949cc5x4701-4a84-895b-354c584a981b", 0); failed += test_uuid("84949cc504701-4a84-895b-354c584a981b", 0); failed += test_uuid("84949cc5-470104a84-895b-354c584a981b", 0); failed += test_uuid("84949cc5-4701-4a840895b-354c584a981b", 0); failed += test_uuid("84949cc5-4701-4a84-895b0354c584a981b", 0); failed += test_uuid("g4949cc5-4701-4a84-895b-354c584a981b", 0); failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981g", 0); if (failed) { printf("%d failures.\n", failed); exit(1); } return 0; } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/unpack.c0000644000076200007630000000013112617742532020564 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/unpack.c0000644000076200007630000000405112617742532021002 0ustar00jenkinsjenkins00000000000000/* * Internal routine for unpacking UUID * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include #include "uuidP.h" void uuid_unpack(const uuid_t in, struct uuid *uu) { const uint8_t *ptr = in; uint32_t tmp; tmp = *ptr++; tmp = (tmp << 8) | *ptr++; tmp = (tmp << 8) | *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_low = tmp; tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_mid = tmp; tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_hi_and_version = tmp; tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->clock_seq = tmp; memcpy(uu->node, ptr, 6); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/unparse.c0000644000076200007630000000013112617742532020760 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/unparse.c0000644000076200007630000000476312617742532021210 0ustar00jenkinsjenkins00000000000000/* * unparse.c -- convert a UUID to string * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include #include "uuidP.h" static const char *fmt_lower = "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"; static const char *fmt_upper = "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"; #ifdef UUID_UNPARSE_DEFAULT_UPPER #define FMT_DEFAULT fmt_upper #else #define FMT_DEFAULT fmt_lower #endif static void gf_uuid_unparse_x(const uuid_t uu, char *out, const char *fmt) { struct uuid uuid; uuid_unpack(uu, &uuid); sprintf(out, fmt, uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, uuid.clock_seq >> 8, uuid.clock_seq & 0xFF, uuid.node[0], uuid.node[1], uuid.node[2], uuid.node[3], uuid.node[4], uuid.node[5]); } void gf_uuid_unparse_lower(const uuid_t uu, char *out) { gf_uuid_unparse_x(uu, out, fmt_lower); } void gf_uuid_unparse_upper(const uuid_t uu, char *out) { gf_uuid_unparse_x(uu, out, fmt_upper); } void gf_uuid_unparse(const uuid_t uu, char *out) { gf_uuid_unparse_x(uu, out, FMT_DEFAULT); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/copy.c0000644000076200007630000000013112617742532020255 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/copy.c0000644000076200007630000000336212617742532020477 0ustar00jenkinsjenkins00000000000000/* * copy.c --- copy UUIDs * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #include "uuidP.h" void gf_uuid_copy(uuid_t dst, const uuid_t src) { unsigned char *cp1; const unsigned char *cp2; int i; for (i=0, cp1 = dst, cp2 = src; i < 16; i++) *cp1++ = *cp2++; } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/gen_uuid.c0000644000076200007630000000013112617742532021102 xustar000000000000000030 mtime=1447019866.048471374 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/gen_uuid.c0000644000076200007630000003657112617742532021334 0ustar00jenkinsjenkins00000000000000/* * gen_uuid.c --- generate a DCE-compatible uuid * * Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ /* * Force inclusion of SVID stuff since we need it if we're compiling in * gcc-wall wall mode */ #define _SVID_SOURCE #include "config.h" #ifdef _WIN32 #define _WIN32_WINNT 0x0500 #include #define UUID MYUUID #endif #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #include #include #ifdef HAVE_SYS_FILE_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_UN_H #include #endif #ifdef HAVE_SYS_SOCKIO_H #include #endif #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NET_IF_DL_H #include #endif #if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H) #include #endif #ifdef HAVE_SYS_RESOURCE_H #include #endif #include #include "uuidP.h" #include "uuidd.h" #ifdef HAVE_SRANDOM #define srand(x) srandom(x) #define rand() random() #endif #ifdef TLS #define THREAD_LOCAL static TLS #else #define THREAD_LOCAL static #endif #if defined(__linux__) && defined(__NR_gettid) && defined(HAVE_JRAND48) #define DO_JRAND_MIX THREAD_LOCAL unsigned short jrand_seed[3]; #endif #ifndef OPEN_MAX #define OPEN_MAX 1024 #endif #ifdef _WIN32 static void gettimeofday (struct timeval *tv, void *dummy) { FILETIME ftime; uint64_t n; GetSystemTimeAsFileTime (&ftime); n = (((uint64_t) ftime.dwHighDateTime << 32) + (uint64_t) ftime.dwLowDateTime); if (n) { n /= 10; n -= ((369 * 365 + 89) * (uint64_t) 86400) * 1000000; } tv->tv_sec = n / 1000000; tv->tv_usec = n % 1000000; } static int getuid (void) { return 1; } #endif static int get_random_fd(void) { struct timeval tv; static int fd = -2; int i; if (fd == -2) { gettimeofday(&tv, 0); #ifndef _WIN32 fd = open("/dev/urandom", O_RDONLY); if (fd == -1) fd = open("/dev/random", O_RDONLY | O_NONBLOCK); if (fd >= 0) { i = fcntl(fd, F_GETFD); if (i >= 0) fcntl(fd, F_SETFD, i | FD_CLOEXEC); } #endif srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); #ifdef DO_JRAND_MIX jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF); jrand_seed[1] = getppid() ^ (tv.tv_usec & 0xFFFF); jrand_seed[2] = (tv.tv_sec ^ tv.tv_usec) >> 16; #endif } /* Crank the random number generator a few times */ gettimeofday(&tv, 0); for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--) rand(); return fd; } /* * Generate a series of random bytes. Use /dev/urandom if possible, * and if not, use srandom/random. */ static void get_random_bytes(void *buf, int nbytes) { int i, n = nbytes, fd = get_random_fd(); int lose_counter = 0; unsigned char *cp = (unsigned char *) buf; #ifdef DO_JRAND_MIX unsigned short tmp_seed[3]; #endif if (fd >= 0) { while (n > 0) { i = read(fd, cp, n); if (i <= 0) { if (lose_counter++ > 16) break; continue; } n -= i; cp += i; lose_counter = 0; } } /* * We do this all the time, but this is the only source of * randomness if /dev/random/urandom is out to lunch. */ for (cp = buf, i = 0; i < nbytes; i++) *cp++ ^= (rand() >> 7) & 0xFF; #ifdef DO_JRAND_MIX memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed)); jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid); for (cp = buf, i = 0; i < nbytes; i++) *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF; memcpy(jrand_seed, tmp_seed, sizeof(jrand_seed)-sizeof(unsigned short)); #endif return; } /* * Get the ethernet hardware address, if we can find it... * * XXX for a windows version, probably should use GetAdaptersInfo: * http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451 * commenting out get_node_id just to get gen_uuid to compile under windows * is not the right way to go! */ static int get_node_id(unsigned char *node_id) { #ifdef HAVE_NET_IF_H int sd; struct ifreq ifr, *ifrp; struct ifconf ifc; char buf[1024]; int n, i; unsigned char *a; #ifdef HAVE_NET_IF_DL_H struct sockaddr_dl *sdlp; #endif /* * BSD 4.4 defines the size of an ifreq to be * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len * However, under earlier systems, sa_len isn't present, so the size is * just sizeof(struct ifreq) */ #ifdef HAVE_SA_LEN #ifndef max #define max(a,b) ((a) > (b) ? (a) : (b)) #endif #define ifreq_size(i) max(sizeof(struct ifreq),\ sizeof((i).ifr_name)+(i).ifr_addr.sa_len) #else #define ifreq_size(i) sizeof(struct ifreq) #endif /* HAVE_SA_LEN*/ sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (sd < 0) { return -1; } memset(buf, 0, sizeof(buf)); ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) { close(sd); return -1; } n = ifc.ifc_len; for (i = 0; i < n; i+= ifreq_size(*ifrp) ) { ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); #ifdef SIOCGIFHWADDR if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) continue; a = (unsigned char *) &ifr.ifr_hwaddr.sa_data; #else #ifdef SIOCGENADDR if (ioctl(sd, SIOCGENADDR, &ifr) < 0) continue; a = (unsigned char *) ifr.ifr_enaddr; #else #ifdef HAVE_NET_IF_DL_H sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr; if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen != 6)) continue; a = (unsigned char *) &sdlp->sdl_data[sdlp->sdl_nlen]; #else /* * XXX we don't have a way of getting the hardware * address */ close(sd); return 0; #endif /* HAVE_NET_IF_DL_H */ #endif /* SIOCGENADDR */ #endif /* SIOCGIFHWADDR */ if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) continue; if (node_id) { memcpy(node_id, a, 6); close(sd); return 1; } } close(sd); #endif return 0; } /* Assume that the gettimeofday() has microsecond granularity */ #define MAX_ADJUSTMENT 10 static int get_clock(uint32_t *clock_high, uint32_t *clock_low, uint16_t *ret_clock_seq, int *num) { THREAD_LOCAL int adjustment = 0; THREAD_LOCAL struct timeval last = {0, 0}; THREAD_LOCAL int state_fd = -2; THREAD_LOCAL FILE *state_f; THREAD_LOCAL uint16_t clock_seq; struct timeval tv; struct flock fl; uint64_t clock_reg; mode_t save_umask; int len; if (state_fd == -2) { save_umask = umask(0); state_fd = open("/var/lib/libuuid/clock.txt", O_RDWR|O_CREAT, 0660); (void) umask(save_umask); state_f = fdopen(state_fd, "r+"); if (!state_f) { close(state_fd); state_fd = -1; } } fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_pid = 0; if (state_fd >= 0) { rewind(state_f); while (fcntl(state_fd, F_SETLKW, &fl) < 0) { if ((errno == EAGAIN) || (errno == EINTR)) continue; fclose(state_f); close(state_fd); state_fd = -1; break; } } if (state_fd >= 0) { unsigned int cl; unsigned long tv1, tv2; int a; if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n", &cl, &tv1, &tv2, &a) == 4) { clock_seq = cl & 0x3FFF; last.tv_sec = tv1; last.tv_usec = tv2; adjustment = a; } } if ((last.tv_sec == 0) && (last.tv_usec == 0)) { get_random_bytes(&clock_seq, sizeof(clock_seq)); clock_seq &= 0x3FFF; gettimeofday(&last, 0); last.tv_sec--; } try_again: gettimeofday(&tv, 0); if ((tv.tv_sec < last.tv_sec) || ((tv.tv_sec == last.tv_sec) && (tv.tv_usec < last.tv_usec))) { clock_seq = (clock_seq+1) & 0x3FFF; adjustment = 0; last = tv; } else if ((tv.tv_sec == last.tv_sec) && (tv.tv_usec == last.tv_usec)) { if (adjustment >= MAX_ADJUSTMENT) goto try_again; adjustment++; } else { adjustment = 0; last = tv; } clock_reg = tv.tv_usec*10 + adjustment; clock_reg += ((uint64_t) tv.tv_sec)*10000000; clock_reg += (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; if (num && (*num > 1)) { adjustment += *num - 1; last.tv_usec += adjustment / 10; adjustment = adjustment % 10; last.tv_sec += last.tv_usec / 1000000; last.tv_usec = last.tv_usec % 1000000; } if (state_fd > 0) { rewind(state_f); len = fprintf(state_f, "clock: %04x tv: %016lu %08lu adj: %08d\n", clock_seq, last.tv_sec, last.tv_usec, adjustment); fflush(state_f); if (ftruncate(state_fd, len) < 0) { fprintf(state_f, " \n"); fflush(state_f); } rewind(state_f); fl.l_type = F_UNLCK; fcntl(state_fd, F_SETLK, &fl); } *clock_high = clock_reg >> 32; *clock_low = clock_reg; *ret_clock_seq = clock_seq; return 0; } #if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) static ssize_t read_all(int fd, char *buf, size_t count) { ssize_t ret; ssize_t c = 0; int tries = 0; memset(buf, 0, count); while (count > 0) { ret = read(fd, buf, count); if (ret <= 0) { if ((errno == EAGAIN || errno == EINTR || ret == 0) && (tries++ < 5)) continue; return c ? c : -1; } if (ret > 0) tries = 0; count -= ret; buf += ret; c += ret; } return c; } #endif /* * Close all file descriptors */ #if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) static void close_all_fds(void) { #ifdef F_CLOSEM (void)fcntl(0, F_CLOSEM); (void)open("/dev/null", O_RDWR); /* stdin */ (void)open("/dev/null", O_RDWR); /* stdout */ (void)open("/dev/null", O_RDWR); /* stderr */ #else /* F_CLOSEM */ int i, max; #if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) max = sysconf(_SC_OPEN_MAX); #elif defined(HAVE_GETDTABLESIZE) max = getdtablesize(); #elif defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) struct rlimit rl; getrlimit(RLIMIT_NOFILE, &rl); max = rl.rlim_cur; #else max = OPEN_MAX; #endif for (i=0; i < max; i++) { close(i); if (i <= 2) open("/dev/null", O_RDWR); } #endif /* F_CLOSEM */ } #endif /* * Try using the uuidd daemon to generate the UUID * * Returns 0 on success, non-zero on failure. */ static int get_uuid_via_daemon(int op, uuid_t out, int *num) { #if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) char op_buf[64]; int op_len; int s; ssize_t ret; int32_t reply_len = 0, expected = 16; struct sockaddr_un srv_addr; struct stat st; pid_t pid; static const char *uuidd_path = UUIDD_PATH; static int access_ret = -2; static int start_attempts = 0; if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) return -1; srv_addr.sun_family = AF_UNIX; strcpy(srv_addr.sun_path, UUIDD_SOCKET_PATH); if (connect(s, (const struct sockaddr *) &srv_addr, sizeof(struct sockaddr_un)) < 0) { if (access_ret == -2) access_ret = access(uuidd_path, X_OK); if (access_ret == 0) access_ret = stat(uuidd_path, &st); if (access_ret == 0 && (st.st_mode & (S_ISUID | S_ISGID)) == 0) access_ret = access(UUIDD_DIR, W_OK); if (access_ret == 0 && start_attempts++ < 5) { if ((pid = fork()) == 0) { close_all_fds(); execl(uuidd_path, "uuidd", "-qT", "300", (char *) NULL); exit(1); } (void) waitpid(pid, 0, 0); if (connect(s, (const struct sockaddr *) &srv_addr, sizeof(struct sockaddr_un)) < 0) goto fail; } else goto fail; } op_buf[0] = op; op_len = 1; if (op == UUIDD_OP_BULK_TIME_UUID) { memcpy(op_buf+1, num, sizeof(*num)); op_len += sizeof(*num); expected += sizeof(*num); } ret = write(s, op_buf, op_len); if (ret < 1) goto fail; ret = read_all(s, (char *) &reply_len, sizeof(reply_len)); if (ret < 0) goto fail; if (reply_len != expected) goto fail; ret = read_all(s, op_buf, reply_len); if (op == UUIDD_OP_BULK_TIME_UUID) memcpy(op_buf+16, num, sizeof(int)); memcpy(out, op_buf, 16); close(s); return ((ret == expected) ? 0 : -1); fail: close(s); #endif return -1; } void uuid__generate_time(uuid_t out, int *num) { static unsigned char node_id[6]; static int has_init = 0; struct uuid uu; uint32_t clock_mid; if (!has_init) { if (get_node_id(node_id) <= 0) { get_random_bytes(node_id, 6); /* * Set multicast bit, to prevent conflicts * with IEEE 802 addresses obtained from * network cards */ node_id[0] |= 0x01; } has_init = 1; } get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num); uu.clock_seq |= 0x8000; uu.time_mid = (uint16_t) clock_mid; uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000; memcpy(uu.node, node_id, 6); uuid_pack(&uu, out); } void gf_uuid_generate_time(uuid_t out) { #ifdef TLS THREAD_LOCAL int num = 0; THREAD_LOCAL struct uuid uu; THREAD_LOCAL time_t last_time = 0; time_t now; if (num > 0) { now = time(0); if (now > last_time+1) num = 0; } if (num <= 0) { num = 1000; if (get_uuid_via_daemon(UUIDD_OP_BULK_TIME_UUID, out, &num) == 0) { last_time = time(0); uuid_unpack(out, &uu); num--; return; } num = 0; } if (num > 0) { uu.time_low++; if (uu.time_low == 0) { uu.time_mid++; if (uu.time_mid == 0) uu.time_hi_and_version++; } num--; uuid_pack(&uu, out); return; } #else if (get_uuid_via_daemon(UUIDD_OP_TIME_UUID, out, 0) == 0) return; #endif uuid__generate_time(out, 0); } void uuid__generate_random(uuid_t out, int *num) { uuid_t buf; struct uuid uu; int i, n; if (!num || !*num) n = 1; else n = *num; for (i = 0; i < n; i++) { get_random_bytes(buf, sizeof(buf)); uuid_unpack(buf, &uu); uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000; uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000; uuid_pack(&uu, out); out += sizeof(uuid_t); } } void gf_uuid_generate_random(uuid_t out) { int num = 1; /* No real reason to use the daemon for random uuid's -- yet */ uuid__generate_random(out, &num); } /* * This is the generic front-end to gf_uuid_generate_random and * gf_uuid_generate_time. It uses gf_uuid_generate_random only if * /dev/urandom is available, since otherwise we won't have * high-quality randomness. */ void gf_uuid_generate(uuid_t out) { if (get_random_fd() >= 0) gf_uuid_generate_random(out); else gf_uuid_generate_time(out); } glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuid_types.h0000644000076200007630000000013212617742617021507 xustar000000000000000030 mtime=1447019919.163672284 30 atime=1447019928.834526795 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/uuid_types.h0000644000076200007630000000206612617742617021730 0ustar00jenkinsjenkins00000000000000/* * If linux/types.h is already been included, assume it has defined * everything we need. (cross fingers) Other header files may have * also defined the types that we need. */ #if (!defined(_STDINT_H) && !defined(_UUID_STDINT_H)) #define _UUID_STDINT_H typedef unsigned char uint8_t; typedef signed char int8_t; #if (4 == 8) typedef int int64_t; typedef unsigned int uint64_t; #elif (8 == 8) typedef long int64_t; typedef unsigned long uint64_t; #elif (8 == 8) #if defined(__GNUC__) typedef __signed__ long long int64_t; #else typedef signed long long int64_t; #endif typedef unsigned long long uint64_t; #endif #if (4 == 2) typedef int int16_t; typedef unsigned int uint16_t; #elif (2 == 2) typedef short int16_t; typedef unsigned short uint16_t; #else ?==error: undefined 16 bit type #endif #if (4 == 4) typedef int int32_t; typedef unsigned int uint32_t; #elif (8 == 4) typedef long int32_t; typedef unsigned long uint32_t; #elif (2 == 4) typedef short int32_t; typedef unsigned short uint32_t; #else ?== error: undefined 32 bit type #endif #endif glusterfs-3.7.6/contrib/uuid/PaxHeaders.7244/uuidd.h0000644000076200007630000000013112617742532020422 xustar000000000000000030 mtime=1447019866.049471359 29 atime=1447019866.37646644 30 ctime=1447019929.997509298 glusterfs-3.7.6/contrib/uuid/uuidd.h0000644000076200007630000000421512617742532020642 0ustar00jenkinsjenkins00000000000000/* * Definitions used by the uuidd daemon * * Copyright (C) 2007 Theodore Ts'o. * * %Begin-Header% * 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, and the entire permission notice in its entirety, * including the disclaimer of warranties. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * %End-Header% */ #ifndef _UUID_UUIDD_H #define _UUID_UUIDD_H #define UUIDD_DIR "/var/lib/libuuid" #define UUIDD_SOCKET_PATH UUIDD_DIR "/request" #define UUIDD_PIDFILE_PATH UUIDD_DIR "/uuidd.pid" #define UUIDD_PATH "/usr/sbin/uuidd" #define UUIDD_OP_GETPID 0 #define UUIDD_OP_GET_MAXOP 1 #define UUIDD_OP_TIME_UUID 2 #define UUIDD_OP_RANDOM_UUID 3 #define UUIDD_OP_BULK_TIME_UUID 4 #define UUIDD_OP_BULK_RANDOM_UUID 5 #define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID extern void uuid__generate_time(uuid_t out, int *num); extern void uuid__generate_random(uuid_t out, int *num); #endif /* _UUID_UUID_H */ glusterfs-3.7.6/PaxHeaders.7244/run-tests.sh0000644000076200007630000000013212617742532017032 xustar000000000000000030 mtime=1447019866.149469855 30 atime=1447019866.419465793 30 ctime=1447019929.862511329 glusterfs-3.7.6/run-tests.sh0000755000076200007630000002030212617742532017247 0ustar00jenkinsjenkins00000000000000#!/bin/bash # Copyright (c) 2013-2014 Red Hat, Inc. # export TZ=UTC function check_dependencies() { ## Check all dependencies are present MISSING="" # Check for dbench env dbench --usage > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING dbench" fi # Check for git env git --version > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING git" fi # Check for nfs-utils (Linux-only: built-in NetBSD with different name) if [ "x`uname -s`" = "xLinux" ] ; then env mount.nfs -V > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING nfs-utils" fi fi # Check for the Perl Test Harness env prove --version > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING perl-Test-Harness" fi which json_verify > /dev/null if [ $? -ne 0 ]; then MISSING="$MISSING json_verify" fi # Check for XFS programs (Linux Only: NetBSD does without) if [ "x`uname -s`" = "xLinux" ] ; then env mkfs.xfs -V > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING xfsprogs" fi fi # Check for attr env getfattr --version > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING attr" fi # Check for pidof pidof pidof > /dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING pidof" fi # check for psutil python package test `uname -s` == "Darwin" || test `uname -s` == "FreeBSD" && { pip show psutil | grep -q psutil >/dev/null 2>&1 if [ $? -ne 0 ]; then MISSING="$MISSING psutil" fi } ## If dependencies are missing, warn the user and abort if [ "x$MISSING" != "x" ]; then test "x${force}" != "xyes" && echo "Aborting." echo echo "The following required tools are missing:" echo for pkg in $MISSING; do echo " * $pkg" done echo test "x${force}" = "xyes" && return echo "Please install them and try again." echo exit 2 fi } function check_location() { regression_testsdir=$(dirname $0); if [ ! -f ${regression_testsdir}/tests/include.rc ]; then echo "Aborting." echo echo "The tests/ subdirectory seems to be missing." echo echo "Please correct the problem and try again." echo exit 1 fi } function check_user() { # If we're not running as root, warn the user and abort MYUID=`/usr/bin/id -u` if [ 0${MYUID} -ne 0 ]; then echo "Aborting." echo echo "The GlusterFS Test Framework must be run as root." echo echo "Please change to the root user and try again." echo exit 3 fi } function run_tests() { declare -A DONE match() { # Patterns considered valid: # 1. full or partial file/directory names # basic matches tests/basic # basic/afr matches tests/basic/afr # 2. globs # basic/* matches all files and directories in basic # basic/*/ matches subdirectories in basic (afr|ec) # 3. numbered bug matching # 884455 matches bugs/bug-884455.t # 859927 matches bugs/859927, bugs/bug-859927.t # 1015990 matches /bugs/bug-1015990-rep.t, bug-1015990.t # ...lots of other cases accepted as well, since globbing is tricky. local t=$1 local mt=$1 shift local a local match=1 if [ -d $t ] ; then # Allow matching on globs like 'basic/*/' mt=$t/ fi for a in "$@" ; do case "$mt" in *$a|*/bugs/$a/|*/bugs/$a.t|*/bugs/bug-$a.t|*/bugs/bug-$a-*.t) match=0 ;; esac done if [ "${DONE[$(dirname $t)]}" != "" ] ; then # Parentdir is already matched match=1 if [ -d $t ] ; then # Ignore subdirectory as well DONE[$t]=$t fi elif [ $match -eq 0 -a -d $t ] ; then # Make sure children of this matched directory will be ignored DONE[$t]=$t elif [[ -f $t && ! $t =~ .*\.t ]] ; then # Ignore files not ending in .t match=1 fi return $match } RES=0 for t in $(find ${regression_testsdir}/tests | grep -v geo-rep \ | LC_COLLATE=C sort) ; do if match $t "$@" ; then if [ -d $t ] ; then echo "Running tests in directory $t" prove -rf --timer $t elif [ -f $t ] ; then echo "Running tests in file $t" prove -f --timer $t fi TMP_RES=$? if [ ${TMP_RES} -ne 0 ] ; then RES=${TMP_RES} FAILED="$FAILED $t" fi fi done if [ ${RES} -ne 0 ] ; then FAILED=$( echo ${FAILED} | tr ' ' '\n' | sort -u ) echo "Failed tests ${FAILED}" fi return ${RES} } # If you're submitting a fix related to one of these tests and want its result # to be considered, you'll need to remove it from the list as part of your # patch. function is_bad_test () { local name=$1 for bt in ./tests/basic/quota-anon-fd-nfs.t \ ./tests/basic/quota-nfs.t \ ./tests/basic/tier/tier_lookup_heal.t \ ./tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t \ ./tests/bugs/snapshot/bug-1109889.t \ ./tests/bugs/distribute/bug-1066798.t \ ./tests/geo-rep/georep-basic-dr-rsync.t \ ./tests/geo-rep/georep-basic-dr-tarssh.t \ ./tests/basic/tier/tier.t \ ./tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t \ ./tests/bugs/glusterd/bug-948686.t \ ./tests/basic/ec/ec-readdir.t \ ; do [ x"$name" = x"$bt" ] && return 0 # bash: zero means true/success done return 1 # bash: non-zero means false/failure } function run_all () { find ${regression_testsdir}/tests -name '*.t' \ | grep -v geo-rep \ | LC_COLLATE=C sort \ | while read t; do old_cores=$(ls /core.* 2> /dev/null | wc -l) retval=0 prove -f --timer $t TMP_RES=$? if [ ${TMP_RES} -ne 0 ] ; then echo "$t: bad status $TMP_RES" retval=$((retval+1)) fi new_cores=$(ls /core.* 2> /dev/null | wc -l) if [ x"$new_cores" != x"$old_cores" ]; then core_diff=$((new_cores-old_cores)) echo "$t: $core_diff new core files" retval=$((retval+2)) fi if [ $retval -ne 0 ]; then if is_bad_test $t; then echo "Ignoring failure from known-bad test $t" else return $retval fi fi done } function main() { if [ $# -lt 1 ]; then echo "Running all the regression test cases (new way)" #prove -rf --timer ${regression_testsdir}/tests; run_all else run_tests "$@" fi } function main_and_retry() { RESFILE=`mktemp /tmp/${0##*/}.XXXXXX` || exit 1 main "$@" | tee ${RESFILE} RET=$? FAILED=$( awk '/Failed: /{print $1}' ${RESFILE} ) if [ "x${FAILED}" != "x" ] ; then echo "" echo " *********************************" echo " * REGRESSION FAILED *" echo " * Retrying failed tests in case *" echo " * we got some spurous failures *" echo " *********************************" echo "" main ${FAILED} RET=$? fi rm -f ${RESFILE} return ${RET} } echo echo ... GlusterFS Test Framework ... echo force="no" retry="no" args=`getopt fr $*` set -- $args while [ $# -gt 0 ]; do case "$1" in -f) force="yes" ;; -r) retry="yes" ;; --) shift; break;; esac shift done # Make sure we're running as the root user check_user # Make sure the needed programs are available check_dependencies # Check we're running from the right location check_location # Run the tests if [ "x${retry}" = "xyes" ] ; then main_and_retry $@ else main "$@" fi glusterfs-3.7.6/PaxHeaders.7244/INSTALL0000644000076200007630000000013212617742532015563 xustar000000000000000030 mtime=1447019866.007471991 30 atime=1447019866.357466725 30 ctime=1447019929.813512066 glusterfs-3.7.6/INSTALL0000644000076200007630000000261712617742532016006 0ustar00jenkinsjenkins00000000000000Installation Instructions ************************* 0. If you have cloned from git, run ./autogen.sh. 1. Run ./configure. bash# ./configure GlusterFS configure summary =========================== GlusterFS configure summary =========================== FUSE client : yes Infiniband verbs : yes epoll IO multiplex : yes argp-standalone : no fusermount : yes readline : yes georeplication : yes Linux-AIO : yes Enable Debug : no systemtap : no Block Device xlator : yes glupy : yes Use syslog : yes XML output : yes QEMU Block formats : yes Encryption xlator : yes The configure summary will tell you what all components will be built with GlusterFS. Other than 'argp-standalone' if something else says 'no', that feature in GlusterFS will not be built. 'argp-standalone' package will only be used if the system doesn't have a proper argp package installed. 2. Now just run 'make' and later run 'make install' to install the package. bash# make bash# make install Installation completed :-) bash# glusterfs --version Make sure your version is the latest from the release, and the one you just installed :-) For more information on GlusterFS installation refer# http://gluster.org/community/documentation/index.php/Building_GlusterFS glusterfs-3.7.6/PaxHeaders.7244/cli0000644000076200007630000000013012617742653015226 xustar000000000000000030 mtime=1447019947.406247403 28 atime=1447019949.3342184 30 ctime=1447019947.406247403 glusterfs-3.7.6/cli/0000755000076200007630000000000012617742653015522 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/cli/PaxHeaders.7244/Makefile.am0000644000076200007630000000013212617742532017335 xustar000000000000000030 mtime=1447019866.012471916 30 atime=1447019866.359466695 30 ctime=1447019947.397247539 glusterfs-3.7.6/cli/Makefile.am0000644000076200007630000000003412617742532017547 0ustar00jenkinsjenkins00000000000000SUBDIRS = src CLEANFILES = glusterfs-3.7.6/cli/PaxHeaders.7244/src0000644000076200007630000000013012617742653016015 xustar000000000000000030 mtime=1447019947.538245418 28 atime=1447019949.3342184 30 ctime=1447019947.538245418 glusterfs-3.7.6/cli/src/0000755000076200007630000000000012617742653016311 5ustar00jenkinsjenkins00000000000000glusterfs-3.7.6/cli/src/PaxHeaders.7244/cli-quotad-client.c0000644000076200007630000000013212617742532021552 xustar000000000000000030 mtime=1447019866.016471856 30 atime=1447019866.361466665 30 ctime=1447019947.535245463 glusterfs-3.7.6/cli/src/cli-quotad-client.c0000644000076200007630000001015212617742532021766 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2010-2013 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include "cli-quotad-client.h" extern struct rpc_clnt global_quotad_rpc; extern struct rpc_clnt_program cli_quotad_clnt; int cli_quotad_submit_request (void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) { int ret = -1; int count = 0; struct iovec iov = {0, }; struct iobuf *iobuf = NULL; char new_iobref = 0; ssize_t xdr_size = 0; GF_ASSERT (this); if (req) { xdr_size = xdr_sizeof (xdrproc, req); iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size); if (!iobuf) { goto out; }; if (!iobref) { iobref = iobref_new (); if (!iobref) { goto out; } new_iobref = 1; } iobref_add (iobref, iobuf); iov.iov_base = iobuf->ptr; iov.iov_len = iobuf_size (iobuf); /* Create the xdr payload */ ret = xdr_serialize_generic (iov, req, xdrproc); if (ret == -1) { goto out; } iov.iov_len = ret; count = 1; } /* Send the msg */ ret = rpc_clnt_submit (&global_quotad_rpc, prog, procnum, cbkfn, &iov, count, NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL); ret = 0; out: if (new_iobref) iobref_unref (iobref); if (iobuf) iobuf_unref (iobuf); return ret; } int cli_quotad_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, void *data) { xlator_t *this = NULL; int ret = 0; this = mydata; switch (event) { case RPC_CLNT_CONNECT: { gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); break; } case RPC_CLNT_DISCONNECT: { gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); break; } default: gf_log (this->name, GF_LOG_TRACE, "got some other RPC event %d", event); ret = 0; break; } return ret; } struct rpc_clnt * cli_quotad_clnt_init (xlator_t *this, dict_t *options) { struct rpc_clnt *rpc = NULL; int ret = -1; ret = dict_set_str (options, "transport.address-family", "unix"); if (ret) goto out; ret = dict_set_str (options, "transport-type", "socket"); if (ret) goto out; ret = dict_set_str (options, "transport.socket.connect-path", "/var/run/gluster/quotad.socket"); if (ret) goto out; rpc = rpc_clnt_new (options, this, this->name, 16); if (!rpc) goto out; ret = rpc_clnt_register_notify (rpc, cli_quotad_notify, this); if (ret) { gf_log ("cli", GF_LOG_ERROR, "failed to register notify"); goto out; } rpc_clnt_start (rpc); out: if (ret) { if (rpc) rpc_clnt_unref (rpc); rpc = NULL; } return rpc; } glusterfs-3.7.6/cli/src/PaxHeaders.7244/Makefile.am0000644000076200007630000000013212617742532020124 xustar000000000000000030 mtime=1447019866.012471916 30 atime=1447019866.359466695 30 ctime=1447019947.481246275 glusterfs-3.7.6/cli/src/Makefile.am0000644000076200007630000000213412617742532020341 0ustar00jenkinsjenkins00000000000000sbin_PROGRAMS = gluster gluster_SOURCES = cli.c registry.c input.c cli-cmd.c cli-rl.c cli-cmd-global.c \ cli-cmd-volume.c cli-cmd-peer.c cli-rpc-ops.c cli-cmd-parser.c\ cli-cmd-system.c cli-cmd-misc.c cli-xml-output.c cli-quotad-client.c cli-cmd-snapshot.c gluster_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD) \ $(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(XML_LIBS) gluster_LDFLAGS = $(GF_LDFLAGS) noinst_HEADERS = cli.h cli-mem-types.h cli-cmd.h cli-quotad-client.h AM_CPPFLAGS = $(GF_CPPFLAGS) \ -I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src\ -I$(top_srcdir)/rpc/xdr/src\ -DDATADIR=\"$(localstatedir)\" \ -DCONFDIR=\"$(sysconfdir)/glusterfs\" \ -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\"\ -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) -DSBIN_DIR=\"$(sbindir)\"\ $(XML_CPPFLAGS) AM_CFLAGS = -Wall $(GF_CFLAGS) CLEANFILES = $(top_builddir)/libglusterfs/src/libglusterfs.la: $(MAKE) -C $(top_builddir)/libglusterfs/src/ all install-data-hook: $(MKDIR_P) $(DESTDIR)$(localstatedir)/run/gluster glusterfs-3.7.6/cli/src/PaxHeaders.7244/cli.c0000644000076200007630000000012712617742532017007 xustar000000000000000029 mtime=1447019866.02147178 29 atime=1447019866.36446662 29 ctime=1447019947.48824617 glusterfs-3.7.6/cli/src/cli.c0000644000076200007630000005204712617742532017230 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2010-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #ifdef HAVE_MALLOC_H #include #endif #ifdef HAVE_MALLOC_STATS #ifdef DEBUG #include #endif #endif #include "cli.h" #include "cli-quotad-client.h" #include "cli-cmd.h" #include "cli-mem-types.h" #include "xlator.h" #include "glusterfs.h" #include "compat.h" #include "logging.h" #include "dict.h" #include "list.h" #include "timer.h" #include "stack.h" #include "revision.h" #include "common-utils.h" #include "event.h" #include "globals.h" #include "syscall.h" #include "call-stub.h" #include #include "xdr-generic.h" extern int connected; /* using argp for command line parsing */ const char *argp_program_version = "" \ PACKAGE_NAME" "PACKAGE_VERSION" built on "__DATE__" "__TIME__ \ "\nRepository revision: " GLUSTERFS_REPOSITORY_REVISION "\n" \ "Copyright (c) 2006-2011 Gluster Inc. " \ "\n" \ "GlusterFS comes with ABSOLUTELY NO WARRANTY.\n" \ "You may redistribute copies of GlusterFS under the terms of "\ "the GNU General Public License."; const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; struct rpc_clnt *global_quotad_rpc; struct rpc_clnt *global_rpc; rpc_clnt_prog_t *cli_rpc_prog; extern struct rpc_clnt_program cli_prog; static int glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) { cmd_args_t *cmd_args = NULL; struct rlimit lim = {0, }; call_pool_t *pool = NULL; int ret = -1; ret = xlator_mem_acct_init (THIS, cli_mt_end); if (ret != 0) { return ret; } ctx->process_uuid = generate_glusterfs_ctx_id (); if (!ctx->process_uuid) return -1; ctx->page_size = 128 * GF_UNIT_KB; ctx->iobuf_pool = iobuf_pool_new (); if (!ctx->iobuf_pool) return -1; ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE, STARTING_EVENT_THREADS); if (!ctx->event_pool) return -1; pool = GF_CALLOC (1, sizeof (call_pool_t), cli_mt_call_pool_t); if (!pool) return -1; /* frame_mem_pool size 112 * 64 */ pool->frame_mem_pool = mem_pool_new (call_frame_t, 32); if (!pool->frame_mem_pool) return -1; /* stack_mem_pool size 256 * 128 */ pool->stack_mem_pool = mem_pool_new (call_stack_t, 16); if (!pool->stack_mem_pool) return -1; ctx->stub_mem_pool = mem_pool_new (call_stub_t, 16); if (!ctx->stub_mem_pool) return -1; ctx->dict_pool = mem_pool_new (dict_t, 32); if (!ctx->dict_pool) return -1; ctx->dict_pair_pool = mem_pool_new (data_pair_t, 512); if (!ctx->dict_pair_pool) return -1; ctx->dict_data_pool = mem_pool_new (data_t, 512); if (!ctx->dict_data_pool) return -1; ctx->logbuf_pool = mem_pool_new (log_buf_t, 256); if (!ctx->logbuf_pool) return -1; INIT_LIST_HEAD (&pool->all_frames); LOCK_INIT (&pool->lock); ctx->pool = pool; pthread_mutex_init (&(ctx->lock), NULL); cmd_args = &ctx->cmd_args; INIT_LIST_HEAD (&cmd_args->xlator_options); lim.rlim_cur = RLIM_INFINITY; lim.rlim_max = RLIM_INFINITY; setrlimit (RLIMIT_CORE, &lim); return 0; } static int logging_init (glusterfs_ctx_t *ctx, struct cli_state *state) { char *log_file = state->log_file ? state->log_file : DEFAULT_CLI_LOG_FILE_DIRECTORY "/cli.log"; /* passing ident as NULL means to use default ident for syslog */ if (gf_log_init (ctx, log_file, NULL) == -1) { fprintf (stderr, "ERROR: failed to open logfile %s\n", log_file); return -1; } /* CLI should not have something to DEBUG after the release, hence defaulting to INFO loglevel */ gf_log_set_loglevel ((state->log_level == GF_LOG_NONE) ? GF_LOG_INFO : state->log_level); return 0; } int cli_submit_request (struct rpc_clnt *rpc, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) { int ret = -1; int count = 0; struct iovec iov = {0, }; struct iobuf *iobuf = NULL; char new_iobref = 0; ssize_t xdr_size = 0; GF_ASSERT (this); if (req) { xdr_size = xdr_sizeof (xdrproc, req); iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size); if (!iobuf) { goto out; }; if (!iobref) { iobref = iobref_new (); if (!iobref) { goto out; } new_iobref = 1; } iobref_add (iobref, iobuf); iov.iov_base = iobuf->ptr; iov.iov_len = iobuf_size (iobuf); /* Create the xdr payload */ ret = xdr_serialize_generic (iov, req, xdrproc); if (ret == -1) { goto out; } iov.iov_len = ret; count = 1; } if (!rpc) rpc = global_rpc; /* Send the msg */ ret = rpc_clnt_submit (rpc, prog, procnum, cbkfn, &iov, count, NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL); ret = 0; out: if (new_iobref) iobref_unref (iobref); if (iobuf) iobuf_unref (iobuf); return ret; } int cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, void *data) { xlator_t *this = NULL; int ret = 0; this = mydata; switch (event) { case RPC_CLNT_CONNECT: { cli_cmd_broadcast_connected (); gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); break; } case RPC_CLNT_DISCONNECT: { gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); connected = 0; if (!global_state->prompt && global_state->await_connected) { ret = 1; cli_out ("Connection failed. Please check if gluster " "daemon is operational."); exit (ret); } break; } default: gf_log (this->name, GF_LOG_TRACE, "got some other RPC event %d", event); ret = 0; break; } return ret; } /* * ret: 0: option successfully processed * 1: signalling end of option list * -1: unknown option or other issue */ int cli_opt_parse (char *opt, struct cli_state *state) { char *oarg = NULL; gf_boolean_t secure_mgmt_tmp = 0; if (strcmp (opt, "") == 0) return 1; if (strcmp (opt, "version") == 0) { cli_out ("%s", argp_program_version); exit (0); } if (strcmp (opt, "print-logdir") == 0) { cli_out ("%s", DEFAULT_LOG_FILE_DIRECTORY); exit (0); } if (strcmp (opt, "print-statedumpdir") == 0) { cli_out ("%s", DEFAULT_VAR_RUN_DIRECTORY); exit (0); } if (strcmp (opt, "xml") == 0) { #if (HAVE_LIB_XML) state->mode |= GLUSTER_MODE_XML; #else cli_err ("XML output not supported. Ignoring '--xml' option"); #endif return 0; } if (strcmp (opt, "wignore") == 0) { state->mode |= GLUSTER_MODE_WIGNORE; return 0; } oarg = strtail (opt, "mode="); if (oarg) { if (strcmp (oarg, "script") == 0) { state->mode |= GLUSTER_MODE_SCRIPT; return 0; } if (strcmp (oarg, "interactive") == 0) return 0; return -1; } oarg = strtail (opt, "remote-host="); if (oarg) { state->remote_host = oarg; return 0; } oarg = strtail (opt, "log-file="); if (oarg) { state->log_file = oarg; return 0; } oarg = strtail (opt, "log-level="); if (oarg) { state->log_level = glusterd_check_log_level(oarg); if (state->log_level == -1) return -1; return 0; } oarg = strtail (opt, "glusterd-sock="); if (oarg) { state->glusterd_sock = oarg; return 0; } oarg = strtail (opt, "secure-mgmt="); if (oarg) { if (gf_string2boolean(oarg,&secure_mgmt_tmp) == 0) { if (secure_mgmt_tmp) { /* See declaration for why this is an int. */ state->ctx->secure_mgmt = 1; } } else { cli_err ("invalide secure-mgmt value (ignored)"); } return 0; } return -1; } int parse_cmdline (int argc, char *argv[], struct cli_state *state) { int ret = 0; int i = 0; int j = 0; char *opt = NULL; gf_boolean_t geo_rep_config = _gf_false; state->argc=argc-1; state->argv=&argv[1]; /* Do this first so that an option can override. */ if (access(SECURE_ACCESS_FILE,F_OK) == 0) { state->ctx->secure_mgmt = 1; } if (state->argc > GEO_REP_CMD_CONFIG_INDEX && strtail (state->argv[GEO_REP_CMD_INDEX], "geo") && strtail (state->argv[GEO_REP_CMD_CONFIG_INDEX], "co")) geo_rep_config = _gf_true; for (i = 0; i < state->argc; i++) { opt = strtail (state->argv[i], "--"); if (opt && !geo_rep_config) { ret = cli_opt_parse (opt, state); if (ret == -1) { cli_out ("unrecognized option --%s", opt); return ret; } for (j = i; j < state->argc - 1; j++) state->argv[j] = state->argv[j + 1]; state->argc--; /* argv shifted, next check should be at i again */ i--; if (ret == 1) { /* end of cli options */ ret = 0; break; } } } state->argv[state->argc] = NULL; return ret; } int cli_cmd_tree_init (struct cli_cmd_tree *tree) { struct cli_cmd_word *root = NULL; int ret = 0; root = &tree->root; root->tree = tree; return ret; } int cli_state_init (struct cli_state *state) { struct cli_cmd_tree *tree = NULL; int ret = 0; state->log_level = GF_LOG_NONE; tree = &state->tree; tree->state = state; ret = cli_cmd_tree_init (tree); return ret; } int cli_usage_out (const char *usage) { GF_ASSERT (usage); GF_ASSERT (usage[0] != '\0'); if (!usage || usage[0] == '\0') return -1; cli_err ("Usage: %s", usage); return 0; } int _cli_err (const char *fmt, ...) { struct cli_state *state = NULL; va_list ap; int ret = 0; state = global_state; va_start (ap, fmt); #ifdef HAVE_READLINE if (state->rl_enabled && !state->rl_processing) return cli_rl_err(state, fmt, ap); #endif ret = vfprintf (stderr, fmt, ap); fprintf (stderr, "\n"); va_end (ap); return ret; } int _cli_out (const char *fmt, ...) { struct cli_state *state = NULL; va_list ap; int ret = 0; state = global_state; va_start (ap, fmt); #ifdef HAVE_READLINE if (state->rl_enabled && !state->rl_processing) return cli_rl_out(state, fmt, ap); #endif ret = vprintf (fmt, ap); printf ("\n"); va_end (ap); return ret; } struct rpc_clnt * cli_quotad_clnt_rpc_init (void) { struct rpc_clnt *rpc = NULL; dict_t *rpc_opts = NULL; int ret = -1; rpc_opts = dict_new (); if (!rpc_opts) { ret = -1; goto out; } ret = dict_set_str (rpc_opts, "transport.address-family", "unix"); if (ret) goto out; ret = dict_set_str (rpc_opts, "transport-type", "socket"); if (ret) goto out; ret = dict_set_str (rpc_opts, "transport.socket.connect-path", "/var/run/gluster/quotad.socket"); if (ret) goto out; rpc = cli_quotad_clnt_init (THIS, rpc_opts); if (!rpc) goto out; global_quotad_rpc = rpc; out: if (ret) { if (rpc_opts) dict_destroy(rpc_opts); } return rpc; } struct rpc_clnt * cli_rpc_init (struct cli_state *state) { struct rpc_clnt *rpc = NULL; dict_t *options = NULL; int ret = -1; int port = CLI_GLUSTERD_PORT; xlator_t *this = NULL; this = THIS; cli_rpc_prog = &cli_prog; options = dict_new (); if (!options) goto out; /* Connect to glusterd using the specified method, giving preference * to a unix socket connection. If nothing is specified, connect to * the default glusterd socket. */ if (state->glusterd_sock) { gf_log ("cli", GF_LOG_INFO, "Connecting to glusterd using " "sockfile %s", state->glusterd_sock); ret = rpc_transport_unix_options_build (&options, state->glusterd_sock, 0); if (ret) goto out; } else if (state->remote_host) { gf_log ("cli", GF_LOG_INFO, "Connecting to remote glusterd at " "%s", state->remote_host); ret = dict_set_str (options, "remote-host", state->remote_host); if (ret) goto out; if (state->remote_port) port = state->remote_port; ret = dict_set_int32 (options, "remote-port", port); if (ret) goto out; ret = dict_set_str (options, "transport.address-family", "inet"); if (ret) goto out; } else { gf_log ("cli", GF_LOG_DEBUG, "Connecting to glusterd using " "default socket"); ret = rpc_transport_unix_options_build (&options, DEFAULT_GLUSTERD_SOCKFILE, 0); if (ret) goto out; } rpc = rpc_clnt_new (options, this, this->name, 16); if (!rpc) goto out; ret = rpc_clnt_register_notify (rpc, cli_rpc_notify, this); if (ret) { gf_log ("cli", GF_LOG_ERROR, "failed to register notify"); goto out; } ret = rpc_clnt_start (rpc); out: if (ret) { if (rpc) rpc_clnt_unref (rpc); rpc = NULL; } return rpc; } cli_local_t * cli_local_get () { cli_local_t *local = NULL; local = GF_CALLOC (1, sizeof (*local), cli_mt_cli_local_t); LOCK_INIT (&local->lock); return local; } void cli_local_wipe (cli_local_t *local) { if (local) { GF_FREE (local->get_vol.volname); if (local->dict) dict_unref (local->dict); GF_FREE (local); } return; } struct cli_state *global_state; int main (int argc, char *argv[]) { struct cli_state state = {0, }; int ret = -1; glusterfs_ctx_t *ctx = NULL; ctx = glusterfs_ctx_new (); if (!ctx) return ENOMEM; #ifdef DEBUG gf_mem_acct_enable_set (ctx); #endif ret = glusterfs_globals_init (ctx); if (ret) return ret; THIS->ctx = ctx; ret = glusterfs_ctx_defaults_init (ctx); if (ret) goto out; ret = cli_state_init (&state); if (ret) goto out; state.ctx = ctx; global_state = &state; ret = parse_cmdline (argc, argv, &state); if (ret) goto out; ret = logging_init (ctx, &state); if (ret) goto out; gf_log ("cli", GF_LOG_INFO, "Started running %s with version %s", argv[0], PACKAGE_VERSION); global_rpc = cli_rpc_init (&state); if (!global_rpc) goto out; global_quotad_rpc = cli_quotad_clnt_rpc_init (); if (!global_quotad_rpc) goto out; ret = cli_cmds_register (&state); if (ret) goto out; ret = cli_cmd_cond_init (); if (ret) goto out; ret = cli_input_init (&state); if (ret) goto out; ret = event_dispatch (ctx->event_pool); out: // glusterfs_ctx_destroy (ctx); return ret; } void cli_print_line (int len) { GF_ASSERT (len > 0); while (len--) printf ("-"); printf ("\n"); } void print_quota_list_header (int type) { if (type == GF_QUOTA_OPTION_TYPE_LIST) { cli_out (" Path Hard-limit " " Soft-limit Used Available Soft-limit " "exceeded? Hard-limit exceeded?"); cli_out ("-----------------------------------------------------" "-----------------------------------------------------" "---------------------"); } else { cli_out (" Path Hard-limit " " Soft-limit Files Dirs Available " "Soft-limit exceeded? Hard-limit exceeded?"); cli_out ("-----------------------------------------------------" "-----------------------------------------------------" "-------------------------------------"); } } void print_quota_list_empty (char *path, int type) { if (type == GF_QUOTA_OPTION_TYPE_LIST) cli_out ("%-40s %7s %9s %10s %7s %15s %20s", path, "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"); else cli_out ("%-40s %9s %9s %12s %10s %10s %15s %20s", path, "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"); } glusterfs-3.7.6/cli/src/PaxHeaders.7244/cli-cmd-snapshot.c0000644000076200007630000000013212617742532021401 xustar000000000000000030 mtime=1447019866.015471871 30 atime=1447019866.361466665 30 ctime=1447019947.539245403 glusterfs-3.7.6/cli/src/cli-cmd-snapshot.c0000644000076200007630000001173712617742532021627 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2013-2014 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include "cli.h" #include "cli-cmd.h" #include "cli-mem-types.h" extern rpc_clnt_prog_t *cli_rpc_prog; int cli_cmd_snapshot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); int cli_cmd_snapshot_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = 0; int parse_err = 0; dict_t *options = NULL; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; cli_local_t *local = NULL; proc = &cli_rpc_prog->proctable [GLUSTER_CLI_SNAP]; if (proc == NULL) { ret = -1; goto out; } frame = create_frame (THIS, THIS->ctx->pool); if (frame == NULL) { ret = -1; goto out; } /* Parses the command entered by the user */ ret = cli_cmd_snapshot_parse (words, wordcount, &options, state); if (ret) { if (ret < 0) { cli_usage_out (word->pattern); parse_err = 1; } else { /* User might have cancelled the snapshot operation */ ret = 0; } goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) ret = proc->fn (frame, THIS, options); out: if (ret && parse_err == 0) cli_out ("Snapshot command failed"); CLI_STACK_DESTROY (frame); return ret; } struct cli_cmd snapshot_cmds[] = { { "snapshot help", cli_cmd_snapshot_help_cbk, "display help for snapshot commands" }, { "snapshot create [no-timestamp] " "[description ] [force]", cli_cmd_snapshot_cbk, "Snapshot Create." }, { "snapshot clone ", cli_cmd_snapshot_cbk, "Snapshot Clone." }, { "snapshot restore ", cli_cmd_snapshot_cbk, "Snapshot Restore." }, { "snapshot status [(snapname | volume )]", cli_cmd_snapshot_cbk, "Snapshot Status." }, { "snapshot info [(snapname | volume )]", cli_cmd_snapshot_cbk, "Snapshot Info." }, { "snapshot list [volname]", cli_cmd_snapshot_cbk, "Snapshot List." }, {"snapshot config [volname] ([snap-max-hard-limit ] " "[snap-max-soft-limit ]) " "| ([auto-delete ])" "| ([activate-on-create ])", cli_cmd_snapshot_cbk, "Snapshot Config." }, {"snapshot delete (all | snapname | volume )", cli_cmd_snapshot_cbk, "Snapshot Delete." }, {"snapshot activate [force]", cli_cmd_snapshot_cbk, "Activate snapshot volume." }, {"snapshot deactivate ", cli_cmd_snapshot_cbk, "Deactivate snapshot volume." }, { NULL, NULL, NULL } }; int cli_cmd_snapshot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount) { struct cli_cmd *cmd = NULL; struct cli_cmd *snap_cmd = NULL; int count = 0; cmd = GF_CALLOC (1, sizeof (snapshot_cmds), cli_mt_cli_cmd); memcpy (cmd, snapshot_cmds, sizeof (snapshot_cmds)); count = (sizeof (snapshot_cmds) / sizeof (struct cli_cmd)); cli_cmd_sort (cmd, count); for (snap_cmd = cmd; snap_cmd->pattern; snap_cmd++) if (_gf_false == snap_cmd->disable) cli_out ("%s - %s", snap_cmd->pattern, snap_cmd->desc); GF_FREE (cmd); return 0; } int cli_cmd_snapshot_register (struct cli_state *state) { int ret = 0; struct cli_cmd *cmd = NULL; for (cmd = snapshot_cmds; cmd->pattern; cmd++) { ret = cli_cmd_register (&state->tree, cmd); if (ret) goto out; } out: return ret; } glusterfs-3.7.6/cli/src/PaxHeaders.7244/input.c0000644000076200007630000000013012617742532017371 xustar000000000000000029 mtime=1447019866.02147178 29 atime=1447019866.36446662 30 ctime=1447019947.495246065 glusterfs-3.7.6/cli/src/input.c0000644000076200007630000000437712617742532017623 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2010-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include "cli.h" #include "cli-mem-types.h" #define CMDBUFSIZ 1024 void * cli_batch (void *d) { struct cli_state *state = NULL; int ret = 0; state = d; ret = cli_cmd_process (state, state->argc, state->argv); gf_log ("", GF_LOG_INFO, "Exiting with: %d", ret); exit (-ret); return NULL; } void * cli_input (void *d) { struct cli_state *state = NULL; int ret = 0; char cmdbuf[CMDBUFSIZ]; char *cmd = NULL; size_t len = 0; state = d; for (;;) { printf ("%s", state->prompt); cmd = fgets (cmdbuf, CMDBUFSIZ, stdin); if (!cmd) break; len = strlen(cmd); if (len > 0 && cmd[len - 1] == '\n') //strip trailing \n cmd[len - 1] = '\0'; ret = cli_cmd_process_line (state, cmd); if (ret != 0 && state->mode & GLUSTER_MODE_ERR_FATAL) break; } exit (-ret); return NULL; } int cli_input_init (struct cli_state *state) { int ret = 0; if (state->argc) { ret = pthread_create (&state->input, NULL, cli_batch, state); return ret; } if (isatty (STDIN_FILENO)) { state->prompt = "gluster> "; cli_rl_enable (state); } else { state->prompt = ""; state->mode |= GLUSTER_MODE_SCRIPT | GLUSTER_MODE_ERR_FATAL; } if (!state->rl_enabled) ret = pthread_create (&state->input, NULL, cli_input, state); return ret; } glusterfs-3.7.6/cli/src/PaxHeaders.7244/cli-cmd-system.c0000644000076200007630000000013212617742532021066 xustar000000000000000030 mtime=1447019866.015471871 30 atime=1447019866.361466665 30 ctime=1447019947.526245598 glusterfs-3.7.6/cli/src/cli-cmd-system.c0000644000076200007630000004367112617742532021316 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2010-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include "cli.h" #include "cli-cmd.h" #include "cli-mem-types.h" #include "protocol-common.h" extern struct rpc_clnt *global_rpc; extern rpc_clnt_prog_t *cli_rpc_prog; int cli_cmd_system_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); int cli_cmd_copy_file_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount); int cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount); int cli_cmd_getspec_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; if (wordcount != 3) { cli_usage_out (word->pattern); goto out; } ret = dict_set_str (dict, "volid", (char *)words[2]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GETSPEC]; if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (!proc && ret) { if (dict) dict_destroy (dict); if (wordcount > 1) cli_out ("Fetching spec for volume %s failed", (char *)words[2]); } return ret; } int cli_cmd_pmap_b2p_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; if (wordcount != 4) { cli_usage_out (word->pattern); goto out; } ret = dict_set_str (dict, "brick", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PMAP_PORTBYBRICK]; if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (!proc && ret) { if (dict) dict_destroy (dict); if (wordcount > 1) cli_out ("Fetching spec for volume %s failed", (char *)words[3]); } return ret; } int cli_cmd_fsm_log_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; char *name = ""; if ((wordcount != 4) && (wordcount != 3)) { cli_usage_out (word->pattern); goto out; } if (wordcount == 4) name = (char*)words[3]; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_FSM_LOG]; if (proc && proc->fn) { frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = proc->fn (frame, THIS, (void*)name); } out: return ret; } int cli_cmd_getwd_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; if (wordcount != 2) { cli_usage_out (word->pattern); goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GETWD]; if (proc && proc->fn) { frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = proc->fn (frame, THIS, NULL); } out: return ret; } static dict_t * make_seq_dict (int argc, char **argv) { char index[] = "4294967296"; // 1<<32 int i = 0; int ret = 0; dict_t *dict = dict_new (); if (!dict) return NULL; for (i = 0; i < argc; i++) { snprintf(index, sizeof(index), "%d", i); ret = dict_set_str (dict, index, argv[i]); if (ret == -1) break; } if (ret) { dict_destroy (dict); dict = NULL; } return dict; } int cli_cmd_mount_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int ret = -1; dict_t *dict = NULL; void *dataa[] = {NULL, NULL}; if (wordcount < 4) { cli_usage_out (word->pattern); goto out; } dict = make_seq_dict (wordcount - 3, (char **)words + 3); if (!dict) goto out; dataa[0] = (void *)words[2]; dataa[1] = dict; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_MOUNT]; if (proc && proc->fn) { frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = proc->fn (frame, THIS, dataa); } out: if (dict) dict_unref (dict); if (!proc && ret) cli_out ("Mount command failed"); return ret; } int cli_cmd_umount_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int ret = -1; dict_t *dict = NULL; if (!(wordcount == 3 || (wordcount == 4 && strcmp (words[3], "lazy") == 0))) { cli_usage_out (word->pattern); goto out; } dict = dict_new (); if (!dict) goto out; ret = dict_set_str (dict, "path", (char *)words[2]); if (ret != 0) goto out; ret = dict_set_int32 (dict, "lazy", wordcount == 4); if (ret != 0) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UMOUNT]; if (proc && proc->fn) { frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = proc->fn (frame, THIS, dict); } out: if (dict) dict_unref (dict); if (!proc && ret) cli_out ("Umount command failed"); return ret; } int cli_cmd_uuid_get_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; int sent = 0; int parse_error = 0; dict_t *dict = NULL; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; cli_local_t *local = NULL; xlator_t *this = NULL; this = THIS; if (wordcount != 3) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UUID_GET]; frame = create_frame (this, this->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) ret = proc->fn (frame, this, dict); out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("uuid get failed"); } if (dict) dict_unref (dict); CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_uuid_reset_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int sent = 0; int parse_error = 0; gf_answer_t answer = GF_ANSWER_NO; char *question = NULL; cli_local_t *local = NULL; dict_t *dict = NULL; xlator_t *this = NULL; question = "Resetting uuid changes the uuid of local glusterd. " "Do you want to continue?"; if (wordcount != 3) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UUID_RESET]; this = THIS; frame = create_frame (this, this->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) { ret = -1; goto out; } CLI_LOCAL_INIT (local, words, frame, dict); answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } //send NULL as argument since no dictionary is sent to glusterd if (proc->fn) { ret = proc->fn (frame, this, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("uuid reset failed"); } CLI_STACK_DESTROY (frame); return ret; } struct cli_cmd cli_system_cmds[] = { { "system:: getspec ", cli_cmd_getspec_cbk, "fetch the volume file for the volume "}, { "system:: portmap brick2port ", cli_cmd_pmap_b2p_cbk, "query which port listens on"}, { "system:: fsm log []", cli_cmd_fsm_log_cbk, "display fsm transitions"}, { "system:: getwd", cli_cmd_getwd_cbk, "query glusterd work directory"}, { "system:: mount */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); j++; } } /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d", i); ret = cli_xml_output_vol_info_options (local->writer, dict, key); if (ret) goto out; /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); } if (volname) { GF_FREE (local->get_vol.volname); local->get_vol.volname = gf_strdup (volname); local->vol_count += count; } out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_info_begin (cli_local_t *local, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; GF_ASSERT (local); ret = cli_begin_xml_output (&(local->writer), &(local->doc)); if (ret) goto out; ret = cli_xml_output_common (local->writer, op_ret, op_errno, op_errstr); if (ret) goto out; /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"volInfo"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"volumes"); XML_RET_CHECK_AND_GOTO (ret, out); /* Init vol count */ local->vol_count = 0; out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_info_end (cli_local_t *local) { #if (HAVE_LIB_XML) int ret = -1; GF_ASSERT (local); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"count", "%d", local->vol_count); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (local->writer, local->doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_quota_limit_list_end (cli_local_t *local) { #if (HAVE_LIB_XML) int ret = -1; ret = xmlTextWriterEndElement (local->writer); if (ret) { goto out; } ret = cli_end_xml_output (local->writer, local->doc); out: return ret; #else return 0; #endif } int cli_xml_output_vol_quota_limit_list_begin (cli_local_t *local, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; ret = cli_begin_xml_output (&(local->writer), &(local->doc)); if (ret) goto out; ret = cli_xml_output_common (local->writer, op_ret, op_errno, op_errstr); if (ret) goto out; /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"volQuota"); XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } #if (HAVE_LIB_XML) static int cli_xml_output_peer_hostnames (xmlTextWriterPtr writer, dict_t *dict, const char *prefix, int count) { int ret = -1; int i = 0; char *hostname = NULL; char key[1024] = {0,}; /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"hostnames"); XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < count; i++) { memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d", prefix, i); ret = dict_get_str (dict, key, &hostname); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"hostname", "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); hostname = NULL; } /* */ ret = xmlTextWriterEndElement (writer); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; } #endif int cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; int count = 0; char *uuid = NULL; char *hostname = NULL; int connected = 0; int state_id = 0; char *state_str = NULL; int hostname_count = 0; int i = 1; char key[1024] = {0,}; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"peerStatus"); XML_RET_CHECK_AND_GOTO (ret, out); if (!dict) goto cont; ret = dict_get_int32 (dict, "count", &count); if (ret) goto out; while (i <= count) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"peer"); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.uuid", i); ret = dict_get_str (dict, key, &uuid); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"uuid", "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"hostname", "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname_count", i); ret = dict_get_int32 (dict, key, &hostname_count); if ((ret == 0) && (hostname_count > 0)) { memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", i); ret = cli_xml_output_peer_hostnames (writer, dict, key, hostname_count); XML_RET_CHECK_AND_GOTO (ret, out); } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.connected", i); ret = dict_get_int32 (dict, key, &connected); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"connected", "%d", connected); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.stateId", i); ret = dict_get_int32 (dict, key, &state_id); if (!ret) { /* ignore */ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"state", "%d", state_id); XML_RET_CHECK_AND_GOTO (ret, out); } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.state", i); ret = dict_get_str (dict, key, &state_str); if (!ret) { /* ignore */ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"stateStr", "%s", state_str); XML_RET_CHECK_AND_GOTO (ret, out); } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); i++; } cont: /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } #if (HAVE_LIB_XML) /* Used for rebalance stop/status, remove-brick status */ int cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, enum gf_task_types task_type) { int ret = -1; int count = 0; char *node_name = NULL; char *node_uuid = NULL; uint64_t files = 0; uint64_t size = 0; uint64_t lookups = 0; int status_rcd = 0; uint64_t failures = 0; uint64_t skipped = 0; uint64_t total_files = 0; uint64_t total_size = 0; uint64_t total_lookups = 0; uint64_t total_failures = 0; uint64_t total_skipped = 0; char key[1024] = {0,}; int i = 0; int overall_status = -1; double elapsed = 0; double overall_elapsed = 0; if (!dict) { ret = 0; goto out; } ret = dict_get_int32 (dict, "count", &count); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeCount", "%d", count); XML_RET_CHECK_AND_GOTO (ret, out); while (i < count) { i++; /* Getting status early, to skip nodes that don't have the * rebalance process started */ memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, &status_rcd); /* If glusterd is down it fails to get the status, try getting status from other nodes */ if (ret) continue; if (GF_DEFRAG_STATUS_NOT_STARTED == status_rcd) continue; /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeName", "%s", node_name); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-uuid-%d", i); ret = dict_get_str (dict, key, &node_uuid); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"id", "%s", node_uuid); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "files-%d", i); ret = dict_get_uint64 (dict, key, &files); if (ret) goto out; total_files += files; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"files", "%"PRIu64, files); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "size-%d", i); ret = dict_get_uint64 (dict, key, &size); if (ret) goto out; total_size += size; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"size", "%"PRIu64,size); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "lookups-%d", i); ret = dict_get_uint64 (dict, key, &lookups); if (ret) goto out; total_lookups += lookups; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"lookups", "%"PRIu64, lookups); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "failures-%d", i); ret = dict_get_uint64 (dict, key, &failures); if (ret) goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "skipped-%d", i); ret = dict_get_uint64 (dict, key, &skipped); if (ret) goto out; if (task_type == GF_TASK_TYPE_REMOVE_BRICK) { failures += skipped; skipped = 0; } total_failures += failures; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"failures", "%"PRIu64, failures); XML_RET_CHECK_AND_GOTO (ret, out); total_skipped += skipped; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"skipped", "%"PRIu64, skipped); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"status", "%d", status_rcd); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"statusStr", "%s", cli_vol_task_status_str[status_rcd]); memset (key, 0, 256); snprintf (key, 256, "run-time-%d", i); ret = dict_get_double (dict, key, &elapsed); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"runtime", "%.2f", elapsed); XML_RET_CHECK_AND_GOTO (ret, out); if (elapsed > overall_elapsed) { overall_elapsed = elapsed; } /* Rebalance has 5 states, * NOT_STARTED, STARTED, STOPPED, COMPLETE, FAILED * The precedence used to determine the aggregate status is as * below, * STARTED > FAILED > STOPPED > COMPLETE > NOT_STARTED */ /* TODO: Move this to a common place utilities that both CLI and * glusterd need. * Till then if the below algorithm is changed, change it in * glusterd_volume_status_aggregate_tasks_status in * glusterd-utils.c */ if (-1 == overall_status) overall_status = status_rcd; int rank[] = { [GF_DEFRAG_STATUS_STARTED] = 1, [GF_DEFRAG_STATUS_FAILED] = 2, [GF_DEFRAG_STATUS_STOPPED] = 3, [GF_DEFRAG_STATUS_COMPLETE] = 4, [GF_DEFRAG_STATUS_NOT_STARTED] = 5 }; if (rank[status_rcd] <= rank[overall_status]) overall_status = status_rcd; /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } /* Aggregate status */ /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"aggregate"); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"files", "%"PRIu64, total_files); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"size", "%"PRIu64, total_size); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"lookups", "%"PRIu64, total_lookups); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"failures", "%"PRIu64, total_failures); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"skipped", "%"PRIu64, total_skipped); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"status", "%d", overall_status); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"statusStr", "%s", cli_vol_task_status_str[overall_status]); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"runtime", "%.2f", overall_elapsed); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; } #endif int cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, enum gf_task_types task_type) { #if (HAVE_LIB_XML) int ret = -1; int count = 0; char *node_name = NULL; char *status_str = NULL; uint64_t promoted = 0; uint64_t demoted = 0; int i = 1; char key[1024] = {0,}; gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; GF_VALIDATE_OR_GOTO ("cli", dict, out); ret = dict_get_int32 (dict, "count", &count); if (ret) { gf_log ("cli", GF_LOG_ERROR, "count not set"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeCount", "%d", count); XML_RET_CHECK_AND_GOTO (ret, out); while (i <= count) { promoted = 0; node_name = NULL; demoted = 0; ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeName", "%s", node_name); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "promoted-%d", i); ret = dict_get_uint64 (dict, key, &promoted); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"promoted" "Files", "%"PRIu64, promoted); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "demoted-%d", i); ret = dict_get_uint64 (dict, key, &demoted); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"demoted" "Files", "%"PRIu64, demoted); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, 256); snprintf (key, 256, "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); status_str = cli_vol_task_status_str[status_rcd]; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"statusStr", "%s", status_str); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); i++; } out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_rebalance (gf_cli_defrag_type op, dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *task_id_str = NULL; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volRebalance"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, GF_REBALANCE_TID_KEY, &task_id_str); if (ret == 0) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"task-id", "%s", task_id_str); XML_RET_CHECK_AND_GOTO (ret, out); } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"op", "%d", op); XML_RET_CHECK_AND_GOTO (ret, out); if (GF_DEFRAG_CMD_STATUS_TIER == op) { ret = cli_xml_output_vol_tier_status (writer, dict, GF_TASK_TYPE_REBALANCE); if (ret) goto out; } if ((GF_DEFRAG_CMD_STOP == op) || (GF_DEFRAG_CMD_STATUS == op)) { ret = cli_xml_output_vol_rebalance_status (writer, dict, GF_TASK_TYPE_REBALANCE); if (ret) goto out; } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_remove_brick_detach_tier (gf_boolean_t status_op, dict_t *dict, int op_ret, int op_errno, char *op_errstr, const char *op) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *task_id_str = NULL; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; ret = xmlTextWriterStartElement (writer, (xmlChar *) op); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY, &task_id_str); if (ret == 0) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"task-id", "%s", task_id_str); XML_RET_CHECK_AND_GOTO (ret, out); } if (status_op) { ret = cli_xml_output_vol_rebalance_status (writer, dict, GF_TASK_TYPE_REMOVE_BRICK); if (ret) goto out; } ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_replace_brick (char *op, dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; int status = 0; uint64_t files = 0; char *current_file = 0; char *task_id_str = NULL; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_vol_create (dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *volname = NULL; char *volid = NULL; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; if (dict) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volCreate"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "volname", &volname); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", volname); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "volume-id", &volid); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"id", "%s", volid); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_generic_volume (char *op, dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *volname = NULL; char *volid = NULL; GF_ASSERT (op); ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; if (dict) { /* <"op"> */ ret = xmlTextWriterStartElement (writer, (xmlChar *)op); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "volname", &volname); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", volname); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "vol-id", &volid); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"id", "%s", volid); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } #if (HAVE_LIB_XML) int _output_gsync_config (FILE *fp, xmlTextWriterPtr writer, char *op_name) { char resbuf[256 + PATH_MAX] = {0,}; char *ptr = NULL; char *v = NULL; int blen = sizeof(resbuf); int ret = 0; for (;;) { ptr = fgets (resbuf, blen, fp); if (!ptr) break; v = resbuf + strlen (resbuf) - 1; while (isspace (*v)) { /* strip trailing space */ *v-- = '\0'; } if (v == resbuf) { /* skip empty line */ continue; } if (op_name!= NULL){ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)op_name, "%s", resbuf); XML_RET_CHECK_AND_GOTO (ret, out); goto out; } v = strchr (resbuf, ':'); if (!v) { ret = -1; goto out; } *v++ = '\0'; while (isspace (*v)) v++; v = gf_strdup (v); if (!v) { ret = -1; goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)resbuf, "%s", v); XML_RET_CHECK_AND_GOTO (ret, out); } out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; } #endif #if (HAVE_LIB_XML) int get_gsync_config (runner_t *runner, int (*op_conf)(FILE *fp, xmlTextWriterPtr writer, char *op_name), xmlTextWriterPtr writer, char *op_name) { int ret = 0; runner_redir (runner, STDOUT_FILENO, RUN_PIPE); if (runner_start (runner) != 0) { gf_log ("cli", GF_LOG_ERROR, "spawning child failed"); return -1; } ret = op_conf (runner_chio (runner, STDOUT_FILENO), writer, op_name); ret |= runner_end (runner); if (ret) gf_log ("cli", GF_LOG_ERROR, "reading data from child failed"); return ret ? -1 : 0; } #endif #if (HAVE_LIB_XML) int cli_xml_generate_gsync_config (dict_t *dict, xmlTextWriterPtr writer) { runner_t runner = {0,}; char *subop = NULL; char *gwd = NULL; char *slave = NULL; char *confpath = NULL; char *master = NULL; char *op_name = NULL; int ret = -1; char conf_path[PATH_MAX] = ""; if (dict_get_str (dict, "subop", &subop) != 0) { ret = -1; goto out; } if (strcmp (subop, "get") != 0 && strcmp (subop, "get-all") != 0) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"message", "%s",GEOREP" config updated successfully" ); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; goto out; } if (dict_get_str (dict, "glusterd_workdir", &gwd) != 0 || dict_get_str (dict, "slave", &slave) != 0) { ret = -1; goto out; } if (dict_get_str (dict, "master", &master) != 0) master = NULL; if (dict_get_str (dict, "op_name", &op_name) != 0) op_name = NULL; ret = dict_get_str (dict, "conf_path", &confpath); if (!confpath) { ret = snprintf (conf_path, sizeof (conf_path) - 1, "%s/"GEOREP"/gsyncd_template.conf", gwd); conf_path[ret] = '\0'; confpath = conf_path; } runinit (&runner); runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "-c", NULL); runner_argprintf (&runner, "%s", confpath); runner_argprintf (&runner, "--iprefix=%s", DATADIR); if (master) runner_argprintf (&runner, ":%s", master); runner_add_arg (&runner, slave); runner_argprintf (&runner, "--config-%s", subop); if (op_name) runner_add_arg (&runner, op_name); ret = get_gsync_config (&runner, _output_gsync_config, writer, op_name); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; } #endif #if (HAVE_LIB_XML) int cli_xml_output_vol_gsync_status (dict_t *dict, xmlTextWriterPtr writer) { int ret = -1; int i = 1; int j = 0; int count = 0; const int number_of_fields = 20; int closed = 1; int session_closed = 1; gf_gsync_status_t **status_values = NULL; gf_boolean_t status_detail = _gf_false; char status_value_name[PATH_MAX] = ""; char *tmp = NULL; char *volume = NULL; char *volume_next = NULL; char *slave = NULL; char *slave_next = NULL; char *title_values[] = {"master_node", "", "master_brick", "slave_user", "slave", "slave_node", "status", "crawl_status", /* last_synced */ "", "entry", "data", "meta", "failures", /* checkpoint_time */ "", "checkpoint_completed", /* checkpoint_completion_time */ "", "master_node_uuid", /* last_synced_utc */ "last_synced", /* checkpoint_time_utc */ "checkpoint_time", /* checkpoint_completion_time_utc */ "checkpoint_completion_time"}; GF_ASSERT (dict); ret = dict_get_int32 (dict, "gsync-count", &count); if (ret) goto out; status_detail = dict_get_str_boolean (dict, "status-detail", _gf_false); status_values = GF_CALLOC (count, sizeof (gf_gsync_status_t *), gf_common_mt_char); if (!status_values) { ret = -1; goto out; } for (i = 0; i < count; i++) { status_values[i] = GF_CALLOC (1, sizeof (gf_gsync_status_t), gf_common_mt_char); if (!status_values[i]) { ret = -1; goto out; } snprintf (status_value_name, sizeof (status_value_name), "status_value%d", i); ret = dict_get_bin (dict, status_value_name, (void **)&(status_values[i])); if (ret) { gf_log ("cli", GF_LOG_ERROR, "struct member empty."); goto out; } } qsort(status_values, count, sizeof (gf_gsync_status_t *), gf_gsync_status_t_comparator); for (i = 0; i < count; i++) { if (closed) { ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); tmp = get_struct_variable (1, status_values[i]); if (!tmp) { gf_log ("cli", GF_LOG_ERROR, "struct member empty."); ret = -1; goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"name", "%s",tmp); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterStartElement (writer, (xmlChar *)"sessions"); XML_RET_CHECK_AND_GOTO (ret, out); closed = 0; } if (session_closed) { ret = xmlTextWriterStartElement (writer, (xmlChar *)"session"); XML_RET_CHECK_AND_GOTO (ret, out); session_closed = 0; tmp = get_struct_variable (21, status_values[i]); if (!tmp) { gf_log ("cli", GF_LOG_ERROR, "struct member empty."); ret = -1; goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"session_slave", "%s", tmp); XML_RET_CHECK_AND_GOTO (ret, out); } ret = xmlTextWriterStartElement (writer, (xmlChar *)"pair"); XML_RET_CHECK_AND_GOTO (ret, out); for (j = 0; j < number_of_fields; j++) { /* XML ignore fields */ if (strcmp(title_values[j], "") == 0) continue; tmp = get_struct_variable (j, status_values[i]); if (!tmp) { gf_log ("cli", GF_LOG_ERROR, "struct member empty."); ret = -1; goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)title_values[j], "%s", tmp); XML_RET_CHECK_AND_GOTO (ret, out); } ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); if (i+1 < count) { slave = get_struct_variable (20, status_values[i]); slave_next = get_struct_variable (20, status_values[i+1]); volume = get_struct_variable (1, status_values[i]); volume_next = get_struct_variable (1, status_values[i+1]); if (!slave || !slave_next || !volume || !volume_next) { gf_log ("cli", GF_LOG_ERROR, "struct member empty."); ret = -1; goto out; } if (strcmp (volume, volume_next)!=0) { closed = 1; session_closed = 1; ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } else if (strcmp (slave, slave_next)!=0) { session_closed = 1; ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } } else { ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } } out: gf_log ("cli",GF_LOG_DEBUG, "Returning %d", ret); return ret; } #endif int cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *master = NULL; char *slave = NULL; int type = 0; GF_ASSERT (dict); ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"geoRep"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, "type", &type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get type"); goto out; } switch (type) { case GF_GSYNC_OPTION_TYPE_START: case GF_GSYNC_OPTION_TYPE_STOP: case GF_GSYNC_OPTION_TYPE_PAUSE: case GF_GSYNC_OPTION_TYPE_RESUME: case GF_GSYNC_OPTION_TYPE_CREATE: case GF_GSYNC_OPTION_TYPE_DELETE: if (dict_get_str (dict, "master", &master) != 0) master = "???"; if (dict_get_str (dict, "slave", &slave) != 0) slave = "???"; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"master", "%s", master); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"slave", "%s", slave); XML_RET_CHECK_AND_GOTO (ret, out); break; case GF_GSYNC_OPTION_TYPE_CONFIG: if (op_ret == 0) { ret = xmlTextWriterStartElement (writer, (xmlChar *)"config"); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_xml_generate_gsync_config (dict, writer); if (ret) goto out; ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } break; case GF_GSYNC_OPTION_TYPE_STATUS: ret = cli_xml_output_vol_gsync_status (dict, writer); break; default: ret = 0; break; } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_end_xml_output (writer, doc); out: gf_log ("cli",GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif } #if (HAVE_LIB_XML) /* This function will generate snapshot create output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing create output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_create (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; char *str_value = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapCreate"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapname", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapuuid", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot restore output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing restore output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_restore (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; char *str_value = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapRestore"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "volname", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get vol name"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "volid", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get volume id"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapname", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapuuid", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot list output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing list output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_list (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; int i = 0; int snapcount = 0; char *str_value = NULL; char key[PATH_MAX] = ""; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapList"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, "snapcount", &snapcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snapcount"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "count", "%d", snapcount); XML_RET_CHECK_AND_GOTO (ret, out); for (i = 1; i <= snapcount; ++i) { ret = snprintf (key, sizeof (key), "snapname%d", i); if (ret < 0) { goto out; } ret = dict_get_str (dict, key, &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not get %s ", key); goto out; } else { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"snapshot", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); } } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate xml output for origin volume * of the given snapshot. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing info output * @param keyprefix prefix for dictionary key * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_info_orig_vol (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, char *keyprefix) { int ret = -1; int value = 0; char *buffer = NULL; char key [PATH_MAX] = ""; GF_ASSERT (dict); GF_ASSERT (keyprefix); GF_ASSERT (writer); GF_ASSERT (doc); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"originVolume"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%sorigin-volname", keyprefix); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_WARNING, "Failed to get %s", key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%ssnapcount", keyprefix); ret = dict_get_int32 (dict, key, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "snapCount", "%d", value); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%ssnaps-available", keyprefix); ret = dict_get_int32 (dict, key, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "snapRemaining", "%d", value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate xml output of snapshot volume info. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing info output * @param keyprefix key prefix for dictionary * @param snap_driven boolean to check if output is based of volume * or snapshot * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_info_snap_vol (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, char *keyprefix, gf_boolean_t snap_driven) { char key [PATH_MAX] = ""; char *buffer = NULL; int value = 0; int ret = -1; GF_ASSERT (dict); GF_ASSERT (keyprefix); GF_ASSERT (writer); GF_ASSERT (doc); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapVolume"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.volname", keyprefix); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.vol-status", keyprefix); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get %s", key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "status", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); /* If the command is snap_driven then we need to show origin volume * info. Else this is shown in the start of info display.*/ if (snap_driven) { snprintf (key, sizeof (key), "%s.", keyprefix); ret = cli_xml_snapshot_info_orig_vol (writer, doc, dict, key); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot's origin volume"); goto out; } } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot info of individual snapshot * in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing info output * @param keyprefix key prefix for dictionary * @param snap_driven boolean to check if output is based of volume * or snapshot * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_info_per_snap (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, char *keyprefix, gf_boolean_t snap_driven) { char key_buffer[PATH_MAX] = ""; char *buffer = NULL; int volcount = 0; int ret = -1; int i = 0; GF_ASSERT (dict); GF_ASSERT (keyprefix); GF_ASSERT (writer); GF_ASSERT (doc); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key_buffer, sizeof (key_buffer), "%s.snapname", keyprefix); ret = dict_get_str (dict, key_buffer, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to fetch snapname %s ", key_buffer); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key_buffer, sizeof (key_buffer), "%s.snap-id", keyprefix); ret = dict_get_str (dict, key_buffer, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to fetch snap-id %s ", key_buffer); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key_buffer, sizeof (key_buffer), "%s.snap-desc", keyprefix); ret = dict_get_str (dict, key_buffer, &buffer); if (!ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "description", "%s", buffer); } else { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "description", "%s", ""); } XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key_buffer, sizeof (key_buffer), "%s.snap-time", keyprefix); ret = dict_get_str (dict, key_buffer, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to fetch snap-time %s ", keyprefix); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "createTime", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key_buffer, sizeof (key_buffer), "%s.vol-count", keyprefix); ret = dict_get_int32 (dict, key_buffer, &volcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Fail to get snap vol count"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "volCount", "%d", volcount); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, key_buffer, &volcount); /* Display info of each snapshot volume */ for (i = 1 ; i <= volcount ; i++) { snprintf (key_buffer, sizeof (key_buffer), "%s.vol%d", keyprefix, i); ret = cli_xml_snapshot_info_snap_vol (writer, doc, dict, key_buffer, snap_driven); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not list " "details of volume in a snap"); goto out; } } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); out: return ret; } /* This function will generate snapshot info output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing info output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_info (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; int i = 0; int snapcount = 0; char key [PATH_MAX] = ""; char *str_value = NULL; gf_boolean_t snap_driven = _gf_false; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapInfo"); XML_RET_CHECK_AND_GOTO (ret, out); snap_driven = dict_get_str_boolean (dict, "snap-driven", _gf_false); /* If the approach is volume based then we should display orgin volume * information first followed by per snap info*/ if (!snap_driven) { ret = cli_xml_snapshot_info_orig_vol (writer, doc, dict, ""); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot's origin volume"); goto out; } } ret = dict_get_int32 (dict, "snapcount", &snapcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snapcount"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "count", "%d", snapcount); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshots"); XML_RET_CHECK_AND_GOTO (ret, out); /* Get snapshot info of individual snapshots */ for (i = 1; i <= snapcount; ++i) { snprintf (key, sizeof (key), "snap%d", i); ret = cli_xml_snapshot_info_per_snap (writer, doc, dict, key, snap_driven); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not get %s ", key); goto out; } } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot status of individual * snapshot volume in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing status output * @param keyprefix key prefix for dictionary * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, const char *keyprefix) { int ret = -1; int brickcount = 0; int i = 0; int value = 0; int pid = 0; char *buffer = NULL; char key[PATH_MAX] = ""; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); GF_ASSERT (keyprefix); snprintf (key, sizeof (key), "%s.brickcount", keyprefix); ret = dict_get_int32 (dict, key, &brickcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to fetch brickcount"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "brickCount", "%d", brickcount); XML_RET_CHECK_AND_GOTO (ret, out); /* Get status of every brick belonging to the snapshot volume */ for (i = 0 ; i < brickcount ; i++) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.brick%d.path", keyprefix, i); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_INFO, "Unable to get Brick Path"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "path", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.brick%d.vgname", keyprefix, i); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_INFO, "Unable to get Volume Group"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "volumeGroup", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.brick%d.status", keyprefix, i); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get Brick Running"); goto out; } snprintf (key, sizeof (key), "%s.brick%d.pid", keyprefix, i); ret = dict_get_int32 (dict, key, &pid); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get pid"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "pid", "%d", pid); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.brick%d.data", keyprefix, i); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get Data Percent"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "lvUsage", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.brick%d.lvsize", keyprefix, i); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_INFO, "Unable to get LV Size"); goto out; } /* Truncate any newline character */ buffer = strtok (buffer, "\n"); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "lvSize", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } out: return ret; } /* This function will generate snapshot status of individual * snapshot in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing status output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_status_per_snap (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, const char *keyprefix) { int ret = -1; int snapcount = 0; int volcount = 0; int i = 0; char *buffer = NULL; char key [PATH_MAX] = ""; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); GF_ASSERT (keyprefix); ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.snapname", keyprefix); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get snapname"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.uuid", keyprefix); ret = dict_get_str (dict, key, &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get snap UUID"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.volcount", keyprefix); ret = dict_get_int32 (dict, key, &volcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Unable to get volume count"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "volCount", "%d", volcount); XML_RET_CHECK_AND_GOTO (ret, out); /* Get snapshot status of individual snapshot volume */ for (i = 0 ; i < volcount ; i++) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (key, sizeof (key), "%s.vol%d", keyprefix, i); ret = cli_xml_snapshot_volume_status (writer, doc, dict, key); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not get snap volume status"); goto out; } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot status output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing status output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_status (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; int snapcount = 0; int i = 0; int status_cmd = 0; char *str_value = NULL; char key [PATH_MAX] = ""; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapStatus"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, "sub-cmd", &status_cmd); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch status type"); goto out; } if (GF_SNAP_STATUS_TYPE_SNAP == status_cmd) { snapcount = 1; } else { ret = dict_get_int32 (dict, "status.snapcount", &snapcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not get snapcount"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "count", "%d", snapcount); XML_RET_CHECK_AND_GOTO (ret, out); } for (i = 0 ; i < snapcount; i++) { snprintf (key, sizeof (key), "status.snap%d", i); ret = cli_xml_snapshot_status_per_snap (writer, doc, dict, key); if (ret < 0) { gf_log ("cli", GF_LOG_ERROR, "failed to create xml " "output for snapshot status"); goto out; } } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot config show output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing status output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_config_show (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; uint64_t i = 0; uint64_t value = 0; uint64_t volcount = 0; char buf[PATH_MAX] = ""; char *str_value = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"systemConfig"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_uint64 (dict, "snap-max-hard-limit", &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get " "snap-max-hard-limit"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "hardLimit", "%"PRIu64, value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_uint64 (dict, "snap-max-soft-limit", &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get " "snap-max-soft-limit"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "softLimit", "%"PRIu64"%%", value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "auto-delete", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch auto-delete"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "autoDelete", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snap-activate-on-create", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch snap-activate-on-create-delete"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "activateOnCreate", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volumeConfig"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_uint64 (dict, "voldisplaycount", &volcount); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch volcount"); goto out; } /* Get config of all the volumes */ for (i = 0; i < volcount; i++) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (buf, sizeof(buf), "volume%"PRIu64"-volname", i); ret = dict_get_str (dict, buf, &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch %s", buf); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (buf, sizeof(buf), "volume%"PRIu64"-snap-max-hard-limit", i); ret = dict_get_uint64 (dict, buf, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch %s", buf); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "hardLimit", "%"PRIu64, value); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (buf, sizeof(buf), "volume%"PRIu64"-active-hard-limit", i); ret = dict_get_uint64 (dict, buf, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch" " effective snap_max_hard_limit for " "%s", str_value); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "effectiveHardLimit", "%"PRIu64, value); XML_RET_CHECK_AND_GOTO (ret, out); snprintf (buf, sizeof(buf), "volume%"PRIu64"-snap-max-soft-limit", i); ret = dict_get_uint64 (dict, buf, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch %s", buf); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "softLimit", "%"PRIu64, value); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot config set output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing status output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_config_set (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; uint64_t hard_limit = 0; uint64_t soft_limit = 0; char *volname = NULL; char *auto_delete = NULL; char *snap_activate = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* This is optional parameter therefore ignore the error */ ret = dict_get_uint64 (dict, "snap-max-hard-limit", &hard_limit); /* This is optional parameter therefore ignore the error */ ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit); ret = dict_get_str (dict, "auto-delete", &auto_delete); ret = dict_get_str (dict, "snap-activate-on-create", &snap_activate); if (!hard_limit && !soft_limit && !auto_delete && !snap_activate) { ret = -1; gf_log ("cli", GF_LOG_ERROR, "At least one option from " "snap-max-hard-limit, snap-max-soft-limit, auto-delete" " and snap-activate-on-create should be set"); goto out; } /* Ignore the error, as volname is optional */ ret = dict_get_str (dict, "volname", &volname); if (NULL == volname) { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"systemConfig"); } else { /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volumeConfig"); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", volname); } XML_RET_CHECK_AND_GOTO (ret, out); if (hard_limit) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "newHardLimit", "%"PRIu64, hard_limit); XML_RET_CHECK_AND_GOTO (ret, out); } if (soft_limit) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "newSoftLimit", "%"PRIu64, soft_limit); XML_RET_CHECK_AND_GOTO (ret, out); } if (auto_delete) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "autoDelete", "%s", auto_delete); XML_RET_CHECK_AND_GOTO (ret, out); } if (snap_activate) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "activateOnCreate", "%s", snap_activate); XML_RET_CHECK_AND_GOTO (ret, out); } /* or */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot config output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing config output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_config (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict) { int ret = -1; int config_command = 0; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapConfig"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, "config-command", &config_command); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch config type"); goto out; } switch (config_command) { case GF_SNAP_CONFIG_TYPE_SET: ret = cli_xml_snapshot_config_set (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create xml " "output for snapshot config set command"); goto out; } break; case GF_SNAP_CONFIG_DISPLAY: ret = cli_xml_snapshot_config_show (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create xml " "output for snapshot config show command"); goto out; } break; default: gf_log ("cli", GF_LOG_ERROR, "Uknown config command :%d", config_command); ret = -1; goto out; } /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } /* This function will generate snapshot activate or * deactivate output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing activate or deactivate output * * @return 0 on success and -1 on failure */ static int cli_xml_snapshot_activate_deactivate (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, int cmd) { int ret = -1; char *buffer = NULL; char *tag = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); if (GF_SNAP_OPTION_TYPE_ACTIVATE == cmd) { tag = "snapActivate"; } else if (GF_SNAP_OPTION_TYPE_DEACTIVATE == cmd) { tag = "snapDeactivate"; } else { gf_log ("cli", GF_LOG_ERROR, "invalid command %d", cmd); goto out; } /* or */ ret = xmlTextWriterStartElement (writer, (xmlChar *)tag); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapname", &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapuuid", &buffer); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", buffer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); /* or */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); ret = 0; out: return ret; } #endif /* HAVE_LIB_XML */ /* This function will generate snapshot delete output in xml format. * * @param writer xmlTextWriterPtr * @param doc xmlDocPtr * @param dict dict containing delete output * @param rsp cli response * * @return 0 on success and -1 on failure */ int cli_xml_snapshot_delete (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict, gf_cli_rsp *rsp) { int ret = -1; #ifdef HAVE_LIB_XML char *str_value = NULL; GF_ASSERT (writer); GF_ASSERT (doc); GF_ASSERT (dict); /* */ ret = xmlTextWriterStartElement (writer, (xmlChar *)"snapshot"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_str (dict, "snapname", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap name"); goto xmlend; } if (!rsp->op_ret) { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "status", "Success"); XML_RET_CHECK_AND_GOTO (ret, xmlend); } else { ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "status", "Failure"); XML_RET_CHECK_AND_GOTO (ret, xmlend); ret = cli_xml_output_common (writer, rsp->op_ret, rsp->op_errno, rsp->op_errstr); XML_RET_CHECK_AND_GOTO (ret, xmlend); } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, xmlend); ret = dict_get_str (dict, "snapuuid", &str_value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto xmlend; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); xmlend: /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); #endif /* HAVE_LIB_XML */ ret = 0; out: return ret; } int cli_xml_output_snap_status_begin (cli_local_t *local, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; GF_ASSERT (local); ret = cli_begin_xml_output (&(local->writer), &(local->doc)); XML_RET_CHECK_AND_GOTO (ret, out); ret = cli_xml_output_common (local->writer, op_ret, op_errno, op_errstr); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *) "snapStatus"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"snapshots"); XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_snap_status_end (cli_local_t *local) { #if (HAVE_LIB_XML) int ret = -1; GF_ASSERT (local); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO(ret, out); ret = cli_end_xml_output (local->writer, local->doc); out: gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_snap_delete_begin (cli_local_t *local, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; int delete_cmd = -1; GF_ASSERT (local); ret = cli_begin_xml_output (&(local->writer), &(local->doc)); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (local->dict, "sub-cmd", &delete_cmd); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get sub-cmd"); goto out; } ret = cli_xml_output_common (local->writer, op_ret, op_errno, op_errstr); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *) "snapDelete"); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"snapshots"); XML_RET_CHECK_AND_GOTO (ret, out); out: gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); return ret; #else return 0; #endif } int cli_xml_output_snap_delete_end (cli_local_t *local) { #if (HAVE_LIB_XML) int ret = -1; GF_ASSERT (local); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO(ret, out); ret = cli_end_xml_output (local->writer, local->doc); out: gf_log ("cli", GF_LOG_TRACE, "Returning %d", ret); return ret; #else return 0; #endif } /* This function will generate xml output for all the snapshot commands * * @param cmd_type command type * @param dict dict containing snapshot command output * @param op_ret return value of the snapshot command * @param op_errno errno for the snapshot command * @param op_errstr error string for the snapshot command * * @return 0 on success and -1 on failure */ int cli_xml_output_snapshot (int cmd_type, dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int ret = -1; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; GF_ASSERT (dict); ret = cli_begin_xml_output (&writer, &doc); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to output " "xml begin block"); goto out; } ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to output " "xml common block"); goto out; } /* In case of command failure just printing the error message is good * enough */ if (0 != op_ret) { goto end; } switch (cmd_type) { case GF_SNAP_OPTION_TYPE_CREATE: ret = cli_xml_snapshot_create (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot create command"); goto out; } break; case GF_SNAP_OPTION_TYPE_RESTORE: ret = cli_xml_snapshot_restore (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot restore command"); goto out; } break; case GF_SNAP_OPTION_TYPE_LIST: ret = cli_xml_snapshot_list (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot list command"); goto out; } break; case GF_SNAP_OPTION_TYPE_STATUS: ret = cli_xml_snapshot_status (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create" "xml output for snapshot status command"); goto out; } break; case GF_SNAP_OPTION_TYPE_INFO: ret = cli_xml_snapshot_info (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot info command"); goto out; } break; case GF_SNAP_OPTION_TYPE_ACTIVATE: case GF_SNAP_OPTION_TYPE_DEACTIVATE: ret = cli_xml_snapshot_activate_deactivate (writer, doc, dict, cmd_type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot config command"); } break; case GF_SNAP_OPTION_TYPE_CONFIG: ret = cli_xml_snapshot_config (writer, doc, dict); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to create " "xml output for snapshot config command"); } break; default: gf_log ("cli", GF_LOG_ERROR, "Unexpected snapshot command: %d", cmd_type); goto out; } end: ret = cli_end_xml_output (writer, doc); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to output " "xml end block"); goto out; } ret = 0; out: return ret; #else return 0; #endif /* HAVE_LIB_XML */ } int cli_xml_snapshot_begin_composite_op (cli_local_t *local) { int ret = -1; #ifdef HAVE_LIB_XML int cmd = -1; int type = -1; ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get " "sub-cmd"); ret = 0; goto out; } if (cmd == GF_SNAP_STATUS_TYPE_SNAP || cmd == GF_SNAP_DELETE_TYPE_SNAP){ ret = 0; goto out; } ret = dict_get_int32 (local->dict, "type", &type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snapshot " "command type from dictionary"); goto out; } if (GF_SNAP_OPTION_TYPE_STATUS == type) ret = cli_xml_output_snap_status_begin (local, 0, 0, NULL); else if (GF_SNAP_OPTION_TYPE_DELETE == type) ret = cli_xml_output_snap_delete_begin (local, 0, 0, NULL); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Error creating xml output"); goto out; } #endif /* HAVE_LIB_XML */ ret = 0; out: return ret; } int cli_xml_snapshot_end_composite_op (cli_local_t *local) { int ret = -1; #ifdef HAVE_LIB_XML int cmd = -1; int type = -1; ret = dict_get_int32 (local->dict, "sub-cmd", &cmd); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get " "sub-cmd"); ret = 0; goto out; } if (cmd == GF_SNAP_STATUS_TYPE_SNAP || cmd == GF_SNAP_DELETE_TYPE_SNAP){ ret = 0; goto out; } ret = dict_get_int32 (local->dict, "type", &type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get snapshot " "command type from dictionary"); goto out; } if (GF_SNAP_OPTION_TYPE_STATUS == type) ret = cli_xml_output_snap_status_end (local); else if (GF_SNAP_OPTION_TYPE_DELETE == type) ret = cli_xml_output_snap_delete_end (local); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Error creating xml " "output"); goto out; } #endif /* HAVE_LIB_XML */ ret = 0; out: return ret; } int cli_xml_snapshot_status_single_snap (cli_local_t *local, dict_t *dict, char *key) { #if (HAVE_LIB_XML) int ret = -1; GF_VALIDATE_OR_GOTO ("cli", (local != NULL), out); GF_VALIDATE_OR_GOTO ("cli", (dict != NULL), out); GF_VALIDATE_OR_GOTO ("cli", (key != NULL), out); ret = cli_xml_snapshot_status_per_snap (local->writer, local->doc, dict, key); out: return ret; #else return 0; #endif /* HAVE_LIB_XML */ } int cli_xml_output_vol_getopts (dict_t *dict, int op_ret, int op_errno, char *op_errstr) { #if (HAVE_LIB_XML) int i = 0; int ret = -1; int count = 0; xmlTextWriterPtr writer = NULL; xmlDocPtr doc = NULL; char *key = NULL; char *value = NULL; char dict_key[50] = {0,}; ret = cli_begin_xml_output (&writer, &doc); if (ret) goto out; ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); if (ret) goto out; ret = xmlTextWriterStartElement (writer, (xmlChar *)"volGetopts"); XML_RET_CHECK_AND_GOTO (ret, out); ret = dict_get_int32 (dict, "count", &count); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to retrieve count " "from the dictionary"); goto out; } if (count <= 0) { gf_log ("cli", GF_LOG_ERROR, "Value of count :%d is " "invalid", count); ret = -1; goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"count", "%d", count); XML_RET_CHECK_AND_GOTO (ret, out); for (i=1; i<=count; i++) { sprintf (dict_key, "key%d", i); ret = dict_get_str (dict, dict_key, &key); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to" " retrieve %s from the " "dictionary", dict_key); goto out; } sprintf (dict_key, "value%d", i); ret = dict_get_str (dict, dict_key, &value); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to " "retrieve key value for %s from" "the dictionary", dict_key); goto out; } ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"Option", "%s", key); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"Value", "%s", value); XML_RET_CHECK_AND_GOTO (ret, out); } ret = cli_end_xml_output (writer, doc); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; #else return 0; #endif /* HAVE_LIB_XML */ } int cli_quota_list_xml_error (cli_local_t *local, char *path, char *errstr) { #if (HAVE_LIB_XML) int ret = -1; ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"limit"); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"path", "%s", path); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"errstr", "%s", errstr); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); out: return ret; #else return 0; #endif } int cli_quota_xml_output (cli_local_t *local, char *path, int64_t hl_str, char *sl_final, int64_t sl_num, int64_t used, int64_t avail, char *sl, char *hl) { #if (HAVE_LIB_XML) int ret = -1; ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"limit"); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"path", "%s", path); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hard_limit", "%"PRIu64, hl_str); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"soft_limit_percent", "%s", sl_final); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"soft_limit_value", "%"PRIu64, sl_num); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"used_space", "%"PRIu64, used); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"avail_space", "%"PRIu64, avail); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"sl_exceeded", "%s", sl); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hl_exceeded", "%s", hl); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); out: return ret; #else return 0; #endif /* HAVE_LIB_XML */ } int cli_quota_object_xml_output (cli_local_t *local, char *path, char *sl_str, int64_t sl_val, quota_limits_t *limits, quota_meta_t *used_space, int64_t avail, char *sl, char *hl) { #if (HAVE_LIB_XML) int ret = -1; ret = xmlTextWriterStartElement (local->writer, (xmlChar *)"limit"); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"path", "%s", path); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hard_limit", "%"PRIu64, limits->hl); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"soft_limit_percent", "%s", sl_str); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"soft_limit_value", "%"PRIu64, sl_val); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"file_count", "%"PRIu64, used_space->file_count); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"dir_count", "%"PRIu64, used_space->dir_count); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"available", "%"PRIu64, avail); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"sl_exceeded", "%s", sl); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"hl_exceeded", "%s", hl); XML_RET_CHECK_AND_GOTO (ret, out); ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); out: return ret; #else return 0; #endif /* HAVE_LIB_XML */ } glusterfs-3.7.6/cli/src/PaxHeaders.7244/cli-cmd-volume.c0000644000076200007630000000013212617742532021051 xustar000000000000000030 mtime=1447019866.016471856 30 atime=1447019866.361466665 30 ctime=1447019947.510245839 glusterfs-3.7.6/cli/src/cli-cmd-volume.c0000644000076200007630000026001612617742532021273 0ustar00jenkinsjenkins00000000000000/* Copyright (c) 2010-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #include #include #include #include #include #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include "cli.h" #include "cli-cmd.h" #include "cli-mem-types.h" #include "cli1-xdr.h" #include "run.h" #include "syscall.h" #include "common-utils.h" extern struct rpc_clnt *global_rpc; extern struct rpc_clnt *global_quotad_rpc; extern rpc_clnt_prog_t *cli_rpc_prog; extern rpc_clnt_prog_t cli_quotad_clnt; int cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); int cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; cli_cmd_volume_get_ctx_t ctx = {0,}; cli_local_t *local = NULL; int sent = 0; int parse_error = 0; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if ((wordcount == 2) || (wordcount == 3 && !strcmp (words[2], "all"))) { ctx.flags = GF_CLI_GET_NEXT_VOLUME; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_NEXT_VOLUME]; } else if (wordcount == 3) { ctx.flags = GF_CLI_GET_VOLUME; ctx.volname = (char *)words[2]; if (strlen (ctx.volname) > GD_VOLUME_NAME_MAX) { cli_out ("Invalid volume name"); goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOLUME]; } else { cli_usage_out (word->pattern); parse_error = 1; return -1; } local = cli_local_get (); if (!local) goto out; local->get_vol.flags = ctx.flags; if (ctx.volname) local->get_vol.volname = gf_strdup (ctx.volname); frame->local = local; if (proc->fn) { ret = proc->fn (frame, THIS, &ctx); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Getting Volume information failed!"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int sent = 0; int parse_error = 0; dict_t *dict = NULL; cli_local_t *local = NULL; gf_answer_t answer = GF_ANSWER_NO; const char *question = "Sync volume may make data " "inaccessible while the sync " "is in progress. Do you want " "to continue?"; if ((wordcount < 3) || (wordcount > 4)) { cli_usage_out (word->pattern); parse_error = 1; goto out; } dict = dict_new (); if (!dict) goto out; if ((wordcount == 3) || !strcmp(words[3], "all")) { ret = dict_set_int32 (dict, "flags", (int32_t) GF_CLI_SYNC_ALL); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "failed to set" "flag"); goto out; } } else { ret = dict_set_str (dict, "volname", (char *) words[3]); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "failed to set " "volume"); goto out; } } ret = dict_set_str (dict, "hostname", (char *) words[2]); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "failed to set hostname"); goto out; } if (!(state->mode & GLUSTER_MODE_SCRIPT)) { answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYNC_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume sync failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; char *brick_list = NULL; int32_t brick_count = 0; int32_t sub_count = 0; int32_t type = GF_CLUSTER_TYPE_NONE; cli_local_t *local = NULL; char *trans_type = NULL; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_CREATE_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_create_parse (state, words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_get_str (options, "transport", &trans_type); if (ret) { gf_log("cli", GF_LOG_ERROR, "Unable to get transport type"); goto out; } if (state->mode & GLUSTER_MODE_WIGNORE) { ret = dict_set_int32 (options, "force", _gf_true); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set force " "option"); goto out; } } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume create failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; char *volname = NULL; gf_answer_t answer = GF_ANSWER_NO; const char *question = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; dict_t *dict = NULL; question = "Deleting volume will erase all information about the volume. " "Do you want to continue?"; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DELETE_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; if (wordcount != 3) { cli_usage_out (word->pattern); parse_error = 1; goto out; } volname = (char *)words[2]; ret = dict_set_str (dict, "volname", volname); if (ret) { gf_log (THIS->name, GF_LOG_WARNING, "dict set failed"); goto out; } if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { question = "Deleting the shared storage volume" "(gluster_shared_storage), will affect features " "like snapshot scheduler, geo-replication " "and NFS-Ganesha. Do you still want to " "continue?"; } answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume delete failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int sent = 0; int parse_error = 0; dict_t *dict = NULL; int flags = 0; cli_local_t *local = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if (wordcount < 3 || wordcount > 4) { cli_usage_out (word->pattern); parse_error = 1; goto out; } dict = dict_new (); if (!dict) { goto out; } if (!words[2]) goto out; ret = dict_set_str (dict, "volname", (char *)words[2]); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "dict set failed"); goto out; } if (wordcount == 4) { if (!strcmp("force", words[3])) { flags |= GF_CLI_FLAG_OP_FORCE; } else { ret = -1; cli_usage_out (word->pattern); parse_error = 1; goto out; } } ret = dict_set_int32 (dict, "flags", flags); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "dict set failed"); goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_START_VOLUME]; CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume start failed"); } CLI_STACK_DESTROY (frame); return ret; } gf_answer_t cli_cmd_get_confirmation (struct cli_state *state, const char *question) { char answer[5] = {'\0', }; char flush = '\0'; size_t len; if (state->mode & GLUSTER_MODE_SCRIPT) return GF_ANSWER_YES; printf ("%s (y/n) ", question); if (fgets (answer, 4, stdin) == NULL) { cli_out("gluster cli read error"); goto out; } len = strlen (answer); if (len && answer [len - 1] == '\n'){ answer [--len] = '\0'; } else { do{ flush = getchar (); }while (flush != '\n'); } if (len > 3) goto out; if (!strcasecmp (answer, "y") || !strcasecmp (answer, "yes")) return GF_ANSWER_YES; else if (!strcasecmp (answer, "n") || !strcasecmp (answer, "no")) return GF_ANSWER_NO; out: cli_out ("Invalid input, please enter y/n"); return GF_ANSWER_NO; } int cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int flags = 0; gf_answer_t answer = GF_ANSWER_NO; int sent = 0; int parse_error = 0; dict_t *dict = NULL; char *volname = NULL; cli_local_t *local = NULL; const char *question = "Stopping volume will make its data inaccessible. " "Do you want to continue?"; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if (wordcount < 3 || wordcount > 4) { cli_usage_out (word->pattern); parse_error = 1; goto out; } volname = (char*) words[2]; dict = dict_new (); ret = dict_set_str (dict, "volname", volname); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "dict set failed"); goto out; } if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { question = "Stopping the shared storage volume" "(gluster_shared_storage), will affect features " "like snapshot scheduler, geo-replication " "and NFS-Ganesha. Do you still want to " "continue?"; } if (wordcount == 4) { if (!strcmp("force", words[3])) { flags |= GF_CLI_FLAG_OP_FORCE; } else { ret = -1; cli_usage_out (word->pattern); parse_error = 1; goto out; } } ret = dict_set_int32 (dict, "flags", flags); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "dict set failed"); goto out; } answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STOP_VOLUME]; CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume stop on '%s' failed", volname); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; int sent = 0; int parse_error = 0; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; if (wordcount != 4) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_set_str (dict, "old-volname", (char *)words[2]); if (ret) goto out; ret = dict_set_str (dict, "new-volname", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RENAME_VOLUME]; if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (dict) dict_destroy (dict); if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume rename on '%s' failed", (char *)words[2]); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; #ifdef GF_SOLARIS_HOST_OS cli_out ("Command not supported on Solaris"); goto out; #endif frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_defrag_parse (words, wordcount, &dict); if (ret) { cli_usage_out (word->pattern); parse_error = 1; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEFRAG_VOLUME]; CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume rebalance failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int sent = 0; int parse_error = 0; int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; cli_local_t *local = NULL; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RESET_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_reset_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume reset failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_profile_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int sent = 0; int parse_error = 0; int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; cli_local_t *local = NULL; ret = cli_cmd_volume_profile_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROFILE_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume profile failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int sent = 0; int parse_error = 0; int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; cli_local_t *local = NULL; char *op_errstr = NULL; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SET_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_set_parse (state, words, wordcount, &options, &op_errstr); if (ret) { if (op_errstr) { cli_err ("%s", op_errstr); GF_FREE (op_errstr); } else cli_usage_out (word->pattern); parse_error = 1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume set failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_add_brick_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; gf_answer_t answer = GF_ANSWER_NO; cli_local_t *local = NULL; const char *question = "Changing the 'stripe count' of the volume is " "not a supported feature. In some cases it may result in data " "loss on the volume. Also there may be issues with regular " "filesystem operations on the volume after the change. Do you " "really want to continue with 'stripe' count option ? "; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options, 0); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } /* TODO: there are challenges in supporting changing of stripe-count, until it is properly supported give warning to user */ if (dict_get (options, "stripe-count")) { answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } } if (state->mode & GLUSTER_MODE_WIGNORE) { ret = dict_set_int32 (options, "force", _gf_true); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set force " "option"); goto out; } } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ADD_BRICK]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume add-brick failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_tier_validate_replica_type (dict_t *dict, int type) { int brick_count = -1; int replica_count = 1; int ret = -1; ret = dict_get_int32 (dict, "count", &brick_count); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get brick count"); goto out; } ret = dict_get_int32 (dict, "replica-count", &replica_count); if (ret) { gf_log ("cli", GF_LOG_DEBUG, "Failed to get replica count. " "Defaulting to one"); replica_count = 1; } /* * Change the calculation of sub_count once attach-tier support * disperse volume. * sub_count = disperse_count for disperse volume * */ if (brick_count % replica_count) { if (type == GF_CLUSTER_TYPE_REPLICATE) cli_err ("number of bricks is not a multiple of " "replica count"); else if (type == GF_CLUSTER_TYPE_DISPERSE) cli_err ("number of bricks is not a multiple of " "disperse count"); else cli_err ("number of bricks given doesn't match " "required count"); ret = -1; goto out; } ret = 0; out: return ret; } int do_cli_cmd_volume_attach_tier (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; int type = 0; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options, &type); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } /* * Merge this check when attach-tier has it's own cli parse function. */ ret = cli_tier_validate_replica_type (options, type); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } if (state->mode & GLUSTER_MODE_WIGNORE) { ret = dict_set_int32 (options, "force", _gf_true); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set force " "option"); goto out; } } ret = dict_set_int32 (options, "attach-tier", 1); if (ret) goto out; ret = dict_set_int32 (options, "hot-type", type); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ATTACH_TIER]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("attach-tier failed"); } CLI_STACK_DESTROY (frame); return ret; } int do_cli_cmd_volume_detach_tier (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; gf_answer_t answer = GF_ANSWER_NO; cli_local_t *local = NULL; int need_question = 0; const char *question = "Removing tier can result in data loss. " "Do you want to Continue?"; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_detach_tier_parse(words, wordcount, &options, &need_question); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_set_int32 (options, "force", 1); if (ret) goto out; ret = dict_set_int32 (options, "count", 0); if (ret) goto out; if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { /* we need to ask question only in case of 'commit or force' */ answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DETACH_TIER]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume detach-tier failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_tier_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; call_frame_t *frame = NULL; dict_t *options = NULL; char *volname = NULL; rpc_clnt_procedure_t *proc = NULL; cli_local_t *local = NULL; int i = 0; if (wordcount < 4) { cli_usage_out (word->pattern); if (wordcount == 3 && !strcmp(words[2], "help")) ret = 0; goto out; } if (!strcmp(words[1], "detach-tier")) { ret = do_cli_cmd_volume_detach_tier (state, word, words, wordcount); goto out; } else if (!strcmp(words[3], "detach")) { for (i = 3; i < wordcount; i++) words[i] = words[i+1]; ret = do_cli_cmd_volume_detach_tier (state, word, words, wordcount-1); goto out; } else if (!strcmp(words[1], "attach-tier")) { ret = do_cli_cmd_volume_attach_tier (state, word, words, wordcount); goto out; } else if (!strcmp(words[3], "attach")) { for (i = 3; i < wordcount; i++) words[i] = words[i+1]; ret = do_cli_cmd_volume_attach_tier (state, word, words, wordcount-1); goto out; } ret = cli_cmd_volume_tier_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TIER]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_out ("Tier command failed"); } if (options) dict_unref (options); return ret; } static int gf_cli_create_auxiliary_mount (char *volname) { int ret = -1; char mountdir[PATH_MAX] = {0,}; char pidfile_path[PATH_MAX] = {0,}; char logfile[PATH_MAX] = {0,}; char qpid [16] = {0,}; GLUSTERFS_GET_AUX_MOUNT_PIDFILE (pidfile_path, volname); if (gf_is_service_running (pidfile_path, NULL)) { gf_log ("cli", GF_LOG_DEBUG, "Aux mount of volume %s is running" " already", volname); ret = 0; goto out; } GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volname, "/"); ret = mkdir (mountdir, 0777); if (ret && errno != EEXIST) { gf_log ("cli", GF_LOG_ERROR, "Failed to create auxiliary mount " "directory %s. Reason : %s", mountdir, strerror (errno)); goto out; } snprintf (logfile, PATH_MAX-1, "%s/quota-mount-%s.log", DEFAULT_LOG_FILE_DIRECTORY, volname); snprintf(qpid, 15, "%d", GF_CLIENT_PID_QUOTA_MOUNT); ret = runcmd (SBIN_DIR"/glusterfs", "-s", "localhost", "--volfile-id", volname, "-l", logfile, "-p", pidfile_path, "--client-pid", qpid, mountdir, NULL); if (ret) { gf_log ("cli", GF_LOG_WARNING, "failed to mount glusterfs " "client. Please check the log file %s for more details", logfile); ret = -1; goto out; } ret = 0; out: return ret; } static int cli_stage_quota_op (char *volname, int op_code) { int ret = -1; switch (op_code) { case GF_QUOTA_OPTION_TYPE_ENABLE: case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE: case GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS: case GF_QUOTA_OPTION_TYPE_REMOVE: case GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS: case GF_QUOTA_OPTION_TYPE_LIST: ret = gf_cli_create_auxiliary_mount (volname); if (ret) { cli_err ("quota: Could not start quota " "auxiliary mount"); goto out; } ret = 0; break; default: ret = 0; break; } out: return ret; } int cli_get_soft_limit (dict_t *options, const char **words, dict_t *xdata) { call_frame_t *frame = NULL; cli_local_t *local = NULL; rpc_clnt_procedure_t *proc = NULL; char *default_sl = NULL; char *default_sl_dup = NULL; int ret = -1; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) { ret = -1; goto out; } //We need a ref on @options to prevent CLI_STACK_DESTROY //from destroying it prematurely. dict_ref (options); CLI_LOCAL_INIT (local, words, frame, options); proc = &cli_rpc_prog->proctable[GLUSTER_CLI_QUOTA]; ret = proc->fn (frame, THIS, options); ret = dict_get_str (options, "default-soft-limit", &default_sl); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get default soft limit"); goto out; } default_sl_dup = gf_strdup (default_sl); if (!default_sl_dup) { ret = -1; goto out; } ret = dict_set_dynstr (xdata, "default-soft-limit", default_sl_dup); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set default soft limit"); GF_FREE (default_sl_dup); goto out; } out: CLI_STACK_DESTROY (frame); return ret; } /* Checks if at least one limit has been set on the volume * * Returns true if at least one limit is set. Returns false otherwise. */ gf_boolean_t _limits_set_on_volume (char *volname, int type) { gf_boolean_t limits_set = _gf_false; int ret = -1; char quota_conf_file[PATH_MAX] = {0,}; int fd = -1; char buf[16] = {0,}; float version = 0.0f; char gfid_type_stored = 0; char gfid_type = 0; /* TODO: fix hardcoding; Need to perform an RPC call to glusterd * to fetch working directory */ sprintf (quota_conf_file, "%s/vols/%s/quota.conf", GLUSTERD_DEFAULT_WORKDIR, volname); fd = open (quota_conf_file, O_RDONLY); if (fd == -1) goto out; ret = quota_conf_read_version (fd, &version); if (ret) goto out; if (type == GF_QUOTA_OPTION_TYPE_LIST) gfid_type = GF_QUOTA_CONF_TYPE_USAGE; else gfid_type = GF_QUOTA_CONF_TYPE_OBJECTS; /* Try to read atleast one gfid of type 'gfid_type' */ while (1) { ret = quota_conf_read_gfid (fd, buf, &gfid_type_stored, version); if (ret <= 0) break; if (gfid_type_stored == gfid_type) { limits_set = _gf_true; break; } } out: if (fd != -1) close (fd); return limits_set; } /* Checks if the mount is connected to the bricks * * Returns true if connected and false if not */ gf_boolean_t _quota_aux_mount_online (char *volname) { int ret = 0; char mount_path[PATH_MAX + 1] = {0,}; struct stat buf = {0,}; GF_ASSERT (volname); /* Try to create the aux mount before checking if bricks are online */ ret = gf_cli_create_auxiliary_mount (volname); if (ret) { cli_err ("quota: Could not start quota auxiliary mount"); return _gf_false; } GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mount_path, volname, "/"); ret = sys_stat (mount_path, &buf); if (ret) { if (ENOTCONN == errno) { cli_err ("quota: Cannot connect to bricks. Check if " "bricks are online."); } else { cli_err ("quota: Error on quota auxiliary mount (%s).", strerror (errno)); } return _gf_false; } return _gf_true; } int cli_cmd_quota_handle_list_all (const char **words, dict_t *options) { int all_failed = 1; int count = 0; int ret = -1; rpc_clnt_procedure_t *proc = NULL; cli_local_t *local = NULL; call_frame_t *frame = NULL; dict_t *xdata = NULL; char *gfid_str = NULL; char *volname = NULL; char *volname_dup = NULL; unsigned char buf[16] = {0}; int fd = -1; char quota_conf_file[PATH_MAX] = {0}; gf_boolean_t xml_err_flag = _gf_false; char err_str[NAME_MAX] = {0,}; int32_t type = 0; char gfid_type = 0; float version = 0.0f; xdata = dict_new (); if (!xdata) { ret = -1; goto out; } ret = dict_get_str (options, "volname", &volname); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get volume name"); goto out; } ret = dict_get_int32 (options, "type", &type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get quota option type"); goto out; } ret = dict_set_int32 (xdata, "type", type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set type in xdata"); goto out; } ret = cli_get_soft_limit (options, words, xdata); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to fetch default " "soft-limit"); goto out; } /* Check if at least one limit is set on volume. No need to check for * quota enabled as cli_get_soft_limit() handles that */ if (!_limits_set_on_volume (volname, type)) { snprintf (err_str, sizeof (err_str), "No%s quota configured on" " volume %s", (type == GF_QUOTA_OPTION_TYPE_LIST) ? "" : " inode", volname); if (global_state->mode & GLUSTER_MODE_XML) { xml_err_flag = _gf_true; } else { cli_out ("quota: %s", err_str); } ret = 0; goto out; } /* Check if the mount is online before doing any listing */ if (!_quota_aux_mount_online (volname)) { ret = -1; goto out; } frame = create_frame (THIS, THIS->ctx->pool); if (!frame) { ret = -1; goto out; } volname_dup = gf_strdup (volname); if (!volname_dup) { ret = -1; goto out; } ret = dict_set_dynstr (xdata, "volume-uuid", volname_dup); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set volume-uuid"); GF_FREE (volname_dup); goto out; } //TODO: fix hardcoding; Need to perform an RPC call to glusterd //to fetch working directory sprintf (quota_conf_file, "%s/vols/%s/quota.conf", GLUSTERD_DEFAULT_WORKDIR, volname); fd = open (quota_conf_file, O_RDONLY); if (fd == -1) { //This may because no limits were yet set on the volume gf_log ("cli", GF_LOG_TRACE, "Unable to open " "quota.conf"); ret = 0; goto out; } ret = quota_conf_read_version (fd, &version); if (ret) goto out; CLI_LOCAL_INIT (local, words, frame, xdata); proc = &cli_quotad_clnt.proctable[GF_AGGREGATOR_GETLIMIT]; gfid_str = GF_CALLOC (1, gf_common_mt_char, 64); if (!gfid_str) { ret = -1; goto out; } for (count = 0;; count++) { ret = quota_conf_read_gfid (fd, buf, &gfid_type, version); if (ret == 0) { break; } else if (ret < 0) { gf_log (THIS->name, GF_LOG_CRITICAL, "Quota " "configuration store may be corrupt."); goto out; } if ((type == GF_QUOTA_OPTION_TYPE_LIST && gfid_type == GF_QUOTA_CONF_TYPE_OBJECTS) || (type == GF_QUOTA_OPTION_TYPE_LIST_OBJECTS && gfid_type == GF_QUOTA_CONF_TYPE_USAGE)) continue; uuid_utoa_r (buf, gfid_str); ret = dict_set_str (xdata, "gfid", gfid_str); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set gfid"); goto out; } ret = proc->fn (frame, THIS, xdata); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get quota " "limits for %s", uuid_utoa ((unsigned char*)buf)); } dict_del (xdata, "gfid"); all_failed = all_failed && ret; } if (global_state->mode & GLUSTER_MODE_XML) { ret = cli_xml_output_vol_quota_limit_list_end (local); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Error in printing " "xml output"); goto out; } } if (count > 0) { ret = all_failed? -1: 0; } else { ret = 0; } out: if (xml_err_flag) { ret = cli_xml_output_str ("volQuota", NULL, -1, 0, err_str); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Error outputting in " "xml format"); } } if (fd != -1) { close (fd); } GF_FREE (gfid_str); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Could not fetch and display quota" " limits"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; int parse_err = 0; call_frame_t *frame = NULL; dict_t *options = NULL; cli_local_t *local = NULL; rpc_clnt_procedure_t *proc = NULL; int sent = 0; ret = cli_cmd_bitrot_parse (words, wordcount, &options); if (ret < 0) { cli_usage_out (word->pattern); parse_err = 1; goto out; } frame = create_frame (THIS, THIS->ctx->pool); if (!frame) { ret = -1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_BITROT]; if (proc == NULL) { ret = -1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_err == 0)) cli_err ("Bit rot command failed. Please check the cli " "logs for more details"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = 0; int parse_err = 0; int32_t type = 0; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; gf_answer_t answer = GF_ANSWER_NO; cli_local_t *local = NULL; int sent = 0; char *volname = NULL; const char *question = "Disabling quota will delete all the quota " "configuration. Do you want to continue?"; //parse **words into options dictionary if (strcmp (words[1], "inode-quota") == 0) { ret = cli_cmd_inode_quota_parse (words, wordcount, &options); if (ret < 0) { cli_usage_out (word->pattern); parse_err = 1; goto out; } } else { ret = cli_cmd_quota_parse (words, wordcount, &options); if (ret < 0) { cli_usage_out (word->pattern); parse_err = 1; goto out; } } ret = dict_get_int32 (options, "type", &type); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get opcode"); goto out; } //handle quota-disable and quota-list-all different from others switch (type) { case GF_QUOTA_OPTION_TYPE_DISABLE: answer = cli_cmd_get_confirmation (state, question); if (answer == GF_ANSWER_NO) goto out; break; case GF_QUOTA_OPTION_TYPE_LIST: case GF_QUOTA_OPTION_TYPE_LIST_OBJECTS: if (wordcount != 4) break; ret = cli_cmd_quota_handle_list_all (words, options); goto out; default: break; } ret = dict_get_str (options, "volname", &volname); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to get volume name"); goto out; } //create auxiliary mount need for quota commands that operate on path ret = cli_stage_quota_op (volname, type); if (ret) goto out; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) { ret = -1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); proc = &cli_rpc_prog->proctable[GLUSTER_CLI_QUOTA]; if (proc->fn) ret = proc->fn (frame, THIS, options); out: if (ret) { cli_cmd_sent_status_get (&sent); if (sent == 0 && parse_err == 0) cli_out ("Quota command failed. Please check the cli " "logs for more details"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_remove_brick_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; gf_answer_t answer = GF_ANSWER_NO; int sent = 0; int parse_error = 0; int need_question = 0; cli_local_t *local = NULL; char *volname = NULL; const char *question = "Removing brick(s) can result in data loss. " "Do you want to Continue?"; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options, &need_question); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_get_str (options, "volname", &volname); if (ret || !volname) { gf_log ("cli", GF_LOG_ERROR, "Failed to fetch volname"); ret = -1; goto out; } if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) { question = "Removing brick from the shared storage volume" "(gluster_shared_storage), will affect features " "like snapshot scheduler, geo-replication " "and NFS-Ganesha. Do you still want to " "continue?"; need_question = _gf_true; } if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) { /* we need to ask question only in case of 'commit or force' */ answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { ret = 0; goto out; } } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_REMOVE_BRICK]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume remove-brick failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_replace_brick_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; #ifdef GF_SOLARIS_HOST_OS cli_out ("Command not supported on Solaris"); goto out; #endif proc = &cli_rpc_prog->proctable[GLUSTER_CLI_REPLACE_BRICK]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_volume_replace_brick_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume replace-brick failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_set_transport_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { cli_cmd_broadcast_response (0); return 0; } int cli_cmd_volume_top_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; ret = cli_cmd_volume_top_parse (words, wordcount, &options); if (ret) { parse_error = 1; cli_usage_out (word->pattern); goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TOP_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume top failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_log_rotate_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; if (!((wordcount == 4) || (wordcount == 5))) { cli_usage_out (word->pattern); parse_error = 1; goto out; } if (!((strcmp ("rotate", words[2]) == 0) || (strcmp ("rotate", words[3]) == 0))) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LOG_ROTATE]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; ret = cli_cmd_log_rotate_parse (words, wordcount, &options); if (ret) goto out; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume log rotate failed"); } CLI_STACK_DESTROY (frame); return ret; } #if (SYNCDAEMON_COMPILE) static int cli_check_gsync_present () { char buff[PATH_MAX] = {0, }; runner_t runner = {0,}; char *ptr = NULL; int ret = 0; ret = setenv ("_GLUSTERD_CALLED_", "1", 1); if (-1 == ret) { gf_log ("", GF_LOG_WARNING, "setenv syscall failed, hence could" "not assert if geo-replication is installed"); goto out; } runinit (&runner); runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--version", NULL); runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); ret = runner_start (&runner); if (ret == -1) { gf_log ("", GF_LOG_INFO, "geo-replication not installed"); goto out; } ptr = fgets(buff, sizeof(buff), runner_chio (&runner, STDOUT_FILENO)); if (ptr) { if (!strstr (buff, "gsyncd")) { ret = -1; goto out; } } else { ret = -1; goto out; } ret = runner_end (&runner); if (ret) gf_log ("", GF_LOG_ERROR, "geo-replication not installed"); out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret ? -1 : 0; } void cli_cmd_check_gsync_exists_cbk (struct cli_cmd *this) { int ret = 0; ret = cli_check_gsync_present (); if (ret) this->disable = _gf_true; } #endif int cli_cmd_volume_gsync_set_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = 0; int parse_err = 0; dict_t *options = NULL; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; cli_local_t *local = NULL; proc = &cli_rpc_prog->proctable [GLUSTER_CLI_GSYNC_SET]; frame = create_frame (THIS, THIS->ctx->pool); if (frame == NULL) { ret = -1; goto out; } ret = cli_cmd_gsync_set_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_err = 1; goto out; } CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) ret = proc->fn (frame, THIS, options); out: if (ret && parse_err == 0) cli_out (GEOREP" command failed"); CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_status_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; uint32_t cmd = 0; cli_local_t *local = NULL; ret = cli_cmd_volume_status_parse (words, wordcount, &dict); if (ret) { cli_usage_out (word->pattern); goto out; } ret = dict_get_uint32 (dict, "cmd", &cmd); if (ret) goto out; if (!(cmd & GF_CLI_STATUS_ALL)) { /* for one volume or brick */ proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATUS_VOLUME]; } else { /* volume status all or all detail */ proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATUS_ALL]; } if (!proc->fn) goto out; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; CLI_LOCAL_INIT (local, words, frame, dict); ret = proc->fn (frame, THIS, dict); out: CLI_STACK_DESTROY (frame); return ret; } int cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) { uint64_t free = 0; uint64_t total = 0; char key[1024] = {0}; int ret = 0; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free", i); ret = dict_get_uint64 (dict, key, &free); status->free = gf_uint64_2human_readable (free); if (!status->free) goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total", i); ret = dict_get_uint64 (dict, key, &total); status->total = gf_uint64_2human_readable (total); if (!status->total) goto out; #ifdef GF_LINUX_HOST_OS memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.device", i); ret = dict_get_str (dict, key, &(status->device)); if (ret) status->device = NULL; #endif memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.block_size", i); ret = dict_get_uint64 (dict, key, &(status->block_size)); if (ret) { ret = 0; status->block_size = 0; } #ifdef GF_LINUX_HOST_OS memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mnt_options", i); ret = dict_get_str (dict, key, &(status->mount_options)); if (ret) status->mount_options = NULL; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.fs_name", i); ret = dict_get_str (dict, key, &(status->fs_name)); if (ret) { ret = 0; status->fs_name = NULL; } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.inode_size", i); ret = dict_get_str (dict, key, &(status->inode_size)); if (ret) status->inode_size = NULL; #endif /* GF_LINUX_HOST_OS */ memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total_inodes", i); ret = dict_get_uint64 (dict, key, &(status->total_inodes)); if (ret) status->total_inodes = 0; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free_inodes", i); ret = dict_get_uint64 (dict, key, &(status->free_inodes)); if (ret) { ret = 0; status->free_inodes = 0; } out: return ret; } void cli_print_detailed_status (cli_volume_status_t *status) { cli_out ("%-20s : %-20s", "Brick", status->brick); if (status->online) { cli_out ("%-20s : %-20d", "TCP Port", status->port); cli_out ("%-20s : %-20d", "RDMA Port", status->rdma_port); } else { cli_out ("%-20s : %-20s", "TCP Port", "N/A"); cli_out ("%-20s : %-20s", "RDMA Port", "N/A"); } cli_out ("%-20s : %-20c", "Online", (status->online) ? 'Y' : 'N'); cli_out ("%-20s : %-20s", "Pid", status->pid_str); #ifdef GF_LINUX_HOST_OS if (status->fs_name) cli_out ("%-20s : %-20s", "File System", status->fs_name); else cli_out ("%-20s : %-20s", "File System", "N/A"); if (status->device) cli_out ("%-20s : %-20s", "Device", status->device); else cli_out ("%-20s : %-20s", "Device", "N/A"); if (status->mount_options) { cli_out ("%-20s : %-20s", "Mount Options", status->mount_options); } else { cli_out ("%-20s : %-20s", "Mount Options", "N/A"); } if (status->inode_size) { cli_out ("%-20s : %-20s", "Inode Size", status->inode_size); } else { cli_out ("%-20s : %-20s", "Inode Size", "N/A"); } #endif if (status->free) cli_out ("%-20s : %-20s", "Disk Space Free", status->free); else cli_out ("%-20s : %-20s", "Disk Space Free", "N/A"); if (status->total) cli_out ("%-20s : %-20s", "Total Disk Space", status->total); else cli_out ("%-20s : %-20s", "Total Disk Space", "N/A"); if (status->total_inodes) { cli_out ("%-20s : %-20"GF_PRI_INODE, "Inode Count", status->total_inodes); } else { cli_out ("%-20s : %-20s", "Inode Count", "N/A"); } if (status->free_inodes) { cli_out ("%-20s : %-20"GF_PRI_INODE, "Free Inodes", status->free_inodes); } else { cli_out ("%-20s : %-20s", "Free Inodes", "N/A"); } } int cli_print_brick_status (cli_volume_status_t *status) { int fieldlen = CLI_VOL_STATUS_BRICK_LEN; int bricklen = 0; char *p = NULL; int num_spaces = 0; p = status->brick; bricklen = strlen (p); while (bricklen > 0) { if (bricklen > fieldlen) { cli_out ("%.*s", fieldlen, p); p += fieldlen; bricklen -= fieldlen; } else { num_spaces = (fieldlen - bricklen) + 1; printf ("%s", p); while (num_spaces-- != 0) printf (" "); if (status->port || status->rdma_port) { if (status->online) cli_out ("%-10d%-11d%-8c%-5s", status->port, status->rdma_port, status->online?'Y':'N', status->pid_str); else cli_out ("%-10s%-11s%-8c%-5s", "N/A", "N/A", status->online?'Y':'N', status->pid_str); } else cli_out ("%-10s%-11s%-8c%-5s", "N/A", "N/A", status->online?'Y':'N', status->pid_str); bricklen = 0; } } return 0; } #define NEEDS_GLFS_HEAL(op) ((op == GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE) || \ (op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) || \ (op == GF_SHD_OP_INDEX_SUMMARY) || \ (op == GF_SHD_OP_SPLIT_BRAIN_FILES)) int cli_launch_glfs_heal (int heal_op, dict_t *options) { char buff[PATH_MAX] = {0}; runner_t runner = {0}; char *filename = NULL; char *hostname = NULL; char *path = NULL; char *volname = NULL; char *out = NULL; int ret = 0; runinit (&runner); ret = dict_get_str (options, "volname", &volname); runner_add_args (&runner, SBIN_DIR"/glfsheal", volname, NULL); runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); switch (heal_op) { case GF_SHD_OP_INDEX_SUMMARY: break; case GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE: ret = dict_get_str (options, "file", &filename); runner_add_args (&runner, "bigger-file", filename, NULL); break; case GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK: ret = dict_get_str (options, "heal-source-hostname", &hostname); ret = dict_get_str (options, "heal-source-brickpath", &path); runner_add_args (&runner, "source-brick", NULL); runner_argprintf (&runner, "%s:%s", hostname, path); if (dict_get_str (options, "file", &filename) == 0) runner_argprintf (&runner, filename); break; case GF_SHD_OP_SPLIT_BRAIN_FILES: runner_add_args (&runner, "split-brain-info", NULL); break; default: ret = -1; } ret = runner_start (&runner); if (ret == -1) goto out; while ((out = fgets (buff, sizeof(buff), runner_chio (&runner, STDOUT_FILENO)))) { printf ("%s", out); } ret = runner_end (&runner); ret = WEXITSTATUS (ret); out: return ret; } int cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; int sent = 0; int parse_error = 0; dict_t *options = NULL; xlator_t *this = NULL; cli_local_t *local = NULL; int heal_op = 0; this = THIS; frame = create_frame (this, this->ctx->pool); if (!frame) goto out; if (wordcount < 3) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = cli_cmd_volume_heal_options_parse (words, wordcount, &options); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_get_int32 (options, "heal-op", &heal_op); if (ret < 0) goto out; if (NEEDS_GLFS_HEAL (heal_op)) { ret = cli_launch_glfs_heal (heal_op, options); if (ret == -1) goto out; } else { proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume heal failed."); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_statedump_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if (wordcount < 3) { cli_usage_out (word->pattern); parse_error = 1; goto out; } if (wordcount >= 3) { ret = cli_cmd_volume_statedump_options_parse (words, wordcount, &options); if (ret) { parse_error = 1; gf_log ("cli", GF_LOG_ERROR, "Error parsing " "statedump options"); cli_out ("Error parsing options"); cli_usage_out (word->pattern); } } ret = dict_set_str (options, "volname", (char *)words[2]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATEDUMP_VOLUME]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error = 0)) cli_out ("Volume statedump failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_list_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; call_frame_t *frame = NULL; rpc_clnt_procedure_t *proc = NULL; int sent = 0; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LIST_VOLUME]; if (proc->fn) { ret = proc->fn (frame, THIS, NULL); } out: if (ret) { cli_cmd_sent_status_get (&sent); if (sent == 0) cli_out ("Volume list failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_clearlocks_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if (wordcount < 7 || wordcount > 8) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = cli_cmd_volume_clrlks_opts_parse (words, wordcount, &options); if (ret) { parse_error = 1; gf_log ("cli", GF_LOG_ERROR, "Error parsing " "clear-locks options"); cli_out ("Error parsing options"); cli_usage_out (word->pattern); } ret = dict_set_str (options, "volname", (char *)words[2]); if (ret) goto out; ret = dict_set_str (options, "path", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_CLRLOCKS_VOLUME]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume clear-locks failed"); } CLI_STACK_DESTROY (frame); return ret; } int cli_cmd_volume_barrier_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; if (wordcount != 4) { cli_usage_out (word->pattern); parse_error = 1; goto out; } options = dict_new(); if (!options) { ret = -1; goto out; } ret = dict_set_str(options, "volname", (char *)words[2]); if (ret) goto out; ret = dict_set_str (options, "barrier", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_BARRIER_VOLUME]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) ret = proc->fn (frame, THIS, options); out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_err ("Volume barrier failed"); } CLI_STACK_DESTROY (frame); if (options) dict_unref (options); return ret; } int cli_cmd_volume_getopt_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *options = NULL; int sent = 0; int parse_err = 0; cli_local_t *local = NULL; if (wordcount != 4) { cli_usage_out (word->pattern); parse_err = 1; goto out; } frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; options = dict_new (); if (!options) goto out; ret = dict_set_str (options, "volname", (char *)words[2]); if (ret) goto out; ret = dict_set_str (options, "key", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOL_OPT]; CLI_LOCAL_INIT (local, words, frame, options); if (proc->fn) ret = proc->fn (frame, THIS, options); out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_err == 0)) cli_err ("Volume get option failed"); } CLI_STACK_DESTROY (frame); if (options) dict_unref (options); return ret; } struct cli_cmd volume_cmds[] = { { "volume info [all|]", cli_cmd_volume_info_cbk, "list information of all volumes"}, { "volume create [stripe ] " "[replica [arbiter ]] " "[disperse []] [disperse-data ] [redundancy ] " "[transport ] " #ifdef HAVE_BD_XLATOR "?" #endif "... [force]", cli_cmd_volume_create_cbk, "create a new volume of specified type with mentioned bricks"}, { "volume delete ", cli_cmd_volume_delete_cbk, "delete volume specified by "}, { "volume start [force]", cli_cmd_volume_start_cbk, "start volume specified by "}, { "volume stop [force]", cli_cmd_volume_stop_cbk, "stop volume specified by "}, /*{ "volume rename ", cli_cmd_volume_rename_cbk, "rename volume to "},*/ { "volume tier status\n" "volume tier attach [] ...\n" "volume tier detach \n", cli_cmd_volume_tier_cbk, "Tier translator specific operations."}, { "volume attach-tier [] ...", cli_cmd_volume_tier_cbk, "NOTE: this is old syntax, will be depreciated in next release. " "Please use gluster volume tier attach " "[] ..."}, { "volume detach-tier " " ", cli_cmd_volume_tier_cbk, "NOTE: this is old syntax, will be depreciated in next release. " "Please use gluster volume tier detach " "{start|stop|commit} [force]"}, { "volume add-brick [ ] ... [force]", cli_cmd_volume_add_brick_cbk, "add brick to volume "}, { "volume remove-brick [replica ] ..." " ", cli_cmd_volume_remove_brick_cbk, "remove brick from volume "}, { "volume rebalance {{fix-layout start} | {start [force]|stop|status}}", cli_cmd_volume_defrag_cbk, "rebalance operations"}, { "volume replace-brick " "{commit force}", cli_cmd_volume_replace_brick_cbk, "replace-brick operations"}, /*{ "volume set-transport [] ...", cli_cmd_volume_set_transport_cbk, "set transport type for volume "},*/ { "volume set ", cli_cmd_volume_set_cbk, "set options for volume "}, { "volume help", cli_cmd_volume_help_cbk, "display help for the volume command"}, { "volume log rotate [BRICK]", cli_cmd_log_rotate_cbk, "rotate the log file for corresponding volume/brick"}, { "volume log rotate [BRICK]", cli_cmd_log_rotate_cbk, "rotate the log file for corresponding volume/brick" " NOTE: This is an old syntax, will be deprecated from next release."}, { "volume sync [all|]", cli_cmd_sync_volume_cbk, "sync the volume information from a peer"}, { "volume reset [option] [force]", cli_cmd_volume_reset_cbk, "reset all the reconfigured options"}, #if (SYNCDAEMON_COMPILE) {"volume "GEOREP" [] [] {create [[no-verify]|[push-pem]] [force]" "|start [force]|stop [force]|pause [force]|resume [force]|config|status [detail]|delete} [options...]", cli_cmd_volume_gsync_set_cbk, "Geo-sync operations", cli_cmd_check_gsync_exists_cbk}, #endif { "volume profile {start|info [peek|incremental [peek]|cumulative|clear]|stop} [nfs]", cli_cmd_volume_profile_cbk, "volume profile operations"}, { "volume quota {enable|disable|list [ ...]| " "list-objects [ ...] | remove | remove-objects | " "default-soft-limit } |\n" "volume quota {limit-usage []} |\n" "volume quota {limit-objects []} |\n" "volume quota {alert-time|soft-timeout|hard-timeout} {