sleuthkit-3.2.3/000777 000765 000024 00000000000 11643647554 014350 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/aclocal.m4000644 000765 000024 00001142602 11643647512 016204 0ustar00carrierstaff000000 000000 # generated automatically by aclocal 1.10 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 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. # 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_if(m4_PACKAGE_VERSION, [2.61],, [m4_fatal([this file was generated for autoconf 2.61. You have another version of autoconf. If you want to use that, you should regenerate the build system entirely.], [63])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 56 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl _LT_PROG_ECHO_BACKSLASH case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_quote(m4_if([$2], [], m4_quote(lt_decl_tag_varnames), m4_quote(m4_shift($@)))), m4_split(m4_normalize(m4_quote(_LT_TAGS))))]) m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\[$]0 --fallback-echo"')dnl " lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` ;; esac _LT_OUTPUT_LIBTOOL_INIT ]) # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) cat >"$CONFIG_LT" <<_LTEOF #! $SHELL # Generated by $as_me. # Run this file to recreate a libtool stub with the current configuration. lt_cl_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2008 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. if test "$no_create" != yes; then lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) fi ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM -f \"$cfgfile\"; exit 1" 1 2 15 $RM -f "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_XSI_SHELLFNS sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(whole_archive_flag_spec, $1)='' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" if test "$GCC" = "yes"; then output_verbose_link_cmd=echo _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX # ----------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl AC_LINK_IFELSE(AC_LANG_PROGRAM,[ lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) $1 AC_DIVERT_POP ])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. m4_defun([_LT_PROG_ECHO_BACKSLASH], [_LT_SHELL_INIT([ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac ECHO=${lt_ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF [$]* _LT_EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(lt_ECHO) ]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that does not interpret backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [AC_CHECK_TOOL(AR, ar, false) test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1]) AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM -r conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line __oline__ "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM -r conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM -r conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM -r conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method == "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -r -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -r -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; icpc* | ecpc* ) # Intel C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC*) # IBM XL 8.0 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu) case $cc_basename in icc* | ecc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl*) # IBM XL C 8.0/Fortran 10.1 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Sun\ F*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw*) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE(int foo(void) {}, _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' ) LDFLAGS="$save_LDFLAGS" else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_MSG_CHECKING([whether -lc should be explicitly linked in]) $RM -r conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then _LT_TAGVAR(archive_cmds_need_lc, $1)=no else _LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM -r conftest* AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [fix_srcfile_path], [1], [Fix the shell variable $srcfile for the compiler]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_PROG_CXX # ------------ # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ # compiler, we have our own version here. m4_defun([_LT_PROG_CXX], [ pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) AC_PROG_CXX if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_CXX dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_CXX], []) # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [AC_REQUIRE([_LT_PROG_CXX])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=echo else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_PROG_F77 # ------------ # Since AC_PROG_F77 is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_F77], [ pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) AC_PROG_F77 if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_F77 dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_F77], []) # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_REQUIRE([_LT_PROG_F77])dnl AC_LANG_PUSH(Fortran 77) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${F77-"f77"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_PROG_FC # ----------- # Since AC_PROG_FC is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_FC], [ pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) AC_PROG_FC if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_FC dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_FC], []) # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_REQUIRE([_LT_PROG_FC])dnl AC_LANG_PUSH(Fortran) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${FC-"f95"} compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC="$lt_save_CC" ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC= CC=${RC-"windres"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC="$lt_save_CC" ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_XSI_SHELLFNS # --------------------- # Bourne and XSI compatible variants of some useful shell functions. m4_defun([_LT_PROG_XSI_SHELLFNS], [case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $[*] )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } dnl func_dirname_and_basename dnl A portable version of this function is already defined in general.m4sh dnl so there is no need for it here. # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[[^=]]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$[@]"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]+=\$[2]" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]=\$$[1]\$[2]" } _LT_EOF ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # 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 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [0], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # 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 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. m4_define([lt_combine], [m4_if([$2], [], [], [m4_if([$4], [], [], [lt_join(m4_quote(m4_default([$1], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2], [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]), [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl ]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # 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. # Generated from ltversion.in. # serial 2976 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.2.4]) m4_define([LT_PACKAGE_REVISION], [1.2976]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.2.4' macro_revision='1.2976' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # 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 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) # Copyright (C) 2002, 2003, 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_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.10' 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.10], [], [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 AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.10])dnl _AM_AUTOCONF_VERSION(m4_PACKAGE_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 # 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 8 # 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 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 # 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 # 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 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 case $depmode in 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 ;; none) break ;; esac # 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. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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 # 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 3 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [for mf in $CONFIG_FILES; 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 10q "$mf" | grep '^#.*generated by automake' > /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"]) ]) # Copyright (C) 1996, 1997, 2000, 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. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 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. # serial 12 # 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.60])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) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP 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 ]) ]) # 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_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $1 | $1:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) # 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_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} 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])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 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 4 AC_DEFUN([AM_MAINTAINER_MODE], [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode is disabled by default AC_ARG_ENABLE(maintainer-mode, [ --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer], USE_MAINTAINER_MODE=$enableval, USE_MAINTAINER_MODE=no) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST(MAINT)dnl ] ) AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 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 3 # 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 done .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 # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi 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 # 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_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 test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # 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 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 3 # _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], [AC_FOREACH([_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 # 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_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # 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) 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 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_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_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 sleuthkit-3.2.3/ChangeLog.txt000644 000765 000024 00000000601 11643647433 016725 0ustar00carrierstaff000000 000000 This program does not distribute an official ChangeLog file. You can generate one from the subversion repository though using the following command: svn log http://svn.sleuthkit.org/repos/sleuthkit/ For a specific release, try something like: svn log http://svn.sleuthkit.org/repos/sleuthkit/tags/sleuthkit-3.0.0 and replace 3.0.0 with the version you are interested in. sleuthkit-3.2.3/config/000777 000765 000024 00000000000 11643647552 015613 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/configure000755 000765 000024 00002410340 11643647520 016250 0ustar00carrierstaff000000 000000 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for sleuthkit 3.2.3. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 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=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # 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 # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh 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.) as_nl=' ' 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 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. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # 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 || 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=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _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=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (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 autoconf@gnu.org about your system, echo including any error possibly output before this echo message } 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" || { 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 fi echo >conf$$.file 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 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'" # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` ;; esac ECHO=${lt_ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF $* _LT_EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL $0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL $0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "$0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" fi 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='sleuthkit' PACKAGE_TARNAME='sleuthkit' PACKAGE_VERSION='3.2.3' PACKAGE_STRING='sleuthkit 3.2.3' PACKAGE_BUGREPORT='' ac_unique_file="tsk3/base/tsk_base.h" # 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_header_list= ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA am__isrc CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar LIBTOOL build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED GREP EGREP FGREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S AR RANLIB lt_ECHO DSYMUTIL NMEDIT LIPO OTOOL OTOOL64 CPP MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP PERL ALLOCA LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false # 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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=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 ;; -*) { 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 && { 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. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && 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'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. 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 case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { 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 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 .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { 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 -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | 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 .." { 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" || { 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 sleuthkit 3.2.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/sleuthkit] --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 System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of sleuthkit 3.2.3:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-libtool-lock avoid locking (might break parallel builds) --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --disable-largefile omit support for large files Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --without-afflib Do not use AFFLIB even if it is installed --with-afflib=dir Specify that AFFLIB is installed in directory 'dir' --without-libewf Do not use libewf even if it is installed --with-libewf=dir Specify that libewf is installed in directory 'dir' 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 CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP 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" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`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 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 sleuthkit configure 3.2.3 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 sleuthkit $as_me 3.2.3, which was generated by GNU Autoconf 2.61. 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=. 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=`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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $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=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac 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=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac 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 && echo "$as_me: caught signal $ac_signal" 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 explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 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 { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi ac_header_list="$ac_header_list utime.h" # 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,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 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 { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`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 { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 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 ac_config_headers="$ac_config_headers tsk3/tsk_config.h" ac_aux_dir= for ac_dir in config "$srcdir"/config; 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 { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config \"$srcdir\"/config" >&5 echo "$as_me: error: cannot find install-sh or install.sh in config \"$srcdir\"/config" >&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.10' # 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. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS 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 { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$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' { echo "$as_me:$LINENO: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } # Just in case sleep 1 echo timestamp > conftest.file # 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". { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 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 { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}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 $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm -f conftest.sed # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi { echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { echo "$as_me:$LINENO: result: $MKDIR_P" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$AWK" && break done { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`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 echo $ECHO_N "(cached) $ECHO_C" >&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 { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 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='sleuthkit' VERSION='3.2.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"} install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} # 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&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" # 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 -' case `pwd` in *\ * | *\ *) { echo "$as_me:$LINENO: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.2.4' macro_revision='1.2976' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi { echo "$as_me:$LINENO: result: $_am_result" >&5 echo "${ECHO_T}$_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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 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. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? 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.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. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? 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 | *.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 { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 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. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? 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 { { 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 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 { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out 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. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 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 { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? 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 ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 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 { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$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= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 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 case $depmode in 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 ;; none) break ;; esac # 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. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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 { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6; } if test "${ac_cv_path_SED+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" | sed 99q >conftest.sed $as_unset ac_script || ac_script= # Extract the first word of "sed gsed" to use in msg output if test -z "$SED"; then set dummy sed gsed; ac_prog_name=$2 if test "${ac_cv_path_SED+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_SED_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 do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "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_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_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_SED_found && break 3 done done done IFS=$as_save_IFS fi SED="$ac_cv_path_SED" if test -z "$SED"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in \$PATH" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in \$PATH" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_SED=$SED fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5 echo "${ECHO_T}$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else 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 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" 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 fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else 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 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" 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 fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name 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 { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for fgrep" >&5 echo $ECHO_N "checking for fgrep... $ECHO_C" >&6; } if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else # Extract the first word of "fgrep" to use in msg output if test -z "$FGREP"; then set dummy fgrep; ac_prog_name=$2 if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_FGREP_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 fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "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_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_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_FGREP_found && break 3 done done done IFS=$as_save_IFS fi FGREP="$ac_cv_path_FGREP" if test -z "$FGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_FGREP=$FGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5 echo "${ECHO_T}$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { echo "$as_me:$LINENO: checking for ld used by $CC" >&5 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { echo "$as_me:$LINENO: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; } else { echo "$as_me:$LINENO: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; } fi if test "${lt_cv_path_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 echo "${ECHO_T}$LD" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5 echo $ECHO_N "checking for BSD- or MS-compatible name lister (nm)... $ECHO_C" >&6; } if test "${lt_cv_path_NM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 echo "${ECHO_T}$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$ac_tool_prefix"; then for ac_prog in "dumpbin -symbols" "link -dump -symbols" 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_DUMPBIN+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # 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_DUMPBIN="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { echo "$as_me:$LINENO: result: $DUMPBIN" >&5 echo "${ECHO_T}$DUMPBIN" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in "dumpbin -symbols" "link -dump -symbols" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # 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_DUMPBIN="$ac_prog" 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_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5 echo "${ECHO_T}$ac_ct_DUMPBIN" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5 echo $ECHO_N "checking the name lister ($NM) interface... $ECHO_C" >&6; } if test "${lt_cv_nm_interface+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:4277: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:4280: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:4283: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -r -f conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5 echo "${ECHO_T}$lt_cv_nm_interface" >&6; } { echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; } if test "${lt_cv_sys_max_cmd_len+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6; } else { echo "$as_me:$LINENO: result: none" >&5 echo "${ECHO_T}none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5 echo $ECHO_N "checking whether the shell understands some XSI constructs... $ECHO_C" >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { echo "$as_me:$LINENO: result: $xsi_shell" >&5 echo "${ECHO_T}$xsi_shell" >&6; } { echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5 echo $ECHO_N "checking whether the shell understands \"+=\"... $ECHO_C" >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { echo "$as_me:$LINENO: result: $lt_shell_append" >&5 echo "${ECHO_T}$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6; } if test "${lt_cv_ld_reload_flag+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_reload_flag='-r' fi { echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac { echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5 echo $ECHO_N "checking how to recognize dependent libraries... $ECHO_C" >&6; } if test "${lt_cv_deplibs_check_method+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6; } file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # 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_AR="${ac_tool_prefix}ar" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { echo "$as_me:$LINENO: result: $AR" >&5 echo "${ECHO_T}$AR" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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_AR="ar" 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_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 echo "${ECHO_T}$ac_ct_AR" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6; } if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -r -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Now try to grab the symbols. nlist=conftest.nm if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { echo "$as_me:$LINENO: result: failed" >&5 echo "${ECHO_T}failed" >&6; } else { echo "$as_me:$LINENO: result: ok" >&5 echo "${ECHO_T}ok" >&6; } fi # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line 5394 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6; } if test "${lt_cv_cc_needs_belf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else 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 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then lt_cv_cc_needs_belf=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext 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 fi { echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_DSYMUTIL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # 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_DSYMUTIL="${ac_tool_prefix}dsymutil" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { echo "$as_me:$LINENO: result: $DSYMUTIL" >&5 echo "${ECHO_T}$DSYMUTIL" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # 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_DSYMUTIL="dsymutil" 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_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5 echo "${ECHO_T}$ac_ct_DSYMUTIL" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_NMEDIT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # 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_NMEDIT="${ac_tool_prefix}nmedit" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { echo "$as_me:$LINENO: result: $NMEDIT" >&5 echo "${ECHO_T}$NMEDIT" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # 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_NMEDIT="nmedit" 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_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5 echo "${ECHO_T}$ac_ct_NMEDIT" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_LIPO+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # 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_LIPO="${ac_tool_prefix}lipo" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { echo "$as_me:$LINENO: result: $LIPO" >&5 echo "${ECHO_T}$LIPO" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # 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_LIPO="lipo" 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_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { echo "$as_me:$LINENO: result: $ac_ct_LIPO" >&5 echo "${ECHO_T}$ac_ct_LIPO" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_OTOOL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # 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_OTOOL="${ac_tool_prefix}otool" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { echo "$as_me:$LINENO: result: $OTOOL" >&5 echo "${ECHO_T}$OTOOL" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # 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_OTOOL="otool" 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_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { echo "$as_me:$LINENO: result: $ac_ct_OTOOL" >&5 echo "${ECHO_T}$ac_ct_OTOOL" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_OTOOL64+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # 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_OTOOL64="${ac_tool_prefix}otool64" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { echo "$as_me:$LINENO: result: $OTOOL64" >&5 echo "${ECHO_T}$OTOOL64" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # 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_OTOOL64="otool64" 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_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { echo "$as_me:$LINENO: result: $ac_ct_OTOOL64" >&5 echo "${ECHO_T}$ac_ct_OTOOL64" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { echo "$as_me:$LINENO: checking for -single_module linker flag" >&5 echo $ECHO_N "checking for -single_module linker flag... $ECHO_C" >&6; } if test "${lt_cv_apple_cc_single_mod+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5 echo "${ECHO_T}$lt_cv_apple_cc_single_mod" >&6; } { echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5 echo $ECHO_N "checking for -exported_symbols_list linker flag... $ECHO_C" >&6; } if test "${lt_cv_ld_exported_symbols_list+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then lt_cv_ld_exported_symbols_list=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5 echo "${ECHO_T}$lt_cv_ld_exported_symbols_list" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; 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 { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&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 echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 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 { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 -r 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 -r 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then withval=$with_pic; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { echo "$as_me:$LINENO: checking for objdir" >&5 echo $ECHO_N "checking for objdir... $ECHO_C" >&6; } if test "${lt_cv_objdir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 echo "${ECHO_T}$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { echo "$as_me:$LINENO: checking for file" >&5 echo $ECHO_N "checking for file... $ECHO_C" >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" 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 # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM -r conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' { echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:7241: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:7245: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= { echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu) case $cc_basename in icc* | ecc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl*) # IBM XL C 8.0/Fortran 10.1 on PPC lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Sun\ F*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 echo "${ECHO_T}$lt_prog_compiler_pic" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_pic_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:7565: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:7569: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_static_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:7670: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:7674: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM -r conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; } { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:7725: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:7729: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM -r conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } hard_links=yes $RM -r conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6; } if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported whole_archive_flag_spec='' link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" if test "$GCC" = "yes"; then output_verbose_link_cmd=echo archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat >conftest.$ac_ext <<_ACEOF int foo(void) {} _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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { echo "$as_me:$LINENO: result: $ld_shlibs" >&5 echo "${ECHO_T}$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } $RM -r conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc=no else archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM -r conftest* { echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 echo "${ECHO_T}$archive_cmds_need_lc" >&6; } ;; esac fi ;; esac { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then shlibpath_overrides_runpath=yes fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { echo "$as_me:$LINENO: result: $hardcode_action" >&5 echo "${ECHO_T}$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) { echo "$as_me:$LINENO: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; } if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 shl_load to an innocuous variant, in case declares shl_load. For example, HP-UX 11i declares gettimeofday. */ #define shl_load innocuous_shl_load /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef shl_load /* 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 shl_load (); /* 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_shl_load || defined __stub___shl_load choke me #endif int main () { return shl_load (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_func_shl_load=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shl_load=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6; } if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; } if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 shl_load (); int main () { return shl_load (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_dld_shl_load=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; } if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else { echo "$as_me:$LINENO: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; } if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 dlopen to an innocuous variant, in case declares dlopen. For example, HP-UX 11i declares gettimeofday. */ #define dlopen innocuous_dlopen /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef dlopen /* 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 dlopen (); /* 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_dlopen || defined __stub___dlopen choke me #endif int main () { return dlopen (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_func_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6; } if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; } if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_svld_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; } if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; } if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 dld_link (); int main () { return dld_link (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_dld_dld_link=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; } if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; } if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line 10473 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); } _LT_EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; } if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line 10573 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); } _LT_EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi ;; *) { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } ;; esac fi # Report which library types will actually be built { echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $can_build_shared" >&5 echo "${ECHO_T}$can_build_shared" >&6; } { echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { echo "$as_me:$LINENO: result: $enable_shared" >&5 echo "${ECHO_T}$enable_shared" >&6; } { echo "$as_me:$LINENO: checking whether to build static libraries" >&5 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { echo "$as_me:$LINENO: result: $enable_static" >&5 echo "${ECHO_T}$enable_static" >&6; } 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 CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: { echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # 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_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_CXX="$ac_prog" 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_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else 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_cxx_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CXXFLAGS="" 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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else 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_cxx_werror_flag=$ac_save_cxx_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi 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 depcc="$CXX" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi 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 case $depmode in 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 ;; none) break ;; esac # 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. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # 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_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_CXX="$ac_prog" 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_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else 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_cxx_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CXXFLAGS="" 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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else 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_cxx_werror_flag=$ac_save_cxx_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi 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 depcc="$CXX" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi 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 case $depmode in 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 ;; none) break ;; esac # 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. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; } if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : else 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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else 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_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { echo "$as_me:$LINENO: result: $CXXCPP" >&5 echo "${ECHO_T}$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : else 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 "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else 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 _lt_caught_CXX_error=yes 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 else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_flag_spec_ld_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM -r conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { echo "$as_me:$LINENO: checking for ld used by $CC" >&5 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { echo "$as_me:$LINENO: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; } else { echo "$as_me:$LINENO: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; } fi if test "${lt_cv_path_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 echo "${ECHO_T}$LD" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32*) # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported whole_archive_flag_spec_CXX='' link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_lt_dar_allow_undefined" if test "$GCC" = "yes"; then output_verbose_link_cmd=echo archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd[12]*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5]* | *pgcpp\ [1-5]*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=echo else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= { echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; icpc* | ecpc* ) # Intel C++ lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC*) # IBM XL 8.0 on PPC lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:13797: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:13801: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:13896: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:13900: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM -r conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; } { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:13948: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:13952: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM -r conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM -r conftest* fi { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } hard_links=yes $RM -r conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6; } if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw*) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } $RM -r conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_CXX=no else archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM -r conftest* { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6; } ;; esac fi ;; esac { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" 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 conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $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 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then shlibpath_overrides_runpath=yes fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 echo "${ECHO_T}$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes ac_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 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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" 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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 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. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$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= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 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 case $depmode in 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 ;; none) break ;; esac # 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. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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 { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&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 echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$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 "echo \"\$as_me:$LINENO: $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 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 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 "echo \"\$as_me:$LINENO: $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 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 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 { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 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 # 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. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS 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 { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$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' { echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6; } fi { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`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 echo $ECHO_N "(cached) $ECHO_C" >&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 { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_PERL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $PERL in [\\/]* | ?:[\\/]*) ac_cv_path_PERL="$PERL" # Let the user override the test with a path. ;; *) 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_path_PERL="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PERL=$ac_cv_path_PERL if test -n "$PERL"; then { echo "$as_me:$LINENO: result: $PERL" >&5 echo "${ECHO_T}$PERL" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi # Checks for header files. { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 -r 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 -r 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi #AC_HEADER_MAJOR #AC_HEADER_SYS_WAIT #AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h memory.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/time.h unistd.h utime.h wchar.h wctype.h]) for ac_header in inttypes.h unistd.h sys/param.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } if test "${ac_cv_header_stdbool_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; bool e = &s; char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; # if defined __xlc__ || defined __GNUC__ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 reported by James Lemley on 2005-10-05; see http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html This test is not quite right, since xlc is allowed to reject this program, as the initializer for xlcbug is not one of the forms that C requires support for. However, doing the test right would require a runtime test, and that would make cross-compilation harder. Let us hope that IBM fixes the xlc bug, and also adds support for this kind of constant expression. In the meantime, this test will reject xlc, which is OK, since our stdbool.h substitute should suffice. We also test this with GCC, where it should work, to detect more quickly whether someone messes up the test in the future. */ char digs[] = "0123456789"; int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); # endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; 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 "echo \"\$as_me:$LINENO: $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 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_stdbool_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } { echo "$as_me:$LINENO: checking for _Bool" >&5 echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } if test "${ac_cv_type__Bool+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 typedef _Bool ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) 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 "echo \"\$as_me:$LINENO: $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 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_type__Bool=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type__Bool=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 echo "${ECHO_T}$ac_cv_type__Bool" >&6; } if test $ac_cv_type__Bool = yes; then cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_STDBOOL_H 1 _ACEOF fi { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi { echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5 echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; } if test "${ac_cv_type_uid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f -r conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 echo "${ECHO_T}$ac_cv_type_uid_t" >&6; } if test $ac_cv_type_uid_t = no; then cat >>confdefs.h <<\_ACEOF #define uid_t int _ACEOF cat >>confdefs.h <<\_ACEOF #define gid_t int _ACEOF fi { echo "$as_me:$LINENO: checking for mode_t" >&5 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; } if test "${ac_cv_type_mode_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 typedef mode_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) 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 "echo \"\$as_me:$LINENO: $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 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_type_mode_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_mode_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5 echo "${ECHO_T}$ac_cv_type_mode_t" >&6; } if test $ac_cv_type_mode_t = yes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi { echo "$as_me:$LINENO: checking for off_t" >&5 echo $ECHO_N "checking for off_t... $ECHO_C" >&6; } if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 typedef off_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) 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 "echo \"\$as_me:$LINENO: $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 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_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_off_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 echo "${ECHO_T}$ac_cv_type_off_t" >&6; } if test $ac_cv_type_off_t = yes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi { echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 typedef size_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) 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 "echo \"\$as_me:$LINENO: $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 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_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6; } if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi #AC_CHECK_MEMBERS([struct stat.st_rdev]) #AC_HEADER_TIME #AC_STRUCT_TM # check for large file support # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_largefile_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; 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 "echo \"\$as_me:$LINENO: $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 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 break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" 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 "echo \"\$as_me:$LINENO: $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 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_sys_largefile_CC=' -n32'; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_file_offset_bits+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; 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 "echo \"\$as_me:$LINENO: $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 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_sys_file_offset_bits=no; break else 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 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; 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 "echo \"\$as_me:$LINENO: $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 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_sys_file_offset_bits=64; break else 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 ac_cv_sys_file_offset_bits=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -f -r conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_large_files+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; 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 "echo \"\$as_me:$LINENO: $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 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_sys_large_files=no; break else 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 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; 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 "echo \"\$as_me:$LINENO: $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 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_sys_large_files=1; break else 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 ac_cv_sys_large_files=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 echo "${ECHO_T}$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -f -r conftest* fi fi # Checks for library functions. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { echo "$as_me:$LINENO: checking for working alloca.h" >&5 echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; } if test "${ac_cv_working_alloca_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_working_alloca_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for alloca" >&5 echo $ECHO_N "checking for alloca... $ECHO_C" >&6; } if test "${ac_cv_func_alloca_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_func_alloca_works=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; } if test "${ac_cv_os_cray+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 -r conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 echo "${ECHO_T}$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; } if test "${ac_cv_c_stack_direction+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_stack_direction=1 else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi { echo "$as_me:$LINENO: checking for error_at_line" >&5 echo $ECHO_N "checking for error_at_line... $ECHO_C" >&6; } if test "${ac_cv_lib_error_at_line+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 () { error_at_line (0, 0, "", 0, "an error occurred"); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_error_at_line=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_lib_error_at_line" >&5 echo "${ECHO_T}$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi #AC_FUNC_FORK { echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_largefile_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do 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 () { return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_sys_largefile_source=no; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 #include int main () { return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_sys_largefile_source=1; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext ac_cv_sys_largefile_source=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6; } case $ac_cv_sys_largefile_source in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source _ACEOF ;; esac rm -f -r conftest* # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug # in glibc 2.1.3, but that breaks too many other things. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. if test $ac_cv_sys_largefile_source != unknown; then cat >>confdefs.h <<\_ACEOF #define HAVE_FSEEKO 1 _ACEOF fi if test $ac_cv_c_compiler_gnu = yes; then { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } if test "${ac_cv_prog_gcc_traditional+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f -r conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f -r conftest* fi fi { echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi { echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f conftest.sym conftest.file echo >conftest.file if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then if test "$cross_compiling" = yes; then ac_cv_func_lstat_dereferences_slashed_symlink=no 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 main () { struct stat sbuf; /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ; 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_lstat_dereferences_slashed_symlink=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi else # If the `ln -s' command failed, then we probably don't even # have an lstat function. ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f conftest.sym conftest.file fi { echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && cat >>confdefs.h <<_ACEOF #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 _ACEOF if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then case " $LIBOBJS " in *" lstat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; esac fi { echo "$as_me:$LINENO: checking whether lstat accepts an empty string" >&5 echo $ECHO_N "checking whether lstat accepts an empty string... $ECHO_C" >&6; } if test "${ac_cv_func_lstat_empty_string_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_lstat_empty_string_bug=yes 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 main () { struct stat sbuf; return lstat ("", &sbuf) == 0; ; 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_lstat_empty_string_bug=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_empty_string_bug=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_lstat_empty_string_bug" >&5 echo "${ECHO_T}$ac_cv_func_lstat_empty_string_bug" >&6; } if test $ac_cv_func_lstat_empty_string_bug = yes; then case " $LIBOBJS " in *" lstat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; esac cat >>confdefs.h <<_ACEOF #define HAVE_LSTAT_EMPTY_STRING_BUG 1 _ACEOF fi { echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f conftest.sym conftest.file echo >conftest.file if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then if test "$cross_compiling" = yes; then ac_cv_func_lstat_dereferences_slashed_symlink=no 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 main () { struct stat sbuf; /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ; 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_lstat_dereferences_slashed_symlink=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi else # If the `ln -s' command failed, then we probably don't even # have an lstat function. ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f conftest.sym conftest.file fi { echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && cat >>confdefs.h <<_ACEOF #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 _ACEOF if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then case " $LIBOBJS " in *" lstat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; esac fi #AC_FUNC_MALLOC #AC_FUNC_MBRTOWC #AC_FUNC_MEMCMP #AC_FUNC_MKTIME #AC_FUNC_MMAP #AC_FUNC_REALLOC for ac_header in sys/select.h sys/socket.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking types of arguments for select" >&5 echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } if test "${ac_cv_func_select_args+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else for ac_arg234 in 'fd_set *' 'int *' 'void *'; do for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do 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 #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif int main () { extern int select ($ac_arg1, $ac_arg234, $ac_arg234, $ac_arg234, $ac_arg5); ; 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 "echo \"\$as_me:$LINENO: $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 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_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 else 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 done done done # Provide a safe default value. : ${ac_cv_func_select_args='int,int *,struct timeval *'} fi { echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 echo "${ECHO_T}$ac_cv_func_select_args" >&6; } ac_save_IFS=$IFS; IFS=',' set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` IFS=$ac_save_IFS shift cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG234 ($2) _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG5 ($3) _ACEOF rm -f -r conftest* #AC_FUNC_STAT for ac_header in $ac_header_list do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking whether utime accepts a null argument" >&5 echo $ECHO_N "checking whether utime accepts a null argument... $ECHO_C" >&6; } if test "${ac_cv_func_utime_null+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f conftest.data; >conftest.data # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. if test "$cross_compiling" = yes; then ac_cv_func_utime_null=no 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 #ifdef HAVE_UTIME_H # include #endif int main () { struct stat s, t; return ! (stat ("conftest.data", &s) == 0 && utime ("conftest.data", 0) == 0 && stat ("conftest.data", &t) == 0 && t.st_mtime >= s.st_mtime && t.st_mtime - s.st_mtime < 120); ; 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_utime_null=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_utime_null=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_utime_null" >&5 echo "${ECHO_T}$ac_cv_func_utime_null" >&6; } if test $ac_cv_func_utime_null = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_UTIME_NULL 1 _ACEOF fi rm -f conftest.data for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF { echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done #AC_CHECK_FUNCS([dup2 gethostname isascii iswprint memset munmap regcomp select setlocale strcasecmp strchr strdup strerror strndup strrchr strtol strtoul strtoull utime wcwidth]) # Not all compilers include /usr/local in the include and link path if test -d /usr/local/include; then CFLAGS="$CFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" fi # Checks for libraries. # Check if we should link afflib. # Check whether --with-afflib was given. if test "${with_afflib+set}" = set; then withval=$with_afflib; # If --with-afflib or --without-afflib is given else # if nothing was specified, default to a test with_afflib=yes fi # check for the lib if they did not specify no if test "x$with_afflib" != "xno"; then # Test the dir if they specified something beyond yes/no if test "x$with_afflib" != "xyes"; then if test -d ${with_afflib}/include; then CFLAGS="$CFLAGS -I${with_afflib}/include" LDFLAGS="$LDFLAGS -L${with_afflib}/lib" else # Dir given was not correct { { echo "$as_me:$LINENO: error: AFFLIB directory not found at ${with_afflib} See \`config.log' for more details." >&5 echo "$as_me: error: AFFLIB directory not found at ${with_afflib} See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi # Check for the header file first to make sure they have the dev install for ac_header in afflib/afflib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF { echo "$as_me:$LINENO: checking for af_open in -lafflib" >&5 echo $ECHO_N "checking for af_open in -lafflib... $ECHO_C" >&6; } if test "${ac_cv_lib_afflib_af_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lafflib $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 af_open (); int main () { return af_open (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_afflib_af_open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_afflib_af_open=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_afflib_af_open" >&5 echo "${ECHO_T}$ac_cv_lib_afflib_af_open" >&6; } if test $ac_cv_lib_afflib_af_open = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBAFFLIB 1 _ACEOF LIBS="-lafflib $LIBS" fi fi done fi # Check if we should link libewf. # Check whether --with-libewf was given. if test "${with_libewf+set}" = set; then withval=$with_libewf; # If --with-libewf or --without-libewf is given else # if nothing was specified, default to a test with_libewf=yes fi # check for the lib if they did not specify no if test "x$with_libewf" != "xno"; then # Test the dir if they specified something beyond yes/no if test "x$with_libewf" != "xyes"; then if test -d ${with_libewf}/include; then CFLAGS="$CFLAGS -I${with_libewf}/include" LDFLAGS="$LDFLAGS -L${with_libewf}/lib" else # Dir given was not correct { { echo "$as_me:$LINENO: error: libewf directory not found at ${with_libewf} See \`config.log' for more details." >&5 echo "$as_me: error: libewf directory not found at ${with_libewf} See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi # Check for the header file first to make sure they have the dev install for ac_header in libewf.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&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 "echo \"\$as_me:$LINENO: $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 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 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 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF { echo "$as_me:$LINENO: checking for libewf_open in -lewf" >&5 echo $ECHO_N "checking for libewf_open in -lewf... $ECHO_C" >&6; } if test "${ac_cv_lib_ewf_libewf_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lewf $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 libewf_open (); int main () { return libewf_open (); ; 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_lib_ewf_libewf_open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ewf_libewf_open=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_ewf_libewf_open" >&5 echo "${ECHO_T}$ac_cv_lib_ewf_libewf_open" >&6; } if test $ac_cv_lib_ewf_libewf_open = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBEWF 1 _ACEOF LIBS="-lewf $LIBS" fi fi done fi # sqlite requires pthread libraries - this was copied from its configure.ac { echo "$as_me:$LINENO: checking for library containing pthread_create" >&5 echo $ECHO_N "checking for library containing pthread_create... $ECHO_C" >&6; } if test "${ac_cv_search_pthread_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF for ac_lib in '' pthread; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_search_pthread_create=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_pthread_create+set}" = set; then break fi done if test "${ac_cv_search_pthread_create+set}" = set; then : else ac_cv_search_pthread_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_pthread_create" >&5 echo "${ECHO_T}$ac_cv_search_pthread_create" >&6; } ac_res=$ac_cv_search_pthread_create if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { echo "$as_me:$LINENO: checking for library containing dlopen" >&5 echo $ECHO_N "checking for library containing dlopen... $ECHO_C" >&6; } if test "${ac_cv_search_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF for ac_lib in '' dl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi 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 "echo \"\$as_me:$LINENO: $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 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 && $as_test_x conftest$ac_exeext; then ac_cv_search_dlopen=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_dlopen+set}" = set; then break fi done if test "${ac_cv_search_dlopen+set}" = set; then : else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_dlopen" >&5 echo "${ECHO_T}$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi ac_config_commands="$ac_config_commands tsk3/tsk_incs.h" ac_config_files="$ac_config_files Makefile tsk3/Makefile tsk3/base/Makefile tsk3/img/Makefile tsk3/vs/Makefile tsk3/fs/Makefile tsk3/hashdb/Makefile tsk3/auto/Makefile tools/Makefile tools/imgtools/Makefile tools/vstools/Makefile tools/fstools/Makefile tools/hashtools/Makefile tools/srchtools/Makefile tools/autotools/Makefile tools/sorter/Makefile tools/timeline/Makefile tests/Makefile samples/Makefile man/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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $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" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 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=`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 -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&5 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 { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 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 "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCXX\" 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 { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 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_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $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 ## --------------------- ## ## 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=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # 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 # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh 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.) as_nl=' ' 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 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. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # 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 || 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" || { 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 fi echo >conf$$.file 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 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 sleuthkit $as_me 3.2.3, which was generated by GNU Autoconf 2.61. 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 cat >>$CONFIG_STATUS <<_ACEOF # 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_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet 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_cs_version="\\ sleuthkit config.status 3.2.3 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 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' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. 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 ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) 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. -*) { 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 if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`' predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`' postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`' predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`' postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`' LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ AR \ AR_FLAGS \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ SHELL \ ECHO \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_wl \ lt_prog_compiler_pic \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_flag_spec_ld_CXX \ hardcode_libdir_separator_CXX \ fix_srcfile_path_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` ;; esac ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' ac_cv_header_unistd_h=$ac_cv_header_unistd_h ac_cv_header_inttypes_h=$ac_cv_header_inttypes_h ac_cv_header_sys_param_h=$ac_cv_header_sys_param_h _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "tsk3/tsk_config.h") CONFIG_HEADERS="$CONFIG_HEADERS tsk3/tsk_config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "tsk3/tsk_incs.h") CONFIG_COMMANDS="$CONFIG_COMMANDS tsk3/tsk_incs.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "tsk3/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/Makefile" ;; "tsk3/base/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/base/Makefile" ;; "tsk3/img/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/img/Makefile" ;; "tsk3/vs/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/vs/Makefile" ;; "tsk3/fs/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/fs/Makefile" ;; "tsk3/hashdb/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/hashdb/Makefile" ;; "tsk3/auto/Makefile") CONFIG_FILES="$CONFIG_FILES tsk3/auto/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; "tools/imgtools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/imgtools/Makefile" ;; "tools/vstools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/vstools/Makefile" ;; "tools/fstools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/fstools/Makefile" ;; "tools/hashtools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/hashtools/Makefile" ;; "tools/srchtools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/srchtools/Makefile" ;; "tools/autotools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/autotools/Makefile" ;; "tools/sorter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/sorter/Makefile" ;; "tools/timeline/Makefile") CONFIG_FILES="$CONFIG_FILES tools/timeline/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; "samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 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") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim am__isrc!$am__isrc$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim ACLOCAL!$ACLOCAL$ac_delim AUTOCONF!$AUTOCONF$ac_delim AUTOMAKE!$AUTOMAKE$ac_delim AUTOHEADER!$AUTOHEADER$ac_delim MAKEINFO!$MAKEINFO$ac_delim install_sh!$install_sh$ac_delim STRIP!$STRIP$ac_delim INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim mkdir_p!$mkdir_p$ac_delim AWK!$AWK$ac_delim SET_MAKE!$SET_MAKE$ac_delim am__leading_dot!$am__leading_dot$ac_delim AMTAR!$AMTAR$ac_delim am__tar!$am__tar$ac_delim am__untar!$am__untar$ac_delim LIBTOOL!$LIBTOOL$ac_delim build!$build$ac_delim build_cpu!$build_cpu$ac_delim build_vendor!$build_vendor$ac_delim build_os!$build_os$ac_delim host!$host$ac_delim host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim DEPDIR!$DEPDIR$ac_delim am__include!$am__include$ac_delim am__quote!$am__quote$ac_delim AMDEP_TRUE!$AMDEP_TRUE$ac_delim AMDEP_FALSE!$AMDEP_FALSE$ac_delim AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim SED!$SED$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim FGREP!$FGREP$ac_delim LD!$LD$ac_delim DUMPBIN!$DUMPBIN$ac_delim ac_ct_DUMPBIN!$ac_ct_DUMPBIN$ac_delim NM!$NM$ac_delim LN_S!$LN_S$ac_delim AR!$AR$ac_delim RANLIB!$RANLIB$ac_delim lt_ECHO!$lt_ECHO$ac_delim DSYMUTIL!$DSYMUTIL$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 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 ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF CEOF$ac_eof _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF NMEDIT!$NMEDIT$ac_delim LIPO!$LIPO$ac_delim OTOOL!$OTOOL$ac_delim OTOOL64!$OTOOL64$ac_delim CPP!$CPP$ac_delim MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim MAINT!$MAINT$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim ac_ct_CXX!$ac_ct_CXX$ac_delim CXXDEPMODE!$CXXDEPMODE$ac_delim am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim CXXCPP!$CXXCPP$ac_delim PERL!$PERL$ac_delim ALLOCA!$ALLOCA$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 19; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 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 ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _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 fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 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 || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; 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 "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; 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 || 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=`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 || 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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 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=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`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 # 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= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF 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 sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;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 " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out 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"; } && { 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 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 ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then 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. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $ac_file | $ac_file:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $ac_file" >`$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 || echo X$ac_file | 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) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; 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 10q "$mf" | grep '^#.*generated by automake' > /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 || 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 || 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=`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 || 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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM -f \"$cfgfile\"; exit 1" 1 2 15 $RM -f "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="CXX " # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == "file_magic". file_magic_cmd=$lt_file_magic_cmd # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name of the directory that contains temporary libtool files. objdir=$objdir # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that does not interpret backslashes. ECHO=$lt_ECHO # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $* )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[^=]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$@"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1+=\$2" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1=\$$1\$2" } _LT_EOF ;; esac sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; "tsk3/tsk_incs.h":C) echo "#ifndef _TSK_INCS_H" > tsk3/tsk_incs.h echo "#define _TSK_INCS_H" >> tsk3/tsk_incs.h echo "// automatically by ./configure" >> tsk3/tsk_incs.h echo "// Contains the config.h data needed by programs that use libtsk" >> tsk3/tsk_incs.h echo "" >> tsk3/tsk_incs.h if test x$ac_cv_header_unistd_h = xyes; then echo "#include " >> tsk3/tsk_incs.h fi if test x$ac_cv_header_inttypes_h = xyes; then echo "#ifndef __STDC_FORMAT_MACROS" >> tsk3/tsk_incs.h echo "#define __STDC_FORMAT_MACROS" >> tsk3/tsk_incs.h echo "#endif" >> tsk3/tsk_incs.h echo "#include " >> tsk3/tsk_incs.h fi if test x$ac_cv_header_sys_param_h = xyes; then echo "#include " >> tsk3/tsk_incs.h fi echo "" >> tsk3/tsk_incs.h echo "#endif" >> tsk3/tsk_incs.h ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # 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 sleuthkit-3.2.3/configure.ac000644 000765 000024 00000013544 11643647467 016644 0ustar00carrierstaff000000 000000 # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) AC_INIT(sleuthkit, 3.2.3) AC_CONFIG_SRCDIR([tsk3/base/tsk_base.h]) AM_CONFIG_HEADER([tsk3/tsk_config.h]) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE([foreign]) AM_PROG_LIBTOOL AM_MAINTAINER_MODE AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PATH_PROG(PERL, perl) # Checks for header files. AC_HEADER_STDC #AC_HEADER_MAJOR #AC_HEADER_SYS_WAIT #AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h memory.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/time.h unistd.h utime.h wchar.h wctype.h]) AC_CHECK_HEADERS([inttypes.h unistd.h sys/param.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_TYPE_UID_T AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_SIZE_T #AC_CHECK_MEMBERS([struct stat.st_rdev]) #AC_HEADER_TIME #AC_STRUCT_TM # check for large file support AC_SYS_LARGEFILE # Checks for library functions. AC_FUNC_ALLOCA AC_FUNC_ERROR_AT_LINE #AC_FUNC_FORK AC_FUNC_FSEEKO AC_PROG_GCC_TRADITIONAL AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK #AC_FUNC_MALLOC #AC_FUNC_MBRTOWC #AC_FUNC_MEMCMP #AC_FUNC_MKTIME #AC_FUNC_MMAP #AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES #AC_FUNC_STAT AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF #AC_CHECK_FUNCS([dup2 gethostname isascii iswprint memset munmap regcomp select setlocale strcasecmp strchr strdup strerror strndup strrchr strtol strtoul strtoull utime wcwidth]) # Not all compilers include /usr/local in the include and link path if test -d /usr/local/include; then CFLAGS="$CFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" fi # Checks for libraries. # Check if we should link afflib. AC_ARG_WITH([afflib], [AS_HELP_STRING([--without-afflib],[Do not use AFFLIB even if it is installed])] [AS_HELP_STRING([--with-afflib=dir],[Specify that AFFLIB is installed in directory 'dir'])], # If --with-afflib or --without-afflib is given [], # if nothing was specified, default to a test [with_afflib=yes]) # check for the lib if they did not specify no AS_IF([test "x$with_afflib" != "xno"], # Test the dir if they specified something beyond yes/no [AS_IF([test "x$with_afflib" != "xyes"], [AS_IF([test -d ${with_afflib}/include], [CFLAGS="$CFLAGS -I${with_afflib}/include" LDFLAGS="$LDFLAGS -L${with_afflib}/lib"], # Dir given was not correct [AC_MSG_FAILURE([AFFLIB directory not found at ${with_afflib}])]) ] )] # Check for the header file first to make sure they have the dev install [AC_CHECK_HEADERS([afflib/afflib.h], [AC_CHECK_LIB([afflib], [af_open])] )] ) # Check if we should link libewf. AC_ARG_WITH([libewf], [AS_HELP_STRING([--without-libewf],[Do not use libewf even if it is installed])] [AS_HELP_STRING([--with-libewf=dir],[Specify that libewf is installed in directory 'dir'])], # If --with-libewf or --without-libewf is given [], # if nothing was specified, default to a test [with_libewf=yes]) # check for the lib if they did not specify no AS_IF([test "x$with_libewf" != "xno"], # Test the dir if they specified something beyond yes/no [AS_IF([test "x$with_libewf" != "xyes"], [AS_IF([test -d ${with_libewf}/include], [CFLAGS="$CFLAGS -I${with_libewf}/include" LDFLAGS="$LDFLAGS -L${with_libewf}/lib"], # Dir given was not correct [AC_MSG_FAILURE([libewf directory not found at ${with_libewf}])]) ] )] # Check for the header file first to make sure they have the dev install [AC_CHECK_HEADERS([libewf.h], [AC_CHECK_LIB([ewf], [libewf_open])] )] ) # sqlite requires pthread libraries - this was copied from its configure.ac AC_SEARCH_LIBS(pthread_create, pthread) AC_SEARCH_LIBS(dlopen, dl) AC_CONFIG_COMMANDS([tsk3/tsk_incs.h], [ echo "#ifndef _TSK_INCS_H" > tsk3/tsk_incs.h echo "#define _TSK_INCS_H" >> tsk3/tsk_incs.h echo "// automatically by ./configure" >> tsk3/tsk_incs.h echo "// Contains the config.h data needed by programs that use libtsk" >> tsk3/tsk_incs.h echo "" >> tsk3/tsk_incs.h if test x$ac_cv_header_unistd_h = xyes; then echo "#include " >> tsk3/tsk_incs.h fi if test x$ac_cv_header_inttypes_h = xyes; then echo "#ifndef __STDC_FORMAT_MACROS" >> tsk3/tsk_incs.h echo "#define __STDC_FORMAT_MACROS" >> tsk3/tsk_incs.h echo "#endif" >> tsk3/tsk_incs.h echo "#include " >> tsk3/tsk_incs.h fi if test x$ac_cv_header_sys_param_h = xyes; then echo "#include " >> tsk3/tsk_incs.h fi echo "" >> tsk3/tsk_incs.h echo "#endif" >> tsk3/tsk_incs.h ], [ ac_cv_header_unistd_h=$ac_cv_header_unistd_h ac_cv_header_inttypes_h=$ac_cv_header_inttypes_h ac_cv_header_sys_param_h=$ac_cv_header_sys_param_h ]) AC_CONFIG_FILES([Makefile tsk3/Makefile tsk3/base/Makefile tsk3/img/Makefile tsk3/vs/Makefile tsk3/fs/Makefile tsk3/hashdb/Makefile tsk3/auto/Makefile tools/Makefile tools/imgtools/Makefile tools/vstools/Makefile tools/fstools/Makefile tools/hashtools/Makefile tools/srchtools/Makefile tools/autotools/Makefile tools/sorter/Makefile tools/timeline/Makefile tests/Makefile samples/Makefile man/Makefile]) AC_OUTPUT sleuthkit-3.2.3/docs/000777 000765 000024 00000000000 11643647552 015276 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/INSTALL.txt000644 000765 000024 00000006017 11643647435 016215 0ustar00carrierstaff000000 000000 The Sleuth Kit http://www.sleuthkit.org/sleuthkit Installation Instructions Last Modified: March 2010 REQUIREMENTS ============================================================================= Tested Platform: - FreeBSD 2-6.* - Linux 2.* - OpenBSD 2-3.* - Mac OS X - SunOS 4-5.* - Windows System: - C compiler - GNU Make Optional Programs: - Autopsy: Provides a graphical HTML-based interface to The Sleuth Kit (which makes it much easier to use). Install this AFTER installing The Sleuth Kit. Available at: http://www.sleuthkit.org/autopsy Optional Libraries: There are optional features that TSK can use if you have installed them before you build and install TSK. - AFFLIB: Allows you to process disk images that are stored in the AFF format. Version 3.3.6 has been tested to compile and work with this release. Available at: http://www.afflib.org - LibEWF: Allows you to process disk images that are stored in the Expert Witness format (EnCase Format). Version 20100226 has been tested to compile and work with this release. NOTE that this does not include the experimental V2 API. Available at: http://sourceforge.net/projects/libewf/ INSTALLATION ============================================================================= Refer to the README_win32.txt file for details on Windows. The Sleuth Kit uses the GNU autotools for building and installation. There are a few steps to this process. First, run the 'configure' script in the root TSK directory. See the CONFIGURE OPTIONS section for useful arguments that can be given to 'configure. $ ./configure If there were no errors, then run 'make'. $ make The 'make' process will take a while and will build the TSK tools. When this process is complete, the libraries and executables will be located in the TSK sub-directories. To install them, type 'make install'. $ make install By default, this will copy everything in to the /usr/local/ structure. So, the executables will be in '/usr/local/bin'. This directory will need to be in your PATH if you want to run the TSK commands without specifying '/usr/local/bin' everytime. CONFIGURE OPTIONS ----------------------------------------------------------------------------- There are some arguments to 'configure' that you can supply to customize the setup. Currently, they focus on the optional disk image format libraries. --without-afflib: Supply this if you want TSK to ignore AFFLIB even if it is installed. --with-afflib=dir: Supply this if you want TSK to look in 'dir' for the AFFLIB installation (the directory should have 'lib' and 'include' directories in it). --without-ewf: Supply this if you want TSK to ignore libewf even if it is installed. --with-libewf=dir: Supply this if you want TSK to look in 'dir' for the libewf installation (the directory should have 'lib' and 'include' directories in it). ----------------------------------------------------------------------------- Brian Carrier carrier sleuthkit org sleuthkit-3.2.3/licenses/000777 000765 000024 00000000000 11643647552 016153 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/Makefile.am000644 000765 000024 00000004202 11643647435 016374 0ustar00carrierstaff000000 000000 # Files that we want to include in the dist EXTRA_DIST = README_win32.txt README.txt INSTALL.txt ChangeLog.txt NEWS.txt \ licenses/GNU-COPYING licenses/IBM-LICENSE licenses/cpl1.0.txt \ docs/README.txt \ packages/sleuthkit.spec \ win32/BUILDING.txt \ win32/blkcalc/blkcalc.vcproj win32/blkcat/blkcat.vcproj \ win32/blkls/blkls.vcproj win32/blkstat/blkstat.vcproj \ win32/ffind/ffind.vcproj win32/fls/fls.vcproj \ win32/fsstat/fsstat.vcproj win32/hfind/hfind.vcproj \ win32/icat/icat.vcproj win32/ifind/ifind.vcproj \ win32/ils/ils.vcproj win32/img_cat/img_cat.vcproj \ win32/img_stat/img_stat.vcproj \ win32/istat/istat.vcproj win32/jcat/jcat.vcproj \ win32/jls/jls.vcproj win32/mmls/mmls.vcproj \ win32/mmstat/mmstat.vcproj win32/mmcat/mmcat.vcproj \ win32/tsk_recover/tsk_recover.vcproj win32/tsk_loaddb/tsk_loaddb.vcproj \ win32/tsk_comparedir/tsk_compare.vcproj \ win32/tsk_gettimes/tsk_gettimes.vcproj \ win32/tsk-win.sln \ win32/libauxtools/libauxtools.vcproj \ win32/libfstools/libfstools.vcproj \ win32/libhashdbtools/libhashdbtools.vcproj \ win32/libimgtools/libimgtools.vcproj \ win32/libmmtools/libmmtools.vcproj \ win32/libautotools/libautotools.vcproj \ win32/posix-sample/posix-sample.vcproj \ win32/callback-sample/callback-sample.vcproj CLEANFILES = tsk3/tsk_incs.h # directories to compile SUBDIRS = tsk3 tools tests samples man nobase_include_HEADERS = tsk3/libtsk.h tsk3/tsk_incs.h \ tsk3/base/tsk_base.h tsk3/base/tsk_os.h \ tsk3/img/tsk_img.h tsk3/vs/tsk_vs.h \ tsk3/vs/tsk_bsd.h tsk3/vs/tsk_dos.h tsk3/vs/tsk_gpt.h \ tsk3/vs/tsk_mac.h tsk3/vs/tsk_sun.h \ tsk3/fs/tsk_fs.h tsk3/fs/tsk_ffs.h tsk3/fs/tsk_ext2fs.h tsk3/fs/tsk_fatfs.h \ tsk3/fs/tsk_ntfs.h tsk3/fs/tsk_iso9660.h tsk3/fs/tsk_hfs.h \ tsk3/hashdb/tsk_hashdb.h tsk3/auto/tsk_auto.h nobase_dist_data_DATA = tsk3/sorter/default.sort tsk3/sorter/freebsd.sort \ tsk3/sorter/images.sort tsk3/sorter/linux.sort tsk3/sorter/openbsd.sort \ tsk3/sorter/solaris.sort tsk3/sorter/windows.sort api-docs: doxygen tsk3/docs/Doxyfile man-html: cd man;build-html sleuthkit-3.2.3/Makefile.in000644 000765 000024 00000056061 11643647517 016420 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = . DIST_COMMON = $(am__configure_deps) $(nobase_dist_data_DATA) \ $(nobase_include_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(top_srcdir)/configure \ config/config.guess config/config.sub config/depcomp \ config/install-sh config/ltmain.sh config/missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(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 = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = 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 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(datadir)" "$(DESTDIR)$(includedir)" nobase_dist_dataDATA_INSTALL = $(install_sh_DATA) DATA = $(nobase_dist_data_DATA) nobase_includeHEADERS_INSTALL = $(install_sh_DATA) HEADERS = $(nobase_include_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive 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); }; } 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@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # Files that we want to include in the dist EXTRA_DIST = README_win32.txt README.txt INSTALL.txt ChangeLog.txt NEWS.txt \ licenses/GNU-COPYING licenses/IBM-LICENSE licenses/cpl1.0.txt \ docs/README.txt \ packages/sleuthkit.spec \ win32/BUILDING.txt \ win32/blkcalc/blkcalc.vcproj win32/blkcat/blkcat.vcproj \ win32/blkls/blkls.vcproj win32/blkstat/blkstat.vcproj \ win32/ffind/ffind.vcproj win32/fls/fls.vcproj \ win32/fsstat/fsstat.vcproj win32/hfind/hfind.vcproj \ win32/icat/icat.vcproj win32/ifind/ifind.vcproj \ win32/ils/ils.vcproj win32/img_cat/img_cat.vcproj \ win32/img_stat/img_stat.vcproj \ win32/istat/istat.vcproj win32/jcat/jcat.vcproj \ win32/jls/jls.vcproj win32/mmls/mmls.vcproj \ win32/mmstat/mmstat.vcproj win32/mmcat/mmcat.vcproj \ win32/tsk_recover/tsk_recover.vcproj win32/tsk_loaddb/tsk_loaddb.vcproj \ win32/tsk_comparedir/tsk_compare.vcproj \ win32/tsk_gettimes/tsk_gettimes.vcproj \ win32/tsk-win.sln \ win32/libauxtools/libauxtools.vcproj \ win32/libfstools/libfstools.vcproj \ win32/libhashdbtools/libhashdbtools.vcproj \ win32/libimgtools/libimgtools.vcproj \ win32/libmmtools/libmmtools.vcproj \ win32/libautotools/libautotools.vcproj \ win32/posix-sample/posix-sample.vcproj \ win32/callback-sample/callback-sample.vcproj CLEANFILES = tsk3/tsk_incs.h # directories to compile SUBDIRS = tsk3 tools tests samples man nobase_include_HEADERS = tsk3/libtsk.h tsk3/tsk_incs.h \ tsk3/base/tsk_base.h tsk3/base/tsk_os.h \ tsk3/img/tsk_img.h tsk3/vs/tsk_vs.h \ tsk3/vs/tsk_bsd.h tsk3/vs/tsk_dos.h tsk3/vs/tsk_gpt.h \ tsk3/vs/tsk_mac.h tsk3/vs/tsk_sun.h \ tsk3/fs/tsk_fs.h tsk3/fs/tsk_ffs.h tsk3/fs/tsk_ext2fs.h tsk3/fs/tsk_fatfs.h \ tsk3/fs/tsk_ntfs.h tsk3/fs/tsk_iso9660.h tsk3/fs/tsk_hfs.h \ tsk3/hashdb/tsk_hashdb.h tsk3/auto/tsk_auto.h nobase_dist_data_DATA = tsk3/sorter/default.sort tsk3/sorter/freebsd.sort \ tsk3/sorter/images.sort tsk3/sorter/linux.sort tsk3/sorter/openbsd.sort \ tsk3/sorter/solaris.sort tsk3/sorter/windows.sort all: all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ cd $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ 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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool install-nobase_dist_dataDATA: $(nobase_dist_data_DATA) @$(NORMAL_INSTALL) test -z "$(datadir)" || $(MKDIR_P) "$(DESTDIR)$(datadir)" @$(am__vpath_adj_setup) \ list='$(nobase_dist_data_DATA)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__vpath_adj) \ echo " $(nobase_dist_dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(datadir)/$$f'"; \ $(nobase_dist_dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(datadir)/$$f"; \ done uninstall-nobase_dist_dataDATA: @$(NORMAL_UNINSTALL) @$(am__vpath_adj_setup) \ list='$(nobase_dist_data_DATA)'; for p in $$list; do \ $(am__vpath_adj) \ echo " rm -f '$(DESTDIR)$(datadir)/$$f'"; \ rm -f "$(DESTDIR)$(datadir)/$$f"; \ done install-nobase_includeHEADERS: $(nobase_include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @$(am__vpath_adj_setup) \ list='$(nobase_include_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__vpath_adj) \ echo " $(nobase_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ $(nobase_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ done uninstall-nobase_includeHEADERS: @$(NORMAL_UNINSTALL) @$(am__vpath_adj_setup) \ list='$(nobase_include_HEADERS)'; for p in $$list; do \ $(am__vpath_adj) \ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ rm -f "$(DESTDIR)$(includedir)/$$f"; \ done # 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): @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; \ (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): @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; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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 || \ tags="$$tags $$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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -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-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) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && 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 $(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: @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 $(DATA) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(datadir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done 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) 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 $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-libtool \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-nobase_dist_dataDATA \ install-nobase_includeHEADERS install-dvi: install-dvi-recursive install-exec-am: install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -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: uninstall-nobase_dist_dataDATA \ uninstall-nobase_includeHEADERS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ distclean-generic distclean-libtool 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-nobase_dist_dataDATA \ install-nobase_includeHEADERS 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 uninstall-nobase_dist_dataDATA \ uninstall-nobase_includeHEADERS api-docs: doxygen tsk3/docs/Doxyfile man-html: cd man;build-html # 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: sleuthkit-3.2.3/man/000777 000765 000024 00000000000 11643647554 015123 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/NEWS.txt000644 000765 000024 00000216125 11643647435 015666 0ustar00carrierstaff000000 000000 Numbers refer to SourceForge.net tracker IDs: http://sourceforge.net/tracker/?group_id=55685 ---------------- VERSION 3.2.3 -------------- New Features: - new TskAuto method (handleNotification()) that gets verbose messages that allow for debugging when the class makes decisions. - DOS partitions are loaded even if an extended partition fails to load - new TskAuto::findFilesInFs(TSK_FS_INFO *) method - Need to only specify first E01 file and the rest are found - Changed docs license to non-commercial - Unicode conversion routines fix invalid UTF-16 text during conversion - Added '-d' to tsk_recover to specify directory to recover Bug Fixes: - Added check to fatfs_open to compare first sectors of FAT if we used backup boot sector and verify it is FAT32. - More checks to make sure that FAT short names are valid ASCII - 3406523: Mactime size sanity check - 3393960: hfind reading of Windows input file - 3316603: Error reading last blocks of RAW CD images - Fixed bugs in how directories and files were detected in TskAuto ---------------- VERSION 3.2.2 -------------- Bug Fixes - 3213886: ISO9660 directory hole not advancing - 3173095 contd: Updated checks so that tougher FAT checks are applied to deleted directories. - 3303678: Image type in Sqlite DB is now not always 0 - 3303679: Deleted FAT files have more name cleanup in short names - X: Fixed FAT orphan file problem (overwriting of dinodes and adding '.' to seen list. New Features: - 3213888: RAW CD format - Auto class accepts TSK_IMG_INFO as argument - Copies of split image file names are stored in TSK so that the caller can free them before TSK_IMG_INFO is freed. ---------------- VERSION 3.2.1 -------------- Bug Fixes - 3108272: fls arguments for -d and -u - 3105539: compile error issues because of SQlite and pthreads - 3173095: missing FAT files because of invalid dates. - 3184419: mingew compile errors. - 3191391: surround file name in quotes in mactime -d csv output New Features: - A single dummy entry is added to the SQlite DB if no volume exists so that all programs can assume that there will be at least one volume in the table. - 3184455: allow srcdir != builddir ---------------- VERSION 3.2.0 -------------- Bug Fixes - 3043092: Minor logic errors with ifind code. - FAT performance fix when looking for parent directories in $OrphanFiles. - 3052302: Crash on NTFS/UFS detection test because of corrupt data -- tsk_malloc error. - 3088447: Error adding attribute because of run collision. Solved by assigning unique IDs. New Features: - 3012324: Name mangling moved out of library into outer tools so that they can see control characters if they want to. Patch by Anthony Lawrence. - 2993806: ENUM values have a specified NONE value if you don't want to specify any special flags. Patch by Anthony Lawrence. - 3026989: Add -e and -s flags to img_cat. patch by Simson Garfinkel. - 2941805: Add case sensitive flag to fsstat in HFS. Patch by Rob Joyce. - 3017764: Changed how default NTFS $DATA attribute was named. Now it has no name, while it previously had a fake name of "$Data". - New TskAuto class. - New tsk_loaddb, tsk_recover, tsk_comparedir, and tsk_gettimes tools. ---------------- VERSION 3.1.3 -------------- Bug Fixes - 3006733: FAT directory listings were slow because the inner code was not stopping when it found the parent directory. - Adjusted sanity / testing code on FAT directory entries to allow non-ascii in extensions and reject entries with lots of 0s. - 3023606: Ext2 / ffs corrupted file names. - Applied NTFS SID fixes from Mandiant. - ntfs_load_secure() memory leak patch from Michael Cohen ---------------- VERSION 3.1.2 -------------- Bug Fixes - 2982426: FAT directory listings were slow because the entire image was being scanned for parent directory information. - 2982965: fs_attr length bug fix. - 2988619: mmls -B display error. - 2988330: ntfs SII cluster size increment bug - 2991487: Zeroed content in NTFS files that were not fully intialized. - 2993767: Slow FAT listings of OrphanFiles because hunt for parent directory resulted in many searches for OrphanFiles. Added cache of OrphanFiles. - 2999567: ifind was not stopping after first hit. - 2993804: read past end of file did not always return -1. ---------------- VERSION 3.1.1 -------------- Bug Fixes - 2954703: ISO9660 missing files because duplicate files had same starting block. - 2954707: ISO9660 missing some files with zero length and duplicate starting block. Also changed behavior of how multiple volume descriptors are processed. - 2955898: Orphan files not found if no deleted file names exist. - 2955899: NTFS internal setting of USED flag. - 2972721: Sorter fails with hash lookup if '-l' is given. - 2941813: Reverse HFS case sensitive flags (internal fix only) - 2954448: Debian package typo fixes, etc. - 2975245: sorter ignores realloc entries to reduce misleading mismatch entries and duplicate entries. ---------------- VERSION 3.1.0 -------------- New Features and Changes - 2206285: HFS+ can now be read. Lots of tracker items about this. Thanks to Rob Joyce and ATC-NY for many of the patches and reports. - 2677069: DOS Safety Partitions in GPT Volume Systems are better detected instead of reporting multiple VSs. - Windows executables can be build in Visual Studio w/out needing other image format libraries. - 2367426: Uninitialized file space is shown if slack space is requested. - 2677107 All image formats supported by AFFLIB can be accessed by specifying the "afflib" type. - 2206265: sigfind can now process non-raw files. - 2206331: Indirect block addresses are now available in the library and command line tools. They are stored in a different attribute. - Removed 'docs' files and moved them to the wiki. - Removed disk_stat and disk_sreset because they were out of date and hdparm now has the same functionality. - 2874854: Image layer tools now support non-512 byte device sector sizes. Users can specify sector size using the -b argument to the command line tools. This has several consequences: -- 'mmls -b' is now 'mmls -B'. Similarly with istat -b. -- Changed command line format for '-o' so that sector size is specified only via -b and not using '-o 62@4096'. - 2874852: Sanity checking on partition table entires is relaxed and only first couple of partitions are checked to make sure that they can fit into the image. - 2895607: NTFS SID data is available in the library and 'istat'. - 2206341: AFF encrypted images now give more proper error message if password is not given. - 2351426: mactime is now distributed with Windows execs. Developer-level Changes - Abstracted name comparison to file system-specific function. - Added support in mactime to read body files with comment lines. - 2596153: Changed img_open arguments, similar to getopt(). - 2797169: tsk_fs_make_ls is now supported as an external library function. Now named tsk_fs_meta_make_ls. - 2908510: Nanosecond resolution of timestamps is now available. - 2914255: Version info is now available in .h files in both string and integer form. Bug Fixes: - 2568528: incorrect adjustment of attribute FILLER offset. - 2596397: Incorrect date sorting in mactime. - 2708195: Errors when doing long reads in fragmented attributes. - Fixed typo bugs in sorter (reported via e-mail by Drew Hunt). - 2734458: added orphan cache map to prevent slow NTFS listing times. - 2655831: Sorter now knows about the ext2 and ext3 types. - 2725799: ifind not converting UTF16 names properly on Windows because it was using endian ordering of file system and not local system. - 2662168: warning messages on macs when reading the raw character device. - 2778170: incorrect read size on resident attributes. - 2777633: missing second resolution on FAT creation times. - Added the READ_SHARE option to the CreateFile command for split image files. Patch by Christopher Siwy. - 2786963: NTFS compression infinite loop fix. - 2645156: FAT / blkls error getting slack because allocsize was being set too small (and other values were not being reset). - 2367426: Zeros are set for VDL slack on NTFS files. - 2796945: Inifite loop in fs_attr. - 2821031: Missing fls -m fields. - 2840345: Extended DOS partitions in extended partitions are now marked as Meta. - 2848162: Reading attributes at offsets that are on boundary of run fragment. - 2824457: Fixed issue reading last block of file system with blkcat. - 2891285: Fixed issue that prevented reads from the last block of a file system when using the POSIX-style API. - 2825690: Fixed issue that prevented blkls -A from working. - 2901365: Allow FAT files to have a 0 wdate. - 2900761: Added FAT directory sanity checks to prevent infinite loops. - 2895607: Fixed various memory leaks. - 2907248: Fixed image layer cache crash. - 2905750: all file system read() functions now return -1 when offset given is past end of file. ---------------- VERSION 3.0.1 -------------- 11/11/08: Bug Fix: Fixed crashing bug in ifind on FAT file system. Bug: 2265927 11/11/08: Bug Fix: Fixed crashing bug in istat on ExtX $OrphanFiles dir. Bug: 2266104 11/26/08: Update: Updated fls man page. 11/30/08: Update: Removed TODO file and using tracker for bugs and feature requests. 12/29/08: Bug Fix: Fixed incorrectly setting block status in file_walk for compressed files (Bug: 2475246) 12/29/08: Bug Fix: removed fs_info field from FS_META because it was not being set and should have been removed in 3.0. Reported by Rob Joyce and Judson Powers. 12/29/08: Bug Fix: orphan files and NTFS files found via parent directory have an unknown file name type (instead of being equal to meta type). (Bug: 2389901). Reported by Barry Grundy. 1/12/09: Bug Fix: Fixed ISO9660 bug where large directory contents were not displayed. (Bug: 2503552). Reported by Tom Black. 1/24/09: Bug Fix: Fixed bug 2534449 where extra NTFS files were shown if the MFT address was changed to 0 because fs_dir_add was checking the address and name. Reported by Andy Bontoft. 1/29/09: Update: Fixed fix for bug 2534449. The fix is in ifind instead of fs_dir_add(). 2/2/09: Update: Added RPM spec file from Morgan Weetmam. ---------------- VERSION 3.0.0 -------------- 0/00/00: Update: Many, many, many API changes. 2/14/08: Update: Added mmcat tool. 2/26/08: Update: Added flags to mmls to specify partition types. 3/1/08: Update: Major update of man pages. 4/14/08: Bug Fix: Fixed the calculation of "actual" last block. Off by 1 error. Reported by steve. 5/23/08: Bug Fix: Incorrect malloc return check in srch_strings. reported by Petri Latvala. 5/29/08: Bug Fix: Fixed endian ordering bug in ISO9660 code. Reported by Eduardo Aguiar de Oliveira. 6/17/08: Update: 'sorter' now uses the ifind method for finding deleted NTFS files (like Autopsy) does instead of relying on fls. Reported by John Lehr. 6/17/08: Update: 'ifind -p' reports data on ADS. 7/10/08: Update: FAT looks for a backup boot sector in FAT32 if magic is 0 7/21/08: Bug Fix: Changed define of strcasecmp to _stricmp instead of _strnicmp in Windows. (reported by Darren Bilby). 7/21/08: Bug Fix: Fall back to open "\\.\" image files on Windows with SHARE_WRITE access so that drive devices can be opened. (reported by Darren Bilby). 8/20/08: Bug Fix: Look for Windows objects when opening files in Cygwin, not just Win32. Reported by Par Osterberg Medina. 8/21/08: Update: Renamed library and install header files to have a '3' in them to allow parallel installations of v2 and v3. Suggested by Simson Garfinkel. 8/22/08: Update: Added -b option to sorter to specify minimum file size to process. Suggested by Jeff Kell. 8/22/08: Update: Added libewf as a requirement to build win32 so that E01 files are supported. 8/29/08: Update: Added initial mingw patches for cross compiling and Windows. Patches by Michael Cohen. 9/X/08: Update: Added ability to access attibutes 9/6/08: Update: Added image layer cache. 9/12/08: Bug Fix: Fixed crash from incorrectly cleared value in FS_DIR structure. Reported and patched by Jason Miller. 9/13/08: Update: Changed d* tool names to blk*. 9/17/08: Update: Finished mingw support so that both tools and library work with Unicode file name support. 9/22/08: Update: Added new HFS+ code from Judson Powers and Rob Joyce (ATC-NY) 9/24/08: Bug Fix: Fixed some cygwin compile errors about types on Cygwin. Reported by Phil Peacock. 9/25/08: Bug Fix: Added O_BINARY to open() in raw and split because Cygwin was having problems. Reported by Mark Stam. 10/1/08: Update: Added ifndef to TSK_USE_HFS define to allow people to define it on the command line. Patch by RB. ---------------- VERSION 2.52 -------------- 2/12/08: Bug Fix: Fixed warning messages in mactime about non-Numeric data. Reported by Pope. 2/19/08: Bug Fix: Added #define to tsk_base_i.h to define LARGEFILE64_SOURCE based on LARGEFILE_SOURCE for older Linux systems. 2/20/08: Bug Fix: Updated afflib references and code. 3/13/08: Update: Added more fixes to auto* so that AFF will compile on more systems. I have confirmed that AFFLIB 3.1.3 will run with OS X 10.4.11. 3/14/08: Bug Fix: Added checks to FAT code that calcs size of directories. If starting cluster of deleted dir points into a cluster chain, then problems can occur. Reported by John Ward. 3/19/08: Update: I have verified that this compiles with libewf-20070512. 3/21/08: Bug Fix: Deleted Ext/FFS directories were not being recursed into. This case was rare (because typically the metadata are wiped), but possible. Reported by JWalker. 3/24/08: Update: I have verified that this compiles with libewf-20080322. Updates from Joachim Metz. 3/26/08: Update: Changed some of the header file design for the tools so that the define settings in tsk_config.h can be used (for large files). 3/28/08: Update: Added config.h reference to srch_strings to get the LARGEFILE support. 4/5/08: Update: Improved inode argument number parsing function. ---------------- VERSION 2.51 -------------- 1/30/08: Bug Fix: Fixed potential infinite loop in fls_lib.c. Patch by Nathaniel Pierce. 2/7/08: Bug Fix: Defined some of the new constants that are used in disktools because older Linux distros did not define them. Reported by Russell Reynolds. 2/7/08: Bug Fix: Modified autoconf to check for large file build requirements and look for new 48-bit structures needed by disktools. Both of these were causing problems on older Linux distros. 2/7/08: Update: hfind will normalize hash values in database so that they are case insensitive. ---------------- VERSION 2.50 -------------- 12/19/07: Update: Finished upgrade to autotools building design. No longer include file, afflib, libewf. Resulted in many source code layout changes and sorter now searches for md5, sha1, etc. ---------------- VERSION 2.10 -------------- 7/12/07: Update: 0s are returned for AFF pages that were not imaged. 7/31/07: Bug Fix: ifind -p could crash if a deleted file name was found that did not point to a valid meta data stucture. (Reported by Andy Bontoft) 8/5/07: Update: Added NSRL support back into sorter. 8/15/07: Update: Errors are given if supplied sector offset is larger than disk image. Reported by Simson Garfinkel. 8/16/07: Update: Renamed MD5 and SHA1 functions to TSK_MD5_.. and TSK_SHA_.... 8/16/07: Update: tsk_error_get() does not reset the error messages. 9/26/07: Bug Fix: Changed FATFS check for valid dentries to consider second values of 30. Reported by Alessandro Camillo. 10/18/07: Update: inode_walk for NTFS and FAT will not abort if data corruption is found in one entry -- instead they will just skip it. 10/18/07: Update: tsk_os.h uses standard gcc system names instead of TSK specific ones. 10/18/07: Update: Updated raw.c to use ioctl commands on OS X to get size of raw device because it does not work with SEEK_END. Patch by Rob Joyce. 10/31/07: Update: Finished upgrade to fatfs_file_walk_off so that walking can start at a specific offset. Also finished upgrade that caches FAT run list to make the fatfs_file_walk_off more effecient. 11/14/07: Update: Fixed few places where off_t was being used instead of OFF_T. Reported by GiHan Kim. 11/14/07: Update: Fixed a memory leak in aff.c to free AFF_INFO. Reported by GiHan Kim. 11/24/07: Update: Finished review and update of ISO9660 code. 11/26/07: Bug Fix: Fixed 64-bit calculation in HFS+ code. Submitted by Rob Joyce. 11/29/07: Update: removed linking of srch_strings.c and libtsk. Reported by kwizart. 11/30/07: Upate: Made a #define TSK_USE_HFS compile flag for incorporating the HFS support (flag is in src/fstools/fs_tools_i.h) 11/30/07: Update: restricted the FAT dentry sanity checks to verify space padding in the name and latin-only extensions. 12/5/07: Bug Fix: fs_read_file_int had a bug that ignored the type passed for NTFS files. Reported by Dave Collett. 12/12/07: Update: Changed teh FAT dentry sanity checks to allow spaces in volume labels and do more checking on the attribute flag. ---------------- VERSION 2.09 -------------- 4/6/07: Bug Fix: Inifite loop in ext2 and ffs istat code because of using unsigned size_t variable. Reported by Makoto Shiotsuki. 4/16/07: Bug Fix: Changed use of fseek() to fseeko() in hashtools. Patch by Andy Bontoft. 4/16/07: Bug Fix: Changed Win32 SetFilePointer to use LARGE_INTEGER. Reported by Kim GiHan. 4/19/07: Bug Fix: Not all FAT orphan files were being found because of and offset error. 4/26/07: Bug Fix: ils -O was not working (link value not being checked). Reported by Christian Perst. 4/27/07: Bug Fix: ils -r was showing UNUSED inodes. Reported by Christian Perst. 5/10/07: Update: Redefined the USED and UNUSED flags for NTFS so that UNUSED is set when no attributes exist. 5/16/07: Bug Fix: Fixed several bounds checking bugs that may cause a crash if the disk image is corrupt. Reported by Tim Newsham (iSec Partners) 5/17/07: Update: Updated AFFLIB to 2.2.11 5/17/07: Update: Updated libewf to libewf-20070512 5/17/07: Update: Updated file to 4.20 5/29/07: Update: Removed NTFS SID/SDS contributed code because it causes crashes on some systems and its output is not entirely clear. (most recent bug reported by Andy Scott) 6/11/07: Update: Updated AFFLIB to 2.2.12. 6/12/07: Bug Fix: ifind -p was not reporting back info on the allocated name when one existed (because strtok was overwritting the name when the search continued). Reported by Andy Bontoft. 6/13/07: Update: Updated file to 4.21 ---------------- VERSION 2.08 -------------- 12/19/06: Bug Fix: ifind_path was not setting *result when root inode was searched for. patch by David Collett. 12/29/06: Update: Removed 'strncpy' in ntfs.c to manual assignment of text for '$Data' and 'N/A' for performance reasons. 1/11/07: Update: Added duname to FS_INFO that contains a string of name for a file system's data unit -- Cluster for example. 1/19/07: Bug Fix: ifind_path was returning an error even after some files were found. Errors are now ignored if a file was found. Reported by Michael Cohen. 1/26/07: Bug Fix: Fixed calcuation of inode numbers in fatfs.c (reported by Simson Garfinkel). 2/1/07: Update: Changed aff-install to support symlinked directory. 2/1/07: Update: img_open modified so that it does not report errors for s3:// and http:// files that do not exist. 2/5/07: Update: updated *_read() return values to look for "<0" instead of simply "== -1". (suggested by Simson Garfinkel). 2/8/07: Update: removed typedef for uintptr in WIN32 code. 2/13/07: Update: Applied patch from Kim Kulak to update HFS+ code to internal design changes. 2/16/07: Update: Renamed many of the external data structures and flags so that they start with TSK_ or tsk_ to prevent name collisions. 2/16/07: Update: Moved MD5 and SHA1 routines and binaries to auxtools instead of hashtools so that they are more easy to access. 2/16/07: Update: started redesign and port of hashtools. 2/21/07: Update: Changed inode_walk callback API to remove the flags variable -- this was redundant since flags are also in TSK_FS_INODE. Same for TSK_FS_DENT. 3/7/07: Bug Fix: fs_read_file failed for NTFS resident files. Reported by Michael Cohen. 3/8/07: Bug Fix: FATFS assumed a 512-byte sector in a couple of locations. 3/13/07: Update: Finished hashtools update. 3/13/07: Update: dcat reads block by block instead of all at once. 3/23/07: Update: Change ntfs_load_secure to allocate all of its needed memory at once instead of doing reallocs. 3/23/07: Update: Updated AFFLIB to 2.2.0 3/24/07: Bug Fix: Fixed many locations where return value from strtoull was not being properly checked and therefore invalid numbers were not being detected. 3/24/07: Bug Fix: A couple of error messages in ntfs_file_walk should have been converted to _RECOVER when the _RECOVERY flag was given. 3/24/07: Update: Changed behavior of ntfs_file_walk. If no type is given, then a default type is chosen for files and dirs. Now, no error is generated if that type does not exist -- similar to how no error is generated if a FAT file has 0 file size. 3/26/07: Update: cleaned up and documented fs_data code more. 3/29/07: Update: Updated AFF to 2.2.2. 3/29/07: Update: Updated install scripts for afflib, libewf, and file to touch files so that the auto* files are in the correct time stamp order. 4/5/07: Bug Fix: Added sanity checks to offsets and addresses in ExtX and UFS group descriptors. Reported by Simson Garfinkel. ---------------- VERSION 2.07 -------------- 9/6/06: Update: Changed TCHAR and _T to TSK_TCHAR and _TSK_T to avoid conflicts with other libraries. 9/18/06: Update: Added tsk_list_* functions and strutures. 9/18/06: Update: Added checks for recursive FAT directories. 9/20/06: Update: Changed FS_META_* flags for LINK and UNLINK and moved them to ILS_? flags. 9/20/06: Update: added flags to ils to find only orphan inodes. 9/20/06: Update: Added Orphan support for FAT, NTFS, UFS, Ext2, ISO. 9/20/06: Update: File walk actions now have a flag to identify if a block is SPARSE or not (used to identify if the address being passed is valid or made up). 9/21/06: Update: Added file size sanity check to fatfs_is_dentry and fixed assignment of fatfs->clustcnt. 9/21/06: Update: block_, inode, and dent_walk functions now do more flag checking and make sure that some things are set instead of making the calling code do it. 9/21/06: Update: Added checks for recursive (infinite loop) NTFS, UFS, ExtX, and ISO9660 directories. 9/21/06: Update Added checks to make sure that walking the FAT for files and directories would result in an infinite loop (if FAT is corrupt). 9/21/06: Update: Added -a and -A to dls to specify allocated and unallocated blocks to display. 9/21/06: Update: Updated AFFLIB to 1.6.31. 9/22/06: Update: added a fs_read_file() function that allows you to read random parts of a file. 10/10/06: Update: Improved performance of fs_read_file() and added new FS_FLAG_META_COMP and FS_FLAG_DATA_COMP flags to show if a file and data are using file system-level compression (NTFS only). 10/18/06: Bug fix: in fs_data_put_run, added a check to see if the head was null before looking up. An extra error message was being created for nothing. 10/18/06: Bug Fix: Added a check to the compression buffer to see if it is null in _done(). 10/25/06: Bug Fix: Added some more bounds checks to NTFS uncompression code. 11/3/06: Bug Fix: added check to dcat_lib in case the number of blocks requested is too large. 11/07/06: Update: Added fs_read_file_noid wrapper around fs_read_file interface. 11/09/06: Update: Updated AFF to 1.7.1 11/17/06: Update: Updated libewf to 20061008-1 11/17/06: Bug Fix: Fixed attribute lookup bug in fs_data_lookup. Patch by David Collett. 11/21/06: Bug Fix: Fixed fs_data loops that were stopping when they hit an unused attribute. Patch by David Collett. 11/21/06: Bug Fix: sorter no longer clears the path when it starts. THis was causing errors on Cygwin because OpenSSL libraries could not be found. 11/22/06: Update: Added a tskGetVersion() function to return the string of the current version. 11/29/06: Update: Added more tsk_error_resets to more places to prevent extra error messages from being displayed. 11/30/06: Update: Added Caching to the getFAT function and to fs_read. 12/1/06: Update: Changed TSK_LIST to a reverse sorted list of buckets. 12/5/06: Bug Fix: Fixed FS_DATA_INUSE infinite loop bug. 12/5/06: Bug Fix: Fixed infinite loop bug with NTFS decompression code. 12/5/06: Update: Added NULL check to fs_inode_free (from Michael Cohen). 12/5/06: Update: Updated ifind_path so that an allocated name will be shown if one exists -- do not exit if we find simply an unallocated entry with an address of 0. Suggested by David Collett. 12/6/06: Update: Updated file to version 4.18. 12/6/06: Update: Updated libaff to 2.0a10 and changed build process accordingly. 12/7/06: Update: Added a tsk_error_get() function that returns a string with the error messages -- can be used instead of tsk_error_print. 12/7/06: Update: fixed some memory leaks in FAT and NTFS code. 12/11/06: Bug Fix: fatfs_open error message code referenced a value that was in freed memory -- reordered statements. 12/15/06: Update: Include VCProj files in build. ---------------- VERSION 2.06 -------------- 8/11/06: Bug Fix: Added back in ASCII/UTF-8 checks to remove control characters in file names. 8/11/06: Bug Fix: Added support for fast sym links in UFS1 8/11/06: Update: Redesigned the endian support so that getuX takes only the endian flag so that the Unicode design could be changed as well. 8/11/06: Update: Redesigned the Unicode support so that there is a tsk_UTF... routine instead of fs_UTF... 8/11/06: Update: Updated GPT to fully convert UTF16 to UTF8. 8/11/06: Update: There is now only one aux_tools header file to include instead of libauxtools and/or aux_lib, which were nearly identical. 8/16/06: Bug Fix: ntfs_dent_walk could segfault if two consecutive unallocated entries were found that had an MFT entry address of 0. Reported by Robert-Jan Mora. 8/16/06: Update: Changed a lot of the header files and reduced them so that it is easier to use the library and only one header file needs to be included. 8/21/06: Update: mmtools had char * instead of void * for walk callback 8/22/06: Update: Added fs_load_file function that returns a buffer full with the contents of a file. 8/23/06: Update: Upgraded AFFLIB to 1.6.31 and libewf to 20060820-1. 8/25/06: Update: Created printf wrappers so that output is UTF-16 on Windows and UTF-8 on Unix. 8/25/06: Update: Continued port to Windows by starting to use more TCHARS and defining needed macros for the Unix side. 8/25/06: Bug Fix: Fixed crash that could occur because of SDS code in NTFS. (reported by Simson Garfinkel) (BUG: 1546925). 8/25/06: Bug Fix: Fixed crash that could occur because path stack became corrupt with deep directories or corrupt images. (reported by Simson Garfinkel) (BUG: 1546926). 8/25/06: Bug Fix: Fixed infinite loop that could occur when trying to determine size of FAT directory when the FAT has a loop in it. (BUG: 1546929) 8/25/06: Update: Improved FAT checking code to look for '.' and '..' entries when inode value is replaced during dent_walk. 8/29/06: Update: Finished Win32 port and changes to handle UTF-16 vs UTF-8 inputs. 8/29/06: Update: Created a parse_inum function to handle parsing inode addresses from command line. 8/30/06: Update: Made progname a local variable instead of global. 8/31/06: Bug Fix: Fixed a sizeof() error with the memset in fatfs_inode_walk for the sect_alloc buffer. 8/31/06: Update: if mktime in dos2unixtime returns any negative value, then the return value is set to 0. Windows and glibc seem to have different return values. ---------------- VERSION 2.05 -------------- 5/15/06: Bug Fix: Fixed a bug in img_cat that could cause it to go into an infinite loop. (BUG: 1489284) 5/16/06: Update: Fixed printf statements in tsk_error.c that caused warning messages for some compilers. Reported by Jason DePriest. 5/17/06: Update: created a union of file system-specific file times in FS_INFO (Patch by Wyatt Banks) 5/22/06: Bug Fix: Updated libewf to 20060520 to fix bug with reported image size. (BUG: 1489287) 5/22/06: Bug Fix: Updated AFFLIB to 1.6.24 so that TSK could compile in CYGWIN. (BUG: 1493013) 5/22/06: Update: Fixed some more printf statements that were causing compile warnings. 5/23/06: Update: Added a file existence check to img_open to make error message more accurate. 5/23/06: Update: Usage messages had extra "Supported image types message". 5/25/06: Update: Added block / page range to fsstat for raw and swapfs. 6/5/06: Update: fixed some typos in the output messages of sigfind (reported by Jelle Smet) 6/9/06: Update: Added HFS+ template to sigfind (Patch by Wyatt Banks) 6/9/06: Update: Added ntfs and HFS template to sigfind. 6/19/06: Update: Begin Windows Visual Studio port 6/22/06: Update: Updated a myflags check in ntfs.c (reported by Wyatt Banks) 6/28/06: Update: Incorporated NTFS compression patch from I.D.E.A.L. 6/28/06: Update: Incorporated NTFS SID patch from I.D.E.A.L. 6/28/06: Bug Fix: A segfault could occur with NTFS if no inode was loaded in the dent_walk code. (Reported by Pope). 7/5/06: Update: Added tsk_error_reset function and updated code to use it. 7/5/06: Update: Added more sanity checks to the DOS partitions code. 7/10/06: Update: Upgraded libewf to version 20060708. 7/10/06: Update: Upgraded AFFLIB to version 1.6.28 7/10/06: Update: added 'list' option to usage message so that file system, image, volume system types are listed only if '-x list' is given. Suggested by kenshin. 7/10/06: Update: Compressed NTFS files use the compression unit size specified in the header. 7/10/06: Update: Added -R flag to icat to suppress recovery warnings and use this flag in sorter to prevent FAT recovery messages from filling up screen. 7/10/06: Update: file_walk functions now return FS_ERR_RECOVERY error codes for most cases if the RECOVERY flag is set -- this allows the errors to be more easily suppressed. 7/12/06: Update: Removed individual libraries and now make a single static libtsk.a library. 7/12/06: Update: Cleaned up top-level Makefile. Use '-C' flag (suggested by kenshin). 7/14/06: Update: Fixed and redesigned some of the new NTFS compression code. Changed variable names. 7/20/06: Update: Fixed an NTFS compression bug if a sub-block was not compressed. 7/21/06: Update: Made NTFS compression code thread friendly. ---------------- VERSION 2.04 -------------- 12/1/05: Bug Fix: Fixed a bug in the verbose output of img_open that would crash if no type or offset was given. Reported and patched by Wyatt Banks. 12/20/05: Bug Fix: An NTFS directory index sanity check used 356 instead of 365 when calculating an upper bound on the times. Reported by Wyatt Banks. 12/23/05: Bug Fix: Two printf statements in istat for NTFS printed to stdout instead of a specific file handle. Reported by Wyatt Banks. 1/22/06: Bug Fix: fsstat, imgstat and dcalc were using a char instead of int for the return value of getopt, which caused some systems to not execute the programs. (internal fix and later reported by Bernhard Reiter) 2/23/06: Update: added support for FreeBSD 6. 2/27/06: Bug Fix: Indirect blocks would nto be found by ifind with UFS and Ext2. Reported by Nelson G. Mejias-Diaz. (BUG: 1440075) 3/9/06: Update: Added AFF image file support. 3/14/06: Bug Fix: If the first directory entry of a UFS or ExtX block was unallocated, then later entries may not be shown. Reported by John Langezaal. (BUG: 1449655) 4/3/06: Update: Finished the improved error handling. Many internal changes, not many external changes. error() function no longer used and instead tsk_err variables and function are used. This makes the library more powerful. 4/5/06: Update: The byte offset for a volume is now passed to the mm_ and fs_ functions instead of img_open. This allows img_info to be used for multiple volumes at the same time. This required some mm_ changes. 4/5/06: Update: All TSK libraries are written to the lib directory. 4/6/06: Update: Added FS_FLAG_DATA_RES flag to identify data that are resident in ntfs_data_walk (suggested by Michael Cohen). 4/6/06: Update: The partition code (media Management) now checks that a partition starts before the end of the image file. There are currently no checks about the end of the partition though. 4/6/06: Update: The media management code now shows unpartitioned space as such from the end of the last partition to the end of the image file (using the image file size). (Suggested by Wyatt Banks). 4/7/06: Update: New version of ISO9660 code from Wyatt Banks and Crucial Security added and other code updated to allow CDs to be analyzed. 4/7/06: There was a conflict with guessuXX with mmtools and fstools. Renamed to mm_guessXX and fs_guessXX. 4/10/06: Upgraded AFFLIB to 1.5.6 4/12/06: Added version of libewf and support for it in imgtools 4/13/06: Added new img_cat tool to extract raw data from an image format. 4/24/06: Upgraded AFFLIB to 1.5.12 4/24/06: split and raw check if the image is a directory 4/24/06: Updated libewf to 20060423-1 4/26/06: Updated makedefs to work with SunOS 5.10 5/3/06: Added iso9660 patch from Wyatt Banks so that version number is not printed with file name. 5/4/06: Updated error checking in icat, istat, fatfs_dent, and ntfs_dent 5/8/06: Updated libewf to 20060505-1 to fix some gcc 2 compile errors. 5/9/06: Updated AFFLIB to 1.6.18 5/11/06: Cleaned up error handling (removed %m and unused legacy code) 5/11/06: Updated AFFLIB to 1.6.23 ---------------- VERSION 2.03 -------------- 7/26/05: Update: Removed incorrect print_version() statement from fs_tools.h (reported by Jaime Chang) 7/26/05: Update: Renamed libraries to start with "lib" 7/26/05: Update: Removed the logfp variable for verbose statements and instead use only stderr. 8/12/05: Update: If time is 0, then it is put as 00:00:00 instead of the default 1970 or 1980 time. 8/13/05: Update: Added Unicode support for FAT and NTFS (Supported by I.D.E.A.L. Technology Corp). 9/2/05: Update: Added Unicode support for UFS and ExtX. Non-printable ASCII characters are no longer replaced with '^.'. 9/2/05: Update: Improved the directory entry sanity checks for UFS and ExtX. 9/2/05: Update: Upgraded file to version 4.15. 9/2/05: Update: The dent_walk code of all file systems does not abort if a sub-directory is encountered with an error. If it is the top directory explicitly called, then it still gives an error. 9/2/05: Bug Fix: MD5 and SHA-1 values were incorrect under AMD64 systems because the incorrect variable sizes were being used. (reported by: Regis Friend Cassidy. BUG: 1280966) 9/2/05: Update: Changed all licenses in TSK to Common Public License (except those that were already IBM Public License). 9/15/05: Bug Fix: The Unicode names would not be displayed if the FAT short name entry was using code pages. The ASCII name check was removed, which may lead to more false positives during inode_walk. 10/05/05: Update: improved the sector size check when the FAT boot sector is read (check for specific values besides just mod 512). 10/12/05: Update: The ASCII name check was added back into FAT, but the check no longer looks for values over 0x80. 10/12/05: Update: The inode_walk function in FAT skips clusters that are allocated to files. This makes it much faster, but it will now not find unallocated directory entries in the slack space of allocated files. 10/13/05: Update: sorter updated to handle unicode in HTML output. ---------------- VERSION 2.02 -------------- 4/27/05: Bug Fix: the sizes of 'id' were not consistent in the front-end and library functions for icat and ffind. Reported by John Ward. 5/16/05: Bug Fix: fls could segfault in FAT if short name did not exist. There was also a bug where the long file name variable (fatfs->lfn_len) was not reset after processing a directory and the next entry could incorrectly get the long name. Reported by Jaime Chang. BUG: 1203673. 5/18/05: Update: Updated makedefs to support Darwin 8 (OS X Tiger) 5/23/05: Bug Fix: ntfs_dent_walk would not always stop when WALK_STOP was returned. This caused some issues with previous versions of ifind. This was fixed. 5/24/05: Bug Fix: Would not compile under Suse because it had header file conflicts for the size of int64_t. Reported by: Andrea Ghirardini. BUG: 1203676 5/25/05: Update: Fixed some memory leaks in fstools (reported by Jaime Chang). 6/13/05: Update: Compiled with g++ to get better warning messages. Fixed many signed versus unsigned comparisons, -1 assignments to unsigned vars, and some other minor internal issues. 6/13/05: Bug Fix: if UFS or FFS found a valid dentry in unallocated space, it could have a documented length that is larger than the remaining unallocated space. This would cause an allocated name to be skipped. BUG: 1210204 Reported by Christopher Betz. 6/13/05: Update: Improved design of all dent code so that there are no more global variables. 6/13/05: Update: Improved design of FAT dent code so that FATFS_INFO does not keep track of long file name information. 6/13/05: Bug Fix: If a cluster in a directory started with a strange dentry, then FAT inode_walk would skip it. The fixis to make sure that all directory sectors are processed. (BUG: 1203669). Reported by Jaime Chang. 6/14/05: Update: Changed design of FS_INODE so that it contains the inode address and the inode_walk action was changed to remove inum as an argument. 6/15/05: Update: Added 'ils -o' back in as 'ils -O' to list open and deleted files. 6/15/05: Update: Added '-m' flag to mactime so that it prints the month as a number instead of its name. 7/2/05: Bug Fix: If an NTFS file did not have a $DATA or $IDX_* attribute, then fls would not print it. The file had no content, but the name should be shown. (BUG: 1231515) (Reported by Fuerst) ---------------- VERSION 2.01 -------------- 3/24/05: Bug Fix: ffind would fail if the directory had two non-printable chars. The handling of non-printable chars was changed to replace with '^.'. (BUG: 1170310) (reported by Brian Baskin) 3/24/05: Bug Fix: icat would not print the output to stdout when split images were used. There was a bug in the image closing process of icat. (BUG: 1170309) (reported by Brian Baskin) 3/24/05: Update: Changed the header files in fstools to make fs_lib.h more self contained. 4/1/05: Bug Fix: Imgtools byte offset with many leading 0s could cause issues. (BUG: 1174977) 4/1/05: Update: Removed test check in mmtools/dos.c for value cluster size because to many partition tables have that as a valid field. Now it checks only OEM name. 4/8/05: Update: Updated usage of 'strtoul' to 'strtoull' for blocks and inodes. ---------------- VERSION 2.00 -------------- 1/6/05: Update: Added '-b' flag to 'mmls' so that sizes can be printed in bytes. Suggested and a patch proposed by Matt Kucenski 1/6/05: Update: Define DADDR_T, INUM_T, OFF_T, PNUM_T as a static size and use those to store values in data structures. Updated print statements as well. 1/6/05: Update: FAT now supports larger images becuase the inode address space is 64-bits. 1/6/05: Moved guess and get functions to misc from mmtools and fstools. 1/7/05: Update: Added imgtools with support for "raw" and "split" layers. All fstools have been updated. 1/7/05: Update: removed dtime from ils output 1/9/05: Update: FAT code reads in clusters instead of sectors to be faster (suggested by David Collett) 1/9/05: Update: mmtools uses imgtools for split images etc. 1/10/05: Update: Removed usage of global variables when using file_walk internally. 1/10/05: Update: mmls BSD will use the next sector automatically if the wrong is given instead of giving an error. 1/10/05: Update: Updated file to version 4.12 1/11/05: Update: Added autodetect to file system tools. 1/11/05: Update: Changed names to specify file system type (not OS-based) 1/11/05: Update: Added '-t' option to fsstat to give just the type. 1/11/05: Update: Added autodetect to mmls 1/17/05: Update: Added the 'mmstat' tool that gives the type of volume system. 1/17/05: Update: Now using CVS for local version control - added date stamps to all files. 2/20/05: Bug Fix: ils / istat would go into an infinte loop if the attribute list had an entry with a length of 0. Reported by Angus Marshall (BUG: 1144846) 3/2/05: Update: non-printable letters in ExtX/UFS file names are now replaced by a '.' 3/2/05: Update: Made file system tools more library friendly by making stubs for each application. 3/4/05: Update: Redesigned the diskstat tool and created the disksreset tool to remove the HPA temporarily. 3/4/05: Update: Added imgstat tool that displays image format details 3/7/05: Bug Fix: In fsstat on ExtX, the final group would have an incorrect _percentage_ of free blocks value (although the actual number was correct). Reported by Knut Eckstein. (BUG: 1158620) 3/11/05: Update: Renamed diskstat, disksreset, sstrings, and imgstat to disk_stat, disk_sreset, srch_strings, and img_stat to make the names more clear. 3/13/05: Bug Fix: The verbose output for fatfs_file_walk had an incorrect sector address. Reported by Rudolph Pereira. 3/13/05: Bug Fix: The beta version had compiling problems on FreeBSD because of a naming clash with the new 'fls' functions. (reported by secman) ---------------- VERSION 1.74 -------------- 11/18/04: Bug Fix: FreeBSD 5 would produce incorrect 'icat' output for Ext2/3 & UFS1 images because it used a 64-bit on-disk address. reported by neutrino neutrino. (BUG: 1068771) 11/30/04: Bug Fix: The makefile in disktools would generate an error on some systems (Cygwin) because of an extra entry. Reported by Vajira Ganepola (BUG: 1076029) ---------------- VERSION 1.73 -------------- 09/09/04: Update: Added journal support for EXT3FS and added jls and jcat tools. 09/13/04: Updated: Added the major and minor device numbers to EXTxFS istat. 09/13/04: Update: Added EXTxFS orphan code to 'fsstat' 09/24/04: Update: Fixed incorrect usage of 'ptr' and "" in action of ntfs_dent.c. Did not affect any code, but could have in the future. Reported by Pete Winkler. 09/25/04: Update: Added UFS flags to fsstat 09/26/04: Update: All fragments are printed for indirect block pointer addresses in UFS istat. 09/29/04: Update: Print extended UFS2 attributes in 'istat' 10/07/04: Bug Fix: Changed usage of (int) to (uintptr_t) for pointer arithmetic. Caused issues with Debian Sarge. (BUG: 1049352) - turned out to be from changes made to package version so that it would compile in 64-bit system (BUG: 928278). 10/11/04: Update: Added diskstat to check for HPA on linux systems. 10/13/04: Update: Added root directory location to FAT32 fsstat output 10/17/04: Bug Fix: EXTxFS superblock location would not be printed for images in fsstat that did not have sparse superblok (which is rare) (BUG: 1049355) 10/17/04: Update: Added sigfind tool to find binary signatures. 10/27/04: Bug Fix: NTFS is_clust_alloc returned an error when loading $MFT that had attribute list entry. Now I assume that clusters referred to by the $MFT are allocated until the $MFT is loaded. (BUG: 1055862). 10/28/04: Bug Fix: Check to see if an attribute with the same name exists instead of relying on id only. (ntfs_proc_attrseq) Affects the processing of attribute lists. Reported by Szakacsits Szabolcs, Matt Kucenski, & Gene Meltser (BUG: 1055862) 10/28/04: Update: Removed usage of mylseek in fstools for all systems (Bug: 928278) ---------------- VERSION 1.72 -------------- 07/31/04: Update: Added flag to mft_lookup so that ifind can run in noabort mode and it will not stop when it finds an invalid magic value. 08/01/04: Update: Removed previous change and removed MAGIC check entirely. XP doesn't even care if the Magic is corrupt, so neither does TSK. The update sequence check should find an invalid MFT entry. 08/01/04: Update: Added error message to 'ifind' if none of the search options are given. 08/05/04: Bug Fix: Fixed g_curdirptr recursive error by clearing the value when dent_walk had to abort because a deleted directory could not be recovered. (BUG: 1004329) Reported by epsilon@yahoo.com 08/16/04: Update: Added a sanity check to fatfs.c fat2unixtime to check if the year is > 137 (which is the overflow date for the 32-bit UNIX time). 08/16/04: Update: Added first version of sstrings from binutils-2.15 08/20/04: Bug Fix: Fixed a bug where the group number for block 0 of an EXT2FS file system would report -1. 'dstat' no longer displays value when it is not part of a block group. (BUG: 1013227) 8/24/04: Update: If an attribute list entry is found with an invalid MFT entry address, then it is ignored instead of an error being generated and exiting. 8/26/04: Update: Changed internal design of NTFS to make is_clust_alloc 8/26/04: Update: If an attribute list entry is found with an invalid MFT entry address AND the entry is unallocated, then no error message is printed, it is just ignored or logged in verbose mode. 8/29/04: Update: Added support for 32-bit GID and UID in EXTxFS 8/30/04: Bug Fix: ntfs_dent_walk was adding 24 extra bytes to the size of the index record for the final record processing (calc of list_len) (BUG: 1019321) (reported and debugging help from Matt Kucenski). 8/30/04: Bug Fix: fs_data_lookup was using an id of 0 as a wild card, but 0 is a legit id value and this could cause confusion. To solve this, a new FS_FLAG_FILE_NOID flag was added and a new fs_data_lookup_noid function that will not use the id to lookup values. (BUG: 1019690) (reported and debugging help from Matt Kucenski) 8/30/04: Update: modified fs_data_lookup_noid to return unamed data attribute if that type is requested (instead of just relying on id value in attributes) 8/31/04: Update: Updated file to v4.10, which seems to fix the CYGWIN compile problem. 9/1/04: Update: Added more DOS partition types to mmls (submitted by Matt Kucenski) 9/2/04: Update: Added EXT3FS extended attributes and Posix ACL to istat output. 9/2/04: Update: Added free inode and block counts per group to fsstat for EXT2FS. 9/7/04: Bug Fix: FreeBSD compile error for PRIx printf stuff in mmtools/gpt.c ---------------- VERSION 1.71 -------------- 06/05/04: Update: Added sanity checks in fat to unix time conversion so that invalid times are set to 0. 06/08/04: Bug Fix: Added a type cast when size is assigned in FAT and removed the assignment to a 32-bit signed variable (which was no longer needed). (Bug: 966839) 06/09/04: Bug Fix: Added a type cast to the 'getuX' macros because some compilers were assuming it was signed (Bug: 966839). 06/11/04: Update: Changed NTFS magic check to use the aa55 at the end and fixed the name of the original "magic" value to oemname. The oemname is now printed in fsstat. 06/12/04: Bug Fix: The NTFS serial number was being printed with bytes in the wrong order in the fsstat output. (BUG: 972207) 06/12/04: Update: The begin offset value in index header for NTFS was 16-bits instead of 32-bits. 06/22/04: Update: Created a library for the MD5 and SHA1 functions so that it can be incorporated into other tools. Also renamed some of the indexing tools that hfind uses. 06/23/04: Update: Changed output of 'istat' for NTFS images. Added more data from $STANDARD_INFORMATION. 07/13/04: Update: Changed output of 'istat' for NTFS images again. Moved more data to the $FILE_NAME section and added new data. 07/13/04: Update: Changed code for processing NTFS runs and no longer check for the offset to be 0 in ntfs_make_data_run(). This could have prevented some sparse files from being processed. 07/13/04: Update: Added flags for compressed and encrypted NTFS files. They are not decrypted or uncompressed yet, just identified. They cannot be displayed from 'icat', but the known layout is given in 'istat'. 07/18/04: Bug Fix: Sometimes, 'icat' would report an error about an existing FILLER entry in an NTFS attribute. This was traced to instances when it was run on a non-base file record. There is now a check for that to not show the error. (BUG: 993459) 07/19/04: Bug Fix: A run of -1 may exist for sparse files in non-NT versions of NTFS. Changed check for this. reported by Matthew Kucenski. (BUG: 994024). 07/24/04: Bug Fix: NTFS attribute names were missing (rarely) on some files because the code assumed they would always be at offset 64 for non-res attributes (Bug: 996981). 07/24/04: Update: Made listing of unallcoated NTFS file names less strict. There was a check for file name length versus stream length. 07/24/04: Update: Added $OBJECT_ID output to 'istat' 07/24/04: Update: Fixed ntfs.c compile warning about constant too large in time conversion code. 07/25/04: Update: Added attribute list contents to NTFS 'istat' output 07/25/04: Bug Fix: Not all slack space was being shown with 'dls -s'. It was documented that this occurs, but it is not what would be expected. (BUG: 997800). 07/25/04: Update: Changed output format of 'dls -s' so that it sends zeros where the file content was. Therefore the output is now a multiple of the data unit size. Also removed limitation to FAT & NTFS. 07/25/04: Update: 'dcalc' now has the '-s' option calculate the original location of data from a slack space image (dls -s). (from Chris Betz). 07/26/04: Update: Created the fs_os.h file and adjusted some of the header files for the PRI macros (C99). Created defines for OSes that do not have the macros already defined. 07/26/04: Non-release bug fix: Fixed file record size bug introduced with recent changes. 07/27/04: Update: Added GPT support to mmls. 07/29/04: Update: Added '-p' flag to 'ifind' to find deleted NTFS files that point to the given parent directory. Added '-l and -z' as well. ---------------- VERSION 1.70 -------------- 04/21/04: Update: Changed attribute and mode for FAT 'istat' so that actual FAT attributes are used instead of UNIX translation. 04/21/04: Update: The FAT 'istat' output better handles Long FIle Name entry 04/21/04: Update: The FAT 'istat' output better handles Volume Label entry 04/21/04: Update: Allowed the FAT volume label entry to be displayed with 'ils' 04/21/04: Update: Allowed the FAT volume label entry to be displayed with 'fls' 04/24/04: Update: 'dstat' on a FAT cluster now shows the cluster address in addition to the sector address. 04/24/04: Update: Added the cluster range to the FAT 'fsstat' output 05/01/04: Update: Improved the FAT version autodetect code. 05/02/04: Update: Removed 'H' flag from 'icat'. 05/02/04: Update: Changed all of the FS_FLAG_XXX variables in the file system tools to constants that are specific to the usage (NAME, DATA, META, FILE). 05/03/04: Update: fatfs_inode_walk now goes by sectors instead of clusters to get more dentries from slack space. 05/03/04: Bug Fix: The allocation status of FAT dentires was set only by the flag and not the allocation status of the cluster it is located in. (BUG: 947112) 05/03/04: Update: Improved comments and variable names in FAT code 05/03/04: Update: Added '-r' flag to 'icat' for deleted file recovery 05/03/04: Update: Added RECOVERY flag to file_walk for deleted file recovery 05/03/04: Update: Added FAT file recovery. 05/03/04: Update: Removed '-H' flag from 'icat'. Default is to display holes. 05/03/04: Update: 'fls -r' will recurse down deleted directories in FAT 05/03/04: Update: 'fsstat' reports FAT clusters that are marked as BAD 05/03/04: Update: 'istat' for FAT now shows recovery clusters for deleted files. 05/04/04: Update: Added output to 'fsstat' for FAT file systems by adding a list of BAD sectors and improving the amount of layout information. I also changed some of the internal variables. 05/08/04: Update: Removed addr_bsize from FS_INFO, moved block_frags to FFS_INFO, modified dcat output only data unit size. 05/20/04: Update: Added RECOVERY flag to 'ifind' so that it can find the data units that are allocated to deleted files 05/20/04: Update: Added icat recovery options to 'sorter'. 05/20/04: Update: Improved the naming convention in sorter for the 'ils' dead files. 05/21/04: Update: Added outlook to sorter rules (from David Berger) 05/27/04: Bug Fix: Added to mylseek.c so that it compiles with Fedora Core 2 (Patch by Angus Marshall) (BUG: 961908). 05/27/04: Update: Changed the letter with 'fls -l' for FIFO to 'p' instead of 'f' (reported by Dave Henkewick). 05/28/04: Update: Added '-u' flag to 'dcat' so that the data unit size can be specified for raw, swap, and dls image types. 05/28/04: Update: Changed the size argument of 'dcat' to be number of data units instead of size in bytes (suggestion by Harald Katzer). ---------------- VERSION 1.69 -------------- 03/06/04: Update: Fixed some memory leaks in ext2fs_close. reported by Paul Bakker. 03/10/04: Bug Fix: If the '-s' flag was used with 'icat' on a EXT2FS or FFS file system, then a large amount of extra data came out. Reported by epsion. (BUG: 913874) 03/10/04: Bug Fix: One of the verbose outputs in ext2fs.c was being sent to STDOUT instead of logfp. (BUG: 913875) 04/14/04: Update: Added more data to fsstat output of FAT file system. 04/15/04: Bug Fix: The last sector of a FAT file system may not be analyzed. (BUG: 935976) 04/16/04: Update: Added full support for swap and raw by making the standard files and functions for them instead of the hack in dcat. Suggested by (and initial patch by) Paul Baker. 04/18/04: Update: Changed error messages in EXT2/3FS code to be extXfs. 04/18/04: Update: Updaged to version 4.09 of 'file'. This will help fix some of the problems people have had compiling it under OS X 10.3. 04/18/04: Update: Added compiling support for SFU 3.5 (Microsoft). Patches from an anonymous person. ---------------- VERSION 1.68 -------------- 01/20/04: Bug Fix: FAT times were an hour too fast during daylight savings. Now use mktime() instead of manual calculation. Reported by Randall Shane. (BUG: 880606) 02/01/04: Update: 'hfind -i' now reports the header entry as an invalid entry. The first header row was ignored. 02/20/04: Bug Fix: indirect block pointer blocks would not be identified by the ifind tool. Reported by Knut Eckstein (BUG: 902709) 03/01/04: Update: Added fs->seek_pos check to fs_read_random. ---------------- VERSION 1.67 -------------- 11/15/03: Bug Fix: Added support for OS X 10.3 to src/makedefs. (BUG: 843029) 11/16/03: Bug Fix: Mac partition tables could generate an error if there were VOID-type partitions. (BUG: 843366) 11/21/03: Update: Changed NOABORT messages to verbose messages, so invalid data is not printed during 'ifind' searches. 11/30/03: Bug Fix: icat would not hide the 'holes' if '-h' was given because the _UNALLOC flag was always being passed to file_walk. (reported by Knut Eckstein). (BUG: 851873) 11/30/03: Bug Fix: NTFS data_walk was not using _ALLOC and _UNALLOC flags and other code that called it was not either. (BUG: 851895) 11/30/03: Bug Fix: Not all needed commands were using _UNALLOC when they called file_walk (although for most cases it did not matter because sparse files would not be found in a directory for example). (Bug: 851897) 12/09/03: Bug Fix: FFS and EXT2FS code was using OFF_T type instead of size_t for the size of the file. This could result in a file > 2GB as being a negative size on some systems (BUG: 856957). 12/26/03: Bug Fix: ffind would crash for root directory of FAT image. Added NULL check and added a NULL name to fake root directory entry. (BUG: 871219) 01/05/04: Bug Fix: The clustcnt value for FAT was incorrectly calculated and was too large for FAT12 and FAT16 by 32 sectors. This could produce extra entries in the 'fsstat' output when the FAT is dumped. (BUG: 871220) 01/05/04: Bug Fix: ils, fls, and istat were not printing the full size of files that are > 2GB. (reported by Knut Eckstein) (BUG: 871457) 01/05/04: Bug Fix: The EXT2FS and EXT3FS code was not using the i_dir_acl value as the upper 32-bits of regular files that are > 2GB (BUG: 871458) 01/06/04: Mitigation: An error was reported where sorter would error that icat was being passed a '-1' argument. I can't find how that would happen, so I added quotes to all arguments so that the next time it occurs, the error is more useful (BUG: 845840). 01/06/04: Update: Incorporated patch from Charles Seeger so that 'cc' can be used and compile time warnings are fixed with Sun 'cc'. 01/06/04: Update: Upgraded file from v3.41 to v4.07 ---------------- VERSION 1.66 -------------- 09/02/03: Bug Fix: Would not compile under OpenBSD 3 because fs_tools.h & mm_tools was missing a defined statment (reported by Randy - m0th_man) NOTE: Bugs now will have an entry into the Source Forge bug tracking sytem. 10/13/03: Bug Fix: buffer was not being cleared between uses and length incorrectly set in NTFS resulted in false deleted file names being shown when the '-r' flag was given. The extra entries were from the previous directory. (BUG: 823057) 10/13/03: Bug Fix: The results of 'sorter' varied depending on the version of Perl and the system. If the file output matched more than one, sorter could not gaurantee which would match. Therefore, results were different for some files and some machines. 'sorter' now enforces the ordering based on the order they are in the configuration file. The entries at the end of the file have priority over the first entries (generic rules to specific rules). (BUG: 823057) 10/14/03: Update: 'mmls' prints 'MS LVM' with partition type 0x42 now. 10/25/03: Bug Fix: NTFS could have a null pointer crash if the image was very corrupt and $Data was not found for the MFT. 11/10/03: Bug Fix: NTFS 'ffind' would only report the file name and not the attribute name because the type and id were ignored. ffind and ntfs_dent were updated - found during NTFS keyword search test. (Bug: 831579() 11/12/03: Update: added support for Solaris x86 partition tables to 'mmls' 11/12/03: Update: Modified the sparc data structure to add the correct location of the 'sanity' magic value. 11/15/03: Update: Added '-s' flag to 'icat' so that slack space is also displayed. ---------------- VERSION 1.65 -------------- 08/03/03: Bug Fix: 'sorter' now checks for inode values that are too small to avoid 'icat' errors about invalid inode values. 08/19/03: Update: 'raw' is now a valid type for 'dcat'. 08/21/03: Update: mactime and sorter look for perl5.6.0 first. 08/21/03: Update: Removed NSRL support from 'sorter' until a better wany to identify the known good and known bad files is found 08/21/03: Bug Fix: The file path replaces < and > with HTML encoding for HTML output (ils names were not being shown) 08/25/03: Update: Added 'nsrl.txt' describing why the NSRL functionality was removed. 08/27/03: Update: Improved code in 'mactime' to reduce warnings when '-w' is used with Perl ('exists' checks on arrays). 08/27/03: Update: Improved code in 'sorter' to reduce warnings when '-w' is used with Perl (inode_int for NTFS). ---------------- VERSION 1.64 -------------- 08/01/03: Docs Fix: The Sun VTOC was documented as Virtual TOC and it should be Volume TOC (Jake @ UMASS). 08/02/03: Bug Fix: Some compilers complained about verbose logging assignment in 'mmls' (Ralf Spenneberg). ---------------- VERSION 1.63 -------------- 06/13/03; Update: Added 'mmtools' directory with 'dos' partitions and 'mmls'. 06/18/03: Update: Updated the documents in the 'doc' directory 06/19/03: Update: Updated error message for EXT3FS magic check 06/27/03: Update: Added slot & table number to mmls 07/08/03: Update: Added mac support to mmtools 07/11/03: Bug Fix: 'sorter' was not processing all unallocated meta data structures because of a regexp error. (reported by Jeff Reava) 07/16/03: Update: Added support for FreeBSD5 07/16/03: Update: Added BSD disk labels to mmtools 07/28/03: Update: Relaxed requirements for DOS directory entries, the wtime can be zero (reported by Adam Uccello). 07/30/03: Update: Added SUN VTOC to mmtools 07/31/03: Update: Added NetBSD support (adam@monkeybyte.org) 08/01/03: Update: Added more sanity checks to FAT so that it would not try and process NTFS images that have the same MAGIC value ---------------- VERSION 1.62 -------------- 04/11/03: Bug Fix: 'fsstat' for an FFS file system could report data fragments in the last group that were larger than the maximum fragment 04/11/03: Bug Fix: 'ffs' allows the image to not be a multiple of the block size. A read error occured when it tried to read the last fragments since a whole block could not be read. 04/15/03: Update: Added debug statements to FAT code. 04/26/03: Update: Added verbose statements to FAT code 04/26/03: Update: Added NOABORT flag to dls -s 04/26/03: Update: Added stderr messages for errors that are not aborted because of NOABORT 05/27/03: Update: Added 'mask' field to FATFS_INFO structure and changed code in fatfs.c to use it. 05/27/03: Update: isdentry now checks the starting cluster to see if it is a valid size. 05/27/03: Bug Fix: Added a sanitizer to 'sorter' to remove invalid chars from the 'file' output and reduce the warnings from Perl. 05/28/03: Bug Fix: Improved sanitize expression in 'sorter' 05/28/03: Update: Added '-d' option to 'mactime' to allow output to be given in comma delimited format for importing into a spread sheet or other graphing tool 06/09/03: Update: Added hourly summary / indexing to mactime 06/09/03: Bug Fix: sorter would not allow linux-ext3 fstype ---------------- VERSION 1.61 -------------- 02/05/03: Update: Started addition of image thumbnails to sorter 03/05/03: Update: Updated 'file' to version 3.41 03/16/03: Update: Added comments and NULL check to 'ifind' 03/16/03: Bug Fix: Added a valid magic of 0 for MFT entries. This was found in an XP image. 03/26/03: Bug Fix: fls would crash for an inode of 0 and a clock skew was given. fixed the bug in fls.c (debug help from Josep Homs) 03/26/03: Update: Added more verbose comments to ntfs_dent.c. 03/26/03: Bug Fix: 'ifind' for a path could return a result that was shorter than the requested name (strncmp was used) 03/26/03: Update: Short FAT names can be used in 'ifind -n' and error messages were improved 03/26/03: Bug Fix: A final NTFS Index Buffer was not always processed in ntfs_dent.c, which resulted in files not being shown. This was fixed with debugging help from Matthew Shannon. 03/27/03: Update: Added an 'index.html' for image thumbnails in sorter and added a 'details' link from the thumbnail to the images.html file 03/27/03: Update: 'sorter' can now take a directory inode to start processing 03/27/03: Update: added '-z' flag when running 'file' in 'sorter' so that compressed file contents are reported 03/27/03: Update: added '-i' flag to 'mactime' that creates a daily summary of events 03/27/03: Update: Added support for Version 2 of the NSRL in 'hfind' 04/01/03: Update: Added support for Hash Keeper to 'hfind' 04/01/03: Update: Added '-e' flag to 'hfind' for extended info (currently hashkeeper only) ---------------- VERSION 1.60 -------------- 10/31/02: Bug Fix: the unmounting status of EXT2FS in the 'fsstat' command was not correct (reported by Stephane Denis). 11/24/02: Bug Fix: The -v argument was not allowed on istat or fls (Michael Stone) 11/24/02: Bug Fix: When doing an 'ifind' on a UNIX fs, it could abort if it looked at an unallocated inode with invalid indirect block pointers. This was fixed by adding a "NOABORT" flag to the walk code and adding error checks in the file system code instead of relying on the fs_io code. (suggested by Micael Stone) 11/26/02: Update: ifind has a '-n' argument that allows one to specify a file name it and it searches to find the meta data structure for it (suggested by William Salusky). 11/26/02: Update: Now that there is a '-n' flag with 'ifind', the '-d' flag was added to specify the data unit address. The old syntax of giving the data_unit at the end is no longer supported. 11/27/02: Update: Added sanity checks on meta data and data unit addresses earlier in the code. 12/12/02: Update: Added additional debug statements to NTFS code 12/19/02: Update: Moved 'hash' directory to 'hashtools' 12/19/02: Update: Started development of 'hfind' 12/31/02: Update: Improved verbose debug statements to show full 64-bit offsets 01/02/03: Update: Finished development of 'hfind' with ability to update for next version of NSRL (which may have a different format) 01/05/03: Bug Fix: FFS and EXT2FS symbolic link destinations where not properly NULL terminated and some extra chars were appended in 'fls' (later reported by Thorsten Zachmann) 01/06/03: Bug Fix: getu64() was not properly masking byte sizes and some data was being lost. This caused incorrect times to be displayed in some NTFS files. 01/06/03: Bug Fix: ifind reported incorrect ownership for some UNIX file systems if the end fragments were allocated to a different file than the first ones were. 01/07/03: Update: Renamed the src/mactime directory to src/timeline. 01/07/03: Update: Updated README and man pages for hfind and sorter 01/12/03: Bug Fix: ntfs_mft_lookup was casting a 64-bit value to a 32-bit variable. This caused MFT Magic errors. Reported and debugged by Keven Murphy 01/12/03: Update: Added verbose argument to 'fls' 01/12/03: Bug Fix: '-V' argument to 'istat' was doing verbose instead of version 01/13/03: Update: Changed static sizes of OFF_T and DADDR_T in Linux version to the actual 'off_t' and 'daddr_t' types 01/23/03: Update: Changed use of strtok_r to strtok in ifind.c so that Mac 10.1 could compile (Dave Goldsmith). 01/28/03: Update: Improved code in 'hfind' and 'sorter' to handle files with spaces in the path (Dave Goldsmith). ---------------- VERSION 1.52 -------------- 09/24/02: Bug Fix: Memory leak in ntfs_dent_idxentry(), ntfs_find_file(), and ntfs_dent_walk() 09/24/02: Update: Removal of index sequences for index buffers is now done using upd_off, which will allow for NTFS to move the structure in the future. 09/26/02: Update: Added create time for NTFS / STANDARD_INFO to istat output. 09/26/02: Update: Changed the method that the NTFS time is converted to UNIX time. Should be more effecient. 10/09/02: Update: dcat error changed. 10/02/02: Update: Includes a Beta version of 'sorter' ---------------- VERSION 1.51 -------------- 09/10/02: Bug Fix: Fixed a design bug that would not allow attribute lists in $MFT. This bug would generate an error that complained about an invalid MFT entry in attribute list. 09/10/02: Update: The size of files and directories is now calculated after each time proc_attrseq() is called so that it is more up to date when dealing with attribute lists. The size has the sizes of all $Data, $IDX_ROOT, and $IDX_ALLOC streams. 09/10/02: Update: The maxinum number of MFT entries is now calculated each time an MFT entry is processed while loading the MFT. This allows us to reflect what the maximum possible MFT entry is at that given point based on how many attribute lists have been processed. 09/10/02: Update: Added file version 3.39 to distro (bigger magic files) (Salusky) 09/10/02: Bug Fix: fs_data was wasting memory when it was allocated 09/10/02: Update: added a fs_data_alloc() function 09/12/02: Bug Fix: Do not give an error if an attribute list of an unallocated file points to an MFT that no longer claims it is a member of the list. 09/12/02: Update: No longer need version to remove update sequence values from on-disk buffers 09/19/02: Bug Fix: fixed memory leak in ntfs_load_ver() 09/19/02: Bug Fix: Update sequence errors were displayed because of a bug that occured when an MFT entry crossed a run in $MFT. Only occured with 512-byte clusters and an odd number of clusters in a run. 09/19/02: Update: New argument to ils, istat, and fls that allows user to specify a time skew in seconds of the compromised system. Originated from discussion at DFRWS II. 09/19/02: Update: Added '-h' argument to mactime to display header info ---------------- VERSION 1.50 -------------- 04/21/02: icat now displays idxroot attribute for NTFS directories 04/21/02: fs_dent_print functions now are passed the FS_DATA structure instead of the extra inode and name strings. (NTFS) 04/21/02: fs_dent_print functions display alternate data stream size instead of the default data size (NTFS) 04/24/02: Fixed bug in istat that displayed too many fragments with ffs images 04/24/02: Fixed bug in istat that did not display sparse files correctly 04/24/02: fsstat of FFS images now identifies the fragments at the beginning of cyl groups as data fragments. 04/26/02: Fixed bug in ext2fs_dent_parse_block that did not advance the directory entry pointer far enough each time 04/26/02: Fixed bug in ext2fs_dent_parse_block so that gave an error if a file name was exactly 255 chars 04/29/02: Removed the getX functions from get.c as they are now macros 05/11/02: Added support for lowercase flag in FAT 05/11/02: Added support for sequence values (NTFS) 05/13/02: Added FS_FLAG_META for FAT 05/13/02: Changed ifind so that it looks the block up to identify if it is a meta data block when an inode can not be found 05/13/02: Added a conditional to ifind so that it handles sparse files better 05/19/02: Changed icat so that the default attribute type is set in the file_walk function 05/20/02: ils and dls now use boundary inode & block values if too large or small are given 05/21/02: istat now displays all NTFS times 05/21/02: Created functions to just display date and time 05/24/02: moved istat functionality to the specific file system file 05/25/02: added linux-ext3 flag, but no new features 05/25/02: Added sha1 (so Autopsy can use the NIST SW Database) 05/26/02: Fixed bug with FAT that did not return all slack space on file_walk 05/26/02: Added '-s' flag to dls to extract slack space of FAT and NTFS 06/07/02: fixed _timezone variable so correct times are shown in CYGWIN 06/11/02: *_copy_inode now sets the flags for the inode 06/11/02: fixed bug in mactimes that displayed a duplicate entry with time because of header entries in body file 06/12/02: Added ntfs.README doc 06/16/02: Added a comment to file Makefile to make it easier to compile for an IR CD. 06/18/02: Fixed NTFS bug that showed ADS when only deleted files were supposed to be shown (when ADS in directory) 06/19/02: added the day of the week to the mactime output (Tan) 07/09/02: Fixed bug that added extra chars to end of symlink destination 07/17/02: 1.50 Released ---------------- VERSION 1.00 -------------- - Integrated TCT-1.09 and TCTUTILs-1.01 - Fixed bug in bcat if size is not given with type of swap. - Added platform indep by including the structures of each file system type - Added flags for large file support under linux - blockcalc was off by 1 if calculated using the raw block number and not the one that lazarus spits out (which start at 1) - Changed the inode_walk and block_walk functions slightly to return a value so that a walk can be ended in the middle of it. - FAT support added - Improved ifind to better handle fragments - '-z' flag to fls and istat now use the time zone string instead of integer value. - no longer prepend / in _dent - verify that '-m' directory in fls ends with a '/' - identify the destination of sym links - fsstat tool added - fixed caching bug with FAT12 when the value overlapped cache entries - added mactime - removed the value in fls when printing mac format (inode is now printed in mactime) - renamed src/misc directory to src/hash (it only has md5 and will have sha) - renamed aux directory to misc (Windows doesn't allow aux as a name ??) - Added support for Cygwin - Use the flags in super block of EXT2FS to identify v1 or v2 - removed file system types of linux1 and linux2 and linux - added file system type of linux-ext2 (as ext3 is becoming more popular) - bug in file command that reported seek error for object files and STDIN sleuthkit-3.2.3/packages/000777 000765 000024 00000000000 11643647552 016124 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/README.txt000644 000765 000024 00000021316 11643647435 016043 0ustar00carrierstaff000000 000000 The Sleuth Kit README File http://www.sleuthkit.org/sleuthkit Last Modified: Sept 2008 INTRODUCTION ============================================================================= The Sleuth Kit is an open source forensic toolkit for analyzing Microsoft and UNIX file systems and disks. The Sleuth Kit enables investigators to identify and recover evidence from images acquired during incident response or from live systems. The Sleuth Kit is open source, which allows investigators to verify the actions of the tool or customize it to specific needs. The Sleuth Kit uses code from the file system analysis tools of The Coroner's Toolkit (TCT) by Wietse Venema and Dan Farmer. The TCT code was modified for platform independence. In addition, support was added for the NTFS (see docs/ntfs.README) and FAT (see docs/fat.README) file systems. Previously, The Sleuth Kit was called The @stake Sleuth Kit (TASK). The Sleuth Kit is now independant of any commercial or academic organizations. It is recommended that these command line tools can be used with the Autopsy Forensic Browser. Autopsy, (http://www.sleuthkit.org/autopsy), is a graphical interface to the tools of The Sleuth Kit and automates many of the procedures and provides features such as image searching and MD5 image integrity checks. As with any investigation tool, any results found with The Sleuth Kit should be be recreated with a second tool to verify the data. OVERVIEW ============================================================================= The Sleuth Kit allows one to analyze a disk or file system image created by 'dd', or a similar application that creates a raw image. These tools are low-level and each performs a single task. When used together, they can perform a full analysis. For a more detailed description of these tools, refer to docs/filesystem.README. The tools are briefly described in a file system layered approach. Each tool name begins with a letter that is assigned to the layer. File System Layer: A disk contains one or more partitions (or slices). Each of these partitions contain a file system. Examples of file systems include the Berkeley Fast File System (FFS), Extended 2 File System (EXT2FS), File Allocation Table (FAT), and New Technologies File System (NTFS). The fsstat tool displays file system details in an ASCII format. Examples of data in this display include volume name, last mounting time, and the details about each "group" in UNIX file systems. Content Layer (block): The content layer of a file system contains the actual file content, or data. Data is stored in large chunks, with names such as blocks, fragments, and clusters. All tools in this layer begin with the letters 'blk'. The blkcat tool can be used to display the contents of a specific unit of the file system (similar to what 'dd' can do with a few arguments). The unit size is file system dependent. The 'blkls' tool displays the contents of all unallocated units of a file system, resulting in a stream of bytes of deleted content. The output can be searched for deleted file content. The 'blkcalc' program allows one to identify the unit location in the original image of a unit in the 'blkls' generated image. A new feature of The Sleuth Kit from TCT is the '-l' argument to 'blkls' (or 'unrm' in TCT). This argument lists the details for data units, similar to the 'ils' command. The 'blkstat' tool displays the statistics of a specific data unit (including allocation status and group number). Metadata Layer (inode): The metadata layer describes a file or directory. This layer contains descriptive data such as dates and size as well as the addresses of the data units. This layer describes the file in terms that the computer can process efficiently. The structures that the data is stored in have names such as inode and directory entry. All tools in this layer begin with an 'i'. The 'ils' program lists some values of the metadata structures. By default, it will only list the unallocated ones. The 'istat' displays metadata information in an ASCII format about a specific structure. New to The Sleuth Kit is that 'istat' will display the destination of symbolic links. The 'icat' function displays the contents of the data units allocated to the metadata structure (similar to the UNIX cat(1) command). The 'ifind' tool will identify which metadata structure has allocated a given content unit or file name. Refer to the ntfs.README doc for information on addressing metadata attributes in NTFS. Human Interface Layer (file): The human interface layer allows one to interact with files in a manner that is more convenient than directly with the metadata layer. In some operating systems there are separate structures for the metadata and human interface layers while others combine them. All tools in this layer begin with the letter 'f'. The 'fls' program lists file and directory names. This tool will display the names of deleted files as well. The 'ffind' program will identify the name of the file that has allocated a given metadata structure. With some file systems, deleted files will be identified. Time Line Generation ----------------------------------------------------------------------------- Time lines are useful to quickly get a picture of file activity. Using The Sleuth Kit a time line of file MAC times can be easily made. The mactime (TCT) program takes as input the 'body' file that was generated by fls and ils. To get data on allocated and unallocated file names, use 'fls -rm dir' and for unallocated inodes use 'ils -m'. Note that the behavior of these tools are different than in TCT. For more information, refer to docs/mac.README. Hash Databases ----------------------------------------------------------------------------- Hash databases are used to quickly identify if a file is known. The MD5 or SHA-1 hash of a file is taken and a database is used to identify if it has been seen before. This allows identification to occur even if a file has been renamed. The Sleuth Kit includes the 'md5' and 'sha1' tools to generate hashes of files and other data. Also included is the 'hfind' tool. The 'hfind' tool allows one to create an index of a hash database and perform quick lookups using a binary search algorithm. The 'hfind' tool can perform lookups on the NIST National Software Reference Library (NSRL) (www.nsrl.nist.gov) and files created from the 'md5' or 'md5sum' command. Refer to the docs/hfind.README file for more details. File Type Categories ----------------------------------------------------------------------------- Different types of files typically have different internal structure. The 'file' command comes with most versions of UNIX and a copy is also distributed with The Sleuth Kit. This is used to identify the type of file or other data regardless of its name and extension. It can even be used on a given data unit to help identify what file used that unit for storage. Note that the 'file' command typically uses data in the first bytes of a file so it may not be able to identify a file type based on the middle blocks or clusters. The 'sorter' program in The Sleuth Kit will use other Sleuth Kit tools to sort the files in a file system image into categories. The categories are based on rule sets in configuration files. The 'sorter' tool will also use hash databases to flag known bad files and ignore known good files. Refer to the 'docs/sorter.README' file for more details. LICENSE ============================================================================= The file system tools (in the src/fstools directory) are released under the IBM open source license and Common Public License, both are located in the license directory. The modifications to 'mactime' from the original 'mactime' in TCT and 'mac-daddy' are released under the Common Public License. Other tools in the src directory are either Common Public License or the GNU Public License. INSTALL ============================================================================= For installation instructions, refer to the INSTALL document. OTHER DOCS ============================================================================= The 'docs' directory contains documents that describe the provided tools in more detail. The Sleuth Kit Informer is a newsletter that contains new documentation and articles. www.sleuthkit.org/informer/ MAILING LIST ============================================================================= Mailing lists exist on SourceForge, for both users and a low-volume announcements list. http://sourceforge.net/mail/?group_id=55685 ----------------------------------------------------------------------------- Brian Carrier carrier sleuthkit org sleuthkit-3.2.3/README_win32.txt000644 000765 000024 00000001604 11643647435 017063 0ustar00carrierstaff000000 000000 The Sleuth Kit Win32 README File http://www.sleuthkit.org/sleuthkit Last Modified: Sept 2008 ==================================================================== The Sleuth Kit (TSK) runs on Windows. If you simply want the executables, you can download them from the www.sleuthkit.org website. If you want to build your own executables, you have two options. One is to use Microsoft Visual Studio. The VS solution file is in the win32 directory. Refer to the BUILDING.txt file in that directory for details. You can also compile Windows executables on Linux using mingw32. Simply give the "--host=i586-mingw32msvc" argument when running the './configure' script and use 'make' to compile. ------------------------------------------------------------------- carrier sleuthkit org Brian Carrier sleuthkit-3.2.3/samples/000777 000765 000024 00000000000 11643647554 016014 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tests/000777 000765 000024 00000000000 11643647554 015512 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tools/000777 000765 000024 00000000000 11643647553 015507 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/000777 000765 000024 00000000000 11643647552 015232 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/000777 000765 000024 00000000000 11643647552 015310 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkcalc/000777 000765 000024 00000000000 11643647552 016703 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkcat/000777 000765 000024 00000000000 11643647552 016550 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkls/000777 000765 000024 00000000000 11643647552 016417 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkstat/000777 000765 000024 00000000000 11643647552 016754 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/BUILDING.txt000755 000765 000024 00000003142 11643647441 017242 0ustar00carrierstaff000000 000000 This file describes how to build TSK using Visual Studio (see README_win32.txt for instructions on building the win32 libraries and executables from Linux). If you do not have a copy of Visual Studio, you can use the free Express Edition: http://www.microsoft.com/express/vc/ The Visual Studio Solution file has three build targets: Debug, Debug_NoLibs, and Release. Debug and Release require that libewf exist and be compiled (libewf provides support for E01 image files). Debug_NoLibs does not require libewf and you should be able to compile Debug_NoLibs without any additional setup. The steps below outline the process required to compile the Debug and Release targets. 1) Download libewf-20091128 or later from: http://sourceforge.net/projects/libewf/ 2) Open archive file, rename directory from libewf-2009XXXX to libewf, and move the libewf directory to the win32 TSK subdirectory. For example, the result should be something like: sleuthkit-3.0.0\win32\libewf. 3) Follow the README instructions in libewf to build libewf_dll (at the time of this writing, that includes downloading the zlib dll). Note that TSK will use only the Release version of libewf_dll. 5) Open the TSK Visual Studio Solution file in the win32 directory. 6) Compile a Debug or Release version of the libraries or executables. 7) Note that the libraries and executables will depend on the libewf and zlib dll files (which are located in libewf/msvscpp/release and libewf/msvscpp/zlib). ------------------------------------------------------------------- carrier sleuthkit org Brian Carrier sleuthkit-3.2.3/win32/callback-sample/000777 000765 000024 00000000000 11643647552 020323 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ffind/000777 000765 000024 00000000000 11643647552 016376 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/fls/000777 000765 000024 00000000000 11643647552 016074 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/fsstat/000777 000765 000024 00000000000 11643647552 016614 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/hfind/000777 000765 000024 00000000000 11643647552 016400 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/icat/000777 000765 000024 00000000000 11643647552 016230 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ifind/000777 000765 000024 00000000000 11643647552 016401 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ils/000777 000765 000024 00000000000 11643647552 016077 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/img_cat/000777 000765 000024 00000000000 11643647552 016713 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/img_stat/000777 000765 000024 00000000000 11643647552 017117 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/istat/000777 000765 000024 00000000000 11643647552 016434 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/jcat/000777 000765 000024 00000000000 11643647552 016231 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/jls/000777 000765 000024 00000000000 11643647552 016100 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libautotools/000777 000765 000024 00000000000 11643647552 020030 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libauxtools/000777 000765 000024 00000000000 11643647552 017655 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libfstools/000777 000765 000024 00000000000 11643647552 017470 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libhashdbtools/000777 000765 000024 00000000000 11643647552 020311 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libimgtools/000777 000765 000024 00000000000 11643647552 017634 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libmmtools/000777 000765 000024 00000000000 11643647552 017471 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmcat/000777 000765 000024 00000000000 11643647552 016411 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmls/000777 000765 000024 00000000000 11643647552 016260 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmstat/000777 000765 000024 00000000000 11643647552 016615 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/posix-sample/000777 000765 000024 00000000000 11643647552 017731 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk-win.sln000644 000765 000024 00000070426 11643647441 017424 0ustar00carrierstaff000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libauxtools", "libauxtools\libauxtools.vcproj", "{F12AA46A-EA91-4AB6-8246-7800DF6128A4}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libimgtools", "libimgtools\libimgtools.vcproj", "{47E72886-0B51-4098-BAF4-68B4494F0872}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "img_stat", "img_stat\img_stat.vcproj", "{48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}" ProjectSection(ProjectDependencies) = postProject {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmmtools", "libmmtools\libmmtools.vcproj", "{47901C6F-77EC-4753-A83A-F6AE975851B9}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfstools", "libfstools\libfstools.vcproj", "{2D0B32C2-B035-4873-8E9A-4D4221D93F68}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mmls", "mmls\mmls.vcproj", "{712DD83B-786E-485E-83C7-7197DD851B78}" ProjectSection(ProjectDependencies) = postProject {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "img_cat", "img_cat\img_cat.vcproj", "{671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}" ProjectSection(ProjectDependencies) = postProject {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mmstat", "mmstat\mmstat.vcproj", "{5D75FBFB-539A-4014-ACEB-520BB16F5BFC}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fls", "fls\fls.vcproj", "{58DA1042-AC19-4779-AC1A-AA8EEB3A4524}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fsstat", "fsstat\fsstat.vcproj", "{D1E6567A-4F65-4832-8018-D33B3CB4692B}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blkcat", "blkcat\blkcat.vcproj", "{A2BEA467-A4CC-4FA6-9C74-587498E35467}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blkstat", "blkstat\blkstat.vcproj", "{FBB66156-9A54-4713-A801-C507BE7A3AE3}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blkcalc", "blkcalc\blkcalc.vcproj", "{46B82840-9832-466F-8568-132407CA3853}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blkls", "blkls\blkls.vcproj", "{48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ffind", "ffind\ffind.vcproj", "{7C132953-1700-42FF-9F61-A814C9F2C758}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icat", "icat\icat.vcproj", "{38D89022-2C83-4436-A333-375A2E3E7BB0}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ifind", "ifind\ifind.vcproj", "{52251CB2-65A3-421B-9CB4-7DAC13BB3758}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ils", "ils\ils.vcproj", "{62C97F5E-64DD-4623-9563-747C4C173348}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "istat", "istat\istat.vcproj", "{D7643AD7-8518-4B3E-8F3F-F11258D9540E}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jcat", "jcat\jcat.vcproj", "{44A003BE-400D-4434-AFED-64D8E3B448D9}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jls", "jls\jls.vcproj", "{C52F935E-1FD2-443C-A181-27908DAB3BC8}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhashdbtools", "libhashdbtools\libhashdbtools.vcproj", "{01C4C49B-5B89-4049-8F9E-1906F82B798D}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hfind", "hfind\hfind.vcproj", "{0B127AE3-0C18-4EEF-AB20-A0693E6AA822}" ProjectSection(ProjectDependencies) = postProject {01C4C49B-5B89-4049-8F9E-1906F82B798D} = {01C4C49B-5B89-4049-8F9E-1906F82B798D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mmcat", "mmcat\mmcat.vcproj", "{A15F1E4F-951A-403E-B746-2A6D63D9C416}" ProjectSection(ProjectDependencies) = postProject {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "callback-sample", "callback-sample\callback-sample.vcproj", "{6CE3D593-E90D-4CC1-A66B-694AC909F6B8}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "posix-sample", "posix-sample\posix-sample.vcproj", "{1BA0B9E8-F135-494F-9CF5-86427C1F6E41}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libautotools", "libautotools\libautotools.vcproj", "{88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tsk_recover", "tsk_recover\tsk_recover.vcproj", "{06D707E5-68FF-4FC4-AFD0-C84584E32F47}" ProjectSection(ProjectDependencies) = postProject {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} = {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tsk_loaddb", "tsk_loaddb\tsk_loaddb.vcproj", "{96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} = {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tsk_comparedir", "tsk_comparedir\tsk_compare.vcproj", "{8EE881F4-78DC-49C7-8845-E842358AC0FA}" ProjectSection(ProjectDependencies) = postProject {F12AA46A-EA91-4AB6-8246-7800DF6128A4} = {F12AA46A-EA91-4AB6-8246-7800DF6128A4} {47901C6F-77EC-4753-A83A-F6AE975851B9} = {47901C6F-77EC-4753-A83A-F6AE975851B9} {47E72886-0B51-4098-BAF4-68B4494F0872} = {47E72886-0B51-4098-BAF4-68B4494F0872} {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} = {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} {2D0B32C2-B035-4873-8E9A-4D4221D93F68} = {2D0B32C2-B035-4873-8E9A-4D4221D93F68} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tsk_gettimes", "tsk_gettimes\tsk_gettimes.vcproj", "{11A8927C-F971-4104-A286-5DC11C25E2EC}" ProjectSection(ProjectDependencies) = postProject {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} = {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_NoLibs|Win32 = Debug_NoLibs|Win32 Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Debug|Win32.ActiveCfg = Debug|Win32 {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Debug|Win32.Build.0 = Debug|Win32 {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Release|Win32.ActiveCfg = Release|Win32 {F12AA46A-EA91-4AB6-8246-7800DF6128A4}.Release|Win32.Build.0 = Release|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Debug|Win32.ActiveCfg = Debug|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Debug|Win32.Build.0 = Debug|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Release|Win32.ActiveCfg = Release|Win32 {47E72886-0B51-4098-BAF4-68B4494F0872}.Release|Win32.Build.0 = Release|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Debug|Win32.ActiveCfg = Debug|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Debug|Win32.Build.0 = Debug|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Release|Win32.ActiveCfg = Release|Win32 {48F52EA8-A5D1-4BF4-B774-6ECFCB0CE3C9}.Release|Win32.Build.0 = Release|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Debug|Win32.ActiveCfg = Debug|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Debug|Win32.Build.0 = Debug|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Release|Win32.ActiveCfg = Release|Win32 {47901C6F-77EC-4753-A83A-F6AE975851B9}.Release|Win32.Build.0 = Release|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Debug|Win32.ActiveCfg = Debug|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Debug|Win32.Build.0 = Debug|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Release|Win32.ActiveCfg = Release|Win32 {2D0B32C2-B035-4873-8E9A-4D4221D93F68}.Release|Win32.Build.0 = Release|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Debug|Win32.ActiveCfg = Debug|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Debug|Win32.Build.0 = Debug|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Release|Win32.ActiveCfg = Release|Win32 {712DD83B-786E-485E-83C7-7197DD851B78}.Release|Win32.Build.0 = Release|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Debug|Win32.ActiveCfg = Debug|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Debug|Win32.Build.0 = Debug|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Release|Win32.ActiveCfg = Release|Win32 {671D843F-4DFA-4CB8-8BC9-D44E7F4ECF1E}.Release|Win32.Build.0 = Release|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Debug|Win32.ActiveCfg = Debug|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Debug|Win32.Build.0 = Debug|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Release|Win32.ActiveCfg = Release|Win32 {5D75FBFB-539A-4014-ACEB-520BB16F5BFC}.Release|Win32.Build.0 = Release|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Debug|Win32.ActiveCfg = Debug|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Debug|Win32.Build.0 = Debug|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Release|Win32.ActiveCfg = Release|Win32 {58DA1042-AC19-4779-AC1A-AA8EEB3A4524}.Release|Win32.Build.0 = Release|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Debug|Win32.ActiveCfg = Debug|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Debug|Win32.Build.0 = Debug|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Release|Win32.ActiveCfg = Release|Win32 {D1E6567A-4F65-4832-8018-D33B3CB4692B}.Release|Win32.Build.0 = Release|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Debug|Win32.ActiveCfg = Debug|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Debug|Win32.Build.0 = Debug|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Release|Win32.ActiveCfg = Release|Win32 {A2BEA467-A4CC-4FA6-9C74-587498E35467}.Release|Win32.Build.0 = Release|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Debug|Win32.ActiveCfg = Debug|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Debug|Win32.Build.0 = Debug|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Release|Win32.ActiveCfg = Release|Win32 {FBB66156-9A54-4713-A801-C507BE7A3AE3}.Release|Win32.Build.0 = Release|Win32 {46B82840-9832-466F-8568-132407CA3853}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {46B82840-9832-466F-8568-132407CA3853}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {46B82840-9832-466F-8568-132407CA3853}.Debug|Win32.ActiveCfg = Debug|Win32 {46B82840-9832-466F-8568-132407CA3853}.Debug|Win32.Build.0 = Debug|Win32 {46B82840-9832-466F-8568-132407CA3853}.Release|Win32.ActiveCfg = Release|Win32 {46B82840-9832-466F-8568-132407CA3853}.Release|Win32.Build.0 = Release|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Debug|Win32.ActiveCfg = Debug|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Debug|Win32.Build.0 = Debug|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Release|Win32.ActiveCfg = Release|Win32 {48D98A0A-BF9C-4D7E-9AF8-E4CAE8437997}.Release|Win32.Build.0 = Release|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Debug|Win32.ActiveCfg = Debug|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Debug|Win32.Build.0 = Debug|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Release|Win32.ActiveCfg = Release|Win32 {7C132953-1700-42FF-9F61-A814C9F2C758}.Release|Win32.Build.0 = Release|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Debug|Win32.ActiveCfg = Debug|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Debug|Win32.Build.0 = Debug|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Release|Win32.ActiveCfg = Release|Win32 {38D89022-2C83-4436-A333-375A2E3E7BB0}.Release|Win32.Build.0 = Release|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Debug|Win32.ActiveCfg = Debug|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Debug|Win32.Build.0 = Debug|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Release|Win32.ActiveCfg = Release|Win32 {52251CB2-65A3-421B-9CB4-7DAC13BB3758}.Release|Win32.Build.0 = Release|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Debug|Win32.ActiveCfg = Debug|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Debug|Win32.Build.0 = Debug|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Release|Win32.ActiveCfg = Release|Win32 {62C97F5E-64DD-4623-9563-747C4C173348}.Release|Win32.Build.0 = Release|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Debug|Win32.ActiveCfg = Debug|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Debug|Win32.Build.0 = Debug|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Release|Win32.ActiveCfg = Release|Win32 {D7643AD7-8518-4B3E-8F3F-F11258D9540E}.Release|Win32.Build.0 = Release|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Debug|Win32.ActiveCfg = Debug|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Debug|Win32.Build.0 = Debug|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Release|Win32.ActiveCfg = Release|Win32 {44A003BE-400D-4434-AFED-64D8E3B448D9}.Release|Win32.Build.0 = Release|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Debug|Win32.ActiveCfg = Debug|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Debug|Win32.Build.0 = Debug|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Release|Win32.ActiveCfg = Release|Win32 {C52F935E-1FD2-443C-A181-27908DAB3BC8}.Release|Win32.Build.0 = Release|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Debug|Win32.ActiveCfg = Debug|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Debug|Win32.Build.0 = Debug|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Release|Win32.ActiveCfg = Release|Win32 {01C4C49B-5B89-4049-8F9E-1906F82B798D}.Release|Win32.Build.0 = Release|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Debug|Win32.ActiveCfg = Debug|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Debug|Win32.Build.0 = Debug|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Release|Win32.ActiveCfg = Release|Win32 {0B127AE3-0C18-4EEF-AB20-A0693E6AA822}.Release|Win32.Build.0 = Release|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Debug|Win32.ActiveCfg = Debug|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Debug|Win32.Build.0 = Debug|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Release|Win32.ActiveCfg = Release|Win32 {A15F1E4F-951A-403E-B746-2A6D63D9C416}.Release|Win32.Build.0 = Release|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Debug|Win32.ActiveCfg = Debug|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Debug|Win32.Build.0 = Debug|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Release|Win32.ActiveCfg = Release|Win32 {6CE3D593-E90D-4CC1-A66B-694AC909F6B8}.Release|Win32.Build.0 = Release|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Debug|Win32.ActiveCfg = Debug|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Debug|Win32.Build.0 = Debug|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Release|Win32.ActiveCfg = Release|Win32 {1BA0B9E8-F135-494F-9CF5-86427C1F6E41}.Release|Win32.Build.0 = Release|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Debug|Win32.ActiveCfg = Debug|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Debug|Win32.Build.0 = Debug|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Release|Win32.ActiveCfg = Release|Win32 {88B5F49E-6EBE-4FEA-8E5B-BE1F0DF7E8E8}.Release|Win32.Build.0 = Release|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Debug|Win32.ActiveCfg = Debug|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Debug|Win32.Build.0 = Debug|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Release|Win32.ActiveCfg = Release|Win32 {06D707E5-68FF-4FC4-AFD0-C84584E32F47}.Release|Win32.Build.0 = Release|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Debug|Win32.ActiveCfg = Debug|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Debug|Win32.Build.0 = Debug|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Release|Win32.ActiveCfg = Release|Win32 {96AFC6D4-A3DC-44D4-8F55-F74E1D21798C}.Release|Win32.Build.0 = Release|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Debug_NoLibs|Win32.ActiveCfg = Debug_NoLibs|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Debug_NoLibs|Win32.Build.0 = Debug_NoLibs|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Debug|Win32.ActiveCfg = Debug|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Debug|Win32.Build.0 = Debug|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Release|Win32.ActiveCfg = Release|Win32 {8EE881F4-78DC-49C7-8845-E842358AC0FA}.Release|Win32.Build.0 = Release|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Debug_NoLibs|Win32.ActiveCfg = Debug|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Debug_NoLibs|Win32.Build.0 = Debug|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Debug|Win32.ActiveCfg = Debug|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Debug|Win32.Build.0 = Debug|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Release|Win32.ActiveCfg = Release|Win32 {11A8927C-F971-4104-A286-5DC11C25E2EC}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal sleuthkit-3.2.3/win32/tsk_comparedir/000777 000765 000024 00000000000 11643647552 020316 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_gettimes/000777 000765 000024 00000000000 11643647552 020012 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_loaddb/000777 000765 000024 00000000000 11643647552 017416 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_recover/000777 000765 000024 00000000000 11643647552 017636 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_recover/tsk_recover.vcproj000644 000765 000024 00000013010 11643647441 023375 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_loaddb/tsk_loaddb.vcproj000644 000765 000024 00000012030 11643647441 022736 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_gettimes/tsk_gettimes.vcproj000755 000765 000024 00000010437 11643647441 023742 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/tsk_comparedir/tsk_compare.vcproj000644 000765 000024 00000012176 11643647441 024052 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/posix-sample/posix-sample.vcproj000755 000765 000024 00000012754 11643647441 023604 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmstat/mmstat.vcproj000644 000765 000024 00000012742 11643647441 021346 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmls/mmls.vcproj000644 000765 000024 00000012734 11643647441 020455 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/mmcat/mmcat.vcproj000644 000765 000024 00000012737 11643647441 020742 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libmmtools/libmmtools.vcproj000644 000765 000024 00000013223 11643647441 023071 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libimgtools/libimgtools.vcproj000644 000765 000024 00000013375 11643647441 023407 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libhashdbtools/libhashdbtools.vcproj000644 000765 000024 00000012572 11643647441 024537 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libfstools/libfstools.vcproj000644 000765 000024 00000020074 11643647441 023071 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libauxtools/libauxtools.vcproj000644 000765 000024 00000013415 11643647441 023444 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/libautotools/libautotools.vcproj000644 000765 000024 00000012227 11643647441 023772 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/jls/jls.vcproj000644 000765 000024 00000012731 11643647441 020112 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/jcat/jcat.vcproj000644 000765 000024 00000012745 11643647441 020401 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/istat/istat.vcproj000644 000765 000024 00000012750 11643647441 021003 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/img_stat/img_stat.vcproj000644 000765 000024 00000012751 11643647441 022152 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/img_cat/img_cat.vcproj000644 000765 000024 00000013040 11643647441 021532 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ils/ils.vcproj000644 000765 000024 00000012776 11643647441 020121 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ifind/ifind.vcproj000644 000765 000024 00000013015 11643647441 020710 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/icat/icat.vcproj000644 000765 000024 00000013001 11643647441 020361 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/hfind/hfind.vcproj000644 000765 000024 00000013006 11643647441 020706 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/fsstat/fsstat.vcproj000644 000765 000024 00000013007 11643647441 021337 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/fls/fls.vcproj000644 000765 000024 00000013007 11643647441 020077 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/ffind/ffind.vcproj000644 000765 000024 00000013004 11643647441 020700 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/callback-sample/callback-sample.vcproj000755 000765 000024 00000012765 11643647441 024572 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkstat/blkstat.vcproj000644 000765 000024 00000013012 11643647441 021633 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkls/blkls.vcproj000644 000765 000024 00000013004 11643647441 020742 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkcat/blkcat.vcproj000644 000765 000024 00000013007 11643647441 021227 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/win32/blkcalc/blkcalc.vcproj000644 000765 000024 00000013012 11643647441 021511 0ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/auto/000777 000765 000024 00000000000 11643647553 016203 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/base/000777 000765 000024 00000000000 11643647552 016144 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/docs/000777 000765 000024 00000000000 11643647552 016162 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/fs/000777 000765 000024 00000000000 11643647553 015643 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/hashdb/000777 000765 000024 00000000000 11643647553 016464 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/img/000777 000765 000024 00000000000 11643647553 016007 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/libtsk.h000644 000765 000024 00000000357 11643647440 016670 0ustar00carrierstaff000000 000000 #ifndef _TSK_LIBTSK_H #define _TSK_LIBTSK_H #include "tsk3/base/tsk_base.h" #include "tsk3/img/tsk_img.h" #include "tsk3/vs/tsk_vs.h" #include "tsk3/fs/tsk_fs.h" #include "tsk3/hashdb/tsk_hashdb.h" #include "tsk3/auto/tsk_auto.h" #endif sleuthkit-3.2.3/tsk3/Makefile.am000644 000765 000024 00000001027 11643647504 017257 0ustar00carrierstaff000000 000000 # Compile the sub directories SUBDIRS = base img vs fs hashdb auto # Merge the libraries into one lib_LTLIBRARIES = libtsk3.la libtsk3_la_SOURCES = libtsk3_la_LIBADD = base/libtskbase.la img/libtskimg.la \ vs/libtskvs.la fs/libtskfs.la hashdb/libtskhashdb.la \ auto/libtskauto.la # current:revision:age libtsk3_la_LDFLAGS = -version-info 7:0:4 EXTRA_DIST = tsk_tools_i.h docs/Doxyfile docs/main.dox \ docs/basics.dox docs/img.dox docs/vs.dox docs/fs.dox \ docs/base.dox docs/hashdb.dox docs/footer.html docs/auto.dox sleuthkit-3.2.3/tsk3/Makefile.in000644 000765 000024 00000043714 11643647517 017305 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/tsk_config.h.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = tsk_config.h CONFIG_CLEAN_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libtsk3_la_DEPENDENCIES = base/libtskbase.la img/libtskimg.la \ vs/libtskvs.la fs/libtskfs.la hashdb/libtskhashdb.la \ auto/libtskauto.la am_libtsk3_la_OBJECTS = libtsk3_la_OBJECTS = $(am_libtsk3_la_OBJECTS) libtsk3_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libtsk3_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtsk3_la_SOURCES) DIST_SOURCES = $(libtsk3_la_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 ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # Compile the sub directories SUBDIRS = base img vs fs hashdb auto # Merge the libraries into one lib_LTLIBRARIES = libtsk3.la libtsk3_la_SOURCES = libtsk3_la_LIBADD = base/libtskbase.la img/libtskimg.la \ vs/libtskvs.la fs/libtskfs.la hashdb/libtskhashdb.la \ auto/libtskauto.la # current:revision:age libtsk3_la_LDFLAGS = -version-info 7:0:4 EXTRA_DIST = tsk_tools_i.h docs/Doxyfile docs/main.dox \ docs/basics.dox docs/img.dox docs/vs.dox docs/fs.dox \ docs/base.dox docs/hashdb.dox docs/footer.html docs/auto.dox all: tsk_config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tsk_config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/tsk_config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status tsk3/tsk_config.h $(srcdir)/tsk_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_srcdir) && $(AUTOHEADER) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f tsk_config.h stamp-h1 install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ f=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ else :; fi; \ done uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ p=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtsk3.la: $(libtsk3_la_OBJECTS) $(libtsk3_la_DEPENDENCIES) $(libtsk3_la_LINK) -rpath $(libdir) $(libtsk3_la_OBJECTS) $(libtsk3_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c 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): @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; \ (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): @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; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) tsk_config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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 || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) tsk_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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) tsk_config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) tsk_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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) tsk_config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done 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) 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-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ distclean distclean-compile distclean-generic distclean-hdr \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-libLTLIBRARIES # 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: sleuthkit-3.2.3/tsk3/sorter/000777 000765 000024 00000000000 11643647552 016550 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/tsk_config.h.in000644 000765 000024 00000010427 11643647440 020132 0ustar00carrierstaff000000 000000 /* tsk/tsk_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 header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `afflib' library (-lafflib). */ #undef HAVE_LIBAFFLIB /* Define to 1 if you have the `ewf' library (-lewf). */ #undef HAVE_LIBEWF /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_LSTAT_EMPTY_STRING_BUG /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_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 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 header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_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 `utime(file, NULL)' sets file's timestamp to the present. */ #undef HAVE_UTIME_NULL /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* 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 /* Define to the type of arg 1 for `select'. */ #undef SELECT_TYPE_ARG1 /* Define to the type of args 2, 3 and 4 for `select'. */ #undef SELECT_TYPE_ARG234 /* Define to the type of arg 5 for `select'. */ #undef SELECT_TYPE_ARG5 /* 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 run-time. 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 /* Version number of package */ #undef VERSION /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if doesn't define. */ #undef gid_t /* Define to `int' if does not define. */ #undef mode_t /* Define to `long' if does not define. */ #undef off_t /* Define to `unsigned' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ #undef uid_t sleuthkit-3.2.3/tsk3/tsk_incs.h000644 000765 000024 00000000425 11643647535 017216 0ustar00carrierstaff000000 000000 #ifndef _TSK_INCS_H #define _TSK_INCS_H // automatically by ./configure // Contains the config.h data needed by programs that use libtsk #include #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif #include #include #endif sleuthkit-3.2.3/tsk3/tsk_tools_i.h000644 000765 000024 00000000666 11643647440 017734 0ustar00carrierstaff000000 000000 #ifndef _TSK_TOOLS_I_H #define _TSK_TOOLS_I_H /* same as tsklib.h except that it includes the base_i.h file * instead of base.h so that we can get the _config defines. * This is to be used by the tools included with TSK (such as fls). */ #include "tsk3/base/tsk_base_i.h" #include "tsk3/img/tsk_img.h" #include "tsk3/vs/tsk_vs.h" #include "tsk3/fs/tsk_fs.h" #include "tsk3/hashdb/tsk_hashdb.h" #include "tsk3/auto/tsk_auto.h" #endif sleuthkit-3.2.3/tsk3/vs/000777 000765 000024 00000000000 11643647553 015663 5ustar00carrierstaff000000 000000 sleuthkit-3.2.3/tsk3/vs/.indent.pro000644 000765 000024 00000000036 11643647440 017732 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nlp -nut sleuthkit-3.2.3/tsk3/vs/bsd.c000644 000765 000024 00000015104 11643647441 016570 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file bsd.c * Contains the internal functions required to process BSD disk labels. */ #include "tsk_vs_i.h" #include "tsk_bsd.h" /* * Return a buffer with a description of the partition type. The buffer * must be freed by the caller. */ static char * bsd_get_desc(uint8_t fstype) { char *str = tsk_malloc(64); if (str == NULL) return ""; switch (fstype) { case 0: strncpy(str, "Unused (0x00)", 64); break; case 1: strncpy(str, "Swap (0x01)", 64); break; case 2: strncpy(str, "Version 6 (0x02)", 64); break; case 3: strncpy(str, "Version 7 (0x03)", 64); break; case 4: strncpy(str, "System V (0x04)", 64); break; case 5: strncpy(str, "4.1BSD (0x05)", 64); break; case 6: strncpy(str, "Eighth Edition (0x06)", 64); break; case 7: strncpy(str, "4.2BSD (0x07)", 64); break; case 8: strncpy(str, "MSDOS (0x08)", 64); break; case 9: strncpy(str, "4.4LFS (0x09)", 64); break; case 10: strncpy(str, "Unknown (0x0A)", 64); break; case 11: strncpy(str, "HPFS (0x0B)", 64); break; case 12: strncpy(str, "ISO9660 (0x0C)", 64); break; case 13: strncpy(str, "Boot (0x0D)", 64); break; case 14: strncpy(str, "Vinum (0x0E)", 64); break; default: snprintf(str, 64, "Unknown Type (0x%.2x)", fstype); break; } return str; } /* * Process the partition table at the sector address * * Return 1 on error and 0 if no error */ static uint8_t bsd_load_table(TSK_VS_INFO * a_vs) { char *sect_buf; bsd_disklabel *dlabel; uint32_t idx = 0; ssize_t cnt; char *table_str; TSK_DADDR_T laddr = a_vs->offset / a_vs->block_size + BSD_PART_SOFFSET; // used for printing only TSK_DADDR_T max_addr = (a_vs->img_info->size - a_vs->offset) / a_vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "bsd_load_table: Table Sector: %" PRIuDADDR "\n", laddr); if ((sect_buf = tsk_malloc(a_vs->block_size)) == NULL) return 1; dlabel = (bsd_disklabel *) sect_buf; /* read the block */ cnt = tsk_vs_read_block (a_vs, BSD_PART_SOFFSET, sect_buf, a_vs->block_size); if (cnt != a_vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "BSD Disk Label in Sector: %" PRIuDADDR, laddr); free(sect_buf); return 1; } /* Check the magic */ if (tsk_vs_guessu32(a_vs, dlabel->magic, BSD_MAGIC)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "BSD partition table (magic #1) (Sector: %" PRIuDADDR ") %" PRIx32, laddr, tsk_getu32(a_vs->endian, dlabel->magic)); free(sect_buf); return 1; } /* Check the second magic value */ if (tsk_getu32(a_vs->endian, dlabel->magic2) != BSD_MAGIC) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "BSD disk label (magic #2) (Sector: %" PRIuDADDR ") %" PRIx32, laddr, tsk_getu32(a_vs->endian, dlabel->magic2)); free(sect_buf); return 1; } /* Add an entry of 1 length for the table to the internal structure */ if ((table_str = tsk_malloc(32)) == NULL) { free(sect_buf); return 1; } snprintf(table_str, 32, "Partition Table"); if (NULL == tsk_vs_part_add(a_vs, BSD_PART_SOFFSET, (TSK_DADDR_T) 1, TSK_VS_PART_FLAG_META, table_str, -1, -1)) { free(sect_buf); return 1; } /* Cycle through the partitions, there are either 8 or 16 */ for (idx = 0; idx < tsk_getu16(a_vs->endian, dlabel->num_parts); idx++) { uint32_t part_start; uint32_t part_size; part_start = tsk_getu32(a_vs->endian, dlabel->part[idx].start_sec); part_size = tsk_getu32(a_vs->endian, dlabel->part[idx].size_sec); if (tsk_verbose) tsk_fprintf(stderr, "load_table: %" PRIu32 " Starting Sector: %" PRIu32 " Size: %" PRIu32 " Type: %d\n", idx, part_start, part_size, dlabel->part[idx].fstype); if (part_size == 0) continue; // make sure the first couple are in the image bounds if ((idx < 2) && (part_start > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "bsd_load_table: Starting sector too large for image"); free(sect_buf); return 1; } /* Add the partition to the internal sorted list */ if (NULL == tsk_vs_part_add(a_vs, (TSK_DADDR_T) part_start, (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_ALLOC, bsd_get_desc(dlabel->part[idx].fstype), -1, idx)) { free(sect_buf); return 1; } } free(sect_buf); return 0; } static void bsd_close(TSK_VS_INFO * a_vs) { tsk_vs_part_free(a_vs); free(a_vs); } /* * analyze the image in img_info and process it as BSD * Initialize the TSK_VS_INFO structure * * Return TSK_VS_INFO or NULL if not BSD or an error */ TSK_VS_INFO * tsk_vs_bsd_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) { TSK_VS_INFO *vs; // clean up any errors that are lying around tsk_error_reset(); vs = (TSK_VS_INFO *) tsk_malloc(sizeof(*vs)); if (vs == NULL) return NULL; vs->img_info = img_info; vs->vstype = TSK_VS_TYPE_BSD; /* use the offset provided */ vs->offset = offset; /* inititialize settings */ vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = bsd_close; /* Load the partitions into the sorted list */ if (bsd_load_table(vs)) { bsd_close(vs); return NULL; } /* fill in the sorted list with the 'unknown' values */ if (tsk_vs_part_unused(vs)) { bsd_close(vs); return NULL; } return vs; } sleuthkit-3.2.3/tsk3/vs/dos.c000644 000765 000024 00000076635 11643647441 016625 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file dos.c * Contains the internal functions to process DOS Partition tables */ #include "tsk_vs_i.h" #include "tsk_dos.h" /* Check the extended partition flags */ #define dos_is_ext(x) \ ((((x) == 0x05) || ((x) == 0x0F) || ((x) == 0x85)) ? 1 : 0) /* * dos_get_desc * * Return a buffer with a string description of the partition type * * From: http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */ static char * dos_get_desc(uint8_t ptype) { #define DESC_LEN 64 char *str = tsk_malloc(DESC_LEN); if (str == NULL) return ""; switch (ptype) { case 0x00: snprintf(str, DESC_LEN, "Empty (0x00)"); break; case 0x01: snprintf(str, DESC_LEN, "DOS FAT12 (0x01)"); break; case 0x04: case 0x06: snprintf(str, DESC_LEN, "DOS FAT16 (0x%.2X)", ptype); break; case 0x05: snprintf(str, DESC_LEN, "DOS Extended (0x05)"); break; case 0x07: snprintf(str, DESC_LEN, "NTFS (0x07)"); break; case 0x08: snprintf(str, DESC_LEN, "AIX Boot (0x08)"); break; case 0x09: snprintf(str, DESC_LEN, "AIX Data (0x09)"); break; case 0x0b: case 0x0c: snprintf(str, DESC_LEN, "Win95 FAT32 (0x%.2X)", ptype); break; case 0x0e: snprintf(str, DESC_LEN, "Win95 FAT16 (0x0E)"); break; case 0x0f: snprintf(str, DESC_LEN, "Win95 Extended (0x0F)"); break; case 0x11: snprintf(str, DESC_LEN, "DOS FAT12 Hidden (0x11)"); break; case 0x12: snprintf(str, DESC_LEN, "Hibernation (0x12)"); break; case 0x14: case 0x16: snprintf(str, DESC_LEN, "DOS FAT16 Hidden (0x%.2X)", ptype); break; case 0x1b: case 0x1c: snprintf(str, DESC_LEN, "Win95 FAT32 Hidden (0x%.2X)", ptype); break; case 0x1e: snprintf(str, DESC_LEN, "Win95 FAT16 Hidden (0x1E)"); break; case 0x42: snprintf(str, DESC_LEN, "Win LVM / Secure FS (0x42)"); break; case 0x44: snprintf(str, DESC_LEN, "GoBack (0x44)"); break; case 0x50: case 0x51: case 0x53: case 0x54: snprintf(str, DESC_LEN, "OnTrack Disk Manager (0x%.2X)", ptype); break; case 0x55: snprintf(str, DESC_LEN, "EZ-Drive (0x55)"); break; return "EZ-Drive"; case 0x57: snprintf(str, DESC_LEN, "DrivePro (0x57)"); break; case 0x61: snprintf(str, DESC_LEN, "SpeedStor (0x61)"); break; case 0x63: snprintf(str, DESC_LEN, "UNIX System V (0x63)"); break; case 0x64: case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: snprintf(str, DESC_LEN, "Novell Netware (0x%.2X)", ptype); break; case 0x82: snprintf(str, DESC_LEN, "Linux Swap / Solaris x86 (0x82)"); break; case 0x83: snprintf(str, DESC_LEN, "Linux (0x83)"); break; case 0x84: snprintf(str, DESC_LEN, "Hibernation (0x84)"); break; case 0x85: snprintf(str, DESC_LEN, "Linux Extended (0x85)"); break; case 0x86: snprintf(str, DESC_LEN, "NTFS Volume Set (0x86)"); break; case 0x8e: snprintf(str, DESC_LEN, "Linux Logical Volume Manager (0x8e)"); break; case 0x93: snprintf(str, DESC_LEN, "Linux Hidden (0x93)"); break; case 0x9f: snprintf(str, DESC_LEN, "BSD/OS (0x9F)"); break; case 0xa0: case 0xa1: snprintf(str, DESC_LEN, "Hibernation (0x%.2X)", ptype); break; case 0xa5: snprintf(str, DESC_LEN, "FreeBSD (0xA5)"); break; case 0xa6: snprintf(str, DESC_LEN, "OpenBSD (0xA6)"); break; case 0xa7: snprintf(str, DESC_LEN, "NextSTEP (0xA7)"); break; case 0xa8: snprintf(str, DESC_LEN, "Mac OS X (0xA8)"); break; case 0xa9: snprintf(str, DESC_LEN, "NetBSD (0xA9)"); break; case 0xab: snprintf(str, DESC_LEN, "Mac OS X (0xAB)"); break; case 0xb7: snprintf(str, DESC_LEN, "BSDI (0xB7)"); break; case 0xb8: snprintf(str, DESC_LEN, "BSDI Swap (0xB8)"); break; case 0xbe: snprintf(str, DESC_LEN, "Solaris 8 Boot (0xBE)"); break; case 0xc2: snprintf(str, DESC_LEN, "Hidden Linux (0xC2)"); break; case 0xc3: snprintf(str, DESC_LEN, "Hidden Linux Swap (0xC3)"); break; case 0xc6: case 0xc7: snprintf(str, DESC_LEN, "Corrupted Windows NT Volume / Stripe Set (0x%.2X)", ptype); break; case 0xee: snprintf(str, DESC_LEN, "GPT Safety Partition (0xEE)"); break; case 0xfb: snprintf(str, DESC_LEN, "VMWare File System (0xFB)"); break; case 0xfc: snprintf(str, DESC_LEN, "VMWare Swap (0xFC)"); break; return "VMware Swap"; case 0xfd: snprintf(str, DESC_LEN, "Linux RAID (0xFD)"); break; case 0x02: snprintf(str, DESC_LEN, "XENIX root (0x02)"); break; case 0x03: snprintf(str, DESC_LEN, "XENIX /usr (0x03)"); break; case 0x0a: snprintf(str, DESC_LEN, "OS/2 Boot Manager (0x0a)"); break; /* case 0x0a: snprintf(str, DESC_LEN, "Coherent swap (0x0a)"); break; case 0x0a: snprintf(str, DESC_LEN, "OPUS (0x0a)"); break; */ case 0x10: snprintf(str, DESC_LEN, "OPUS (0x10)"); break; case 0x17: snprintf(str, DESC_LEN, "Hidden IFS/HPFS (0x17)"); break; case 0x18: snprintf(str, DESC_LEN, "AST SmartSleep (0x18)"); break; case 0x19: case 0x20: case 0x22: case 0x7e: case 0x7f: case 0xed: case 0xf7: snprintf(str, DESC_LEN, "Unused (0x%.2X)", ptype); break; case 0x21: case 0x23: case 0x26: case 0x31: case 0x33: case 0x34: case 0x36: case 0x71: case 0x73: case 0x76: case 0xf3: snprintf(str, DESC_LEN, "Reserved (0x%.2X)", ptype); break; case 0x24: snprintf(str, DESC_LEN, "NEC DOS 3.x (0x24)"); break; case 0x32: snprintf(str, DESC_LEN, "NOS (0x32)"); break; case 0x35: snprintf(str, DESC_LEN, "JFS on OS/2 or eCS (0x35)"); break; case 0x38: snprintf(str, DESC_LEN, "THEOS v3.2 2gb (0x38)"); break; /* case 0x39: snprintf(str, DESC_LEN, "Plan 9 (0x39)"); break; */ case 0x39: snprintf(str, DESC_LEN, "THEOS v4 Spanned (0x39)"); break; case 0x3a: snprintf(str, DESC_LEN, "THEOS v4 4gb (0x3a)"); break; case 0x3b: snprintf(str, DESC_LEN, "THEOS v4 Extended (0x3b)"); break; case 0x3c: snprintf(str, DESC_LEN, "PartitionMagic Recovery (0x3c)"); break; case 0x3d: snprintf(str, DESC_LEN, "Hidden NetWare (0x3d)"); break; case 0x40: snprintf(str, DESC_LEN, "Venix 80286 (0x40)"); break; case 0x41: snprintf(str, DESC_LEN, "Linux/MINIX (Sharing Disk with DR-DOS) (0x41)"); break; /* case 0x41: snprintf(str, DESC_LEN, "Personal RISC Boot (0x41)"); break; case 0x41: snprintf(str, DESC_LEN, "PPC PReP Boot (0x41)"); break; */ case 0x43: snprintf(str, DESC_LEN, "Linux Native (Sharing Disk with DR-DOS) (0x43)"); break; case 0x45: snprintf(str, DESC_LEN, "Boot-US Boot Manager (0x45)"); break; /* case 0x45: snprintf(str, DESC_LEN, "Priam (0x45)"); break; case 0x45: snprintf(str, DESC_LEN, "EUMEL/Elan (0x45)"); break; */ case 0x46: snprintf(str, DESC_LEN, "EUMEL/Elan (0x46)"); break; case 0x47: snprintf(str, DESC_LEN, "EUMEL/Elan (0x47)"); break; case 0x48: snprintf(str, DESC_LEN, "EUMEL/Elan (0x48)"); break; case 0x4a: snprintf(str, DESC_LEN, "Mark Aitchison's ALFS/THIN Lightweight Filesystem (0x4a)"); break; /*case 0x4a: snprintf(str, DESC_LEN, "AdaOS Aquila (0x4a)"); break; */ case 0x4c: snprintf(str, DESC_LEN, "Oberon (0x4c)"); break; case 0x4d: case 0x4e: case 0x4f: snprintf(str, DESC_LEN, "QNX 4.x (0x%.2X)", ptype); break; /*case 0x4f: snprintf(str, DESC_LEN, "Oberon (0x4f)"); break; */ /*case 0x52: snprintf(str, DESC_LEN, "CP/M (0x52)"); break; */ case 0x52: snprintf(str, DESC_LEN, "Microport SysV/AT (0x52)"); break; /*case 0x56: snprintf(str, DESC_LEN, "Golden Bow VFeature Partitioned Volume. (0x56)"); break; */ /*case 0x56: snprintf(str, DESC_LEN, "DM Converted to EZ-BIOS (0x56)"); break; */ case 0x56: snprintf(str, DESC_LEN, "AT&T MS-DOS 3.x Logically Sectored FAT. (0x56)"); break; case 0x5c: snprintf(str, DESC_LEN, "Priam EDisk (0x5c)"); break; case 0x70: snprintf(str, DESC_LEN, "DiskSecure Multi-Boot (0x70)"); break; case 0x74: snprintf(str, DESC_LEN, "Scramdisk (0x74)"); break; case 0x75: snprintf(str, DESC_LEN, "IBM PC/IX (0x75)"); break; /*case 0x77: snprintf(str, DESC_LEN, "M2FS/M2CS (0x77)"); break; */ case 0x77: snprintf(str, DESC_LEN, "VNDI (0x77)"); break; case 0x78: snprintf(str, DESC_LEN, "XOSL FS (0x78)"); break; case 0x80: snprintf(str, DESC_LEN, "MINIX <=v1.4a (0x80)"); break; case 0x81: snprintf(str, DESC_LEN, "MINIX >=v1.4b, Early Linux (0x81)"); break; /*case 0x81: snprintf(str, DESC_LEN, "Mitac Disk Manager (0x81)"); break; */ case 0x87: snprintf(str, DESC_LEN, "NTFS Volume Set (0x87)"); break; case 0x8a: snprintf(str, DESC_LEN, "Linux Kernel (0x8a)"); break; case 0x8b: snprintf(str, DESC_LEN, "Legacy Fault Tolerant FAT32 (0x8b)"); break; case 0x8c: snprintf(str, DESC_LEN, "Legacy Fault Tolerant FAT32 using BIOS extd INT 13h (0x8c)"); break; case 0x8d: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS FAT12 (0x8d)"); break; case 0x90: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS FAT16 (0x90)"); break; case 0x91: snprintf(str, DESC_LEN, "Free FDISK Hidden DOS Extended (0x91)"); break; case 0x92: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS Large FAT16 (0x92)"); break; case 0x94: snprintf(str, DESC_LEN, "Amoeba Bad Block Table (0x94)"); break; case 0x95: snprintf(str, DESC_LEN, "MIT EXOPC (0x95)"); break; case 0x97: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS FAT32 (0x97)"); break; case 0x98: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS FAT32 LBA (0x98)"); break; /*case 0x98: snprintf(str, DESC_LEN, "Datalight ROM-DOS Super-Boot (0x98)"); break; */ case 0x99: snprintf(str, DESC_LEN, "DCE376 Logical Drive (0x99)"); break; case 0x9a: snprintf(str, DESC_LEN, "Free FDISK Hidden Primary DOS FAT16 LBA (0x9a)"); break; case 0x9b: snprintf(str, DESC_LEN, "Free FDISK Hidden DOS Extended LBA (0x9b)"); break; case 0xa3: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xa3)"); break; case 0xa4: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xa4)"); break; case 0xaa: snprintf(str, DESC_LEN, "Olivetti Fat 12 1.44MB Service (0xaa)"); break; case 0xae: snprintf(str, DESC_LEN, "ShagOS Filesystem (0xae)"); break; case 0xaf: snprintf(str, DESC_LEN, "ShagOS swap (0xaf)"); break; case 0xb0: snprintf(str, DESC_LEN, "BootStar Dummy (0xb0)"); break; case 0xb1: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xb1)"); break; case 0xb3: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xb3)"); break; case 0xb4: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xb4)"); break; /*case 0xb6: snprintf(str, DESC_LEN, "HP Volume Expansion (SpeedStor Variant) (0xb6)"); break; */ case 0xb6: snprintf(str, DESC_LEN, "Corrupted Windows NT Mirror Set Master FAT16 (0xb6)"); break; case 0xbb: snprintf(str, DESC_LEN, "Boot Wizard Hidden (0xbb)"); break; /*case 0xc0: snprintf(str, DESC_LEN, "CTOS (0xc0)"); break; */ /*case 0xc0: snprintf(str, DESC_LEN, "REAL/32 Secure Small (0xc0)"); break; */ /*case 0xc0: snprintf(str, DESC_LEN, "NTFT (0xc0)"); break; */ case 0xc0: snprintf(str, DESC_LEN, "DR-DOS Secured (0xc0)"); break; case 0xc1: snprintf(str, DESC_LEN, "DR-DOS Secured FAT12 (0xc1)"); break; case 0xc4: snprintf(str, DESC_LEN, "DR-DOS Secured FAT16 <32M (0xc4)"); break; case 0xc5: snprintf(str, DESC_LEN, "DR-DOS Secured Extended (0xc5)"); break; case 0xc8: snprintf(str, DESC_LEN, "Reserved for DR-DOS 8.0+ (0xc8)"); break; case 0xc9: snprintf(str, DESC_LEN, "Reserved for DR-DOS 8.0+ (0xc9)"); break; case 0xca: snprintf(str, DESC_LEN, "Reserved for DR-DOS 8.0+ (0xca)"); break; case 0xcb: snprintf(str, DESC_LEN, "DR-DOS 7.04+ Secured FAT32 CHS (0xcb)"); break; case 0xcc: snprintf(str, DESC_LEN, "DR-DOS 7.04+ Secured FAT32 LBA (0xcc)"); break; case 0xcd: snprintf(str, DESC_LEN, "CTOS Memdump? (0xcd)"); break; case 0xce: snprintf(str, DESC_LEN, "DR-DOS 7.04+ FAT16X LBA (0xce)"); break; case 0xcf: snprintf(str, DESC_LEN, "DR-DOS 7.04+ Secured EXT DOS LBA (0xcf)"); break; /*case 0xd0: snprintf(str, DESC_LEN, "REAL/32 Secure Big (0xd0)"); break; */ case 0xd0: snprintf(str, DESC_LEN, "Multiuser DOS Secured (0xd0)"); break; case 0xd1: snprintf(str, DESC_LEN, "Old Multiuser DOS Secured FAT12 (0xd1)"); break; case 0xd4: snprintf(str, DESC_LEN, "Old Multiuser DOS Secured FAT16 <32M (0xd4)"); break; case 0xd5: snprintf(str, DESC_LEN, "Old Multiuser DOS Secured extended (0xd5)"); break; case 0xd6: snprintf(str, DESC_LEN, "Old Multiuser DOS Secured FAT16 >=32M (0xd6)"); break; case 0xd8: snprintf(str, DESC_LEN, "CP/M-86 (0xd8)"); break; case 0xda: snprintf(str, DESC_LEN, "Non-FS Data (0xda)"); break; case 0xdb: snprintf(str, DESC_LEN, "Digital Research CP/M, Concurrent CP/M, Concurrent DOS (0xdb)"); break; /*case 0xdb: snprintf(str, DESC_LEN, "Unisys CTOS (0xdb)"); break; */ /*case 0xdb: snprintf(str, DESC_LEN, "KDG Telemetry SCPU boot (0xdb)"); break; */ case 0xdd: snprintf(str, DESC_LEN, "Hidden CTOS Memdump? (0xdd)"); break; case 0xde: snprintf(str, DESC_LEN, "Dell Utilities FAT (0xde)"); break; /*case 0xdf: snprintf(str, DESC_LEN, "DG/UX Virtual Disk Manager (0xdf)"); break; */ /*case 0xdf: snprintf(str, DESC_LEN, "BootIt EMBRM (0xdf)"); break; */ case 0xe0: snprintf(str, DESC_LEN, "Reserved by STMicroelectronics for ST AVFS. (0xe0)"); break; case 0xe1: snprintf(str, DESC_LEN, "DOS Access or SpeedStor 12-bit FAT Extended (0xe1)"); break; case 0xe3: snprintf(str, DESC_LEN, "DOS R/O or SpeedStor (0xe3)"); break; case 0xe4: snprintf(str, DESC_LEN, "SpeedStor 16-bit FAT Extended <1024 cyl. (0xe4)"); break; case 0xe5: snprintf(str, DESC_LEN, "Tandy MS-DOS with Logically Sectored FAT (0xe5)"); break; case 0xe6: snprintf(str, DESC_LEN, "Storage Dimensions SpeedStor (0xe6)"); break; case 0xeb: snprintf(str, DESC_LEN, "BeOS BFS (0xeb)"); break; case 0xef: snprintf(str, DESC_LEN, "EFI File System (0xef)"); break; case 0xf0: snprintf(str, DESC_LEN, "Linux/PA-RISC Boot Loader (0xf0)"); break; case 0xf1: snprintf(str, DESC_LEN, "Storage Dimensions SpeedStor (0xf1)"); break; case 0xf2: snprintf(str, DESC_LEN, "DOS 3.3+ Secondary (0xf2)"); break; case 0xf4: snprintf(str, DESC_LEN, "SpeedStor Large (0xf4)"); break; /*case 0xf4: snprintf(str, DESC_LEN, "Prologue Single-Volume (0xf4)"); break; */ case 0xf5: snprintf(str, DESC_LEN, "Prologue Multi-Volume (0xf5)"); break; case 0xf6: snprintf(str, DESC_LEN, "Storage Dimensions SpeedStor (0xf6)"); break; case 0xf9: snprintf(str, DESC_LEN, "pCache (0xf9)"); break; case 0xfa: snprintf(str, DESC_LEN, "Bochs (0xfa)"); break; /*case 0xfe: snprintf(str, DESC_LEN, "SpeedStor >1024 cyl. (0xfe)"); break; */ /*case 0xfe: snprintf(str, DESC_LEN, "LANstep (0xfe)"); break; */ /*case 0xfe: snprintf(str, DESC_LEN, "IBM PS/2 IML (0xfe)"); break; */ case 0xfe: snprintf(str, DESC_LEN, "Windows NT Disk Administrator Hidden (0xfe)"); break; /*case 0xfe: snprintf(str, DESC_LEN, "Old Linux Logical Volume Manager (0xfe)"); break; */ case 0xff: snprintf(str, DESC_LEN, "Xenix Bad Block Table (0xff)"); break; default: snprintf(str, DESC_LEN, "Unknown Type (0x%.2X)", ptype); break; } return str; } /* * Load an extended partition table into the structure in TSK_VS_INFO. * * sect_cur: The sector where the extended table is located * sect_ext_base: The sector of the primary extended table (this does * not change for recursive calls) * table: a counter that identifies the table depth * (increases by 1 for each recursive call) * * For the primary extended table, sect_cur == sect_ext_base * * Return 1 on error and 0 on success * */ static uint8_t dos_load_ext_table(TSK_VS_INFO * vs, TSK_DADDR_T sect_cur, TSK_DADDR_T sect_ext_base, int table) { dos_sect *sect; char *sect_buf; int i; char *table_str; ssize_t cnt; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "dos_load_ext: Table Sector: %" PRIuDADDR ", Primary Base Sector: %" PRIuDADDR "\n", sect_cur, sect_ext_base); if ((sect_buf = tsk_malloc(vs->block_size)) == NULL) return 1; sect = (dos_sect *) sect_buf; /* Read the partition table sector */ cnt = tsk_vs_read_block(vs, sect_cur, sect_buf, vs->block_size); if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "Extended DOS table sector %" PRIuDADDR, sect_cur); free(sect_buf); return 1; } /* Sanity Check */ if (tsk_getu16(vs->endian, sect->magic) != DOS_MAGIC) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Extended DOS partition table in sector %" PRIuDADDR, sect_cur); free(sect_buf); return 1; } /* Add an entry of 1 length for the table to the internal structure */ if ((table_str = tsk_malloc(32)) == NULL) { free(sect_buf); return 1; } snprintf(table_str, 32, "Extended Table (#%d)", table); if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) sect_cur, (TSK_DADDR_T) 1, TSK_VS_PART_FLAG_META, table_str, table, -1)) { free(sect_buf); return 1; } /* Cycle through the four partitions in the table * * When another extended partition is found, it is processed * inside of the loop */ for (i = 0; i < 4; i++) { dos_part *part = §->ptable[i]; /* Get the starting sector and size, we currently * ignore CHS */ uint32_t part_start = tsk_getu32(vs->endian, part->start_sec); uint32_t part_size = tsk_getu32(vs->endian, part->size_sec); if (tsk_verbose) tsk_fprintf(stderr, "load_ext: %d:%d Start: %" PRIu32 " Size: %" PRIu32 " Type: %d\n", table, i, part_start, part_size, part->ptype); if (part_size == 0) continue; /* partitions are addressed differently * in extended partitions */ if (dos_is_ext(part->ptype)) { /* part start is added to the start of the * first extended partition (the primary * extended partition) */ if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) (sect_ext_base + part_start), (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_META, dos_get_desc(part->ptype), table, i)) { free(sect_buf); return 1; } if (sect_ext_base + part_start > max_addr) { if (tsk_verbose) tsk_fprintf(stderr, "Starting sector %" PRIuDADDR " of extended partition too large for image\n", sect_ext_base + part_start); } /* Process the extended partition */ else if (dos_load_ext_table(vs, sect_ext_base + part_start, sect_ext_base, table + 1)) { free(sect_buf); return 1; } } else { /* part_start is added to the start of the * current partition for the actual * starting location */ // we ignore the max_addr checks on extended partitions... if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) (sect_cur + part_start), (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_ALLOC, dos_get_desc(part->ptype), table, i)) { free(sect_buf); return 1; } } } free(sect_buf); return 0; } /* * Load the primary partition table (MBR) into the internal * data structures in TSK_VS_INFO * * This will automatically call load_ext_table for extended * partitions * * sect_cur is the addres of the table to load * * 0 is returned if the load is successful and 1 if error */ static uint8_t dos_load_prim_table(TSK_VS_INFO * vs, uint8_t test) { dos_sect *sect; char *sect_buf; int i, added = 0; char *table_str; ssize_t cnt; TSK_DADDR_T taddr = vs->offset / vs->block_size + DOS_PART_SOFFSET; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim: Table Sector: %" PRIuDADDR "\n", taddr); if ((sect_buf = tsk_malloc(vs->block_size)) == NULL) return 1; sect = (dos_sect *) sect_buf; /* Read the table */ cnt = tsk_vs_read_block (vs, DOS_PART_SOFFSET, sect_buf, vs->block_size); if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "Primary DOS table sector %" PRIuDADDR, taddr); free(sect_buf); return 1; } /* Sanity Check */ if (tsk_vs_guessu16(vs, sect->magic, DOS_MAGIC)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "File is not a DOS partition (invalid primary magic) (Sector: %" PRIuDADDR ")", taddr); free(sect_buf); return 1; } /* Because FAT and NTFS use the same magic - check for a * standard MS OEM name and sizes. Not a great check, but we can't * really test the table entries. */ if (test) { if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim_table: Testing FAT/NTFS conditions\n"); if (strncmp("MSDOS", sect->oemname, 5) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: MSDOS OEM name exists"); if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim_table: MSDOS OEM name exists\n"); free(sect_buf); return 1; } else if (strncmp("MSWIN", sect->oemname, 5) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: MSWIN OEM name exists"); if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim_table: MSWIN OEM name exists\n"); free(sect_buf); return 1; } else if (strncmp("NTFS", sect->oemname, 4) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: NTFS OEM name exists"); if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim_table: NTFS OEM name exists\n"); free(sect_buf); return 1; } else if (strncmp("FAT", sect->oemname, 4) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: FAT OEM name exists"); if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim_table: FAT OEM name exists\n"); free(sect_buf); return 1; } } /* Add an entry of 1 sector for the table to the internal structure */ if ((table_str = tsk_malloc(32)) == NULL) { free(sect_buf); return 1; } snprintf(table_str, 32, "Primary Table (#0)"); if (NULL == tsk_vs_part_add(vs, DOS_PART_SOFFSET, (TSK_DADDR_T) 1, TSK_VS_PART_FLAG_META, table_str, -1, -1)) { free(sect_buf); return 1; } /* Cycle through the partition table */ for (i = 0; i < 4; i++) { dos_part *part = §->ptable[i]; /* We currently ignore CHS */ uint32_t part_start = tsk_getu32(vs->endian, part->start_sec); uint32_t part_size = tsk_getu32(vs->endian, part->size_sec); if (tsk_verbose) tsk_fprintf(stderr, "load_pri:0:%d Start: %" PRIu32 " Size: %" PRIu32 " Type: %d\n", i, part_start, part_size, part->ptype); if (part_size == 0) continue; // make sure the first couple are in the image bounds if ((i < 2) && (part_start > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: Starting sector too large for image"); if (tsk_verbose) tsk_fprintf(stderr, "Starting sector %" PRIu32 " too large for image\n", part_start); free(sect_buf); return 1; } #if 0 // I'm not sure if this is too strict ... else if ((part_start + part_size) > max_addr) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: Partition ends after image"); return 1; } #endif added = 1; /* Add the partition to the internal structure * If it is an extended partition, process it now */ if (dos_is_ext(part->ptype)) { if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) part_start, (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_META, dos_get_desc(part->ptype), 0, i)) { free(sect_buf); return 1; } if (dos_load_ext_table(vs, part_start, part_start, 1)) { if (tsk_verbose) { fprintf(stderr, "Error loading extended table, moving on"); tsk_error_print(stderr); } tsk_error_reset(); } } else { if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) part_start, (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_ALLOC, dos_get_desc(part->ptype), 0, i)) { free(sect_buf); return 1; } } } free(sect_buf); if (added == 0) { if (tsk_verbose) tsk_fprintf(stderr, "dos_load_prim: No valid entries\n"); tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "dos_load_prim_table: No valid entries in primary table"); return 1; } return 0; } static void dos_close(TSK_VS_INFO * vs) { tsk_vs_part_free(vs); free(vs); } /* * Given the path to the file, open it and load the internal * partition table structure * * offset is the byte offset to the start of the volume system * * If test is 1 then additional tests are performed to make sure * it isn't a FAT or NTFS file system. This is used when autodetection * is being used to detect the volume system type. */ TSK_VS_INFO * tsk_vs_dos_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset, uint8_t test) { TSK_VS_INFO *vs; // clean up any errors that are lying around tsk_error_reset(); vs = (TSK_VS_INFO *) tsk_malloc(sizeof(*vs)); if (vs == NULL) return NULL; vs->vstype = TSK_VS_TYPE_DOS; vs->img_info = img_info; vs->offset = offset; /* inititialize settings */ vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = dos_close; /* Load the partitions into the sorted list */ if (dos_load_prim_table(vs, test)) { dos_close(vs); return NULL; } /* fill in the sorted list with the 'unknown' values */ if (tsk_vs_part_unused(vs)) { dos_close(vs); return NULL; } return vs; } sleuthkit-3.2.3/tsk3/vs/gpt.c000644 000765 000024 00000021767 11643647441 016626 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2004-2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file gpt.c * The internal functions required to process the GPT GUID Partiition Table. */ #include "tsk_vs_i.h" #include "tsk_gpt.h" #include "tsk_dos.h" /* * Process the partition table at the sector address * * It is loaded into the internal sorted list */ static uint8_t gpt_load_table(TSK_VS_INFO * vs) { gpt_head *head; gpt_entry *ent; dos_sect *dos_part; unsigned int i, a; uint32_t ent_size; char *safe_str, *head_str, *tab_str, *ent_buf; ssize_t cnt; char *sect_buf; TSK_DADDR_T taddr = vs->offset / vs->block_size + GPT_PART_SOFFSET; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "gpt_load_table: Sector: %" PRIuDADDR "\n", taddr); if ((sect_buf = tsk_malloc(vs->block_size)) == NULL) return 1; dos_part = (dos_sect *) sect_buf; cnt = tsk_vs_read_block (vs, GPT_PART_SOFFSET, sect_buf, vs->block_size); /* if -1, then tsk_errno is already set */ if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "Error reading DOS safety partition table in Sector: %" PRIuDADDR, taddr); free(sect_buf); return 1; } /* Sanity Check */ if (tsk_vs_guessu16(vs, dos_part->magic, DOS_MAGIC)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Missing DOS safety partition (invalid magic) (Sector: %" PRIuDADDR ")", taddr); free(sect_buf); return 1; } if (dos_part->ptable[0].ptype != GPT_DOS_TYPE) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Missing DOS safety partition (invalid type in table: %d)", dos_part->ptable[0].ptype); free(sect_buf); return 1; } if ((safe_str = tsk_malloc(16)) == NULL) { free(sect_buf); return 1; } snprintf(safe_str, 16, "Safety Table"); if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) 0, (TSK_DADDR_T) 1, TSK_VS_PART_FLAG_META, safe_str, -1, -1)) { free(sect_buf); return 1; } /* Read the GPT header */ head = (gpt_head *) sect_buf; cnt = tsk_vs_read_block (vs, GPT_PART_SOFFSET + 1, sect_buf, vs->block_size); if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "GPT Header structure in Sector: %" PRIuDADDR, taddr + 1); free(sect_buf); return 1; } if (tsk_getu64(vs->endian, &head->signature) != GPT_HEAD_SIG) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "GPT Header: %" PRIx64, tsk_getu64(vs->endian, &head->signature)); free(sect_buf); return 1; } if ((head_str = tsk_malloc(16)) == NULL) { free(sect_buf); return 1; } snprintf(head_str, 16, "GPT Header"); if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) 1, (TSK_DADDR_T) ((tsk_getu32(vs->endian, &head->head_size_b) + 511) / 512), TSK_VS_PART_FLAG_META, head_str, -1, -1)) { free(sect_buf); return 1; } /* Allocate a buffer for each table entry */ ent_size = tsk_getu32(vs->endian, &head->tab_size_b); if (ent_size < sizeof(gpt_entry)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Header reports partition entry size of %" PRIu32 " and not %" PRIuSIZE "", ent_size, sizeof(gpt_entry)); free(sect_buf); return 1; } if ((tab_str = tsk_malloc(20)) == NULL) { free(sect_buf); return 1; } snprintf(tab_str, 20, "Partition Table"); if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) tsk_getu64(vs->endian, &head->tab_start_lba), (TSK_DADDR_T) ((ent_size * tsk_getu32(vs->endian, &head->tab_num_ent) + 511) / 512), TSK_VS_PART_FLAG_META, tab_str, -1, -1)) { free(sect_buf); return 1; } /* Process the partition table */ if ((ent_buf = tsk_malloc(vs->block_size)) == NULL) { free(sect_buf); return 1; } i = 0; for (a = 0; i < tsk_getu32(vs->endian, &head->tab_num_ent); a++) { char *name; /* Read a sector */ cnt = tsk_vs_read_block(vs, tsk_getu64(vs->endian, &head->tab_start_lba) + a, ent_buf, vs->block_size); if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "Error reading GPT partition table sector : %" PRIuDADDR, tsk_getu64(vs->endian, &head->tab_start_lba) + a); free(ent_buf); free(sect_buf); return 1; } /* Process the sector */ ent = (gpt_entry *) ent_buf; for (; (uintptr_t) ent < (uintptr_t) ent_buf + vs->block_size && i < tsk_getu32(vs->endian, &head->tab_num_ent); i++) { UTF16 *name16; UTF8 *name8; int retVal; if (tsk_verbose) tsk_fprintf(stderr, "gpt_load: %d Starting Sector: %" PRIu64 " End: %" PRIu64 " Flag: %" PRIx64 "\n", i, tsk_getu64(vs->endian, ent->start_lba), tsk_getu64(vs->endian, ent->end_lba), tsk_getu64(vs->endian, ent->flags)); if (tsk_getu64(vs->endian, ent->start_lba) == 0) { ent++; continue; } // make sure the first couple are in the image bounds if ((i < 2) && (tsk_getu64(vs->endian, ent->start_lba) > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "gpt_load_table: Starting sector too large for image"); free(sect_buf); free(ent_buf); return 1; } if ((name = tsk_malloc(256)) == NULL) { free(sect_buf); free(ent_buf); return 1; } name16 = (UTF16 *) ((uintptr_t) ent->name); name8 = (UTF8 *) name; retVal = tsk_UTF16toUTF8(vs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + sizeof(ent->name)), &name8, (UTF8 *) ((uintptr_t) name8 + 256), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "gpt_load_table: Error converting name to UTF8: %d\n", retVal); *name = '\0'; } if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) tsk_getu64(vs->endian, ent->start_lba), (TSK_DADDR_T) (tsk_getu64(vs->endian, ent->end_lba) - tsk_getu64(vs->endian, ent->start_lba) + 1), TSK_VS_PART_FLAG_ALLOC, name, -1, i)) { free(sect_buf); free(ent_buf); return 1; } ent++; } } free(sect_buf); free(ent_buf); return 0; } static void gpt_close(TSK_VS_INFO * vs) { tsk_vs_part_free(vs); free(vs); } TSK_VS_INFO * tsk_vs_gpt_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) { TSK_VS_INFO *vs; // clean up any errors that are lying around tsk_error_reset(); vs = (TSK_VS_INFO *) tsk_malloc(sizeof(*vs)); if (vs == NULL) return NULL; vs->img_info = img_info; vs->vstype = TSK_VS_TYPE_GPT; /* If an offset was given, then use that too */ vs->offset = offset; /* inititialize settings */ vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = gpt_close; /* Load the partitions into the sorted list */ if (gpt_load_table(vs)) { gpt_close(vs); return NULL; } /* fill in the sorted list with the 'unknown' values */ if (tsk_vs_part_unused(vs)) { gpt_close(vs); return NULL; } return vs; } sleuthkit-3.2.3/tsk3/vs/mac.c000644 000765 000024 00000015454 11643647441 016570 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file mac.c * Contains the internal functions to process and load a Mac partition table. */ #include "tsk_vs_i.h" #include "tsk_mac.h" /* * Process the partition table at the sector address * * It is loaded into the internal sorted list * * Return 1 on error and 0 on success */ static uint8_t mac_load_table(TSK_VS_INFO * vs) { char *part_buf; mac_part *part; char *table_str; uint32_t idx, max_part; TSK_DADDR_T taddr = vs->offset / vs->block_size + MAC_PART_SOFFSET; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "mac_load_table: Sector: %" PRIuDADDR "\n", taddr); /* The table can be variable length, so we loop on it * The idx variable shows which round it is * Each structure is a block size */ if ((part_buf = tsk_malloc(vs->block_size)) == NULL) return 1; part = (mac_part *) part_buf; max_part = 1; /* set it to 1 and it will be set in the first loop */ for (idx = 0; idx < max_part; idx++) { uint32_t part_start; uint32_t part_size; char *str; ssize_t cnt; /* Read the entry */ cnt = tsk_vs_read_block (vs, MAC_PART_SOFFSET + idx, part_buf, vs->block_size); /* If -1, then tsk_errno is already set */ if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "MAC Partition entry %" PRIuDADDR, taddr + idx); free(part_buf); return 1; } /* Sanity Check */ if (idx == 0) { /* Set the endian ordering the first time around */ if (tsk_vs_guessu16(vs, part->magic, MAC_MAGIC)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Mac partition table entry (Sector: %" PRIuDADDR ") %" PRIx16, (taddr + idx), tsk_getu16(vs->endian, part->magic)); if (tsk_verbose) tsk_fprintf(stderr, "mac_load: Missing initial magic value\n"); free(part_buf); return 1; } /* Get the number of partitions */ max_part = tsk_getu32(vs->endian, part->pmap_size); } else if (tsk_getu16(vs->endian, part->magic) != MAC_MAGIC) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Mac partition table entry (Sector: %" PRIuDADDR ") %" PRIx16, (taddr + idx), tsk_getu16(vs->endian, part->magic)); if (tsk_verbose) tsk_fprintf(stderr, "mac_load: Missing magic value in entry %" PRIu32 "\n", idx); free(part_buf); return 1; } part_start = tsk_getu32(vs->endian, part->start_sec); part_size = tsk_getu32(vs->endian, part->size_sec); if (tsk_verbose) tsk_fprintf(stderr, "mac_load: %" PRIu32 " Starting Sector: %" PRIu32 " Size: %" PRIu32 " Type: %s\n", idx, part_start, part_size, part->type); if (part_size == 0) continue; // make sure the first couple are within the bounds of the image. if ((idx < 2) && (part_start > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "mac_load_table: Starting sector too large for image"); if (tsk_verbose) tsk_fprintf(stderr, "mac_load: Starting sector too large for image (%" PRIu32 " vs %" PRIu32 ")\n", part_start, max_addr); free(part_buf); return 1; } if ((str = tsk_malloc(sizeof(part->name))) == NULL) { free(part_buf); return 1; } strncpy(str, (char *) part->type, sizeof(part->name)); if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) part_start, (TSK_DADDR_T) part_size, TSK_VS_PART_FLAG_ALLOC, str, -1, idx)) return 1; } free(part_buf); part_buf = NULL; /* Add an entry for the table length */ if ((table_str = tsk_malloc(16)) == NULL) { return 1; } snprintf(table_str, 16, "Table"); if (NULL == tsk_vs_part_add(vs, taddr, max_part, TSK_VS_PART_FLAG_META, table_str, -1, -1)) { return 1; } return 0; } static void mac_close(TSK_VS_INFO * vs) { tsk_vs_part_free(vs); free(vs); } /* * Process img_info as a Mac disk. Initialize TSK_VS_INFO or return * NULL on error * */ TSK_VS_INFO * tsk_vs_mac_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) { TSK_VS_INFO *vs; // clean up any errors that are lying around tsk_error_reset(); vs = (TSK_VS_INFO *) tsk_malloc(sizeof(*vs)); if (vs == NULL) return NULL; vs->img_info = img_info; vs->vstype = TSK_VS_TYPE_MAC; /* If an offset was given, then use that too */ vs->offset = offset; //vs->sect_offset = offset + MAC_PART_OFFSET; /* inititialize settings */ vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = mac_close; /* Load the partitions into the sorted list */ if (mac_load_table(vs)) { // try some other sector sizes uint8_t returnNull = 1; if (vs->block_size == 512) { if (tsk_verbose) tsk_fprintf(stderr, "mac_open: Trying 4096-byte sector size instead of 512-byte\n"); vs->block_size = 4096; returnNull = mac_load_table(vs); } else if (vs->block_size == 4096) { if (tsk_verbose) tsk_fprintf(stderr, "mac_open: Trying 512-byte sector size instead of 4096-byte\n"); vs->block_size = 512; returnNull = mac_load_table(vs); } if (returnNull) { mac_close(vs); return NULL; } } /* fill in the sorted list with the 'unknown' values */ if (tsk_vs_part_unused(vs)) { mac_close(vs); return NULL; } return vs; } sleuthkit-3.2.3/tsk3/vs/Makefile.am000644 000765 000024 00000000504 11643647441 017706 0ustar00carrierstaff000000 000000 AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskvs.la # Note that the .h files are in the top-level Makefile libtskvs_la_SOURCES = mm_open.c mm_part.c mm_types.c mm_io.c \ bsd.c dos.c gpt.c mac.c sun.c tsk_vs_i.h indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ sleuthkit-3.2.3/tsk3/vs/Makefile.in000644 000765 000024 00000033435 11643647517 017734 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/vs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskvs_la_LIBADD = am_libtskvs_la_OBJECTS = mm_open.lo mm_part.lo mm_types.lo mm_io.lo \ bsd.lo dos.lo gpt.lo mac.lo sun.lo libtskvs_la_OBJECTS = $(am_libtskvs_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskvs_la_SOURCES) DIST_SOURCES = $(libtskvs_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskvs.la # Note that the .h files are in the top-level Makefile libtskvs_la_SOURCES = mm_open.c mm_part.c mm_types.c mm_io.c \ bsd.c dos.c gpt.c mac.c sun.c tsk_vs_i.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/vs/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/vs/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskvs.la: $(libtskvs_la_OBJECTS) $(libtskvs_la_DEPENDENCIES) $(LINK) $(libtskvs_la_OBJECTS) $(libtskvs_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dos.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mm_io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mm_open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mm_part.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mm_types.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ # 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: sleuthkit-3.2.3/tsk3/vs/mm_io.c000644 000765 000024 00000006270 11643647441 017124 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file mm_io.c * Contains the wrapper code that allows one to read sectors from * a TSK_VS_INFO or TSK_VS_PART_INFO structure. These functions * call the underlying TSK_IMG_INFO functions. */ #include #include "tsk_vs_i.h" /** * \ingroup vslib * Reads one or more blocks of data with an address relative to the start of the volume system. * * @param a_vs Pointer to open volume system * @param a_addr Sector address to read from, relative to start of VOLUME SYSTEM. * @param a_buf Buffer to store data in * @param a_len Amount of data to read (in bytes - must be a multiple of block_size) * @returns Number of bytes read or -1 on error */ ssize_t tsk_vs_read_block(TSK_VS_INFO * a_vs, TSK_DADDR_T a_addr, char *a_buf, size_t a_len) { if (a_len % a_vs->block_size) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_read_block: length %" PRIuSIZE "" " not a multiple of %d", a_len, a_vs->block_size); return -1; } return tsk_img_read(a_vs->img_info, a_vs->offset + (TSK_OFF_T) (a_addr * a_vs->block_size), a_buf, a_len); } /** * \ingroup vslib * Reads data starting at a byte address relative to the start of a VOLUME in a volume system. * * @param a_vs_part info Pointer to open volume in a volume system * @param a_off Byte offset to read from, relative to start of VOLUME in volume system. * @param a_buf Buffer to store data in * @param a_len Amount of data to read (in bytes) * @returns Number of bytes read or -1 on error */ ssize_t tsk_vs_part_read(const TSK_VS_PART_INFO * a_vs_part, TSK_OFF_T a_off, char *a_buf, size_t a_len) { TSK_VS_INFO *vs = a_vs_part->vs; return tsk_img_read(vs->img_info, vs->offset + (TSK_OFF_T) a_vs_part->start * vs->block_size + a_off, a_buf, a_len); } /** * \ingroup vslib * Reads one or more blocks of data with an address relative to the start of a VOLUME in a volume system. * * @param a_vs_part info Pointer to open volume in a volume system * @param a_addr Block address to start reading from, relative to start of VOLUME in volume system. * @param a_buf Buffer to store data in * @param a_len Amount of data to read (in bytes - must be a multiple of block_size) * @returns Number of bytes read or -1 on error */ ssize_t tsk_vs_part_read_block(const TSK_VS_PART_INFO * a_vs_part, TSK_DADDR_T a_addr, char *a_buf, size_t a_len) { TSK_VS_INFO *vs = a_vs_part->vs; if (a_len % vs->block_size) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_part_read_block: length %" PRIuSIZE "" " not a multiple of %d", a_len, vs->block_size); return -1; } return tsk_img_read(vs->img_info, vs->offset + (TSK_OFF_T) (a_vs_part->start + a_addr) * vs->block_size, a_buf, a_len); } sleuthkit-3.2.3/tsk3/vs/mm_open.c000644 000765 000024 00000014652 11643647441 017461 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * tsk_vs_open - wrapper function for specific partition type * * This software is distributed under the Common Public License 1.0 */ /** * \file mm_open.c * Contains general code to open volume systems. */ #include "tsk_vs_i.h" /** * \ingroup vslib * * Open a disk image and process the media management system * data. This calls VS specific code to determine the type and * collect data. * * @param img_info The opened disk image. * @param offset Byte offset in the disk image to start analyzing from. * @param type Type of volume system (including auto detect) * * @return NULL on error. */ TSK_VS_INFO * tsk_vs_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset, TSK_VS_TYPE_ENUM type) { /* Autodetect mode * We need to try all of them in case there are multiple * installations * * NOte that errors that are encountered during the testing process * will not be reported */ if (type == TSK_VS_TYPE_DETECT) { TSK_VS_INFO *vs, *vs_set = NULL; char *set = NULL; if ((vs = tsk_vs_dos_open(img_info, offset, 1)) != NULL) { set = "DOS"; vs_set = vs; } else { tsk_error_reset(); } if ((vs = tsk_vs_bsd_open(img_info, offset)) != NULL) { // if (set == NULL) { // In this case, BSD takes priority because BSD partitions start off with // the DOS magic value in the first sector with the boot code. set = "BSD"; vs_set = vs; /* } else { vs_set->close(vs_set); vs->close(vs); tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "BSD or %s at %" PRIuDADDR, set, offset); tsk_errstr2[0] = '\0'; return NULL; } */ } else { tsk_error_reset(); } if ((vs = tsk_vs_gpt_open(img_info, offset)) != NULL) { if (set != NULL) { /* GPT drives have a DOS Safety partition table. * Test to see if we can ignore one */ if (strcmp(set, "DOS") == 0) { TSK_VS_PART_INFO *tmp_set; for (tmp_set = vs_set->part_list; tmp_set; tmp_set = tmp_set->next) { if ((tmp_set->desc) && (strncmp(tmp_set->desc, "GPT", 3) == 0) && (tmp_set->start <= 63)) { TSK_VS_PART_INFO *tmp_cur; /* see if we can find a GPT partition that ends at the same * location as the DOS (we should be testing for the last GPT partition...) */ for (tmp_cur = vs->part_list; tmp_cur; tmp_cur = tmp_cur->next) { if ((tmp_set->start + tmp_set->len) == (tmp_cur->start + tmp_cur->len)) { if (tsk_verbose) tsk_fprintf(stderr, "mm_open: Ignoring DOS Safety GPT Partition\n"); set = NULL; vs_set = NULL; break; } } if (set == NULL) break; } } } if (set != NULL) { vs_set->close(vs_set); vs->close(vs); tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "GPT or %s at %" PRIuDADDR, set, offset); return NULL; } } set = "GPT"; vs_set = vs; } else { tsk_error_reset(); } if ((vs = tsk_vs_sun_open(img_info, offset)) != NULL) { if (set == NULL) { set = "Sun"; vs_set = vs; } else { vs_set->close(vs_set); vs->close(vs); tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Sun or %s at %" PRIuDADDR, set, offset); return NULL; } } else { tsk_error_reset(); } if ((vs = tsk_vs_mac_open(img_info, offset)) != NULL) { if (set == NULL) { set = "Mac"; vs_set = vs; } else { vs_set->close(vs_set); vs->close(vs); tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Mac or %s at %" PRIuDADDR, set, offset); return NULL; } } else { tsk_error_reset(); } if (vs_set == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNKTYPE; return NULL; } return vs_set; } else { switch (type) { case TSK_VS_TYPE_DOS: return tsk_vs_dos_open(img_info, offset, 0); case TSK_VS_TYPE_MAC: return tsk_vs_mac_open(img_info, offset); case TSK_VS_TYPE_BSD: return tsk_vs_bsd_open(img_info, offset); case TSK_VS_TYPE_SUN: return tsk_vs_sun_open(img_info, offset); case TSK_VS_TYPE_GPT: return tsk_vs_gpt_open(img_info, offset); case TSK_VS_TYPE_UNSUPP: default: tsk_error_reset(); tsk_errno = TSK_ERR_VS_UNSUPTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "%d", type); return NULL; } } } /** * \ingroup vslib * Closes an open volume system * @param a_vs Pointer to the open volume system structure. */ void tsk_vs_close(TSK_VS_INFO * a_vs) { if (a_vs == NULL) { return; } a_vs->close((TSK_VS_INFO *) a_vs); } sleuthkit-3.2.3/tsk3/vs/mm_part.c000644 000765 000024 00000020506 11643647441 017461 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file mm_part.c * Contains the functions need to create, maintain, and access the linked list of * partitions in a volume. */ #include "tsk_vs_i.h" /** * Add a partition to a sorted list * @param a_vs Volume system that partition belongs to * @param a_start Starting sector address of volume (relative to start of volume) * @param len Length of volume in sectors * @param type Type of volume * @param desc Text description of partition. Note that this is not copied * and must not be freed until the volume system has been closed. * @param table The table ID that the volume was located in or -1 for volumes not in a partition table. * @param slot The slot number in the partition table that the volume was located in or -1 for volumes not in a partition table. * @returns Pointer to structure that was created for the partition or NULL on error. */ TSK_VS_PART_INFO * tsk_vs_part_add(TSK_VS_INFO * a_vs, TSK_DADDR_T a_start, TSK_DADDR_T len, TSK_VS_PART_FLAG_ENUM type, char *desc, int8_t table, int8_t slot) { TSK_VS_PART_INFO *part; TSK_VS_PART_INFO *cur_part; if ((part = (TSK_VS_PART_INFO *) tsk_malloc(sizeof(TSK_VS_PART_INFO))) == NULL) { return NULL; } /* set the values */ part->next = NULL; part->prev = NULL; part->start = a_start; part->len = len; part->desc = desc; part->table_num = table; part->slot_num = slot; part->flags = type; part->vs = a_vs; part->addr = 0; /* is this the first entry in the list */ if (a_vs->part_list == NULL) { a_vs->part_list = part; a_vs->part_count = 1; return part; } /* Cycle through to find the correct place to put it into */ for (cur_part = a_vs->part_list; cur_part != NULL; cur_part = cur_part->next) { /* The one to add starts before this partition */ if (cur_part->start > part->start) { part->next = cur_part; part->prev = cur_part->prev; if (part->prev) part->prev->next = part; cur_part->prev = part; /* If we are now the head update a_vs */ if (part->prev == NULL) a_vs->part_list = part; /* update the count and address numbers */ a_vs->part_count++; part->addr = cur_part->addr; for (; cur_part != NULL; cur_part = cur_part->next) cur_part->addr++; return part; } /* the one to add is bigger then current and the list is done */ else if (cur_part->next == NULL) { cur_part->next = part; part->prev = cur_part; /* Update partition counts and addresses */ a_vs->part_count++; part->addr = cur_part->addr + 1; return part; } /* The one to add fits in between this and the next */ else if (cur_part->next->start > part->start) { part->prev = cur_part; part->next = cur_part->next; cur_part->next->prev = part; cur_part->next = part; /* Update partition counts and addresses */ a_vs->part_count++; part->addr = cur_part->addr + 1; for (cur_part = part->next; cur_part != NULL; cur_part = cur_part->next) cur_part->addr++; return part; } } return NULL; } /** * Identify regions in the partition list where there are unused sectors * and create new entries for them. * * @param a_vs Pointer to open volume system * @returns 1 on error and 0 on success */ uint8_t tsk_vs_part_unused(TSK_VS_INFO * a_vs) { TSK_VS_PART_INFO *part = a_vs->part_list; TSK_DADDR_T prev_end = 0; /* prev_ent is set to where the previous entry stopped plus 1 */ for (part = a_vs->part_list; part != NULL; part = part->next) { // ignore the META volume if (part->flags & TSK_VS_PART_FLAG_META) continue; // there is space before current and previous volume if (part->start > prev_end) { char *str; if ((str = tsk_malloc(12)) == NULL) return 1; snprintf(str, 12, "Unallocated"); if (NULL == tsk_vs_part_add(a_vs, prev_end, part->start - prev_end, TSK_VS_PART_FLAG_UNALLOC, str, -1, -1)) { free(str); return 1; } } prev_end = part->start + part->len; } /* Is there unallocated space at the end? */ if (prev_end < (TSK_DADDR_T) (a_vs->img_info->size / a_vs->block_size)) { char *str; if ((str = tsk_malloc(12)) == NULL) return 1; snprintf(str, 12, "Unallocated"); if (NULL == tsk_vs_part_add(a_vs, prev_end, a_vs->img_info->size / a_vs->block_size - prev_end, TSK_VS_PART_FLAG_UNALLOC, str, -1, -1)) { free(str); return 1; } } return 0; } /* * free the buffer with the description */ void tsk_vs_part_free(TSK_VS_INFO * a_vs) { TSK_VS_PART_INFO *part = a_vs->part_list; TSK_VS_PART_INFO *part2; while (part) { if (part->desc) free(part->desc); part2 = part->next; free(part); part = part2; } a_vs->part_list = NULL; return; } /** * \ingroup vslib * Return handle to a volume in the volume system. * * @param a_vs Open volume system * @param a_idx Index for volume to return (0-based) * @returns Handle to volume or NULL on error */ const TSK_VS_PART_INFO * tsk_vs_part_get(const TSK_VS_INFO * a_vs, TSK_PNUM_T a_idx) { TSK_VS_PART_INFO *part; if (a_vs == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_part_get: pointer is NULL"); return NULL; } if (a_idx >= a_vs->part_count) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_part_get: Volume address is too big"); return NULL; } for (part = a_vs->part_list; part != NULL; part = part->next) { if (part->addr == a_idx) return part; } return NULL; } /** * \ingroup vslib * Walk a range of partitions and pass the data to a callback function. * * @param a_vs Pointer to open volume system * @param a_start Address of first partition to walk from. * @param a_last Address of last partition to walk to. * @param a_flags Flags that are used to identify which of the partitions in the range should be returned (if 0, all partitions will be returned). * @param a_action Callback action to call for each partition. * @param a_ptr Pointer to data that will be passed to callback. * @returns 1 on error and 0 on success */ uint8_t tsk_vs_part_walk(TSK_VS_INFO * a_vs, TSK_PNUM_T a_start, TSK_PNUM_T a_last, TSK_VS_PART_FLAG_ENUM a_flags, TSK_VS_PART_WALK_CB a_action, void *a_ptr) { TSK_VS_PART_INFO *part; if (a_start >= a_vs->part_count) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_part_walk: Start partition too large: %" PRIuPNUM "", a_start); return 1; } if (a_last >= a_vs->part_count) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_vs_part_walk: End partition too large: %" PRIuPNUM "", a_last); return 1; } if (a_flags == 0) { a_flags |= (TSK_VS_PART_FLAG_ALLOC | TSK_VS_PART_FLAG_UNALLOC | TSK_VS_PART_FLAG_META); } for (part = a_vs->part_list; part != NULL; part = part->next) { if ((part->addr >= a_start) && ((part->flags & a_flags) != 0)) { int retval; retval = a_action(a_vs, part, a_ptr); if (retval == TSK_WALK_STOP) { return 0; } else if (retval == TSK_WALK_ERROR) { return 1; } } if (part->addr >= a_last) break; } return 0; } sleuthkit-3.2.3/tsk3/vs/mm_types.c000644 000765 000024 00000005734 11643647441 017665 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file mm_types.c * Contains the code to parse and print the strings for the supported volume system types. */ #include "tsk_vs_i.h" typedef struct { char *name; TSK_VS_TYPE_ENUM code; char *comment; } VS_TYPES; VS_TYPES vs_open_table[] = { {"dos", TSK_VS_TYPE_DOS, "DOS Partition Table"}, {"mac", TSK_VS_TYPE_MAC, "MAC Partition Map"}, {"bsd", TSK_VS_TYPE_BSD, "BSD Disk Label"}, {"sun", TSK_VS_TYPE_SUN, "Sun Volume Table of Contents (Solaris)"}, {"gpt", TSK_VS_TYPE_GPT, "GUID Partition Table (EFI)"}, {0}, }; /** * \ingroup vslib * Parse a string with the volume system type and return its internal ID. * * @param str String to parse. * @returns ID of string (or unsupported if the name is unknown) */ TSK_VS_TYPE_ENUM tsk_vs_type_toid(const TSK_TCHAR * str) { char tmp[16]; int i; VS_TYPES *types; // convert to char for (i = 0; i < 15 && str[i] != '\0'; i++) { tmp[i] = (char) str[i]; } tmp[i] = '\0'; for (types = vs_open_table; types->name; types++) { if (strcmp(tmp, types->name) == 0) { return types->code; } } return TSK_VS_TYPE_UNSUPP; } /** * \ingroup vslib * Print the supported volume system type names to an open handle. * @param hFile Handle to print to. */ void tsk_vs_type_print(FILE * hFile) { VS_TYPES *types; tsk_fprintf(hFile, "Supported partition types:\n"); for (types = vs_open_table; types->name; types++) tsk_fprintf(hFile, "\t%s (%s)\n", types->name, types->comment); } /** * \ingroup vslib * Return the supported volume system types. * @returns The bit in the return value is 1 if the type is supported. */ TSK_VS_TYPE_ENUM tsk_vs_type_supported() { TSK_VS_TYPE_ENUM sup_types = 0; VS_TYPES *types; for (types = vs_open_table; types->name; types++) { sup_types |= types->code; } return sup_types; } /** * \ingroup vslib * Return the string name of a partition type ID. * * @param type Volume system type * @returns name of type or NULL on error */ const char * tsk_vs_type_toname(TSK_VS_TYPE_ENUM type) { VS_TYPES *types; for (types = vs_open_table; types->name; types++) { if (types->code == type) { return types->name; } } if (type == TSK_VS_TYPE_DBFILLER) { return "DB Filler"; } return NULL; } /** * \ingroup vslib * Return the string description of a partition type ID. * * @param type Volume system type * @returns description of type or NULL on error */ const char * tsk_vs_type_todesc(TSK_VS_TYPE_ENUM type) { VS_TYPES *types; for (types = vs_open_table; types->name; types++) { if (types->code == type) { return types->comment; } } return NULL; } sleuthkit-3.2.3/tsk3/vs/sun.c000644 000765 000024 00000025032 11643647441 016626 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * SUN - Sun VTOC code * * This software is distributed under the Common Public License 1.0 */ /** \file sun.c * Contains the internal SUN VTOC volume system processing code. */ #include "tsk_vs_i.h" #include "tsk_sun.h" /* * Return a buffer with a description of the partition type */ static char * sun_get_desc(uint16_t fstype) { char *str = tsk_malloc(64); if (str == NULL) return ""; switch (fstype) { case 0: strncpy(str, "Unassigned (0x00)", 64); break; case 1: strncpy(str, "boot (0x01)", 64); break; case 2: strncpy(str, "/ (0x02)", 64); break; case 3: strncpy(str, "swap (0x03)", 64); break; case 4: strncpy(str, "/usr/ (0x04)", 64); break; case 5: strncpy(str, "backup (0x05)", 64); break; case 6: strncpy(str, "stand (0x06)", 64); break; case 7: strncpy(str, "/var/ (0x07)", 64); break; case 8: strncpy(str, "/home/ (0x08)", 64); break; case 9: strncpy(str, "alt sector (0x09)", 64); break; case 10: strncpy(str, "cachefs (0x0A)", 64); break; default: snprintf(str, 64, "Unknown Type (0x%.4x)", fstype); break; } return str; } /* * Load an Intel disk label, this is called by sun_load_table */ static uint8_t sun_load_table_i386(TSK_VS_INFO * vs, sun_dlabel_i386 * dlabel_x86) { uint32_t idx = 0; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector if (tsk_verbose) tsk_fprintf(stderr, "load_table_i386: Number of partitions: %d\n", tsk_getu16(vs->endian, dlabel_x86->num_parts)); /* Cycle through the partitions, there are either 8 or 16 */ for (idx = 0; idx < tsk_getu16(vs->endian, dlabel_x86->num_parts); idx++) { TSK_VS_PART_FLAG_ENUM ptype = TSK_VS_PART_FLAG_ALLOC; if (tsk_verbose) tsk_fprintf(stderr, "load_table_i386: %" PRIu32 " Starting Sector: %" PRIu32 " Size: %" PRIu32 " Type: %" PRIu16 "\n", idx, tsk_getu32(vs->endian, dlabel_x86->part[idx].start_sec), tsk_getu32(vs->endian, dlabel_x86->part[idx].size_sec), tsk_getu16(vs->endian, dlabel_x86->part[idx].type)); if (tsk_getu32(vs->endian, dlabel_x86->part[idx].size_sec) == 0) continue; // make sure the first couple are in the image bounds if ((idx < 2) && (tsk_getu32(vs->endian, dlabel_x86->part[idx].start_sec) > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "sun_load_i386: Starting sector too large for image"); return 1; } // set the entry that covers the entire disk image as DESC if ((tsk_getu16(vs->endian, dlabel_x86->part[idx].type) == 5) && (tsk_getu32(vs->endian, dlabel_x86->part[idx].start_sec) == 0)) ptype = TSK_VS_PART_FLAG_META; /* Add the partition to the internal sorted list */ if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) tsk_getu32(vs->endian, dlabel_x86->part[idx].start_sec), (TSK_DADDR_T) tsk_getu32(vs->endian, dlabel_x86->part[idx].size_sec), ptype, sun_get_desc(tsk_getu16(vs->endian, dlabel_x86->part[idx].type)), -1, idx)) { return 1; } } return 0; } /* load a sparc disk label, this is called from the general * sun_load_table */ static uint8_t sun_load_table_sparc(TSK_VS_INFO * vs, sun_dlabel_sparc * dlabel_sp) { uint32_t idx = 0; uint32_t cyl_conv; TSK_DADDR_T max_addr = (vs->img_info->size - vs->offset) / vs->block_size; // max sector /* The value to convert cylinders to sectors */ cyl_conv = tsk_getu16(vs->endian, dlabel_sp->sec_per_tr) * tsk_getu16(vs->endian, dlabel_sp->num_head); if (tsk_verbose) tsk_fprintf(stderr, "load_table_sparc: Number of partitions: %d\n", tsk_getu16(vs->endian, dlabel_sp->num_parts)); /* Cycle through the partitions, there are either 8 or 16 */ for (idx = 0; idx < tsk_getu16(vs->endian, dlabel_sp->num_parts); idx++) { TSK_VS_PART_FLAG_ENUM ptype = TSK_VS_PART_FLAG_ALLOC; uint32_t part_start = cyl_conv * tsk_getu32(vs->endian, dlabel_sp->part_layout[idx].start_cyl); uint32_t part_size = tsk_getu32(vs->endian, dlabel_sp->part_layout[idx].size_blk); if (tsk_verbose) tsk_fprintf(stderr, "load_table_sparc: %" PRIu32 " Starting Sector: %" PRIu32 " Size: %" PRIu32 " Type: %" PRIu16 "\n", idx, part_start, part_size, tsk_getu16(vs->endian, dlabel_sp->part_meta[idx].type)); if (part_size == 0) continue; // make sure the first couple are in the image bounds if ((idx < 2) && (part_start > max_addr)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "sun_load_sparc: Starting sector too large for image"); return 1; } // set the entry that covers the entire disk image as DESC if ((tsk_getu16(vs->endian, dlabel_sp->part_meta[idx].type) == 5) && (part_start == 0)) ptype = TSK_VS_PART_FLAG_META; /* Add the partition to the internal sorted list */ if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) part_start, (TSK_DADDR_T) part_size, ptype, sun_get_desc(tsk_getu16(vs->endian, dlabel_sp->part_meta[idx].type)), -1, idx)) return 1; } return 0; } /* * Process the partition table at the sector address * * This method just finds out if it is sparc or Intel and then * calls the appropriate method * * Return 0 on success and 1 on error */ static uint8_t sun_load_table(TSK_VS_INFO * vs) { sun_dlabel_sparc *dlabel_sp; sun_dlabel_i386 *dlabel_x86; char *buf; ssize_t cnt; TSK_DADDR_T taddr = vs->offset / vs->block_size + SUN_SPARC_PART_SOFFSET; /* Sanity check in case label sizes change */ if ((sizeof(*dlabel_sp) > vs->block_size) || (sizeof(*dlabel_x86) > vs->block_size)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_BUF; snprintf(tsk_errstr, TSK_ERRSTR_L, "sun_load_table: disk labels bigger than block size"); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "sun_load_table: Trying sector: %" PRIuDADDR "\n", taddr); if ((buf = tsk_malloc(vs->block_size)) == NULL) return 1; /* Try the given offset */ cnt = tsk_vs_read_block (vs, SUN_SPARC_PART_SOFFSET, buf, vs->block_size); /* If -1 is returned, tsk_errno is already set */ if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "SUN Disk Label in Sector: %" PRIuDADDR, taddr); free(buf); return 1; } /* Check the magic value * Both intel and sparc have the magic value in the same location * * We try both in case someone specifies the exact location of the * intel disk label. * */ dlabel_sp = (sun_dlabel_sparc *) buf; dlabel_x86 = (sun_dlabel_i386 *) buf; if (tsk_vs_guessu16(vs, dlabel_sp->magic, SUN_MAGIC) == 0) { if (tsk_getu32(vs->endian, dlabel_sp->sanity) == SUN_SANITY) { free(buf); return sun_load_table_sparc(vs, dlabel_sp); } else if (tsk_getu32(vs->endian, dlabel_x86->sanity) == SUN_SANITY) { free(buf); return sun_load_table_i386(vs, dlabel_x86); } } /* Now try the next sector, which is where the intel * could be stored */ taddr = vs->offset / vs->block_size / SUN_I386_PART_SOFFSET; if (tsk_verbose) tsk_fprintf(stderr, "sun_load_table: Trying sector: %" PRIuDADDR "\n", taddr + 1); cnt = tsk_vs_read_block (vs, SUN_I386_PART_SOFFSET, buf, vs->block_size); if (cnt != vs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "SUN (Intel) Disk Label in Sector: %" PRIuDADDR, taddr); free(buf); return 1; } dlabel_x86 = (sun_dlabel_i386 *) buf; if (tsk_vs_guessu16(vs, dlabel_x86->magic, SUN_MAGIC)) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "SUN (intel) partition table (Sector: %" PRIuDADDR ") %x", taddr, tsk_getu16(vs->endian, dlabel_sp->magic)); free(buf); return 1; } if (tsk_getu32(vs->endian, dlabel_x86->sanity) != SUN_SANITY) { tsk_error_reset(); tsk_errno = TSK_ERR_VS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "SUN (intel) sanity value (Sector: %" PRIuDADDR ") %x", taddr, tsk_getu16(vs->endian, dlabel_sp->magic)); free(buf); return 1; } free(buf); return sun_load_table_i386(vs, dlabel_x86); } static void sun_close(TSK_VS_INFO * vs) { tsk_vs_part_free(vs); free(vs); } TSK_VS_INFO * tsk_vs_sun_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) { TSK_VS_INFO *vs; // clean up any errors that are lying around tsk_error_reset(); vs = (TSK_VS_INFO *) tsk_malloc(sizeof(*vs)); if (vs == NULL) return NULL; vs->img_info = img_info; vs->vstype = TSK_VS_TYPE_SUN; vs->offset = offset; /* inititialize settings */ vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = sun_close; /* Load the partitions into the sorted list */ if (sun_load_table(vs)) { sun_close(vs); return NULL; } /* fill in the sorted list with the 'unknown' values */ if (tsk_vs_part_unused(vs)) { sun_close(vs); return NULL; } return vs; } sleuthkit-3.2.3/tsk3/vs/tsk_bsd.h000644 000765 000024 00000003212 11643647441 017453 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * ** This software is distributed under the Common Public License 1.0 */ /* * C header file with BSD and internal data structures. */ #ifndef _TSK_BSD_H #define _TSK_BSD_H #ifdef __cplusplus extern "C" { #endif typedef struct { uint8_t magic[4]; uint8_t type[2]; uint8_t sub_type[2]; uint8_t type_name[16]; uint8_t packname[16]; uint8_t sec_size[4]; uint8_t sec_per_tr[4]; uint8_t tr_per_cyl[4]; uint8_t cyl_per_unit[4]; uint8_t sec_per_cyl[4]; uint8_t sec_per_unit[4]; uint8_t spare_per_tr[2]; uint8_t spare_per_cyl[2]; uint8_t alt_per_unit[4]; uint8_t rpm[2]; uint8_t interleave[2]; uint8_t trackskew[2]; uint8_t cylskew[2]; uint8_t headswitch[4]; uint8_t track_seek[4]; uint8_t flags[4]; uint8_t drivedata[20]; uint8_t reserved1[20]; uint8_t magic2[4]; uint8_t checksum[2]; uint8_t num_parts[2]; uint8_t bootarea_size[4]; uint8_t sb_size[4]; struct { uint8_t size_sec[4]; uint8_t start_sec[4]; uint8_t frag_size[4]; uint8_t fstype; uint8_t frag_per_block; uint8_t cyl_per_grp[2]; } part[16]; /* padding to make it a full 512 bytes */ uint8_t reserved2[108]; } bsd_disklabel; #define BSD_MAGIC 0x82564557 #define BSD_PART_SOFFSET 1 #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_dos.h000644 000765 000024 00000002115 11643647441 017471 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * C header file with DOS and internal data structures. */ #ifndef _TSK_DOS_H #define _TSK_DOS_H #ifdef __cplusplus extern "C" { #endif typedef struct { uint8_t boot; uint8_t start_chs[3]; uint8_t ptype; uint8_t end_chs[3]; uint8_t start_sec[4]; uint8_t size_sec[4]; } dos_part; /* Boot Sector w/partition table */ typedef struct { uint8_t f1[3]; /* the next three are actually part of NTFS and FAT, but * we use them for sanity checks in the detect code */ char oemname[8]; uint8_t ssize[2]; /* sector size in bytes */ uint8_t csize; /* cluster size in sectors */ uint8_t filler[432]; dos_part ptable[4]; uint8_t magic[2]; } dos_sect; #define DOS_MAGIC 0xaa55 #define DOS_PART_SOFFSET 0 #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_gpt.h000644 000765 000024 00000003534 11643647441 017504 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2004-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * C header file with GPT and internal data structures. */ #ifndef _TSK_GPT_H #define _TSK_GPT_H #ifdef __cplusplus extern "C" { #endif /* Partition type in the safety DOS partition table */ #define GPT_PART_SOFFSET 0 #define GPT_DOS_TYPE 0xEE /* This is located in sector 1 of the disk */ #define GPT_HEAD_OFFSET 1 #define GPT_HEAD_SIG 0x5452415020494645ULL typedef struct { uint8_t signature[8]; /* EFI PART */ uint8_t version[4]; uint8_t head_size_b[4]; /* size of partition header */ uint8_t head_crc[4]; /* crc of header */ uint8_t f1[4]; uint8_t head_lba[8]; /* lba of this header */ uint8_t head2_lba[8]; /* lba of second header */ uint8_t partarea_start[8]; /* lba of partition area start */ uint8_t partarea_end[8]; /* lba of partition area end */ uint8_t guid[16]; /* disk GUID */ uint8_t tab_start_lba[8]; /* lba of table start */ uint8_t tab_num_ent[4]; /* num of table entries */ uint8_t tab_size_b[4]; /* size of each table entry */ uint8_t tab_crc[4]; /* crc of table */ uint8_t f2[420]; } gpt_head; /* The location of this is specified in the header - tab_start */ typedef struct { uint8_t type_guid[16]; /* partition type guid */ uint8_t id_guid[16]; /* unique partition GUID */ uint8_t start_lba[8]; /* Starting lba of part */ uint8_t end_lba[8]; /* end lba of part */ uint8_t flags[8]; /* flags */ uint8_t name[72]; /* name in unicode */ } gpt_entry; #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_mac.h000644 000765 000024 00000002303 11643647441 017443 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * C header file with Mac and internal data structures. */ #ifndef _TSK_MAC_H #define _TSK_MAC_H #ifdef __cplusplus extern "C" { #endif typedef struct { uint8_t magic[2]; uint8_t reserved[2]; uint8_t pmap_size[4]; uint8_t start_sec[4]; uint8_t size_sec[4]; uint8_t name[32]; uint8_t type[32]; uint8_t data_start_sec[4]; uint8_t data_size_sec[4]; uint8_t status[4]; uint8_t boot_start_sec[4]; uint8_t boot_size_sec[4]; uint8_t boot_load_addr[4]; uint8_t reserved2[4]; uint8_t boot_entry[4]; uint8_t reserved3[4]; uint8_t boot_checksum[4]; uint8_t proc_type[16]; uint8_t reserved4[376]; } mac_part; #define MAC_MAGIC 0x504d #define MAC_PART_SOFFSET 1 #define MAC_STAT_VALID 0x00 #define MAC_STAT_ALLOC 0x01 #define MAC_STAT_INUSE 0x02 #define MAC_STAT_BOOT 0x04 #define MAC_STAT_READ 0x08 #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_sun.h000644 000765 000024 00000005104 11643647441 017512 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 * */ /* * C header file with Sun and internal data structures. */ #ifndef _TSK_SUN_H #define _TSK_SUN_H #ifdef __cplusplus extern "C" { #endif typedef struct { uint8_t asciilabel[128]; /* VTOC */ uint8_t version[4]; uint8_t vol_name[8]; uint8_t num_parts[2]; struct { uint8_t type[2]; uint8_t flag[2]; } part_meta[8]; uint8_t bootinfo[4][3]; uint8_t reserved0[2]; uint8_t sanity[4]; uint8_t reserved1[38]; uint8_t timestamp[8][4]; /* End VTOC */ uint8_t write_reinstruct[2]; uint8_t read_reinstruct[2]; uint8_t reserved2[154]; uint8_t rpm[2]; uint8_t num_ph_cyl[2]; uint8_t alt_per_cyl[2]; uint8_t reserved3[4]; uint8_t interleave[2]; uint8_t num_cyl[2]; uint8_t num_alt_cyl[2]; uint8_t num_head[2]; uint8_t sec_per_tr[2]; uint8_t reserved5[4]; struct { uint8_t start_cyl[4]; uint8_t size_blk[4]; } part_layout[8]; uint8_t magic[2]; uint8_t checksum[2]; } sun_dlabel_sparc; typedef struct { /* VTOC */ uint8_t bootinfo[3][4]; uint8_t sanity[4]; uint8_t version[4]; uint8_t vol_name[8]; uint8_t sec_size[2]; uint8_t num_parts[2]; uint8_t reserved0[40]; struct { uint8_t type[2]; uint8_t flag[2]; uint8_t start_sec[4]; uint8_t size_sec[4]; } part[16]; uint8_t timestamp[16][4]; uint8_t asciilabel[128]; /* END of VTOC */ uint8_t num_ph_cyl[4]; uint8_t num_cyl[4]; uint8_t num_alt_cyl[2]; uint8_t cyl_offset[2]; uint8_t num_head[4]; uint8_t sec_per_tr[4]; uint8_t interleave[2]; uint8_t skew[2]; uint8_t alt_per_cyl[2]; uint8_t rpm[2]; uint8_t write_reinstruct[2]; uint8_t read_reinstruct[2]; uint8_t reserved1[8]; uint8_t reserved2[12]; uint8_t magic[2]; uint8_t checksum[2]; } sun_dlabel_i386; #define SUN_MAGIC 0xDABE #define SUN_SANITY 0x600DDEEE #define SUN_FLAG_UNMNT 0x01 #define SUN_FLAG_RO 0x10 #define SUN_SPARC_PART_SOFFSET 0 #define SUN_I386_PART_SOFFSET 1 #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_vs.h000644 000765 000024 00000012521 11643647441 017336 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 * */ /** * \file tsk_vs.h * External header file for media management (volume system) support. * Note that this file is not meant to be directly included. * It is included by both libtsk.h and tsk_vs_i.h. */ /** * \defgroup vslib Volume System Functions */ #ifndef _TSK_VS_H #define _TSK_VS_H #ifdef __cplusplus extern "C" { #endif /* Structures */ typedef struct TSK_VS_INFO TSK_VS_INFO; typedef struct TSK_VS_PART_INFO TSK_VS_PART_INFO; /** * Definition for callback function that vs_part_walk() calls for * each partition that it walks. * * @param a_vs Pointer to volume system being analyzed * @param a_vs_part Pointer to current partition in the walk * @param a_ptr Pointer that was passed to vs_part_walk by caller * @returns Status on whether the vs_part_walk() function should * continue, stop, or error. */ typedef TSK_WALK_RET_ENUM(*TSK_VS_PART_WALK_CB) (TSK_VS_INFO * a_vs, const TSK_VS_PART_INFO * a_vs_part, void *a_ptr); /** * Flags for the partition type. */ typedef enum { TSK_VS_TYPE_DETECT = 0x0000, ///< Use autodetection methods TSK_VS_TYPE_DOS = 0x0001, ///< DOS Partition table TSK_VS_TYPE_BSD = 0x0002, ///< BSD Partition table TSK_VS_TYPE_SUN = 0x0004, ///< Sun VTOC TSK_VS_TYPE_MAC = 0x0008, ///< Mac partition table TSK_VS_TYPE_GPT = 0x0010, ///< GPT partition table TSK_VS_TYPE_DBFILLER = 0x00F0, ///< fake partition table type for loaddb (for images that do not have a volume system) TSK_VS_TYPE_UNSUPP = 0xffff, ///< Unsupported } TSK_VS_TYPE_ENUM; /** * Data structure used to store state and basic information * for open volume systems. */ struct TSK_VS_INFO { TSK_IMG_INFO *img_info; ///< Pointer to disk image that VS is in TSK_VS_TYPE_ENUM vstype; ///< Type of volume system / media management TSK_DADDR_T offset; ///< Byte offset where VS starts in disk image unsigned int block_size; ///< Size of blocks in bytes TSK_ENDIAN_ENUM endian; ///< Endian ordering of data TSK_VS_PART_INFO *part_list; ///< Linked list of partitions TSK_PNUM_T part_count; ///< number of partitions void (*close) (TSK_VS_INFO *); ///< \internal Progs should call tsk_vs_close(). }; /*************************************************************** * Generic structures for partitions / slices */ /** * Flag values that describe the partitions in the VS. Refer * to \ref vs_open2 for more details. */ typedef enum { TSK_VS_PART_FLAG_ALLOC = 0x01, ///< Sectors are allocated to a volume in the volume system TSK_VS_PART_FLAG_UNALLOC = 0x02, ///< Sectors are not allocated to a volume TSK_VS_PART_FLAG_META = 0x04, ///< Sectors contain volume system metadata and could also be ALLOC or UNALLOC TSK_VS_PART_FLAG_ALL = 0x07, ///< Show all sectors in the walk. } TSK_VS_PART_FLAG_ENUM; /** * Linked list entry that describes a volume in a generic way. */ struct TSK_VS_PART_INFO { TSK_VS_PART_INFO *prev; ///< Pointer to previous partition (or NULL) TSK_VS_PART_INFO *next; ///< Pointer to next partition (or NULL) TSK_VS_INFO *vs; ///< Pointer to parent volume system handle TSK_DADDR_T start; ///< Sector offset of start of partition TSK_DADDR_T len; ///< Number of sectors in partition char *desc; ///< UTF-8 description of partition (volume system type-specific) int8_t table_num; ///< Table address that describes this partition int8_t slot_num; ///< Entry in the table that describes this partition TSK_PNUM_T addr; ///< Address of this partition TSK_VS_PART_FLAG_ENUM flags; ///< Flags for partition }; // to and from type ids and names extern TSK_VS_TYPE_ENUM tsk_vs_type_toid(const TSK_TCHAR *); extern const char *tsk_vs_type_toname(TSK_VS_TYPE_ENUM); extern const char *tsk_vs_type_todesc(TSK_VS_TYPE_ENUM); extern TSK_VS_TYPE_ENUM tsk_vs_type_supported(); extern void tsk_vs_type_print(FILE *); // open a volume system extern TSK_VS_INFO *tsk_vs_open(TSK_IMG_INFO *, TSK_DADDR_T, TSK_VS_TYPE_ENUM); extern void tsk_vs_close(TSK_VS_INFO *); // read data in the volume system extern ssize_t tsk_vs_read_block(TSK_VS_INFO * a_vs, TSK_DADDR_T a_addr, char *buf, size_t len); // open a partition extern const TSK_VS_PART_INFO *tsk_vs_part_get(const TSK_VS_INFO *, TSK_PNUM_T idx); extern uint8_t tsk_vs_part_walk(TSK_VS_INFO * vs, TSK_PNUM_T start, TSK_PNUM_T last, TSK_VS_PART_FLAG_ENUM flags, TSK_VS_PART_WALK_CB action, void *ptr); // read data in partitions extern ssize_t tsk_vs_part_read(const TSK_VS_PART_INFO * a_vs_part, TSK_OFF_T a_off, char *buf, size_t len); extern ssize_t tsk_vs_part_read_block(const TSK_VS_PART_INFO * a_vs_part, TSK_DADDR_T a_addr, char *buf, size_t len); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/vs/tsk_vs_i.h000644 000765 000024 00000002627 11643647441 017654 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** * \file tsk_vs_i.h * Contains the internal library definitions for the volume system functions. This should * be included by the code in the volume system library. */ #ifndef _TSK_VS_I_H #define _TSK_VS_I_H // Include the other internal TSK header files #include "tsk3/base/tsk_base_i.h" #include "tsk3/img/tsk_img_i.h" // include the external vs header file #include "tsk_vs.h" #include extern TSK_VS_INFO *tsk_vs_dos_open(TSK_IMG_INFO *, TSK_DADDR_T, uint8_t); extern TSK_VS_INFO *tsk_vs_mac_open(TSK_IMG_INFO *, TSK_DADDR_T); extern TSK_VS_INFO *tsk_vs_bsd_open(TSK_IMG_INFO *, TSK_DADDR_T); extern TSK_VS_INFO *tsk_vs_sun_open(TSK_IMG_INFO *, TSK_DADDR_T); extern TSK_VS_INFO *tsk_vs_gpt_open(TSK_IMG_INFO *, TSK_DADDR_T); extern uint8_t tsk_vs_part_unused(TSK_VS_INFO *); extern TSK_VS_PART_INFO *tsk_vs_part_add(TSK_VS_INFO *, TSK_DADDR_T, TSK_DADDR_T, TSK_VS_PART_FLAG_ENUM, char *, int8_t, int8_t); extern void tsk_vs_part_free(TSK_VS_INFO *); // Endian macros - actual functions in misc/ #define tsk_vs_guessu16(vs, x, mag) \ tsk_guess_end_u16(&(vs->endian), (x), (mag)) #define tsk_vs_guessu32(vs, x, mag) \ tsk_guess_end_u32(&(vs->endian), (x), (mag)) #endif sleuthkit-3.2.3/tsk3/sorter/default.sort000644 000765 000024 00000007657 11643647440 021114 0ustar00carrierstaff000000 000000 # # default.sort # default config file for Sleuth Kit sorter # # These settings have the lowest priority of all config files # # It is used for ALL platform types though # # # Category # If the keyword is found in the 'file' output, then the data is saved # to either the summary file or even copied if the appropriate flags are # given # # category cat_name keywords # # # Extension # If the keywords are found in the 'file' output, and the file extension # is different than then the one on the file, an alert is generated # 'somewhere' # ext ext1,ext2,ext3 keywords ########################################################################## # Multimedia ########################################################################## # Audio category audio audio category audio MIDI ext mid,rmi MIDI category audio MP3 ext mp3 MP3 # Images category images image data ext jpg,jpeg,jpe JPEG image data ext gif GIF image data ext tif TIFF image data ext png PNG image data category images bitmap data ext bmp PC bitmap data category images font ext ttf true type font # Video category video RealMedia ext rm RealMedia ########################################################################## # archive & compression ########################################################################## # archive category archive archive ext zip,jar Zip archive data ext tar tar archive category archive DB ext db Berkeley DB # compression category compress compress ext gz,tgz gzip compressed data ext Z compress'd data ########################################################################## # Executables ########################################################################## # Execs category exec executable category exec \sscript # the above can cause errors with postscript and transcript category exec batch file # NOTE: Some windows binaries have the term "executable not relocatable" # which will trigger on this when it should trigger on executable category exec relocatable # Java category exec class data ext class Java class data category exec object ext o object category exec python compiled ########################################################################## # Documents, ########################################################################## category documents document # Microsoft ext doc,dot,ppt,pot,xls,xlt,msc,pcb Microsoft Office Document category documents Rich Text Format ext rtf Rich Text Format # Corel & Word Perfect category documents Corel\/WP ext wpg,wpd,shw Corel\/WP # Lotus category documents Lotus 1\-2\-3 ext wb2 Lotus 1\-2\-3 # Adobe ext pdf PDF document ext ps,eps PostScript document ########################################################################## # Text ########################################################################## category text ASCII(.*?)text ext txt,log ASCII(.*?)text ext c,cpp,h,js ASCII(.*?)text ext sh,csh ASCII(.*?)text ext conf ASCII(.*?)text category text character data ext txt character data category text ISO\-8859(.*?)text ext txt ISO\-8859(.*?)text category text HTML document text ext htm,html,hta HTML document text category text program text ext c,cpp,h,js program text category text \ssource ########################################################################## # Other ########################################################################## # Disk category disk boot sector category disk filesystem data # Crypto category crypto PGP ext asc PGP armored # Postscript Printer Description category system PPD file ext ppd PPD file # 'file' reports 'data' for all unknown binary files # do not bother with extensions with this category data ^data$ sleuthkit-3.2.3/tsk3/sorter/freebsd.sort000644 000765 000024 00000002575 11643647440 021074 0ustar00carrierstaff000000 000000 # # config file for Sleuth Kit sorter # # FreeBSD Platform # # To make custom modifications, you can also use a file named # freebsd.lcl.sort ########################################################################## # Multimedia ########################################################################## # Images # Audio # video ########################################################################## # archive & compression ########################################################################## ########################################################################## # Executables & Source Code ########################################################################## # object & relocatable are already a category in default ext so,0,1,2,3,4,5,6,7,8,9 shared object #ext o relocatable #category exec library #ext so library #category exec ar archive #ext a ar archive ########################################################################## # Documents, text, and internet (web) ########################################################################## # Text #ext afm ASCII font metrics ext conf ASCII(.*?)text ########################################################################## # Other ########################################################################## category system pixmap image text ext xpm pixmap image text sleuthkit-3.2.3/tsk3/sorter/images.sort000644 000765 000024 00000001255 11643647440 020721 0ustar00carrierstaff000000 000000 # # images.sort # Save Images only # config file for Sleuth Kit sorter # # Category # If the keyword is found in the 'file' output, then the data is saved # to either the summary file or even copied if the appropriate flags are # given # # category cat_name keywords # # # Extension # If the keywords are found in the 'file' output, and the file extension # is different than then the one on the file, an alert is generated # 'somewhere' # ext ext1,ext2,ext3 keywords # Images category images image data ext jpg,jpeg,jpe JPEG image data ext gif GIF image data ext tif TIFF image data ext png PNG image data category images bitmap data ext bmp PC bitmap data sleuthkit-3.2.3/tsk3/sorter/linux.sort000644 000765 000024 00000002512 11643647440 020610 0ustar00carrierstaff000000 000000 # # config file for Sleuth Kit sorter # # Linux Platform # # To make custom modifications, you can also use a file named # linux.lcl.sort ########################################################################## # Multimedia ########################################################################## # Images # Audio # video ########################################################################## # archive & compression ########################################################################## ########################################################################## # Executables & Source Code ########################################################################## # object and relocatable are already a category in default ext so,0,1,2,3,4,5,6,7,8,9 shared object ext o relocatable #category exec library #ext so library #category exec ar archive #ext a ar archive ########################################################################## # Documents, text, and internet (web) ########################################################################## # Text #ext afm ASCII font metrics category text input text category text TeX DVI ########################################################################## # Other ########################################################################## sleuthkit-3.2.3/tsk3/sorter/openbsd.sort000644 000765 000024 00000002575 11643647440 021114 0ustar00carrierstaff000000 000000 # # config file for Sleuth Kit sorter # # OpenBSD Platform # # To make custom modifications, you can also use a file named # openbsd.lcl.sort ########################################################################## # Multimedia ########################################################################## # Images # Audio # video ########################################################################## # archive & compression ########################################################################## ########################################################################## # Executables & Source Code ########################################################################## # object & relocatable are already a category in default ext so,0,1,2,3,4,5,6,7,8,9 shared object #ext o relocatable #category exec library #ext so library #category exec ar archive #ext a ar archive ########################################################################## # Documents, text, and internet (web) ########################################################################## # Text #ext afm ASCII font metrics ext conf ASCII(.*?)text ########################################################################## # Other ########################################################################## category system pixmap image text ext xpm pixmap image text sleuthkit-3.2.3/tsk3/sorter/solaris.sort000644 000765 000024 00000002425 11643647440 021130 0ustar00carrierstaff000000 000000 # # config file for Sleuth Kit sorter # # Solaris Platform # # To make custom modifications, you can also use a file named # solaris.lcl.sort ########################################################################## # Multimedia ########################################################################## # Images # Audio # video ########################################################################## # archive & compression ########################################################################## ########################################################################## # Executables & Source Code ########################################################################## # object & relocatable are already a category in default ext so,0,1,2,3,4,5,6,7,8,9 shared object ext o relocatable category exec library ext so library category exec ar archive ext a ar archive ########################################################################## # Documents, text, and internet (web) ########################################################################## # Text ext afm ASCII font metrics ########################################################################## # Other ########################################################################## sleuthkit-3.2.3/tsk3/sorter/windows.sort000644 000765 000024 00000005146 11643647440 021151 0ustar00carrierstaff000000 000000 # # config file for Sleuth Kit sorter # # Windows Platform # # To make custom modifications, you can also use a file named # windows.lcl.sort ########################################################################## # Multimedia ########################################################################## # Images category images icon resource ext ico ms\-windows icon resource category images animated cursor ext ani animated cursor # It seems that a lot of ttf files come up as raw G3 data ... # category ignore raw G3 data, byte\-padded # Audio ext wav WAVE audio category audio Winamp ext avs Winamp plug in category audio AVI ext avi AVI # Video ########################################################################## # archive & compression ########################################################################## # archive category archive cabinet file data ext cab cabinet file data ext wmz Zip archive data # compression ########################################################################## # Executables ########################################################################## # execs ext exe,dll,com,ocx,sys,tlb,drv,cpl,scr,ax MS\-DOS executable ext 386,acm,flt,fon,lrc,vxd,x32 MS\-DOS executable category exec Windows PE ext exe,dll,com,ocx,sys,wpc,acm,cpl Windows PE ext dll relocatable category exec batch file ext bat batch file # source code category exec MSVC program database ext pdb MSVC program database ########################################################################## # Documents ########################################################################## category documents Outlook binary email folder ext pst Outlook binary email folder ########################################################################## # Text ########################################################################## ext ini,inf,srg,dep ASCII(.*?)text ext ini,inf ISO\-8859(.*?)text ########################################################################## # Other ########################################################################## # System category system Help Data ext hlp Windows Help Data category system Registry file ext dat,log,sav Registry file category system ms\-Windows shortcut ext lnk ms\-Windows shortcut category system Internet shortcut ext url Internet shortcut category system hyperterm ext ht hyperterm # Image Color Matching Profile category system Color Management System ext icm Color Management System sleuthkit-3.2.3/tsk3/img/.indent.pro000644 000765 000024 00000000037 11643647440 020057 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nlp -nut sleuthkit-3.2.3/tsk3/img/aff.c000644 000765 000024 00000021245 11643647440 016702 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** * \file aff.c * Internal code to interface with afflib to read and open AFF image files */ #include "tsk_img_i.h" #if HAVE_LIBAFFLIB typedef int bool; #include "aff.h" static ssize_t aff_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) { ssize_t cnt; IMG_AFF_INFO *aff_info = (IMG_AFF_INFO *) img_info; if (tsk_verbose) tsk_fprintf(stderr, "aff_read: byte offset: %" PRIuOFF " len: %" PRIuOFF "\n", offset, len); if (offset > img_info->size) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_read - %" PRIuOFF, offset); return -1; } if (aff_info->seek_pos != offset) { if (af_seek(aff_info->af_file, offset, SEEK_SET) != offset) { tsk_error_reset(); // @@@ ADD more specific error messages tsk_errno = TSK_ERR_IMG_SEEK; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_read - %" PRIuOFF " - %s", offset, strerror(errno)); return -1; } aff_info->seek_pos = offset; } cnt = af_read(aff_info->af_file, (unsigned char *) buf, len); if (cnt < 0) { // @@@ Add more specific error message tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_read - offset: %" PRIuOFF " - len: %" PRIuSIZE " - %s", offset, len, strerror(errno)); return -1; } /* AFF will return 0 if the page does not exist -- fill the * buffer with zeros in this case */ if (cnt == 0) { // @@@ We could improve this if there is an AFF call // to see if the data exists or not if ((af_eof(aff_info->af_file) == 0) && (offset + len < img_info->size)) { memset(buf, 0, len); cnt = len; } } aff_info->seek_pos += cnt; return cnt; } static void aff_imgstat(TSK_IMG_INFO * img_info, FILE * hFile) { IMG_AFF_INFO *aff_info = (IMG_AFF_INFO *) img_info; unsigned char buf[512]; size_t buf_len = 512; tsk_fprintf(hFile, "IMAGE FILE INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Image Type: "); switch (aff_info->type) { case AF_IDENTIFY_AFF: tsk_fprintf(hFile, "AFF\n"); break; case AF_IDENTIFY_AFD: tsk_fprintf(hFile, "AFD\n"); break; case AF_IDENTIFY_AFM: tsk_fprintf(hFile, "AFM\n"); break; default: tsk_fprintf(hFile, "AFFLIB (%d)\n", aff_info->type); break; } tsk_fprintf(hFile, "\nSize in bytes: %" PRIuOFF "\n", img_info->size); // we won't have the rest of the info for the non-AFF formats. if (img_info->itype == TSK_IMG_TYPE_AFF_ANY) return; tsk_fprintf(hFile, "\nMD5: "); if (af_get_seg(aff_info->af_file, AF_MD5, NULL, buf, &buf_len) == 0) { int i; for (i = 0; i < 16; i++) { tsk_fprintf(hFile, "%x", buf[i]); } tsk_fprintf(hFile, "\n"); } else { tsk_fprintf(hFile, "Segment not found\n"); } buf_len = 512; tsk_fprintf(hFile, "SHA1: "); if (af_get_seg(aff_info->af_file, AF_SHA1, NULL, buf, &buf_len) == 0) { int i; for (i = 0; i < 20; i++) { tsk_fprintf(hFile, "%x", buf[i]); } tsk_fprintf(hFile, "\n"); } else { tsk_fprintf(hFile, "Segment not found\n"); } /* Creator segment */ buf_len = 512; if (af_get_seg(aff_info->af_file, AF_CREATOR, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Creator: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_CASE_NUM, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Case Number: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_IMAGE_GID, NULL, buf, &buf_len) == 0) { unsigned int i; tsk_fprintf(hFile, "Image GID: "); for (i = 0; i < buf_len; i++) { tsk_fprintf(hFile, "%X", buf[i]); } tsk_fprintf(hFile, "\n"); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_ACQUISITION_DATE, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Acquisition Date: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_ACQUISITION_NOTES, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Acquisition Notes: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_ACQUISITION_DEVICE, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Acquisition Device: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_AFFLIB_VERSION, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "AFFLib Version: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_DEVICE_MANUFACTURER, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Device Manufacturer: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_DEVICE_MODEL, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Device Model: %s\n", buf); } buf_len = 512; if (af_get_seg(aff_info->af_file, AF_DEVICE_SN, NULL, buf, &buf_len) == 0) { buf[buf_len] = '\0'; tsk_fprintf(hFile, "Device SN: %s\n", buf); } return; } static void aff_close(TSK_IMG_INFO * img_info) { IMG_AFF_INFO *aff_info = (IMG_AFF_INFO *) img_info; af_close(aff_info->af_file); free(aff_info); } TSK_IMG_INFO * aff_open(const char *const images[], unsigned int a_ssize) { IMG_AFF_INFO *aff_info; TSK_IMG_INFO *img_info; int type; if ((aff_info = (IMG_AFF_INFO *) tsk_malloc(sizeof(IMG_AFF_INFO))) == NULL) { return NULL; } img_info = (TSK_IMG_INFO *) aff_info; img_info->read = aff_read; img_info->close = aff_close; img_info->imgstat = aff_imgstat; img_info->sector_size = 512; if (a_ssize) img_info->sector_size = a_ssize; type = af_identify_file_type(images[0], 1); if ((type == AF_IDENTIFY_ERR) || (type == AF_IDENTIFY_NOEXIST)) { if (tsk_verbose) { tsk_fprintf(stderr, "aff_open: Error determining type of file: %" PRIttocTSK "\n", images[0]); perror("aff_open"); } tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_open file: %" PRIttocTSK ": Error checking type", images[0]); tsk_errstr2[0] = '\0'; free(aff_info); return NULL; } else if (type == AF_IDENTIFY_AFF) { img_info->itype = TSK_IMG_TYPE_AFF_AFF; } else if (type == AF_IDENTIFY_AFD) { img_info->itype = TSK_IMG_TYPE_AFF_AFD; } else if (type == AF_IDENTIFY_AFM) { img_info->itype = TSK_IMG_TYPE_AFF_AFM; } else { img_info->itype = TSK_IMG_TYPE_AFF_ANY; } aff_info->af_file = af_open(images[0], O_RDONLY | O_BINARY, 0); if (!aff_info->af_file) { // @@@ Need to check here if the open failed because of an incorrect password. tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_open file: %" PRIttocTSK ": Error opening - %s", images[0], strerror(errno)); free(aff_info); if (tsk_verbose) { tsk_fprintf(stderr, "Error opening AFF/AFD/AFM file\n"); perror("aff_open"); } return NULL; } // verify that a password was given and we can read encrypted data. if (af_cannot_decrypt(aff_info->af_file)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_PASSWD; snprintf(tsk_errstr, TSK_ERRSTR_L, "aff_open file: %" PRIttocTSK, images[0]); free(aff_info); if (tsk_verbose) { tsk_fprintf(stderr, "Error opening AFF/AFD/AFM file (incorrect password)\n"); } return NULL; } aff_info->type = type; img_info->size = af_imagesize(aff_info->af_file); af_seek(aff_info->af_file, 0, SEEK_SET); aff_info->seek_pos = 0; return img_info; } #endif sleuthkit-3.2.3/tsk3/img/aff.h000644 000765 000024 00000001321 11643647440 016700 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * Header files for AFF-specific data structures and functions. */ #ifndef _AFF_H #define _AFF_H #if HAVE_LIBAFFLIB #include #include extern TSK_IMG_INFO *aff_open(const char *const images[], unsigned int a_ssize); /** \internal * Stores AFF-specific data */ typedef struct { TSK_IMG_INFO img_info; AFFILE *af_file; TSK_OFF_T seek_pos; uint16_t type; /* TYPE - uses AF_IDENTIFY_x values */ } IMG_AFF_INFO; #endif #endif sleuthkit-3.2.3/tsk3/img/ewf.c000644 000765 000024 00000017375 11643647440 016740 0ustar00carrierstaff000000 000000 /* * Joachim Metz , Hoffmann Investigations * Copyright (c) 2006 Joachim Metz. All rights reserved * * ewf * * This software is distributed under the Common Public License 1.0 */ /** \file ewf.c * Internal code for TSK to interface with libewf. */ #include "tsk_img_i.h" #if HAVE_LIBEWF #include "ewf.h" static ssize_t ewf_image_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) { ssize_t cnt; IMG_EWF_INFO *ewf_info = (IMG_EWF_INFO *) img_info; if (tsk_verbose) tsk_fprintf(stderr, "ewf_read: byte offset: %" PRIuOFF " len: %" PRIuSIZE "\n", offset, len); if (offset > img_info->size) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - %" PRIuOFF, offset); return -1; } cnt = libewf_read_random(ewf_info->handle, buf, len, offset); if (cnt < 0) { tsk_error_reset(); // @@@ Add more specific error message tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf_read - offset: %" PRIuOFF " - len: %" PRIuSIZE " - %s", offset, len, strerror(errno)); return -1; } return cnt; } static void ewf_image_imgstat(TSK_IMG_INFO * img_info, FILE * hFile) { IMG_EWF_INFO *ewf_info = (IMG_EWF_INFO *) img_info; tsk_fprintf(hFile, "IMAGE FILE INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Image Type:\t\tewf\n"); tsk_fprintf(hFile, "\nSize of data in bytes:\t%" PRIuOFF "\n", img_info->size); if (ewf_info->md5hash_isset == 1) { tsk_fprintf(hFile, "MD5 hash of data:\t%s\n", ewf_info->md5hash); } return; } static void ewf_image_close(TSK_IMG_INFO * img_info) { int i; IMG_EWF_INFO *ewf_info = (IMG_EWF_INFO *) img_info; libewf_close(ewf_info->handle); for (i = 0; i < ewf_info->num_imgs; i++) { free(ewf_info->images[i]); } free(ewf_info->images); free(img_info); } /* Tests if the image file header against the * header (magic) signature specified. * Returns a 0 on no match and a 1 on a match, and -1 on error. */ #if 0 static int img_file_header_signature_ncmp(const char *filename, const char *file_header_signature, int size_of_signature) { int match; ssize_t read_count = 0; char header[512]; int fd; if ((filename == NULL) || (file_header_signature == NULL)) { return (0); } if (size_of_signature <= 0) { return (0); } if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf magic testing: %s", filename); return -1; } read_count = read(fd, header, 512); if (read_count != 512) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf magic testing: %s", filename); return -1; } close(fd); match = strncmp(file_header_signature, header, size_of_signature) == 0; return (match); } #endif TSK_IMG_INFO * ewf_open(int a_num_img, const TSK_TCHAR * const a_images[], unsigned int a_ssize) { IMG_EWF_INFO *ewf_info; TSK_IMG_INFO *img_info; #if !defined( LIBEWF_STRING_DIGEST_HASH_LENGTH_MD5 ) uint8_t md5_hash[16]; #endif if ((ewf_info = (IMG_EWF_INFO *) tsk_malloc(sizeof(IMG_EWF_INFO))) == NULL) { return NULL; } img_info = (TSK_IMG_INFO *) ewf_info; // See if they specified only the first of the set... if (a_num_img == 1) { if ((ewf_info->images = tsk_img_findFiles(a_images[0], &ewf_info->num_imgs)) == NULL) { free(ewf_info); return NULL; } } else { int i; ewf_info->num_imgs = a_num_img; if ((ewf_info->images = (TSK_TCHAR **) tsk_malloc(a_num_img * sizeof(TSK_TCHAR *))) == NULL) { free(ewf_info); return NULL; } for (i = 0; i < a_num_img; i++) { if ((ewf_info->images[i] = (TSK_TCHAR *) tsk_malloc((TSTRLEN(a_images[i]) + 1) * sizeof(TSK_TCHAR))) == NULL) { free(ewf_info); return NULL; } TSTRNCPY(ewf_info->images[i], a_images[i], TSTRLEN(a_images[i]) + 1); } } /* check the magic before we call the library open */ //if (img_file_header_signature_ncmp(images[0], // "\x45\x56\x46\x09\x0d\x0a\xff\x00", 8) != 1) { #if defined (TSK_WIN32) if (libewf_check_file_signature_wide(ewf_info->images[0]) == 0) { #else if (libewf_check_file_signature(ewf_info->images[0]) == 0) { #endif tsk_error_reset(); tsk_errno = TSK_ERR_IMG_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf_open: Not an EWF file"); free(ewf_info); if (tsk_verbose) tsk_fprintf(stderr, "Not an EWF file\n"); return NULL; } #if defined (TSK_WIN32) ewf_info->handle = libewf_open_wide((wchar_t * const *) ewf_info->images, ewf_info->num_imgs, LIBEWF_OPEN_READ); #else ewf_info->handle = libewf_open((char *const *) ewf_info->images, ewf_info->num_imgs, LIBEWF_OPEN_READ); #endif if (ewf_info->handle == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf_open file: %" PRIttocTSK ": Error opening", ewf_info->images[0]); free(ewf_info); if (tsk_verbose) { tsk_fprintf(stderr, "Error opening EWF file\n"); } return NULL; } // 2007 version #if defined( LIBEWF_STRING_DIGEST_HASH_LENGTH_MD5 ) img_info->size = libewf_get_media_size(ewf_info->handle); ewf_info->md5hash_isset = libewf_get_stored_md5_hash(ewf_info->handle, ewf_info->md5hash, LIBEWF_STRING_DIGEST_HASH_LENGTH_MD5); // libewf-20080322 version #else if (libewf_get_media_size(ewf_info->handle, (size64_t *) & (img_info->size)) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "ewf_open file: %" PRIttocTSK ": Error getting size of image", ewf_info->images[0]); free(ewf_info); if (tsk_verbose) { tsk_fprintf(stderr, "Error getting size of EWF file\n"); } return NULL; } if (libewf_get_md5_hash(ewf_info->handle, md5_hash, 16) == 1) { int md5_string_iterator = 0; int md5_hash_iterator; for (md5_hash_iterator = 0; md5_hash_iterator < 16; md5_hash_iterator++) { int digit = md5_hash[md5_hash_iterator] / 16; if (digit <= 9) ewf_info->md5hash[md5_string_iterator++] = (char) ('0' + digit); else ewf_info->md5hash[md5_string_iterator++] = (char) ('a' + (digit - 10)); digit = md5_hash[md5_hash_iterator] % 16; if (digit <= 9) ewf_info->md5hash[md5_string_iterator++] = (char) ('0' + digit); else ewf_info->md5hash[md5_string_iterator++] = (char) ('a' + (digit - 10)); } ewf_info->md5hash_isset = 1; } #endif img_info->sector_size = 512; if (a_ssize) img_info->sector_size = a_ssize; img_info->itype = TSK_IMG_TYPE_EWF_EWF; img_info->read = ewf_image_read; img_info->close = ewf_image_close; img_info->imgstat = ewf_image_imgstat; return img_info; } #endif sleuthkit-3.2.3/tsk3/img/ewf.h000644 000765 000024 00000001636 11643647440 016736 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit - Add on for EWF image support * Eye Witness Compression Format Support * * Joachim Metz * Copyright (c) 2006 Joachim Metz. All rights reserved * * Based on raw image support of the Sleuth Kit from * Brian Carrier. */ /* * Header files for EWF-specific data structures and functions. */ #ifndef _EWF_H #define _EWF_H #if HAVE_LIBEWF // we used to check only for TSK_WIN32, but that fails on mingw #if defined(_MSC_VER) #include #endif #include #ifdef __cplusplus extern "C" { #endif extern TSK_IMG_INFO *ewf_open(int, const TSK_TCHAR * const images[], unsigned int a_ssize); typedef struct { TSK_IMG_INFO img_info; LIBEWF_HANDLE *handle; char md5hash[33]; int md5hash_isset; TSK_TCHAR **images; int num_imgs; } IMG_EWF_INFO; #ifdef __cplusplus } #endif #endif #endif sleuthkit-3.2.3/tsk3/img/img_io.c000644 000765 000024 00000012035 11643647440 017406 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ /** * \file img_io.c * Contains the basic img reading API redirection functions. */ #include "tsk_img_i.h" /** * \ingroup imglib * Reads data from an open disk image * @param a_img_info Disk image to read from * @param a_off Byte offset to start reading from * @param a_buf Buffer to read into * @param a_len Number of bytes to read into buffer * @returns -1 on error or number of bytes read */ ssize_t tsk_img_read(TSK_IMG_INFO * a_img_info, TSK_OFF_T a_off, char *a_buf, size_t a_len) { #define CACHE_AGE 1000 ssize_t retval = 0; int i; int cache_next = 0; // index to lowest age cache (to use next) size_t len2; if (a_img_info == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_img_read: pointer is NULL"); return -1; } // if they ask for more than the cache length, skip the cache if (a_len > TSK_IMG_INFO_CACHE_LEN) { return a_img_info->read(a_img_info, a_off, a_buf, a_len); } if (a_off >= a_img_info->size) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_img_read - %" PRIuOFF, a_off); return -1; } /* See if the requested length is going to be too long. * we'll use this length when checking the cache. */ len2 = a_len; if (a_off + len2 > a_img_info->size) len2 = (size_t) (a_img_info->size - a_off); // check if it is in the cache for (i = 0; i < TSK_IMG_INFO_CACHE_NUM; i++) { // Look into the in-use cache entries if (a_img_info->cache_len[i] > 0) { // the retval check makes sure we don't go back in after data was read if ((retval == 0) && (a_img_info->cache_off[i] <= a_off) && (a_img_info->cache_off[i] + a_img_info->cache_len[i] >= a_off + len2)) { /* if (tsk_verbose) fprintf(stderr, "tsk_img_read: Read found in cache %d\n", i); */ // We found it... memcpy(a_buf, &a_img_info->cache[i][a_off - a_img_info->cache_off[i]], len2); retval = (ssize_t) len2; // reset its "age" since it was useful a_img_info->cache_age[i] = CACHE_AGE; // we don't break out of the loop so that we update all ages } else { /* decrease its "age" since it was not useful. * We don't let used ones go below 1 so that they are not * confused with entries that have never been used. */ a_img_info->cache_age[i]--; // see if this is the most eligible replacement if ((a_img_info->cache_len[cache_next] > 0) && (a_img_info->cache_age[i] < a_img_info->cache_age[cache_next])) cache_next = i; } } else { cache_next = i; } } // if we didn't find it, then load it into the cache_next entry if (retval == 0) { size_t rlen; // round the offset down to a sector boundary a_img_info->cache_off[cache_next] = (a_off / 512) * 512; /* if (tsk_verbose) fprintf(stderr, "tsk_img_read: Loading data into cache %d (%" PRIuOFF ")\n", cache_next, a_img_info->cache_off[cache_next]); */ // figure out the length to read into the cache rlen = TSK_IMG_INFO_CACHE_LEN; if (a_img_info->cache_off[cache_next] + rlen > a_img_info->size) { rlen = (size_t) (a_img_info->size - a_img_info->cache_off[cache_next]); } retval = a_img_info->read(a_img_info, a_img_info->cache_off[cache_next], a_img_info->cache[cache_next], rlen); // if no error, then set the variables and copy the data if (retval != -1) { a_img_info->cache_age[cache_next] = CACHE_AGE; a_img_info->cache_len[cache_next] = retval; // update the length we can actually copy (in case we did not get to read all that we wanted) if (a_off + len2 > a_img_info->cache_off[cache_next] + retval) len2 = (size_t) (a_img_info->cache_off[cache_next] + retval - a_off); memcpy(a_buf, &a_img_info->cache[cache_next][a_off - a_img_info->cache_off[cache_next]], len2); retval = (ssize_t) len2; } else { a_img_info->cache_len[cache_next] = 0; a_img_info->cache_age[cache_next] = 0; a_img_info->cache_off[cache_next] = 0; } } return retval; } sleuthkit-3.2.3/tsk3/img/img_open.c000644 000765 000024 00000033577 11643647440 017756 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved * Copyright (c) 2005 Brian Carrier. All rights reserved * * tsk_img_open * * This software is distributed under the Common Public License 1.0 */ /** * \file img_open.c * Contains the basic img_open function call, that interfaces with * the format specific _open calls */ #include "tsk_img_i.h" #include "raw.h" #include "split.h" #if HAVE_LIBAFFLIB typedef int bool; #include "aff.h" #endif #if HAVE_LIBEWF #include "ewf.h" #endif /** * \ingroup imglib * Opens a single (non-split) disk image file so that it can be read. This is a * wrapper around tsk_img_open(). See it for more details on detection etc. See * tsk_img_open_sing_utf8() for a version of this function that always takes * UTF-8 as input. * * @param a_image The path to the image file * @param type The disk image type (can be autodetection) * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open_sing(const TSK_TCHAR * a_image, TSK_IMG_TYPE_ENUM type, unsigned int a_ssize) { const TSK_TCHAR *const a = a_image; return tsk_img_open(1, &a, type, a_ssize); } /** * \ingroup imglib * Opens one or more disk image files so that they can be read. If a file format * type is specified, this function will call the specific routine to open the file. * Otherwise, it will detect the type (it will default to raw if no specific type can * be detected). This function must be called before a disk image can be read from. * Note that the data type used to store the image paths is a TSK_TCHAR, which changes * depending on a Unix or Windows build. If you will always have UTF8, then consider * using tsk_img_open_utf8(). * * @param num_img The number of images to open (will be > 1 for split images). * @param images The path to the image files (the number of files must * be equal to num_img and they must be in a sorted order) * @param type The disk image type (can be autodetection) * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open(int num_img, const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM type, unsigned int a_ssize) { TSK_IMG_INFO *img_info = NULL; // Get rid of any old error messages laying around tsk_error_reset(); if ((num_img == 0) || (images[0] == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_NOFILE; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_img_open"); return NULL; } if ((a_ssize > 0) && (a_ssize < 512)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "sector size is less than 512 bytes (%d)", a_ssize); return NULL; } if ((a_ssize % 512) != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "sector size is not a multiple of 512 (%d)", a_ssize); return NULL; } if (tsk_verbose) TFPRINTF(stderr, _TSK_T("tsk_img_open: Type: %d NumImg: %d Img1: %s\n"), type, num_img, images[0]); /* If no type is given, then we use the autodetection methods * In case the image file matches the signatures of multiple formats, * we try all of the embedded formats */ if (type == TSK_IMG_TYPE_DETECT) { TSK_IMG_INFO *img_set = NULL; #if HAVE_LIBAFFLIB || HAVE_LIBEWF char *set = NULL; #endif struct STAT_STR stat_buf; // we rely on tsk_errno, so make sure it is 0 tsk_error_reset(); /* Try the non-raw formats first */ #if HAVE_LIBAFFLIB if ((img_info = aff_open(images, a_ssize)) != NULL) { /* we don't allow the "ANY" when autodetect is used because * we only want to detect the tested formats. */ if (img_info->itype == TSK_IMG_TYPE_AFF_ANY) { img_info->close(img_info); } else { set = "AFF"; img_set = img_info; } } else { // If AFF is otherwise happy except for a password, stop trying to guess if (tsk_errno == TSK_ERR_IMG_PASSWD) { return NULL; } tsk_error_reset(); } #endif #if HAVE_LIBEWF if ((img_info = ewf_open(num_img, images, a_ssize)) != NULL) { if (set == NULL) { set = "EWF"; img_set = img_info; } else { img_set->close(img_set); img_info->close(img_info); tsk_error_reset(); tsk_errno = TSK_ERR_IMG_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "EWF or %s", set); return NULL; } } else { tsk_error_reset(); } #endif // if any of the non-raw formats were detected, then use it. if (img_set != NULL) return img_set; /* We'll use the raw format */ if (num_img == 1) { if ((img_info = raw_open(images[0], a_ssize)) != NULL) { return img_info; } else if (tsk_errno) { return NULL; } } else { if ((img_info = split_open(num_img, images, a_ssize)) != NULL) { return img_info; } else if (tsk_errno) { return NULL; } } /* To improve the error message, verify the file can be read. */ if (TSTAT(images[0], &stat_buf) < 0) { // special case to handle windows objects #if defined(TSK_WIN32) || defined(__CYGWIN__) if (TSTRNCMP(_TSK_T("\\\\.\\"), images[0], 4) == 0) { if (tsk_verbose) TFPRINTF(stderr, _TSK_T ("tsk_img_open: Ignoring stat error because of windows object: %s\n"), images[0]); } else { #endif tsk_error_reset(); tsk_errno = TSK_ERR_IMG_STAT; snprintf(tsk_errstr, TSK_ERRSTR_L, "%" PRIttocTSK " : %s", images[0], strerror(errno)); return NULL; #if defined(TSK_WIN32) || defined(__CYGWIN__) } #endif } tsk_errno = TSK_ERR_IMG_UNKTYPE; tsk_errstr[0] = '\0'; tsk_errstr2[0] = '\0'; return NULL; } /* * Type values * Make a local copy that we can modify the string as we parse it */ switch (type) { case TSK_IMG_TYPE_RAW_SING: /* If we have more than one image name, and raw was the only * type given, then use split */ if (num_img > 1) img_info = split_open(num_img, images, a_ssize); else img_info = raw_open(images[0], a_ssize); break; case TSK_IMG_TYPE_RAW_SPLIT: /* If only one image file is given, and only one type was * given then use raw */ if (num_img == 1) img_info = raw_open(images[0], a_ssize); else img_info = split_open(num_img, images, a_ssize); break; #if HAVE_LIBAFFLIB case TSK_IMG_TYPE_AFF_AFF: case TSK_IMG_TYPE_AFF_AFD: case TSK_IMG_TYPE_AFF_AFM: case TSK_IMG_TYPE_AFF_ANY: img_info = aff_open(images, a_ssize); break; #endif #if HAVE_LIBEWF case TSK_IMG_TYPE_EWF_EWF: img_info = ewf_open(num_img, images, a_ssize); break; #endif default: tsk_error_reset(); tsk_errno = TSK_ERR_IMG_UNSUPTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "%d", type); return NULL; } return img_info; } /** * \ingroup imglib * Opens a single (non-split) disk image file so that it can be read. This version * always takes a UTF-8 encoding of the disk image. See tsk_img_open_sing() for a * version that takes a wchar_t or char depending on the platform. * This is a wrapper around tsk_img_open(). See it for more details on detection etc. * * @param a_image The UTF-8 path to the image file * @param type The disk image type (can be autodetection) * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open_utf8_sing(const char *a_image, TSK_IMG_TYPE_ENUM type, unsigned int a_ssize) { const char *const a = a_image; return tsk_img_open_utf8(1, &a, type, a_ssize); } /** * \ingroup imglib * Opens one or more disk image files so that they can be read. This is a wrapper * around tsk_img_open() and this version always takes a UTF-8 encoding of the * image files. See its description for more details. * * @param num_img The number of images to open (will be > 1 for split images). * @param images The path to the UTF-8 encoded image files (the number of files must * be equal to num_img and they must be in a sorted order) * @param type The disk image type (can be autodetection) * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open_utf8(int num_img, const char *const images[], TSK_IMG_TYPE_ENUM type, unsigned int a_ssize) { #ifdef TSK_WIN32 { /* Note that there is an assumption in this code that wchar_t is 2-bytes. * this is a correct assumption for Windows, but not for all systems... */ TSK_IMG_INFO *retval = NULL; wchar_t **images16; int i; // allocate a buffer to store the UTF-16 version of the images. if ((images16 = (wchar_t **) tsk_malloc(sizeof(wchar_t *) * num_img)) == NULL) { return NULL; } for (i = 0; i < num_img; i++) { size_t ilen; UTF16 *utf16; UTF8 *utf8; TSKConversionResult retval2; // we allocate the buffer with the same number of chars as the UTF-8 length ilen = strlen(images[i]); if ((images16[i] = (wchar_t *) tsk_malloc((ilen + 1) * sizeof(wchar_t))) == NULL) { goto tsk_utf8_cleanup; } utf8 = (UTF8 *) images[i]; utf16 = (UTF16 *) images16[i]; retval2 = tsk_UTF8toUTF16((const UTF8 **) &utf8, &utf8[ilen], &utf16, &utf16[ilen], TSKlenientConversion); if (retval2 != TSKconversionOK) { tsk_errno = TSK_ERR_IMG_CONVERT; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_img_open_utf8: Error converting image %s %d", images[i], retval2); goto tsk_utf8_cleanup; } *utf16 = '\0'; } retval = tsk_img_open(num_img, images16, type, a_ssize); // free up the memory tsk_utf8_cleanup: for (i = 0; i < num_img; i++) { if (images16[i]) free(images16[i]); } free(images16); return retval; } #else return tsk_img_open(num_img, images, type, a_ssize); #endif } #if 0 /* This interface needs some more thought because the size of wchar is not standard. * If the goal i to provide a constant wchar interface, then we need to incorporate * UTF-32 to UTF-8 support as well. If the goal is to provide a standard UTF-16 * interface, we should use another type besiddes wchar_t. */ TSK_IMG_INFO * tsk_img_open_utf16(int num_img, wchar_t * const images[], TSK_IMG_TYPE_ENUM type) { #if TSK_WIN32 return tsk_img_open(num_img, images, type); #else { TSK_IMG_INFO *retval; int i; char **images8; TSK_ENDIAN_ENUM endian; uint16_t tmp1; /* The unicode conversio routines are primarily to convert Unicode * in file and volume system images, which means they could be in * an endian ordering different from the local one. We need to figure * out our local ordering so we can give it the right flag */ tmp1 = 1; if (tsk_guess_end_u16(&endian, (uint8_t *) & tmp1, 1)) { // @@@@ return NULL; } // convert UTF16 to UTF8 if ((images8 = (char **) tsk_malloc(sizeof(char *) * num_img)) == NULL) { return NULL; } for (i = 0; i < num_img; i++) { size_t ilen; UTF16 *utf16; UTF8 *utf8; TSKConversionResult retval2; // we allocate the buffer to be four times the utf-16 length. ilen = wcslen(images[i]); ilen <<= 2; if ((images8[i] = (char *) tsk_malloc(ilen)) == NULL) { return NULL; } utf16 = (UTF16 *) images[i]; utf8 = (UTF8 *) images8[i]; retval2 = tsk_UTF16toUTF8_lclorder((const UTF16 **) &utf16, &utf16[wcslen(images[i]) + 1], &utf8, &utf8[ilen + 1], TSKlenientConversion); if (retval2 != TSKconversionOK) { tsk_errno = TSK_ERR_IMG_CONVERT; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_img_open_utf16: Error converting image %d %d", i, retval2); return NULL; } *utf8 = '\0'; } retval = tsk_img_open(num_img, (const TSK_TCHAR **) images8, type); for (i = 0; i < num_img; i++) { free(images8[i]); } free(images8); return retval; } #endif } #endif /** * \ingroup imglib * Closes an open disk image. * @param a_img_info Pointer to the open disk image structure. */ void tsk_img_close(TSK_IMG_INFO * a_img_info) { if (a_img_info == NULL) { return; } a_img_info->close(a_img_info); } sleuthkit-3.2.3/tsk3/img/img_types.c000644 000765 000024 00000006705 11643647440 020152 0ustar00carrierstaff000000 000000 /* ** img_types ** The Sleuth Kit ** ** Identify the type of image file being used ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier. All rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /** \file img_types.c * Contains basic functions to parse and print the names of the supported disk image types. */ #include "tsk_img_i.h" /** \internal * used to parse and print supported types */ typedef struct { char *name; uint8_t code; char *comment; } IMG_TYPES; /** \internal * The table used to parse input strings * - in order of expected usage */ static IMG_TYPES img_open_table[] = { {"raw", TSK_IMG_TYPE_RAW_SING, "Single raw file (dd)"}, #if HAVE_LIBAFFLIB {"aff", TSK_IMG_TYPE_AFF_AFF, "Advanced Forensic Format"}, {"afd", TSK_IMG_TYPE_AFF_AFD, "AFF Multiple File"}, {"afm", TSK_IMG_TYPE_AFF_AFM, "AFF with external metadata"}, {"afflib", TSK_IMG_TYPE_AFF_ANY, "All AFFLIB image formats (including beta ones)"}, #endif #if HAVE_LIBEWF {"ewf", TSK_IMG_TYPE_EWF_EWF, "Expert Witness format (encase)"}, #endif {"split", TSK_IMG_TYPE_RAW_SPLIT, "Split raw files"}, {0}, }; /** * \ingroup imglib * Parses a string that specifies an image format to determine the * associated type ID. This is used by the TSK command line tools to * parse the type given on the command line. * * @param str String of image format type * @return ID of image type */ TSK_IMG_TYPE_ENUM tsk_img_type_toid(const TSK_TCHAR * str) { char tmp[16]; IMG_TYPES *sp; int i; // convert to char for (i = 0; i < 15 && str[i] != '\0'; i++) { tmp[i] = (char) str[i]; } tmp[i] = '\0'; for (sp = img_open_table; sp->name; sp++) { if (strcmp(tmp, sp->name) == 0) { return sp->code; } } return TSK_IMG_TYPE_UNSUPP; } /** * \ingroup imglib * Prints the name and description of the supported image types to a handle. * This is used by the TSK command line tools to print the supported types * to the console. * @param hFile Handle to print names and descriptions to. */ void tsk_img_type_print(FILE * hFile) { IMG_TYPES *sp; tsk_fprintf(hFile, "Supported image format types:\n"); for (sp = img_open_table; sp->name; sp++) tsk_fprintf(hFile, "\t%s (%s)\n", sp->name, sp->comment); } /** * \ingroup imglib * Returns the name of an image format type, given its type ID. * @param type ID of image type * @returns Pointer to string of the name. */ const char * tsk_img_type_toname(TSK_IMG_TYPE_ENUM type) { IMG_TYPES *sp; for (sp = img_open_table; sp->name; sp++) if (sp->code == type) return sp->name; return NULL; } /** * \ingroup imglib * Returns the description of an image format type, given its type ID. * @param type ID of image type * @returns Pointer to string of the description */ const char * tsk_img_type_todesc(TSK_IMG_TYPE_ENUM type) { IMG_TYPES *sp; for (sp = img_open_table; sp->name; sp++) if (sp->code == type) return sp->comment; return NULL; } /** * \ingroup imglib * Returns the supported file format types. * @returns A bit in the return value is set to 1 if the type is supported. */ TSK_IMG_TYPE_ENUM tsk_img_type_supported() { TSK_IMG_TYPE_ENUM sup_types = 0; IMG_TYPES *sp; for (sp = img_open_table; sp->name; sp++) { sup_types |= sp->code; } return sup_types; } sleuthkit-3.2.3/tsk3/img/Makefile.am000644 000765 000024 00000000454 11643647440 020035 0ustar00carrierstaff000000 000000 AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskimg.la libtskimg_la_SOURCES = img_open.c img_types.c raw.c raw.h \ split.c split.h aff.c aff.h ewf.c ewf.h tsk_img_i.h img_io.c mult_files.c indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ sleuthkit-3.2.3/tsk3/img/Makefile.in000644 000765 000024 00000033330 11643647517 020052 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/img DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskimg_la_LIBADD = am_libtskimg_la_OBJECTS = img_open.lo img_types.lo raw.lo split.lo \ aff.lo ewf.lo img_io.lo mult_files.lo libtskimg_la_OBJECTS = $(am_libtskimg_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskimg_la_SOURCES) DIST_SOURCES = $(libtskimg_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskimg.la libtskimg_la_SOURCES = img_open.c img_types.c raw.c raw.h \ split.c split.h aff.c aff.h ewf.c ewf.h tsk_img_i.h img_io.c mult_files.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/img/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/img/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskimg.la: $(libtskimg_la_OBJECTS) $(libtskimg_la_DEPENDENCIES) $(LINK) $(libtskimg_la_OBJECTS) $(libtskimg_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ewf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/img_io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/img_open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/img_types.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mult_files.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/split.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ # 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: sleuthkit-3.2.3/tsk3/img/mult_files.c000644 000765 000024 00000015742 11643647440 020316 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2011 Brian Carrier, Basis Technology. All rights reserved * * mult_files * * This software is distributed under the Common Public License 1.0 * */ /** * \file mult_files.c * Internal code to find remainder of files in a split / E01 / etc. set */ #include "tsk_img_i.h" /** * @param a_baseName The name minus the incrementing part of hte name ("test.E" for example). Must include '.' * @param a_baseExt The first extention to use "01" for example -- must not have '.' and can only be 2 long and it is case sensitive * @param a_nameList List to add names to. Must be of correct size. No checking is done internally. If NULL, * then no values will be added and instead the method will only count how many files would have been copied. * @param a_numFound The number of files found so far (i.e. starting point into a_nameList and will have the * final number of entries in a_nameList at the end. * @returns 1 on error (memory, args, etc.) */ static uint8_t findFiles2(const TSK_TCHAR *a_baseName, const TSK_TCHAR *a_baseExt, TSK_TCHAR **a_nameList, int *a_numFound) { TSK_TCHAR tmpName[2048]; TSK_TCHAR curExt[3]; int i; uint8_t isNumeric; memset(tmpName, 0, 2048*sizeof(TSK_TCHAR)); memset(curExt, 0, 3*sizeof(TSK_TCHAR)); if (TSTRLEN(a_baseExt) > 2) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "findFiles2: extention is too short: %"PRIttocTSK, a_baseExt); return 1; } TSTRNCPY(curExt, a_baseExt, 3); // @@@ There are problms here if they specify non-standard things (like 00) // could probably use atoi equivalent instead if (TSTRCMP(a_baseExt, _TSK_T("01")) == 0) { isNumeric = 1; i = 1; } else { isNumeric = 0; i = 0; } while (1) { struct STAT_STR stat_buf; // make the name if (isNumeric) { TSNPRINTF(tmpName, 2048, _TSK_T("%s%.2d"), a_baseName, i); } else { // The use of a_base_ext here is not entirely correct if they did not specify AA or aa... HACK TSK_TCHAR a = a_baseExt[0] + (i / 26); TSK_TCHAR b = a_baseExt[0] + (i % 26); TSNPRINTF(tmpName, 2048, _TSK_T("%s%c%c"), a_baseName, a, b); } // does the file exist? if (TSTAT(tmpName, &stat_buf) < 0) { break; } if (tsk_verbose) tsk_fprintf(stderr, "tsk_img_findFiles: %"PRIttocTSK" found\n", tmpName); // save it, if they gave us a buffer if (a_nameList) { TSK_TCHAR *tmpName2; if ((tmpName2 = (TSK_TCHAR *)tsk_malloc((TSTRLEN(tmpName)+1) * sizeof(TSK_TCHAR))) == NULL) { return 1; } TSTRNCPY(tmpName2, tmpName, TSTRLEN(tmpName)+1); a_nameList[*a_numFound] = tmpName2; } (*a_numFound)++; i++; } return 0; } // makes a copy of the passed image name into a ** struct. static TSK_TCHAR ** copyInBase(const TSK_TCHAR *a_image) { TSK_TCHAR **tmpName; if ((tmpName = tsk_malloc(sizeof(TSK_TCHAR *))) == NULL) { return NULL; } if ((tmpName[0] = tsk_malloc((TSTRLEN(a_image)+1) * sizeof(TSK_TCHAR))) == NULL) { free(tmpName); return NULL; } TSTRNCPY(tmpName[0], a_image, TSTRLEN(a_image)+1); return tmpName; } /** * @param a_startingName First name in the list (must be full name) * @param [out] a_numFound Number of images that are in returned list * @returns array of names that caller must free (NULL on error or if supplied file does not exist) */ TSK_TCHAR ** tsk_img_findFiles(const TSK_TCHAR *a_startingName, int *a_numFound) { TSK_TCHAR **retNames = NULL; *a_numFound = 0; // we can't do anything with this... if (TSTRLEN(a_startingName) < 3) { *a_numFound = 1; return copyInBase(a_startingName); } // E01 file if ((TSTRICMP(&a_startingName[TSTRLEN(a_startingName)-4], _TSK_T(".e01")) == 0) || (TSTRICMP(&a_startingName[TSTRLEN(a_startingName)-4], _TSK_T(".s01")) == 0)) { TSK_TCHAR *baseName; int fileCount = 0; if ((baseName = (TSK_TCHAR *)tsk_malloc(TSTRLEN(a_startingName) * sizeof(TSK_TCHAR))) == NULL) { return NULL; } TSTRNCPY(baseName, a_startingName, TSTRLEN(a_startingName)-2); // first lets get a count fileCount = 0; if (findFiles2(baseName, _TSK_T("01"), NULL, &fileCount)) { free(baseName); return NULL; } if (fileCount == 99) { if (findFiles2(baseName, _TSK_T("AA"), NULL, &fileCount)) { free(baseName); return NULL; } } if (tsk_verbose) tsk_fprintf(stderr, "tsk_img_findFiles: %d total images found\n", fileCount); if (fileCount == 0) { free(baseName); return NULL; } // now we copy them if ((retNames = (TSK_TCHAR **)tsk_malloc(fileCount * sizeof(TSK_TCHAR *))) == NULL) { free(baseName); return NULL; } *a_numFound = 0; if (findFiles2(baseName, _TSK_T("01"), retNames, a_numFound)) { free(baseName); free(retNames); return NULL; } if (*a_numFound == 99) { if (findFiles2(baseName, _TSK_T("AA"), retNames, a_numFound)) { free(baseName); free(retNames); return NULL; } } free(baseName); } else if (TSTRICMP(&a_startingName[TSTRLEN(a_startingName)-3], _TSK_T(".aa")) == 0) { TSK_TCHAR *baseName; int fileCount = 0; if ((baseName = (TSK_TCHAR *)tsk_malloc(TSTRLEN(a_startingName) * sizeof(TSK_TCHAR))) == NULL) { return NULL; } TSTRNCPY(baseName, a_startingName, TSTRLEN(a_startingName)-2); // first lets get a count fileCount = 0; if (findFiles2(baseName, &a_startingName[TSTRLEN(a_startingName)-1], NULL, &fileCount)) { free(baseName); return NULL; } if (tsk_verbose) tsk_fprintf(stderr, "tsk_img_findFiles: %d total images found\n", fileCount); if (fileCount == 0) { free(baseName); return NULL; } // now lets copy them if ((retNames = (TSK_TCHAR **)tsk_malloc(fileCount * sizeof(TSK_TCHAR *))) == NULL) { free(baseName); return NULL; } *a_numFound = 0; if (findFiles2(baseName, &a_startingName[TSTRLEN(a_startingName)-1], retNames, a_numFound)) { free(baseName); free(retNames); return NULL; } free(baseName); } return retNames; } sleuthkit-3.2.3/tsk3/img/raw.c000644 000765 000024 00000023752 11643647440 016744 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2005 Brian Carrier. All rights reserved * * raw * * This software is distributed under the Common Public License 1.0 * */ /** * \file raw.c * Internal code to open and read single raw disk images */ #include "tsk_img_i.h" #include "raw.h" #if defined(__APPLE__) #include #endif #ifdef TSK_WIN32 #include "winioctl.h" #endif /** * Read an arbitrary amount of data from a specific location in a raw image file. * This takes two offsets are arguments. The first is the offset of the volume in the * image file and the second is the offset in the volume. Both are added to find the * actual offset. * * @param img_info The image to read from. * @param offset The byte offset in the image to start reading from * @param buf [out] Buffer to store data in * @param len Number of bytes to read * @returns The number of bytes read or -1 on error -- which can occur if the offset is larger than the img. */ static ssize_t raw_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) { ssize_t cnt; IMG_RAW_INFO *raw_info = (IMG_RAW_INFO *) img_info; if (tsk_verbose) tsk_fprintf(stderr, "raw_read: byte offset: %" PRIuOFF " len: %" PRIuSIZE "\n", offset, len); if (offset > img_info->size) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_read - %" PRIuOFF, offset); return -1; } #ifdef TSK_WIN32 { DWORD nread; if (raw_info->seek_pos != offset) { LARGE_INTEGER li; li.QuadPart = offset; li.LowPart = SetFilePointer(raw_info->fd, li.LowPart, &li.HighPart, FILE_BEGIN); if ((li.LowPart == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_SEEK; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_read - %" PRIuOFF, offset); return -1; } raw_info->seek_pos = offset; } if (FALSE == ReadFile(raw_info->fd, buf, (DWORD) len, &nread, NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_read - offset: %" PRIuOFF " - len: %zu", offset, len); return -1; } cnt = (ssize_t) nread; } #else if (raw_info->seek_pos != offset) { if (lseek(raw_info->fd, offset, SEEK_SET) != offset) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_SEEK; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_read - %" PRIuOFF " - %s", offset, strerror(errno)); return -1; } raw_info->seek_pos = offset; } cnt = read(raw_info->fd, buf, len); if (cnt < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_read - offset: %" PRIuOFF " - len: %" PRIuSIZE " - %s", offset, len, strerror(errno)); return -1; } #endif raw_info->seek_pos += cnt; return cnt; } static void raw_imgstat(TSK_IMG_INFO * img_info, FILE * hFile) { tsk_fprintf(hFile, "IMAGE FILE INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Image Type: raw\n"); tsk_fprintf(hFile, "\nSize in bytes: %" PRIuOFF "\n", img_info->size); return; } static void raw_close(TSK_IMG_INFO * img_info) { IMG_RAW_INFO *raw_info = (IMG_RAW_INFO *) img_info; #ifdef TSK_WIN32 CloseHandle(raw_info->fd); #else close(raw_info->fd); #endif free(raw_info); } /** * \internal * Open the file as a raw image. * @param image Path to disk image to open. * @param a_ssize Size of device sector in bytes (or 0 for default) * @returns NULL on error. */ TSK_IMG_INFO * raw_open(const TSK_TCHAR * image, unsigned int a_ssize) { IMG_RAW_INFO *raw_info; TSK_IMG_INFO *img_info; struct STAT_STR stat_buf; int is_winobj = 0; if ((raw_info = (IMG_RAW_INFO *) tsk_malloc(sizeof(IMG_RAW_INFO))) == NULL) return NULL; img_info = (TSK_IMG_INFO *) raw_info; img_info->itype = TSK_IMG_TYPE_RAW_SING; img_info->read = raw_read; img_info->close = raw_close; img_info->imgstat = raw_imgstat; img_info->sector_size = 512; if (a_ssize) img_info->sector_size = a_ssize; #if defined(TSK_WIN32) || defined(__CYGWIN__) if ((image[0] == _TSK_T('\\')) && (image[1] == _TSK_T('\\')) && (image[2] == _TSK_T('.')) && (image[3] == _TSK_T('\\'))) { is_winobj = 1; } #endif if (is_winobj == 0) { /* Exit if we are given a directory */ if (TSTAT(image, &stat_buf) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_STAT; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open: %s", strerror(errno)); return NULL; } else if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) { if (tsk_verbose) TFPRINTF(stderr, _TSK_T("raw_open: image %s is a directory\n"), image); tsk_error_reset(); tsk_errno = TSK_ERR_IMG_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open: path is for a directory"); return NULL; } } #ifdef TSK_WIN32 { DWORD dwHi, dwLo; if ((raw_info->fd = CreateFile(image, FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) { // if it is a device, try with SHARE_WRITE if ((image[0] == _TSK_T('\\')) && (image[1] == _TSK_T('\\')) && (image[2] == _TSK_T('.')) && (image[3] == _TSK_T('\\'))) { if (tsk_verbose) tsk_fprintf(stderr, "raw_open: Trying Windows device with share_write mode\n"); raw_info->fd = CreateFile(image, FILE_READ_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); } if (raw_info->fd == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; // print string of commonly found errors if (GetLastError() == ERROR_ACCESS_DENIED) { snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " (Access Denied)", image); } else if (GetLastError() == ERROR_SHARING_VIOLATION) { snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " (Sharing Violation)", image); } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " (File not found)", image); } else { snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " (%d)", image, (int) GetLastError()); } return NULL; } } /* We need different techniques to determine the size of physical * devices versus normal files */ if (is_winobj == 0) { dwLo = GetFileSize(raw_info->fd, &dwHi); if (dwLo == 0xffffffff) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " GetFileSize: %d", image, (int) GetLastError()); return NULL; } img_info->size = dwLo | ((TSK_OFF_T) dwHi << 32); } else { DISK_GEOMETRY pdg; DWORD junk; if (FALSE == DeviceIoControl(raw_info->fd, // device to be queried IOCTL_DISK_GET_DRIVE_GEOMETRY, // operation to perform NULL, 0, &pdg, sizeof(pdg), &junk, (LPOVERLAPPED) NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " DeviceIoControl: %d", image, (int) GetLastError()); return NULL; } img_info->size = pdg.Cylinders.QuadPart * (TSK_OFF_T) pdg.TracksPerCylinder * (TSK_OFF_T) pdg.SectorsPerTrack * (TSK_OFF_T) pdg.BytesPerSector; } } #else if ((raw_info->fd = open(image, O_RDONLY | O_BINARY)) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " msg: %s", image, strerror(errno)); return NULL; } #if defined(__APPLE__) /* OS X doesn't support SEEK_END on char devices */ if ((stat_buf.st_mode & S_IFMT) != S_IFCHR) { img_info->size = lseek(raw_info->fd, 0, SEEK_END); lseek(raw_info->fd, 0, SEEK_SET); } if (img_info->size == 0) { int blkSize; long long blkCnt; if (ioctl(raw_info->fd, DKIOCGETBLOCKSIZE, &blkSize) >= 0) { if (ioctl(raw_info->fd, DKIOCGETBLOCKCOUNT, &blkCnt) >= 0) { img_info->size = blkCnt * (long long) blkSize; } } } #else /* We don't use the stat output because it doesn't work on raw * devices and such */ img_info->size = lseek(raw_info->fd, 0, SEEK_END); lseek(raw_info->fd, 0, SEEK_SET); #endif #endif raw_info->seek_pos = 0; return img_info; } sleuthkit-3.2.3/tsk3/img/raw.h000644 000765 000024 00000001201 11643647440 016732 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * Contains the single raw data file-specific functions and structures. */ #ifndef _RAW_H #define _RAW_H #ifdef __cplusplus extern "C" { #endif extern TSK_IMG_INFO *raw_open(const TSK_TCHAR *, unsigned int a_ssize); typedef struct { TSK_IMG_INFO img_info; #ifdef TSK_WIN32 HANDLE fd; #else int fd; #endif TSK_OFF_T seek_pos; } IMG_RAW_INFO; #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/img/split.c000644 000765 000024 00000033232 11643647440 017300 0ustar00carrierstaff000000 000000 /* * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved * Copyright (c) 2005 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 * */ /** * \file split.c * Internal code to handle opening and reading of split raw disk images. */ #include "tsk_img_i.h" #include "split.h" /** * \internal * Read from one of the multiple files in a split set of disk images. * * @param split_info Disk image info to read from * @param idx Index of the disk image in the set to read from * @param buf [out] Buffer to write data to * @param len Number of bytes to read * @param rel_offset Byte offset in the disk image to read from (not the offset in the full disk image set) * @return -1 on error or number of bytes read */ static ssize_t split_read_segment(IMG_SPLIT_INFO * split_info, int idx, char *buf, size_t len, TSK_OFF_T rel_offset) { IMG_SPLIT_CACHE *cimg; ssize_t cnt; /* Is the image already open? */ if (split_info->cptr[idx] == -1) { if (tsk_verbose) tsk_fprintf(stderr, "split_read_rand: opening file into slot %d %" PRIttocTSK "\n", split_info->next_slot, split_info->images[idx]); /* Grab the next cache slot */ cimg = &split_info->cache[split_info->next_slot]; /* Free it if being used */ if (cimg->fd != 0) { if (tsk_verbose) tsk_fprintf(stderr, "split_read_rand: closing file %" PRIttocTSK "\n", split_info->images[cimg->image]); #ifdef TSK_WIN32 CloseHandle(cimg->fd); #else close(cimg->fd); #endif split_info->cptr[cimg->image] = -1; } #ifdef TSK_WIN32 if ((cimg->fd = CreateFile(split_info->images[idx], FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read file: %" PRIttocTSK " msg: %d", split_info->images[idx], (int) GetLastError()); return -1; } #else if ((cimg->fd = open(split_info->images[idx], O_RDONLY | O_BINARY)) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read file: %" PRIttocTSK " msg: %s", split_info->images[idx], strerror(errno)); return -1; } #endif cimg->image = idx; cimg->seek_pos = 0; split_info->cptr[idx] = split_info->next_slot; if (++split_info->next_slot == SPLIT_CACHE) { split_info->next_slot = 0; } } else { cimg = &split_info->cache[split_info->cptr[idx]]; } #ifdef TSK_WIN32 { DWORD nread; if (cimg->seek_pos != rel_offset) { LARGE_INTEGER li; li.QuadPart = rel_offset; li.LowPart = SetFilePointer(cimg->fd, li.LowPart, &li.HighPart, FILE_BEGIN); if ((li.LowPart == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_SEEK; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - %" PRIuOFF, rel_offset); return -1; } cimg->seek_pos = rel_offset; } if (FALSE == ReadFile(cimg->fd, buf, (DWORD) len, &nread, NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - offset: %" PRIuOFF " - len: %" PRIuSIZE "", rel_offset, len); return -1; } cnt = (ssize_t) nread; } #else if (cimg->seek_pos != rel_offset) { if (lseek(cimg->fd, rel_offset, SEEK_SET) != rel_offset) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_SEEK; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - %s - %" PRIuOFF " - %s", split_info->images[idx], rel_offset, strerror(errno)); return -1; } cimg->seek_pos = rel_offset; } cnt = read(cimg->fd, buf, len); if (cnt < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - offset: %" PRIuOFF " - len: %" PRIuSIZE " - %s", rel_offset, len, strerror(errno)); return -1; } #endif cimg->seek_pos += cnt; return cnt; } /** * \internal * Read data from a split disk image. The offset to start reading from is * equal to the volume offset plus the read offset. * * @param img_info Disk image to read from * @param offset Byte offset in image to start reading from * @param buf [out] Buffer to write data to * @param len Number of bytes to read * @return number of bytes read or -1 on error */ static ssize_t split_read(TSK_IMG_INFO * img_info, TSK_OFF_T offset, char *buf, size_t len) { IMG_SPLIT_INFO *split_info = (IMG_SPLIT_INFO *) img_info; int i; if (tsk_verbose) tsk_fprintf(stderr, "split_read: byte offset: %" PRIuOFF " len: %" PRIuOFF "\n", offset, len); if (offset > img_info->size) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - %" PRIuOFF, offset); return -1; } // Find the location of the offset for (i = 0; i < split_info->num_img; i++) { /* Does the data start in this image? */ if (offset < split_info->max_off[i]) { TSK_OFF_T rel_offset; size_t read_len; ssize_t cnt; /* Get the offset relative to this image */ if (i > 0) { rel_offset = offset - split_info->max_off[i - 1]; } else { rel_offset = offset; } /* Get the length to read */ if ((split_info->max_off[i] - offset) >= len) read_len = len; else read_len = (size_t) (split_info->max_off[i] - offset); if (tsk_verbose) tsk_fprintf(stderr, "split_read_rand: found in image %d relative: %" PRIuOFF " len: %" PRIuOFF "\n", i, rel_offset, read_len); cnt = split_read_segment(split_info, i, buf, read_len, rel_offset); if (cnt < 0) return -1; if ((TSK_OFF_T) cnt != read_len) return cnt; /* Go to the next image(s) */ if (((TSK_OFF_T) cnt == read_len) && (read_len != len)) { ssize_t cnt2; len -= read_len; while (len > 0) { /* go to the next image */ i++; if (split_info->max_off[i] - split_info->max_off[i - 1] >= len) read_len = len; else read_len = (size_t) (split_info->max_off[i] - split_info->max_off[i - 1]); if (tsk_verbose) tsk_fprintf(stderr, "split_read_rand: Additional image reads: image %d len: %" PRIuOFF "\n", i, read_len); cnt2 = split_read_segment(split_info, i, &buf[cnt], read_len, 0); if (cnt2 < 0) return -1; cnt += cnt2; if ((TSK_OFF_T) cnt2 != read_len) return cnt; len -= cnt2; } } return cnt; } } tsk_error_reset(); tsk_errno = TSK_ERR_IMG_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_read - %" PRIuOFF " - %s", offset, strerror(errno)); return -1; } /** * \internal * Display information about the disk image set. * * @param img_info Disk image to analyze * @param hFile Handle to print information to */ static void split_imgstat(TSK_IMG_INFO * img_info, FILE * hFile) { IMG_SPLIT_INFO *split_info = (IMG_SPLIT_INFO *) img_info; int i; tsk_fprintf(hFile, "IMAGE FILE INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Image Type: split\n"); tsk_fprintf(hFile, "\nSize in bytes: %" PRIuOFF "\n", img_info->size); tsk_fprintf(hFile, "\n--------------------------------------------\n"); tsk_fprintf(hFile, "Split Information:\n"); for (i = 0; i < split_info->num_img; i++) { tsk_fprintf(hFile, "%s (%" PRIuOFF " to %" PRIuOFF ")\n", split_info->images[i], (TSK_OFF_T) (i == 0) ? 0 : split_info->max_off[i - 1], (TSK_OFF_T) (split_info->max_off[i] - 1)); } } /** * \internal * Free the memory and close the file handles for the disk image * * @param img_info Disk image to close */ static void split_close(TSK_IMG_INFO * img_info) { int i; IMG_SPLIT_INFO *split_info = (IMG_SPLIT_INFO *) img_info; for (i = 0; i < SPLIT_CACHE; i++) { if (split_info->cache[i].fd != 0) #ifdef TSK_WIN32 CloseHandle(split_info->cache[i].fd); #else close(split_info->cache[i].fd); #endif } for(i = 0; i < split_info->num_img; i++){ if (split_info->images[i]) free(split_info->images[i]); } if (split_info->max_off) free(split_info->max_off); if (split_info->images) free(split_info->images); if (split_info->cptr) free(split_info->cptr); free(split_info); } /** * \internal * Open the set of disk images as a set of split raw images * * @param num_img Number of images in set * @param images List of disk image paths (in sorted order) * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return NULL on error */ TSK_IMG_INFO * split_open(int num_img, const TSK_TCHAR * const images[], unsigned int a_ssize) { IMG_SPLIT_INFO *split_info; TSK_IMG_INFO *img_info; int i; if ((split_info = (IMG_SPLIT_INFO *) tsk_malloc(sizeof(IMG_SPLIT_INFO))) == NULL) return NULL; img_info = (TSK_IMG_INFO *) split_info; img_info->itype = TSK_IMG_TYPE_RAW_SPLIT; img_info->read = split_read; img_info->close = split_close; img_info->imgstat = split_imgstat; img_info->sector_size = 512; if (a_ssize) img_info->sector_size = a_ssize; /* Open the files */ if ((split_info->cptr = (int *) tsk_malloc(num_img * sizeof(int))) == NULL) { free(split_info); return NULL; } memset((void *) &split_info->cache, 0, SPLIT_CACHE * sizeof(IMG_SPLIT_CACHE)); split_info->next_slot = 0; split_info->max_off = (TSK_OFF_T *) tsk_malloc(num_img * sizeof(TSK_OFF_T)); if (split_info->max_off == NULL) { free(split_info->cptr); free(split_info); return NULL; } img_info->size = 0; split_info->num_img = num_img; split_info->images = (TSK_TCHAR **) tsk_malloc(sizeof(TSK_TCHAR *) * num_img); if(split_info->images == NULL){ free(split_info->max_off); free(split_info->cptr); free(split_info); return NULL; } for(i=0; i < num_img; i++){ size_t len = TSTRLEN(images[i]); split_info->images[i] = (TSK_TCHAR *) tsk_malloc(sizeof(TSK_TCHAR) * (len+1)); if(split_info->images == NULL){ while(i > 0){ i--; free(split_info->images[i]); } free(split_info->images); free(split_info->max_off); free(split_info->cptr); free(split_info); return NULL; } TSTRNCPY(split_info->images[i], images[i], len); } /* Get size info for each file - we do not open each one because that * could cause us to run out of file decsriptors when we only need a few. * The descriptors are opened as needed */ for (i = 0; i < num_img; i++) { struct STAT_STR sb; split_info->cptr[i] = -1; if (TSTAT(images[i], &sb) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_STAT; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_open - %" PRIttocTSK " - %s", images[i], strerror(errno)); free(split_info->max_off); free(split_info->cptr); free(split_info); return NULL; } else if ((sb.st_mode & S_IFMT) == S_IFDIR) { if (tsk_verbose) tsk_fprintf(stderr, "split_open: image %" PRIttocTSK " is a directory\n", images[i]); tsk_error_reset(); tsk_errno = TSK_ERR_IMG_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "split_open: Image is a directory"); return NULL; } /* Add the size of this image to the total and save the current max */ img_info->size += sb.st_size; split_info->max_off[i] = img_info->size; if (tsk_verbose) tsk_fprintf(stderr, "split_open: %d size: %" PRIuOFF " max offset: %" PRIuOFF " Name: %" PRIttocTSK "\n", i, sb.st_size, split_info->max_off[i], images[i]); } return img_info; } sleuthkit-3.2.3/tsk3/img/split.h000644 000765 000024 00000002026 11643647440 017302 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /* * Contains the split raw data file-specific functions and structures. */ #ifndef _SPLIT_H #define _SPLIT_H #ifdef __cplusplus extern "C" { #endif extern TSK_IMG_INFO *split_open(int, const TSK_TCHAR * const images[], unsigned int a_ssize); #define SPLIT_CACHE 15 typedef struct { #ifdef TSK_WIN32 HANDLE fd; #else int fd; #endif int image; TSK_OFF_T seek_pos; } IMG_SPLIT_CACHE; typedef struct { TSK_IMG_INFO img_info; int num_img; TSK_TCHAR **images; TSK_OFF_T *max_off; int *cptr; /* exists for each image - points to entry in cache */ IMG_SPLIT_CACHE cache[SPLIT_CACHE]; /* small number of fds for open images */ int next_slot; } IMG_SPLIT_INFO; #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/img/tsk_img.h000644 000765 000024 00000010712 11643647440 017605 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ #ifndef _TSK_IMG_H #define _TSK_IMG_H /** * \file tsk_img.h * Contains the external library definitions for the disk image functions. * Note that this file is not meant to be directly included. * It is included by both libtsk.h and tsk_img_i.h. */ /** * \defgroup imglib Disk Image Functions */ #ifdef __cplusplus extern "C" { #endif /** * \ingroup imglib * Macro that takes a image type and returns 1 if the type * is for a raw file format. */ #define TSK_IMG_TYPE_ISRAW(t) \ ((((t) & TSK_IMG_TYPE_RAW_SING) || ((t) & TSK_IMG_TYPE_RAW_SPLIT))?1:0) /** * \ingroup imglib * Macro that takes a image type and returns 1 if the type * is for an AFF file format. */ #define TSK_IMG_TYPE_ISAFF(t) \ ((((t) & TSK_IMG_TYPE_AFF_AFF) || ((t) & TSK_IMG_TYPE_AFF_AFD) || ((t) & TSK_IMG_TYPE_AFF_AFM) || \ ((t) & TSK_IMG_TYPE_AFF_ANY))?1:0) /** * \ingroup imglib * Macro that takes a image type and returns 1 if the type * is for an EWF file format. */ #define TSK_IMG_TYPE_ISEWF(t) \ ((((t) & TSK_IMG_TYPE_EWF_EWF))?1:0) /** * Flag values for the disk image format type. Each type has a * bit associated with it. There are TSK_IMG_TYPE_ISXXX macros * to determine the broad group of the type (raw vs aff etc.) */ typedef enum { TSK_IMG_TYPE_DETECT = 0x0000, ///< Use autodetection methods TSK_IMG_TYPE_RAW_SING = 0x0001, ///< Raw single disk image TSK_IMG_TYPE_RAW_SPLIT = 0x0002, ///< Raw split image TSK_IMG_TYPE_AFF_AFF = 0x0004, ///< AFF AFF Format TSK_IMG_TYPE_AFF_AFD = 0x0008, ///< AFD AFF Format TSK_IMG_TYPE_AFF_AFM = 0x0010, ///< AFM AFF Format TSK_IMG_TYPE_AFF_ANY = 0x0020, ///< Any format supported by AFFLIB (including beta ones) TSK_IMG_TYPE_EWF_EWF = 0x0040, ///< EWF version TSK_IMG_TYPE_UNSUPP = 0xffff, ///< Unsupported disk image type } TSK_IMG_TYPE_ENUM; #define TSK_IMG_INFO_CACHE_NUM 4 #define TSK_IMG_INFO_CACHE_LEN 65536 typedef struct TSK_IMG_INFO TSK_IMG_INFO; /** * Created when a disk image has been opened and stores general information and handles. */ struct TSK_IMG_INFO { TSK_IMG_TYPE_ENUM itype; ///< Type of disk image format TSK_OFF_T size; ///< Total size of image in bytes unsigned int sector_size; ///< sector size of device in bytes (typically 512) char cache[TSK_IMG_INFO_CACHE_NUM][TSK_IMG_INFO_CACHE_LEN]; ///< read cache TSK_OFF_T cache_off[TSK_IMG_INFO_CACHE_NUM]; ///< starting byte offset of corresponding cache entry int cache_age[TSK_IMG_INFO_CACHE_NUM]; ///< "Age" of corresponding cache entry, higher means more recently used size_t cache_len[TSK_IMG_INFO_CACHE_NUM]; ///< Length of cache entry used (0 if never used) ssize_t(*read) (TSK_IMG_INFO * img, TSK_OFF_T off, char *buf, size_t len); ///< \internal External progs should call tsk_img_read() void (*close) (TSK_IMG_INFO *); ///< \internal Progs should call tsk_img_close() void (*imgstat) (TSK_IMG_INFO *, FILE *); ///< Pointer to file type specific function }; // open and close functions extern TSK_IMG_INFO *tsk_img_open_sing(const TSK_TCHAR * a_image, TSK_IMG_TYPE_ENUM type, unsigned int a_ssize); extern TSK_IMG_INFO *tsk_img_open(int, const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM, unsigned int a_ssize); extern TSK_IMG_INFO *tsk_img_open_utf8_sing(const char *a_image, TSK_IMG_TYPE_ENUM type, unsigned int a_ssize); extern TSK_IMG_INFO *tsk_img_open_utf8(int num_img, const char *const images[], TSK_IMG_TYPE_ENUM type, unsigned int a_ssize); extern void tsk_img_close(TSK_IMG_INFO *); // read functions extern ssize_t tsk_img_read(TSK_IMG_INFO * img, TSK_OFF_T off, char *buf, size_t len); // type conversion functions extern TSK_IMG_TYPE_ENUM tsk_img_type_toid(const TSK_TCHAR *); extern const char *tsk_img_type_toname(TSK_IMG_TYPE_ENUM); extern const char *tsk_img_type_todesc(TSK_IMG_TYPE_ENUM); extern TSK_IMG_TYPE_ENUM tsk_img_type_supported(); extern void tsk_img_type_print(FILE *); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/img/tsk_img_i.h000644 000765 000024 00000001544 11643647440 020120 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ #ifndef _TSK_IMG_I_H #define _TSK_IMG_I_H /* * Contains the internal library definitions for the disk image functions. This should * be included by the code in the img library. */ // include the base internal header file #include "tsk3/base/tsk_base_i.h" // include the external disk image header file #include "tsk_img.h" // other standard includes #include #include #include #include #include // Cygwin needs this, but not everyone defines it #ifndef O_BINARY #define O_BINARY 0 #endif extern TSK_TCHAR **tsk_img_findFiles(const TSK_TCHAR *a_startingName, int *a_numFound); #endif sleuthkit-3.2.3/tsk3/hashdb/.indent.pro000644 000765 000024 00000000031 11643647440 020526 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nut sleuthkit-3.2.3/tsk3/hashdb/hk_index.c000644 000765 000024 00000031325 11643647440 020414 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * * This software is distributed under the Common Public License 1.0 * */ #include "tsk_hashdb_i.h" /** * \file hk_index.c * Contains functions to read and process hash keeper database files */ /** * Test the file to see if it is a hashkeeper database * * @param hFile File handle to hash database * * @return 1 if hk and 0 if not */ uint8_t hk_test(FILE * hFile) { char buf[TSK_HDB_MAXLEN]; int cnt = 0; char *ptr; fseek(hFile, 0, SEEK_SET); if (NULL == fgets(buf, TSK_HDB_MAXLEN, hFile)) return 0; if (strlen(buf) < TSK_HDB_HTYPE_MD5_LEN) return 0; ptr = buf; /* Cycle through the line looking at the fields in between the commas */ while (NULL != (ptr = strchr(ptr, ','))) { cnt++; // run some tets on the MD5 field if (cnt == 4) { /* Do a length check and more sanity checks */ if ((strlen(ptr) < 2 + TSK_HDB_HTYPE_MD5_LEN) || (ptr[1] != '"') || (ptr[2 + TSK_HDB_HTYPE_MD5_LEN] != '"')) { return 0; } if ((isxdigit((int) ptr[2]) == 0) || (isxdigit((int) ptr[2 + TSK_HDB_HTYPE_MD5_LEN - 1]) == 0)) { return 0; } /* Final sanity check */ if (NULL != strchr(ptr, ',')) { return 0; } return 1; } /* If the next field is in quotes then we need to skip to the * next quote and ignore any ',' in there */ if (ptr[1] == '"') { if (NULL == (ptr = strchr(&ptr[2], '"'))) { return 0; } } else { ptr++; } } return 0; } /** * Give a line from a hash keeper database, parse out the * MD5 (and other) text. NOTE that this will add NULL values * to the input text. * * @param str [in] String to parse * @param md5 [out] Pointer to a pointer, which will be assigned to the MD5 text in original string * @param name [in] Poiner to buffer where name can be copied into (can be NULL) * @param n_len [in] Length of name buffer * @param other [in] Pointer to buffer where extended data should be copied to (can be NULL) * @param o_len [in] Length of other buffer */ static int hk_parse_md5(char *str, char **md5, char *name, int n_len, char *other, int o_len) { char *ptr = str; char *file = NULL, *dir = NULL, *file_id = NULL, *hash_id = NULL; int cnt = 0; if ((str == NULL) || (strlen(str) < TSK_HDB_HTYPE_MD5_LEN)) return 1; if ((md5 == NULL) && (name == NULL) && (other == NULL)) return 0; /* * 0 file_id * 1 hashset_id * 2 file_name * 3 directory * 4 hash * 5 file_size * 6 date_modified * 7 time modified * 8 time_zone * 9 comments * 10 date_accessed * 11 time_accessed */ /* Assign the file_id if we are looking for it */ if (other != NULL) { file_id = ptr; } while (NULL != (ptr = strchr(ptr, ','))) { cnt++; /* End of file_id, begin hash_id */ if ((cnt == 1) && (other != NULL)) { *ptr = '\0'; ptr++; hash_id = ptr; } /* End of hash_id, begin name */ else if (cnt == 2) { /* Finish the 'other' stuff */ if (other != NULL) { *ptr = '\0'; snprintf(other, o_len, "Hash ID: %s File ID: %s", hash_id, file_id); } /* Are we done? */ if ((name == NULL) && (md5 == NULL)) return 0; /* get the pointer to the name */ if (name) { if (ptr[1] != '"') return 1; file = &ptr[2]; /* We utilize the other loop code to find the end of * the name */ } } /* end of the name, begin directory - which may not exist */ else if ((cnt == 3) && (name != NULL)) { /* finish up the name */ if (ptr[-1] != '"') return 1; ptr[-1] = '\0'; /* get the directory start, if it exists */ if (ptr[1] == '"') { dir = &ptr[2]; } else { dir = NULL; } } /* end of directory, begin MD5 value */ else if (cnt == 4) { /* Copy the name into the buffer */ if (name != NULL) { name[0] = '\0'; if (dir) { /* finish up the dir */ if (ptr[-1] != '"') return 1; ptr[-1] = '\0'; strncpy(name, dir, n_len); strncat(name, "\\", n_len); } if (file) { strncat(name, file, n_len); } else { return 1; } } if (md5 == NULL) return 0; /* Do a length check and more sanity checks */ if ((strlen(ptr) < 2 + TSK_HDB_HTYPE_MD5_LEN) || (ptr[1] != '"') || (ptr[2 + TSK_HDB_HTYPE_MD5_LEN] != '"')) { return 1; } ptr = &ptr[2]; ptr[TSK_HDB_HTYPE_MD5_LEN] = '\0'; *md5 = ptr; /* Final sanity check */ if (NULL != strchr(ptr, ',')) { return 1; } return 0; } /* If the next field is in quotes then we need to skip to the * next quote and ignore any ',' in there */ if (ptr[1] == '"') { if (NULL == (ptr = strchr(&ptr[2], '"'))) { return 1; } } else { ptr++; } } return 1; } /** * Process the database to create a sorted index of it. Consecutive * entries with the same hash value are not added to the index, but * will be found during lookup. * * @param hdb_info Hash database to make index of * @param dbtype Text of database type (should always be TSK_HDB_DBTYPE_HK_STR) * * @return 1 on error and 0 on success. */ uint8_t hk_makeindex(TSK_HDB_INFO * hdb_info, TSK_TCHAR * dbtype) { int i; size_t len = 0; char buf[TSK_HDB_MAXLEN]; char *hash = NULL, phash[TSK_HDB_HTYPE_MD5_LEN + 1]; TSK_OFF_T offset = 0; int db_cnt = 0, idx_cnt = 0, ig_cnt = 0; if (tsk_hdb_idxinitialize(hdb_info, dbtype)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hk_makeindex"); return 1; } fseek(hdb_info->hDb, 0, SEEK_SET); /* Status */ if (tsk_verbose) TFPRINTF(stderr, _TSK_T("Extracting Data from Database (%s)\n"), hdb_info->db_fname); /* Allocate a buffer to hold the previous hash values */ memset(phash, '0', TSK_HDB_HTYPE_MD5_LEN + 1); /* read each line of the file */ fseek(hdb_info->hDb, 0, SEEK_SET); for (i = 0; NULL != fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb); offset += (TSK_OFF_T) len, i++) { len = strlen(buf); /* Parse each line to get the MD5 value */ if (hk_parse_md5(buf, &hash, NULL, 0, NULL, 0)) { ig_cnt++; continue; } db_cnt++; /* If this entry is for the same hash value as the last entry, * the skip it -- we'll look for it during lookup */ if (memcmp(hash, phash, TSK_HDB_HTYPE_MD5_LEN) == 0) { continue; } /* Add the entry to the index */ if (tsk_hdb_idxaddentry(hdb_info, hash, offset)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hk_makeindex"); return 1; } idx_cnt++; /* Set the previous hash value */ strncpy(phash, hash, TSK_HDB_HTYPE_MD5_LEN + 1); } if (idx_cnt > 0) { if (tsk_verbose) { fprintf(stderr, " Valid Database Entries: %d\n", db_cnt); fprintf(stderr, " Invalid Database Entries (headers or errors): %d\n", ig_cnt); fprintf(stderr, " Index File Entries %s: %d\n", (idx_cnt == db_cnt) ? "" : "(optimized)", idx_cnt); } /* Finish the index making process */ if (tsk_hdb_idxfinalize(hdb_info)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hk_makeindex"); return 1; } } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_makeindex: No valid entries found in database"); return 1; } return 0; } /** * Find the corresponding name at the * given offset. The offset was likely determined from the index. * The entries in the DB following the one specified are also processed * if they have the same hash value and their name is different. * The callback is called for each entry. * * @param hdb_info Data base to get data from. * @param hash MD5 hash value that was searched for * @param offset Byte offset where hash value should be located in db_file * @param flags * @param action Callback used for each entry found in lookup * @param cb_ptr Pointer to data passed to callback * * @return 1 on error and 0 on success */ uint8_t hk_getentry(TSK_HDB_INFO * hdb_info, const char *hash, TSK_OFF_T offset, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *cb_ptr) { char buf[TSK_HDB_MAXLEN], name[TSK_HDB_MAXLEN], *ptr = NULL, pname[TSK_HDB_MAXLEN], other[TSK_HDB_MAXLEN]; int found = 0; if (tsk_verbose) fprintf(stderr, "hk_getentry: Lookup up hash %s at offset %" PRIuOFF "\n", hash, offset); if (strlen(hash) != TSK_HDB_HTYPE_MD5_LEN) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Invalid hash value: %s", hash); return 1; } memset(pname, '0', TSK_HDB_MAXLEN); /* Loop so that we can find multiple occurances of the same hash */ while (1) { size_t len; if (0 != fseeko(hdb_info->hDb, offset, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Error seeking to get file name: %lu", (unsigned long) offset); return 1; } if (NULL == fgets(hdb_info->idx_lbuf, TSK_HDB_MAXLEN, hdb_info->hDb)) { if (feof(hdb_info->hDb)) { break; } tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Error reading database"); return 1; } len = strlen(buf); if (len < TSK_HDB_HTYPE_MD5_LEN) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Invalid entry in database (too short): %s", buf); return 1; } if (hk_parse_md5(buf, &ptr, name, TSK_HDB_MAXLEN, ((flags & TSK_HDB_FLAG_EXT) ? other : NULL), ((flags & TSK_HDB_FLAG_EXT) ? TSK_HDB_MAXLEN : 0))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Invalid entry in database: %s", buf); return 1; } /* Is this the one that we want? */ if (0 != strcasecmp(ptr, hash)) { break; } if (strcmp(name, pname) != 0) { int retval; retval = action(hdb_info, hash, name, cb_ptr); if (retval == TSK_WALK_ERROR) { return 1; } else if (retval == TSK_WALK_STOP) { return 0; } //if (flags & FLAG_EXT) // printf("%s\t%s\t(%s)\n", hash, name, other); // else // printf("%s\t%s\n", hash, name); found = 1; strncpy(pname, name, TSK_HDB_MAXLEN); } /* Advance to the next row */ offset += len; } if (found == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hk_getentry: Hash not found in file at offset: %lu", (unsigned long) offset); return 1; } return 0; } sleuthkit-3.2.3/tsk3/hashdb/idxonly_index.c000644 000765 000024 00000003560 11643647440 021500 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** * \file idxonly_index.c * Contains the dummy functions that are used when only an index is used for lookups and the * original database is gone. */ #include "tsk_hashdb_i.h" #define STR_EMPTY "" /** * This function should process the database to create a sorted index of it, * but in this case we do not have a database, so just make an error... * * @param hdb_info Hash database to make index of. * @param dbtype Type of hash database * * @return 1 on error and 0 on success. */ uint8_t idxonly_makeindex(TSK_HDB_INFO * hdb_info, TSK_TCHAR * dbtype) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "idxonly_makeindex: Make index not supported when INDEX ONLY option is used"); return 1; } /** * This function should find the corresponding name at a * given offset. In this case though, we do not have the original database, * so just make an error... * * @param hdb_info Hash database to get data from * @param hash MD5 hash value that was searched for * @param offset Byte offset where hash value should be located in db_file * @param flags (not used) * @param action Callback used for each entry found in lookup * @param cb_ptr Pointer to data passed to callback * * @return 1 on error and 0 on succuss */ uint8_t idxonly_getentry(TSK_HDB_INFO * hdb_info, const char *hash, TSK_OFF_T offset, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *cb_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "idxonly_getentry: Not supported when INDEX ONLY option is used"); return 1; } sleuthkit-3.2.3/tsk3/hashdb/Makefile.am000644 000765 000024 00000000427 11643647440 020512 0ustar00carrierstaff000000 000000 AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskhashdb.la libtskhashdb_la_SOURCES = tm_lookup.c md5sum_index.c nsrl_index.c \ hk_index.c idxonly_index.c tsk_hashdb_i.h indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ sleuthkit-3.2.3/tsk3/hashdb/Makefile.in000644 000765 000024 00000033050 11643647517 020526 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/hashdb DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskhashdb_la_LIBADD = am_libtskhashdb_la_OBJECTS = tm_lookup.lo md5sum_index.lo \ nsrl_index.lo hk_index.lo idxonly_index.lo libtskhashdb_la_OBJECTS = $(am_libtskhashdb_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskhashdb_la_SOURCES) DIST_SOURCES = $(libtskhashdb_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskhashdb.la libtskhashdb_la_SOURCES = tm_lookup.c md5sum_index.c nsrl_index.c \ hk_index.c idxonly_index.c tsk_hashdb_i.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/hashdb/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/hashdb/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskhashdb.la: $(libtskhashdb_la_OBJECTS) $(libtskhashdb_la_DEPENDENCIES) $(LINK) $(libtskhashdb_la_OBJECTS) $(libtskhashdb_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hk_index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idxonly_index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5sum_index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsrl_index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tm_lookup.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ # 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: sleuthkit-3.2.3/tsk3/hashdb/md5sum_index.c000644 000765 000024 00000025144 11643647440 021226 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * * This software is distributed under the Common Public License 1.0 */ /** * \file md5sum_index.c * Contains the MD5sum hash database specific extraction and printing routines. */ #include "tsk_hashdb_i.h" #define STR_EMPTY "" /** * Test the file to see if it is a md5sum database * * @param hFile File handle to hash database * * @return 1 if md5sum and 0 if not */ uint8_t md5sum_test(FILE * hFile) { char buf[TSK_HDB_MAXLEN]; fseeko(hFile, 0, SEEK_SET); if (NULL == fgets(buf, TSK_HDB_MAXLEN, hFile)) return 0; if (strlen(buf) < TSK_HDB_HTYPE_MD5_LEN) return 0; if ((buf[0] == 'M') && (buf[1] == 'D') && (buf[2] == '5') && (buf[3] == ' ') && (buf[4] == '(')) { return 1; } if ((isxdigit((int) buf[0])) && (isxdigit((int) buf[TSK_HDB_HTYPE_MD5_LEN - 1])) && (isspace((int) buf[TSK_HDB_HTYPE_MD5_LEN]))) { return 1; } return 0; } /** * Given a line of text from an MD5sum database, return pointers * to the start start of the name and MD5 hash values (original * string will have NULL values in it). * * @param [in]Input string from database -- THIS WILL BE MODIFIED * @param [out] Will contain a pointer to MD5 value in input string * @param [out] Will contain a pointer to name value in input string (input could be NULL) * * @return 1 on error and 0 on success */ static uint8_t md5sum_parse_md5(char *str, char **md5, char **name) { char *ptr; if (strlen(str) < TSK_HDB_HTYPE_MD5_LEN + 1) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_parse_md5: String is too short: %s", str); return 1; } /* Format of: MD5 NAME or even just the MD5 value */ if ((isxdigit((int) str[0])) && (isxdigit((int) str[TSK_HDB_HTYPE_MD5_LEN - 1])) && (isspace((int) str[TSK_HDB_HTYPE_MD5_LEN]))) { unsigned int i; size_t len = strlen(str); if (md5 != NULL) { *md5 = &str[0]; } i = TSK_HDB_HTYPE_MD5_LEN; str[i++] = '\0'; /* Just the MD5 values */ if (i >= len) { if (name != NULL) { *name = STR_EMPTY; } return 0; } while ((i < len) && ((str[i] == ' ') || (str[i] == '\t'))) { i++; } if ((len == i) || (str[i] == '\n')) { return 0; } if (str[i] == '*') { i++; } if (name != NULL) { *name = &str[i]; } ptr = &str[i]; if (ptr[strlen(ptr) - 1] == '\n') ptr[strlen(ptr) - 1] = '\0'; } /* Format of: MD5 (NAME) = MD5 */ else if ((str[0] == 'M') && (str[1] == 'D') && (str[2] == '5') && (str[3] == ' ') && (str[4] == '(')) { ptr = &str[5]; if (name != NULL) { *name = ptr; } if (NULL == (ptr = strchr(ptr, ')'))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_parse_md5: Missing ) in name: %s", str); return 1; } *ptr = '\0'; ptr++; if (4 + TSK_HDB_HTYPE_MD5_LEN > strlen(ptr)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_parse_md5: Invalid MD5 value: %s", ptr); return 1; } if ((*(ptr) != ' ') || (*(++ptr) != '=') || (*(++ptr) != ' ') || (!isxdigit((int) *(++ptr))) || (ptr[TSK_HDB_HTYPE_MD5_LEN] != '\n')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_parse_md5: Invalid hash value %s", ptr); return 1; } *md5 = ptr; ptr[TSK_HDB_HTYPE_MD5_LEN] = '\0'; } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_parse_md5: Invalid md5sum format in file: %s\n", str); return 1; } return 0; } /** * Process the database to create a sorted index of it. Consecutive * entries with the same hash value are not added to the index, but * will be found during lookup. * * @param hdb_info Hash database to make index of. * @param dbtype Type of hash database (should always be TSK_HDB_DBTYPE_MD5SUM_STR) * * @return 1 on error and 0 on success. */ uint8_t md5sum_makeindex(TSK_HDB_INFO * hdb_info, TSK_TCHAR * dbtype) { int i; char buf[TSK_HDB_MAXLEN]; char *hash = NULL, phash[TSK_HDB_HTYPE_MD5_LEN + 1]; TSK_OFF_T offset = 0; int db_cnt = 0, idx_cnt = 0, ig_cnt = 0; size_t len; /* Initialize the TSK index file */ if (tsk_hdb_idxinitialize(hdb_info, dbtype)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "md5sum_makeindex"); return 1; } /* Status */ if (tsk_verbose) TFPRINTF(stderr, _TSK_T("Extracting Data from Database (%s)\n"), hdb_info->db_fname); /* Allocate a buffer for the previous hash value */ memset(phash, '0', TSK_HDB_HTYPE_MD5_LEN + 1); /* read the file and add to the index */ fseek(hdb_info->hDb, 0, SEEK_SET); for (i = 0; NULL != fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb); offset += (TSK_OFF_T) len, i++) { len = strlen(buf); /* Parse each line */ if (md5sum_parse_md5(buf, &hash, NULL)) { ig_cnt++; continue; } db_cnt++; /* We only want to add one of each hash to the index */ if (memcmp(hash, phash, TSK_HDB_HTYPE_MD5_LEN) == 0) { continue; } /* Add the entry to the index */ if (tsk_hdb_idxaddentry(hdb_info, hash, offset)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "md5sum_makeindex"); return 1; } idx_cnt++; /* Set the previous has value */ strncpy(phash, hash, TSK_HDB_HTYPE_MD5_LEN + 1); } if (idx_cnt > 0) { if (tsk_verbose) { fprintf(stderr, " Valid Database Entries: %d\n", db_cnt); fprintf(stderr, " Invalid Database Entries (headers or errors): %d\n", ig_cnt); fprintf(stderr, " Index File Entries %s: %d\n", (idx_cnt == db_cnt) ? "" : "(optimized)", idx_cnt); } /* Close and sort the index */ if (tsk_hdb_idxfinalize(hdb_info)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "md5sum_makeindex"); return 1; } } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_makeindex: No valid entries found in database"); return 1; } return 0; } /** * Find the corresponding name at a * given offset. The offset was likely determined from the index. * The entries in the DB following the one specified are also processed * if they have the same hash value and their name is different. * The callback is called for each entry. * * @param hdb_info Hash database to get data from * @param hash MD5 hash value that was searched for * @param offset Byte offset where hash value should be located in db_file * @param flags (not used) * @param action Callback used for each entry found in lookup * @param cb_ptr Pointer to data passed to callback * * @return 1 on error and 0 on succuss */ uint8_t md5sum_getentry(TSK_HDB_INFO * hdb_info, const char *hash, TSK_OFF_T offset, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *cb_ptr) { char buf[TSK_HDB_MAXLEN], *name, *ptr = NULL, pname[TSK_HDB_MAXLEN]; int found = 0; if (tsk_verbose) fprintf(stderr, "md5sum_getentry: Lookup up hash %s at offset %" PRIuOFF "\n", hash, offset); if (strlen(hash) != TSK_HDB_HTYPE_MD5_LEN) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Invalid hash value: %s", hash); return 1; } memset(pname, '0', TSK_HDB_MAXLEN); /* Loop so that we can find multiple occurances of the same hash */ while (1) { size_t len; if (0 != fseeko(hdb_info->hDb, offset, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Error seeking to get file name: %lu", (unsigned long) offset); return 1; } if (NULL == fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb)) { if (feof(hdb_info->hDb)) { break; } tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Error reading database"); return 1; } len = strlen(buf); if (len < TSK_HDB_HTYPE_MD5_LEN) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Invalid entry in database (too short): %s", buf); return 1; } if (md5sum_parse_md5(buf, &ptr, &name)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Invalid entry in database: %s", buf); return 1; } /* Is this the one that we want? */ if (0 != strcasecmp(ptr, hash)) { break; } if (strcmp(name, pname) != 0) { int retval; retval = action(hdb_info, hash, name, cb_ptr); if (retval == TSK_WALK_ERROR) { return 1; } else if (retval == TSK_WALK_STOP) { return 0; } found = 1; strncpy(pname, name, TSK_HDB_MAXLEN); } /* Advance to the next row */ offset += len; } if (found == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "md5sum_getentry: Hash not found in file at offset: %lu", (unsigned long) offset); return 1; } return 0; } sleuthkit-3.2.3/tsk3/hashdb/nsrl_index.c000644 000765 000024 00000045572 11643647440 021001 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * * This software is distributed under the Common Public License 1.0 */ #include "tsk_hashdb_i.h" /** * \file nsrl_index.c * NSRL specific functions to read the database. */ /** * Version of NSRL Database */ enum TSK_HDB_NSRL_FORM_ENUM { TSK_HDB_NSRL_FORM1 = (1 << 0), ///< Version 1 TSK_HDB_NSRL_FORM2 = (1 << 1) ///< Version 2 }; typedef enum TSK_HDB_NSRL_FORM_ENUM TSK_HDB_NSRL_FORM_ENUM; /** * Analyze the header line of the database to determine the version of NSRL * * @param str line from the database file * * @return version or -1 on error */ static int get_format_ver(char *str) { /* "SHA-1","FileName","FileSize","ProductCode","OpSystemCode","MD4","MD5","CRC32","SpecialCode" */ if ((str[9] == 'F') && (str[20] == 'F') && (str[24] == 'S') && (str[31] == 'P') && (str[45] == 'O')) return TSK_HDB_NSRL_FORM1; /* "SHA-1","MD5","CRC32","FileName","FileSize","ProductCode","OpSystemCode","Specia lCode" */ else if ((str[9] == 'M') && (str[15] == 'C') && (str[23] == 'F') && (str[34] == 'F') && (str[45] == 'P')) return TSK_HDB_NSRL_FORM2; tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl: Unknown header format: %s\n", str); return -1; } /** * Test the file to see if it is an NSRL database * * @param hFile File handle to hash database * * @return 1 if NSRL and 0 if not */ uint8_t nsrl_test(FILE * hFile) { char buf[TSK_HDB_MAXLEN]; fseeko(hFile, 0, SEEK_SET); if (NULL == fgets(buf, TSK_HDB_MAXLEN, hFile)) return 0; if (strlen(buf) < 45) return 0; // Basic checks in first field if ((buf[0] != '"') || (buf[1] != 'S') || (buf[2] != 'H') || (buf[3] != 'A') || (buf[4] != '-') || (buf[5] != '1') || (buf[6] != '"')) return 0; if (-1 == get_format_ver(buf)) return 0; return 1; } /** * Perform a basic check on a string to see if it starts with quotes * and contains a possible SHA-1 value * * @param x string to test * @return 1 if NSRL and 0 if not */ #define is_valid_nsrl(x) \ ( (strlen((x)) > TSK_HDB_HTYPE_SHA1_LEN + 4) && \ ((x)[0] == '"') && ((x)[TSK_HDB_HTYPE_SHA1_LEN + 1] == '"') && \ ((x)[TSK_HDB_HTYPE_SHA1_LEN + 2] == ',') && ((x)[TSK_HDB_HTYPE_SHA1_LEN + 3] == '"') ) /** * Parse a line from the NSRL database and set pointers to the SHA1 and Name. This will modify * the input text by adding NULL values! * * @param str String to parse * @param sha1 Pointer to a pointer that will contain location of SHA1 in original text * @param name Pointer to a pointer that will contain location of the name in original text * @param ver Version of NSRL we are parsing * * @return 1 on error and 0 on success */ static uint8_t nsrl_parse_sha1(char *str, char **sha1, char **name, int ver) { char *ptr = NULL; /* Sanity check */ if (is_valid_nsrl(str) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_sha1: Invalid string to parse: %s", str); return 1; } /* Do they want the hash? */ if (sha1 != NULL) { /* set the hash pointer to just the SHA value (past the ") */ ptr = &str[1]; ptr[TSK_HDB_HTYPE_SHA1_LEN] = '\0'; /* Final sanity check to make sure there are no ',' in hash */ if (NULL != strchr(ptr, ',')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_sha1: Invalid string to parse (commas after SHA1): %s", ptr); return 1; } /* Assign the argument if it is not NULL */ *sha1 = ptr; } /* Do they want the name? */ if (name != NULL) { if (ver == TSK_HDB_NSRL_FORM1) { /* Extract out the name - the field after SHA1 */ ptr = &str[TSK_HDB_HTYPE_SHA1_LEN + 4]; // 4 = 3 " and 1 , *name = ptr; if (NULL == (ptr = strchr(ptr, ','))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_sha1: Invalid string to parse (commas after name): %s", ptr); return 1; } /* Seek back to cover the final " */ ptr[-1] = '\0'; } else if (ver == TSK_HDB_NSRL_FORM2) { /* Extract out the name - the field after SHA1, MD5, and CRC */ ptr = &str[1 + TSK_HDB_HTYPE_SHA1_LEN + 3 + TSK_HDB_HTYPE_MD5_LEN + 3 + TSK_HDB_HTYPE_CRC32_LEN + 3]; *name = ptr; if (NULL == (ptr = strchr(ptr, ','))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_sha1: Invalid string to parse (commas after name): %s", ptr); return 1; } /* Seek back to cover the final " */ ptr[-1] = '\0'; } } return 0; } /** * Parse a line from the NSRL database and set pointers to the MD5 and Name. This will modify * the input text by adding NULL values! * * @param str String to parse * @param md5 Pointer to a pointer that will contain location of MD5 in original text * @param name Pointer to a pointer that will contain location of the name in original text * @param ver Version of NSRL we are parsing * * @return 1 on error and 0 on success */ static uint8_t nsrl_parse_md5(char *str, char **md5, char **name, int ver) { char *ptr = NULL; int cnt = 0; /* Sanity check */ if (is_valid_nsrl(str) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Invalid string to parse: %s", str); return 1; } if ((md5 == NULL) && (name == NULL)) return 0; if (ver == TSK_HDB_NSRL_FORM1) { ptr = str; /* Cycle through the fields to extract name and MD5 * * 1. before name * 2. before size * 3. before prod code * 4. before OS * 5. before MD4 * 6. before MD5 */ cnt = 0; while (NULL != (ptr = strchr(ptr, ','))) { cnt++; /* Begining of the name */ if ((cnt == 1) && (name != NULL)) { *name = &ptr[2]; /* We utilize the other loop code to find the end of * the name */ } /* end of the name */ else if ((cnt == 2) && (name != NULL)) { if (ptr[-1] != '"') { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Missing Quote after name: %s", (char *) name); return 1; } ptr[-1] = '\0'; if (md5 == NULL) return 0; } /* MD5 value */ else if ((cnt == 6) && (md5 != NULL)) { /* Do a length check and more sanity checks */ if ((strlen(ptr) < 2 + TSK_HDB_HTYPE_MD5_LEN) || (ptr[1] != '"') || (ptr[2 + TSK_HDB_HTYPE_MD5_LEN] != '"')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Invalid MD5 value: %s", ptr); return 1; } ptr = &ptr[2]; ptr[TSK_HDB_HTYPE_MD5_LEN] = '\0'; *md5 = ptr; /* Final sanity check */ if (NULL != strchr(ptr, ',')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Missing comma after MD5: %s", (char *) md5); return 1; } return 0; } /* If the next field is in quotes then we need to skip to the * next quote and ignore any ',' in there */ if (ptr[1] == '"') { if (NULL == (ptr = strchr(&ptr[2], '"'))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Error advancing past quote"); return 1; } } else { ptr++; } } } else if (ver == TSK_HDB_NSRL_FORM2) { /* Do they want the hash? */ if (md5 != NULL) { /* set the hash pointer to just the MD5 value (past the SHA1") */ ptr = &str[1 + TSK_HDB_HTYPE_SHA1_LEN + 3]; ptr[TSK_HDB_HTYPE_MD5_LEN] = '\0'; /* Final sanity check to make sure there are no ',' in hash */ if (NULL != strchr(ptr, ',')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Comma in MD5 value: %s", ptr); return 1; } *md5 = ptr; } /* do they want the name */ if (name != NULL) { /* Extract out the name - the field after SHA1, MD5, and CRC */ ptr = &str[1 + TSK_HDB_HTYPE_SHA1_LEN + 3 + TSK_HDB_HTYPE_MD5_LEN + 3 + TSK_HDB_HTYPE_CRC32_LEN + 3]; *name = ptr; if (NULL == (ptr = strchr(ptr, ','))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Missing comma after name: %s", (char *) name); return 1; } /* Seek back to cover the final " */ ptr -= 1; *ptr = '\0'; } return 0; } tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_parse_md5: Invalid version: %d\n", ver); return 1; } /** * Process the database to create a sorted index of it. Consecutive * entries with the same hash value are not added to the index, but * will be found during lookup. * * @param hdb_info Hash database to make index of. * @param dbtype Type of database * * @return 1 on error and 0 on success. */ uint8_t nsrl_makeindex(TSK_HDB_INFO * hdb_info, TSK_TCHAR * dbtype) { size_t i, len; char buf[TSK_HDB_MAXLEN]; char *hash = NULL, phash[TSK_HDB_HTYPE_SHA1_LEN + 1]; TSK_OFF_T offset = 0; int ver = 0; int db_cnt = 0, idx_cnt = 0, ig_cnt = 0; if (tsk_hdb_idxinitialize(hdb_info, dbtype)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "nsrl_makeindex"); return 1; } /* Status */ if (tsk_verbose) TFPRINTF(stderr, _TSK_T("Extracting Data from Database (%s)\n"), hdb_info->db_fname); /* Allocate a buffer for the previous hash value */ memset(phash, '0', TSK_HDB_HTYPE_SHA1_LEN + 1); /* read the file */ fseek(hdb_info->hDb, 0, SEEK_SET); for (i = 0; NULL != fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb); offset += len, i++) { len = strlen(buf); /* Get the version of the database on the first time around */ if (i == 0) { if ((ver = get_format_ver(buf)) == -1) { return 1; } ig_cnt++; continue; } /* Parse the line */ if (hdb_info->hash_type & TSK_HDB_HTYPE_SHA1_ID) { if (nsrl_parse_sha1(buf, &hash, NULL, ver)) { ig_cnt++; continue; } } else if (hdb_info->hash_type & TSK_HDB_HTYPE_MD5_ID) { if (nsrl_parse_md5(buf, &hash, NULL, ver)) { ig_cnt++; continue; } } db_cnt++; /* We only want to add one of each hash to the index */ if (memcmp(hash, phash, hdb_info->hash_len) == 0) { continue; } /* Add the entry to the index */ if (tsk_hdb_idxaddentry(hdb_info, hash, offset)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "nsrl_makeindex"); return 1; } idx_cnt++; /* Set the previous has value */ strncpy(phash, hash, hdb_info->hash_len + 1); } if (idx_cnt > 0) { if (tsk_verbose) { fprintf(stderr, " Valid Database Entries: %d\n", db_cnt); fprintf(stderr, " Invalid Database Entries (headers or errors): %d\n", ig_cnt); fprintf(stderr, " Index File Entries %s: %d\n", (idx_cnt == db_cnt) ? "" : "(optimized)", idx_cnt); } /* Close and sort the index */ if (tsk_hdb_idxfinalize(hdb_info)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "nsrl_makeindex"); return 1; } } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_makeindex: No valid entries found in database"); return 1; } return 0; } /** * Find the corresponding name at a * given offset. The offset was likely determined from the index. * The entries in the DB following the one specified are also processed * if they have the same hash value and their name is different. * The callback is called for each entry. * * @param hdb_info Database to get data from. * @param hash MD5/SHA-1 hash value that was searched for * @param offset Byte offset where hash value should be located in db_file * @param flags (not used) * @param action Callback used for each entry found in lookup * @param cb_ptr Pointer to data passed to callback * * @return 1 on error and 0 on success */ uint8_t nsrl_getentry(TSK_HDB_INFO * hdb_info, const char *hash, TSK_OFF_T offset, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *cb_ptr) { char buf[TSK_HDB_MAXLEN], *name, *cur_hash, pname[TSK_HDB_MAXLEN]; int found = 0; int ver; if (tsk_verbose) fprintf(stderr, "nsrl_getentry: Lookup up hash %s at offset %" PRIuOFF "\n", hash, offset); if ((hdb_info->hash_type == TSK_HDB_HTYPE_MD5_ID) && (strlen(hash) != TSK_HDB_HTYPE_MD5_LEN)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Invalid hash value (expected to be MD5): %s\n", hash); return 1; } else if ((hdb_info->hash_type == TSK_HDB_HTYPE_SHA1_ID) && (strlen(hash) != TSK_HDB_HTYPE_SHA1_LEN)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Invalid hash value (expected to be SHA1): %s\n", hash); return 1; } /* read the header line ... -- this should be done only once... */ fseeko(hdb_info->hDb, 0, SEEK_SET); if (NULL == fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Error reading NSRLFile.txt header\n"); return 1; } if ((ver = get_format_ver(buf)) == -1) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "nsrl_getentry"); return 1; } memset(pname, '0', TSK_HDB_MAXLEN); /* Loop so that we can find consecutive occurances of the same hash */ while (1) { size_t len; if (0 != fseeko(hdb_info->hDb, offset, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Error seeking to get file name: %lu", (unsigned long) offset); return 1; } if (NULL == fgets(buf, TSK_HDB_MAXLEN, hdb_info->hDb)) { if (feof(hdb_info->hDb)) break; tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READDB; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Error reading database"); return 1; } len = strlen(buf); if (len < TSK_HDB_HTYPE_SHA1_LEN + 5) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Invalid entry in database (too short): %s", buf); return 1; } /* Which field are we looking for */ if (hdb_info->hash_type == TSK_HDB_HTYPE_SHA1_ID) { if (nsrl_parse_sha1(buf, &cur_hash, &name, ver)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Invalid entry in database: %s", buf); return 1; } } else if (hdb_info->hash_type == TSK_HDB_HTYPE_MD5_ID) { if (nsrl_parse_md5(buf, &cur_hash, &name, ver)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Invalid entry in database: %s", buf); return 1; } } /* Verify that this is the hash we are looking for */ if (0 != strcasecmp(cur_hash, hash)) { break; } /* Check if this is the same name as the previous entry */ if (strcmp(name, pname) != 0) { int retval; retval = action(hdb_info, hash, name, cb_ptr); if (retval == TSK_WALK_STOP) return 0; else if (retval == TSK_WALK_ERROR) return 1; found = 1; strncpy(pname, name, TSK_HDB_MAXLEN); } /* Advance to the next row */ offset += len; } if (found == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nsrl_getentry: Hash not found in file at offset: %lu", (unsigned long) offset); return 1; } return 0; } sleuthkit-3.2.3/tsk3/hashdb/tm_lookup.c000644 000765 000024 00000107621 11643647440 020637 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * * This software is distributed under the Common Public License 1.0 */ #include "tsk_hashdb_i.h" /** * \file tm_lookup.c * Contains the generic hash database creation and lookup code. */ /** * Setup the hash-type specific information (such as length, index entry * sizes, index name etc.) in the HDB_INFO structure. * * @param hdb_info Structure to fill in. * @param htype Hash type being used * @return 1 on error and 0 on success */ static uint8_t hdb_setuphash(TSK_HDB_INFO * hdb_info, uint8_t htype) { size_t flen; if (hdb_info->hash_type != 0) { return 0; } /* Make the name for the index file */ flen = TSTRLEN(hdb_info->db_fname) + 32; hdb_info->idx_fname = (TSK_TCHAR *) tsk_malloc(flen * sizeof(TSK_TCHAR)); if (hdb_info->idx_fname == NULL) { return 1; } /* Get hash type specific information */ switch (htype) { case TSK_HDB_HTYPE_MD5_ID: hdb_info->hash_type = htype; hdb_info->hash_len = TSK_HDB_HTYPE_MD5_LEN; hdb_info->idx_llen = TSK_HDB_IDX_LEN(htype); TSNPRINTF(hdb_info->idx_fname, flen, _TSK_T("%s-%") PRIcTSK _TSK_T(".idx"), hdb_info->db_fname, TSK_HDB_HTYPE_MD5_STR); return 0; case TSK_HDB_HTYPE_SHA1_ID: hdb_info->hash_type = htype; hdb_info->hash_len = TSK_HDB_HTYPE_SHA1_LEN; hdb_info->idx_llen = TSK_HDB_IDX_LEN(htype); TSNPRINTF(hdb_info->idx_fname, flen, _TSK_T("%s-%") PRIcTSK _TSK_T(".idx"), hdb_info->db_fname, TSK_HDB_HTYPE_SHA1_STR); return 0; } tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setuphash: Invalid hash type as argument: %d", htype); return 1; } /** Initialize the TSK hash DB index file. This creates the intermediate file, * which will have entries added to it. This file must be sorted before the * process is finished. * * @param hdb_info Hash database state structure * @param htype String of index type to create * * @return 1 on error and 0 on success * */ uint8_t tsk_hdb_idxinitialize(TSK_HDB_INFO * hdb_info, TSK_TCHAR * htype) { size_t flen; char dbtmp[32]; int i; /* Use the string of the index/hash type to figure out some * settings */ // convert to char -- cheating way to deal with WCHARs.. for (i = 0; i < 31 && htype[i] != '\0'; i++) { dbtmp[i] = (char) htype[i]; } dbtmp[i] = '\0'; if (strcmp(dbtmp, TSK_HDB_DBTYPE_NSRL_MD5_STR) == 0) { if (hdb_info->db_type != TSK_HDB_DBTYPE_NSRL_ID) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: database detected as: %d index creation as: %d", hdb_info->db_type, TSK_HDB_DBTYPE_NSRL_ID); return 1; } hdb_setuphash(hdb_info, TSK_HDB_HTYPE_MD5_ID); } else if (strcmp(dbtmp, TSK_HDB_DBTYPE_NSRL_SHA1_STR) == 0) { if (hdb_info->db_type != TSK_HDB_DBTYPE_NSRL_ID) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: database detected as: %d index creation as: %d", hdb_info->db_type, TSK_HDB_DBTYPE_NSRL_ID); return 1; } hdb_setuphash(hdb_info, TSK_HDB_HTYPE_SHA1_ID); } else if (strcmp(dbtmp, TSK_HDB_DBTYPE_MD5SUM_STR) == 0) { if (hdb_info->db_type != TSK_HDB_DBTYPE_MD5SUM_ID) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: database detected as: %d index creation as: %d", hdb_info->db_type, TSK_HDB_DBTYPE_MD5SUM_ID); return 1; } hdb_setuphash(hdb_info, TSK_HDB_HTYPE_MD5_ID); } else if (strcmp(dbtmp, TSK_HDB_DBTYPE_HK_STR) == 0) { if (hdb_info->db_type != TSK_HDB_DBTYPE_HK_ID) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: database detected as: %d index creation as: %d", hdb_info->db_type, TSK_HDB_DBTYPE_HK_ID); return 1; } hdb_setuphash(hdb_info, TSK_HDB_HTYPE_MD5_ID); } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: Unknown database type request: %s", dbtmp); return 1; } /* Setup the internal hash information */ if (hdb_setuphash(hdb_info, hdb_info->hash_type)) { return 1; } /* Make the name for the unsorted intermediate index file */ flen = TSTRLEN(hdb_info->db_fname) + 32; hdb_info->uns_fname = (TSK_TCHAR *) tsk_malloc(flen * sizeof(TSK_TCHAR)); if (hdb_info->uns_fname == NULL) { return 1; } TSNPRINTF(hdb_info->uns_fname, flen, _TSK_T("%s-%") PRIcTSK _TSK_T("-ns.idx"), hdb_info->db_fname, TSK_HDB_HTYPE_STR(hdb_info->hash_type)); /* Create temp unsorted file of offsets */ #ifdef TSK_WIN32 { HANDLE hWin; if ((hWin = CreateFile(hdb_info->uns_fname, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CREATE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: %"PRIttocTSK" GetFileSize: %d", hdb_info->uns_fname, (int)GetLastError()); return 1; } hdb_info->hIdxTmp = _fdopen(_open_osfhandle((intptr_t) hWin, _O_WRONLY), "wb"); if (hdb_info->hIdxTmp == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_idxinitialize: Error converting Windows handle to C handle"); free(hdb_info); return 1; } } #else if (NULL == (hdb_info->hIdxTmp = fopen(hdb_info->uns_fname, "w"))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CREATE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating temp index file: %s", hdb_info->uns_fname); return 1; } #endif /* Print the header */ switch (hdb_info->db_type) { case TSK_HDB_DBTYPE_NSRL_ID: fprintf(hdb_info->hIdxTmp, "%s|%s\n", TSK_HDB_IDX_HEAD_STR, TSK_HDB_DBTYPE_NSRL_STR); break; case TSK_HDB_DBTYPE_MD5SUM_ID: fprintf(hdb_info->hIdxTmp, "%s|%s\n", TSK_HDB_IDX_HEAD_STR, TSK_HDB_DBTYPE_MD5SUM_STR); break; case TSK_HDB_DBTYPE_HK_ID: fprintf(hdb_info->hIdxTmp, "%s|%s\n", TSK_HDB_IDX_HEAD_STR, TSK_HDB_DBTYPE_HK_STR); break; /* Used to stop warning messages about missing enum value */ case TSK_HDB_DBTYPE_IDXONLY_ID: default: tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CREATE; snprintf(tsk_errstr, TSK_ERRSTR_L, "idxinit: Invalid db type\n"); return 1; } return 0; } /** * Add an entry to the intermediate index file. * * @param hdb_info Hash database state info * @param hvalue Hash value to add * @param offset Byte offset of hash entry in original database. * @return 1 on error and 0 on success */ uint8_t tsk_hdb_idxaddentry(TSK_HDB_INFO * hdb_info, char *hvalue, TSK_OFF_T offset) { int i; // make the hashes all upper case for (i = 0; hvalue[i] != '\0'; i++) { if (islower((int) hvalue[i])) fprintf(hdb_info->hIdxTmp, "%c", toupper((int) hvalue[i])); else fprintf(hdb_info->hIdxTmp, "%c", hvalue[i]); } /* Print the entry to the unsorted index file */ fprintf(hdb_info->hIdxTmp, "|%.16llu\n", (unsigned long long) offset); return 0; } /** * Finalize index creation process by sorting the index and removing the * intermediate temp file. * * @param hdb_info Hash database state info structure. * @return 1 on error and 0 on success */ uint8_t tsk_hdb_idxfinalize(TSK_HDB_INFO * hdb_info) { #ifdef TSK_WIN32 wchar_t buf[TSK_HDB_MAXLEN]; /// @@ Expand this to be SYSTEM_ROOT -- GetWindowsDirectory() wchar_t *sys32 = _TSK_T("C:\\WINDOWS\\System32\\sort.exe"); DWORD stat; STARTUPINFO myStartInfo; PROCESS_INFORMATION pinfo; /* Close the unsorted file */ fclose(hdb_info->hIdxTmp); hdb_info->hIdxTmp = NULL; /* Close the existing index if it is open */ if (hdb_info->hIdx) { fclose(hdb_info->hIdx); hdb_info->hIdx = NULL; } if (tsk_verbose) tsk_fprintf(stderr, "hdb_idxfinalize: Sorting index\n"); stat = GetFileAttributes(sys32); if ((stat != -1) && ((stat & FILE_ATTRIBUTE_DIRECTORY) == 0)) { TSNPRINTF(buf, TSK_HDB_MAXLEN, _TSK_T("%s /o \"%s\" \"%s\""), sys32, hdb_info->idx_fname, hdb_info->uns_fname); } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_MISSING; snprintf(tsk_errstr, TSK_ERRSTR_L, "Cannot find sort executable"); return 1; } GetStartupInfo(&myStartInfo); if (FALSE == CreateProcess(NULL, buf, NULL, NULL, FALSE, 0, NULL, NULL, &myStartInfo, &pinfo)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_PROC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error starting sorting index file using %S", buf); return 1; } if (WAIT_FAILED == WaitForSingleObject(pinfo.hProcess, INFINITE)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_PROC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error (waiting) sorting index file using %S", buf); return 1; } if (FALSE == DeleteFile(hdb_info->uns_fname)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_DELETE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error deleting temp file: %d", (int)GetLastError()); return 1; } #else char buf[TSK_HDB_MAXLEN]; char *root = "/bin/sort"; char *usr = "/usr/bin/sort"; char *local = "/usr/local/bin/sort"; struct stat stats; if (tsk_verbose) tsk_fprintf(stderr, "hdb_idxfinalize: Sorting index\n"); /* Close the unsorted file */ fclose(hdb_info->hIdxTmp); hdb_info->hIdxTmp = NULL; /* Close the existing index if it is open */ if (hdb_info->hIdx) { fclose(hdb_info->hIdx); hdb_info->hIdx = NULL; } if (0 == stat(local, &stats)) { snprintf(buf, TSK_HDB_MAXLEN, "%s -o %s %s", local, hdb_info->idx_fname, hdb_info->uns_fname); } else if (0 == stat(usr, &stats)) { snprintf(buf, TSK_HDB_MAXLEN, "%s -o \"%s\" \"%s\"", usr, hdb_info->idx_fname, hdb_info->uns_fname); } else if (0 == stat(root, &stats)) { snprintf(buf, TSK_HDB_MAXLEN, "%s -o \"%s\" \"%s\"", root, hdb_info->idx_fname, hdb_info->uns_fname); } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_MISSING; snprintf(tsk_errstr, TSK_ERRSTR_L, "Cannot find sort executable"); return 1; } if (0 != system(buf)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_PROC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error sorting index file using %s", buf); return 1; } unlink(hdb_info->uns_fname); #endif return 0; } /** \internal * Setup the internal variables to read an index. This * opens the index and sets the needed size information. * * @param hdb_info Hash database to analyze * @param hash The hash type that was used to make the index. * * @return 1 on error and 0 on success */ static uint8_t hdb_setupindex(TSK_HDB_INFO * hdb_info, uint8_t htype) { char head[TSK_HDB_MAXLEN]; char *ptr; if ((htype != TSK_HDB_HTYPE_MD5_ID) && (htype != TSK_HDB_HTYPE_SHA1_ID)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Invalid hash type : %d", htype); return 1; } if (hdb_setuphash(hdb_info, htype)) { return 1; } /* Verify the index exists, get its size, and open it */ #ifdef TSK_WIN32 { HANDLE hWin; DWORD szLow, szHi; if (-1 == GetFileAttributes(hdb_info->idx_fname)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_MISSING; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error finding index file: %"PRIttocTSK, hdb_info->idx_fname); return 1; } if ((hWin = CreateFile(hdb_info->idx_fname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error opening index file: %"PRIttocTSK, hdb_info->idx_fname); return 1; } hdb_info->hIdx = _fdopen(_open_osfhandle((intptr_t) hWin, _O_RDONLY), "r"); if (hdb_info->hIdx == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error converting Windows handle to C handle"); return 1; } szLow = GetFileSize(hWin, &szHi); if (szLow == 0xffffffff) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error getting size of index file: %"PRIttocTSK" - %d", hdb_info->idx_fname, (int)GetLastError()); return 1; } hdb_info->idx_size = szLow | ((uint64_t) szHi << 32); } #else { struct stat sb; if (stat(hdb_info->idx_fname, &sb) < 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_MISSING; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error finding index file: %s", hdb_info->idx_fname); return 1; } hdb_info->idx_size = sb.st_size; if (NULL == (hdb_info->hIdx = fopen(hdb_info->idx_fname, "r"))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error opening index file: %s", hdb_info->idx_fname); return 1; } } #endif /* Do some testing on the first line */ if (NULL == fgets(head, TSK_HDB_MAXLEN, hdb_info->hIdx)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Header line of index file"); return 1; } if (strncmp(head, TSK_HDB_IDX_HEAD_STR, strlen(TSK_HDB_IDX_HEAD_STR)) != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Invalid index file: Missing header line"); return 1; } /* Set the offset to the start of the index entries */ hdb_info->idx_off = (uint16_t) strlen(head); /* Skip the space */ ptr = &head[strlen(TSK_HDB_IDX_HEAD_STR) + 1]; ptr[strlen(ptr) - 1] = '\0'; if ((ptr[strlen(ptr) - 1] == 10) || (ptr[strlen(ptr) - 1] == 13)) { ptr[strlen(ptr) - 1] = '\0'; hdb_info->idx_llen++; // make the expected index length longer to account for different cr/nl/etc. } /* Verify the header value in the index */ if (strcmp(ptr, TSK_HDB_DBTYPE_NSRL_STR) == 0) { if ((hdb_info->db_type != TSK_HDB_DBTYPE_NSRL_ID) && (hdb_info->db_type != TSK_HDB_DBTYPE_IDXONLY_ID)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_indexsetup: DB detected as %s, index type has NSRL", ptr); return 1; } } else if (strcmp(ptr, TSK_HDB_DBTYPE_MD5SUM_STR) == 0) { if ((hdb_info->db_type != TSK_HDB_DBTYPE_MD5SUM_ID) && (hdb_info->db_type != TSK_HDB_DBTYPE_IDXONLY_ID)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_indexsetup: DB detected as %s, index type has MD5SUM", ptr); return 1; } } else if (strcmp(ptr, TSK_HDB_DBTYPE_HK_STR) == 0) { if ((hdb_info->db_type != TSK_HDB_DBTYPE_HK_ID) && (hdb_info->db_type != TSK_HDB_DBTYPE_IDXONLY_ID)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_indexsetup: DB detected as %s, index type has hashkeeper", ptr); return 1; } } else if (hdb_info->db_type != TSK_HDB_DBTYPE_IDXONLY_ID) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Unknown Database Type in index header: %s", ptr); return 1; } /* Do some sanity checking */ if (((hdb_info->idx_size - hdb_info->idx_off) % hdb_info->idx_llen) != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_setupindex: Error, size of index file is not a multiple of row size"); return 1; } /* allocate a buffer for a row */ if ((hdb_info->idx_lbuf = tsk_malloc(hdb_info->idx_llen + 1)) == NULL) return 1; return 0; } /** * \ingroup hashdblib * Search the index for a text/ASCII hash value * * @param hdb_info Open hash database (with index) * @param hash Hash value to search for (NULL terminated string) * @param flags Flags to use in lookup * @param action Callback function to call for each hash db entry * (not called if QUICK flag is given) * @param ptr Pointer to data to pass to each callback * * @return -1 on error, 0 if hash value not found, and 1 if value was found. */ int8_t tsk_hdb_lookup_str(TSK_HDB_INFO * hdb_info, const char *hash, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *ptr) { TSK_OFF_T poffset; TSK_OFF_T up; // Offset of the first byte past the upper limit that we are looking in TSK_OFF_T low; // offset of the first byte of the lower limit that we are looking in int cmp; uint8_t wasFound = 0; size_t i; uint8_t htype; /* Sanity checks on the hash input */ if (strlen(hash) == TSK_HDB_HTYPE_MD5_LEN) { htype = TSK_HDB_HTYPE_MD5_ID; } else if (strlen(hash) == TSK_HDB_HTYPE_SHA1_LEN) { htype = TSK_HDB_HTYPE_SHA1_ID; } else { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Invalid hash length: %s", hash); return -1; } for (i = 0; i < strlen(hash); i++) { if (isxdigit((int) hash[i]) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Invalid hash value (hex only): %s", hash); return -1; } } /* See if we have had a lookup yet -- and therefore initialized the variables */ if (hdb_info->hIdx == NULL) { if (hdb_setupindex(hdb_info, htype)) return -1; } /* Sanity check */ if (hdb_info->hash_len != strlen(hash)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Hash passed is different size than expected (%d vs %Zd)", hdb_info->hash_len, strlen(hash)); return -1; } low = hdb_info->idx_off; up = hdb_info->idx_size; poffset = 0; while (1) { TSK_OFF_T offset; /* If top and bottom are the same, it's not there */ if (up == low) { return 0; } /* Get the middle of the windows that we are looking at */ offset = rounddown(((up - low) / 2), hdb_info->idx_llen); /* Sanity Check */ if ((offset % hdb_info->idx_llen) != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Error, new offset is not a multiple of the line length"); return -1; } /* The middle offset is relative to the low offset, so add them */ offset += low; /* If we didn't move, then it's not there */ if (poffset == offset) { return 0; } /* Seek to the offset and read it */ if (0 != fseeko(hdb_info->hIdx, offset, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Error seeking in search: %" PRIuOFF, offset); return -1; } if (NULL == fgets(hdb_info->idx_lbuf, (int) hdb_info->idx_llen + 1, hdb_info->hIdx)) { if (feof(hdb_info->hIdx)) { return 0; } tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error reading index file: %lu", (unsigned long) offset); return -1; } /* Sanity Check */ if ((strlen(hdb_info->idx_lbuf) < hdb_info->idx_llen) || (hdb_info->idx_lbuf[hdb_info->hash_len] != '|')) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid line in index file: %lu (%s)", (unsigned long) (offset / hdb_info->idx_llen), hdb_info->idx_lbuf); return -1; } /* Set the delimter to NULL so we can treat the hash as a string */ hdb_info->idx_lbuf[hdb_info->hash_len] = '\0'; cmp = strcasecmp(hdb_info->idx_lbuf, hash); /* The one we just read is too small, so set the new lower bound * at the start of the next row */ if (cmp < 0) { low = offset + hdb_info->idx_llen; } /* The one we just read is too big, so set the upper bound at this * entry */ else if (cmp > 0) { up = offset; } /* We found it */ else { wasFound = 1; if ((flags & TSK_HDB_FLAG_QUICK) || (hdb_info->db_type == TSK_HDB_DBTYPE_IDXONLY_ID)) { return 1; } else { TSK_OFF_T tmpoff, db_off; #ifdef TSK_WIN32 db_off = _atoi64(&hdb_info->idx_lbuf[hdb_info->hash_len + 1]); #else db_off = strtoull(&hdb_info->idx_lbuf[hdb_info->hash_len + 1], NULL, 10); #endif /* Print the one that we found first */ if (hdb_info-> getentry(hdb_info, hash, db_off, flags, action, ptr)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hdb_lookup"); return -1; } /* there could be additional entries both before and after * this entry - but we can restrict ourselves to the up * and low bounds from our previous hunting */ tmpoff = offset - hdb_info->idx_llen; while (tmpoff >= low) { /* Break if we are at the header */ if (tmpoff <= 0) break; if (0 != fseeko(hdb_info->hIdx, tmpoff, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Error seeking for prev entries: %" PRIuOFF, tmpoff); return -1; } if (NULL == fgets(hdb_info->idx_lbuf, (int) hdb_info->idx_llen + 1, hdb_info->hIdx)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error reading index file (prev): %lu", (unsigned long) tmpoff); return -1; } else if (strlen(hdb_info->idx_lbuf) < hdb_info->idx_llen) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid index file line (prev): %lu", (unsigned long) tmpoff); return -1; } hdb_info->idx_lbuf[hdb_info->hash_len] = '\0'; if (strcasecmp(hdb_info->idx_lbuf, hash) != 0) { break; } #ifdef TSK_WIN32 db_off = _atoi64(&hdb_info-> idx_lbuf[hdb_info->hash_len + 1]); #else db_off = strtoull(&hdb_info-> idx_lbuf[hdb_info->hash_len + 1], NULL, 10); #endif if (hdb_info-> getentry(hdb_info, hash, db_off, flags, action, ptr)) { return -1; } tmpoff -= hdb_info->idx_llen; } /* next entries */ tmpoff = offset + hdb_info->idx_llen; while (tmpoff < up) { if (0 != fseeko(hdb_info->hIdx, tmpoff, SEEK_SET)) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_lookup: Error seeking for next entries: %" PRIuOFF, tmpoff); return -1; } if (NULL == fgets(hdb_info->idx_lbuf, (int) hdb_info->idx_llen + 1, hdb_info->hIdx)) { if (feof(hdb_info->hIdx)) break; tsk_error_reset(); tsk_errno = TSK_ERR_HDB_READIDX; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error reading index file (next): %lu", (unsigned long) tmpoff); return -1; } else if (strlen(hdb_info->idx_lbuf) < hdb_info->idx_llen) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid index file line (next): %lu", (unsigned long) tmpoff); return -1; } hdb_info->idx_lbuf[hdb_info->hash_len] = '\0'; if (strcasecmp(hdb_info->idx_lbuf, hash) != 0) { break; } #ifdef TSK_WIN32 db_off = _atoi64(&hdb_info-> idx_lbuf[hdb_info->hash_len + 1]); #else db_off = strtoull(&hdb_info-> idx_lbuf[hdb_info->hash_len + 1], NULL, 10); #endif if (hdb_info-> getentry(hdb_info, hash, db_off, flags, action, ptr)) { return -1; } tmpoff += hdb_info->idx_llen; } } break; } poffset = offset; } return wasFound; } /** * \ingroup hashdblib * Search the index for the given hash value given (in binary form). * * @param hdb_info Open hash database (with index) * @param hash Array with binary hash value to search for * @param len Number of bytes in binary hash value * @param flags Flags to use in lookup * @param action Callback function to call for each hash db entry * (not called if QUICK flag is given) * @param ptr Pointer to data to pass to each callback * * @return -1 on error, 0 if hash value not found, and 1 if value was found. */ int8_t tsk_hdb_lookup_raw(TSK_HDB_INFO * hdb_info, uint8_t * hash, uint8_t len, TSK_HDB_FLAG_ENUM flags, TSK_HDB_LOOKUP_FN action, void *ptr) { char hashbuf[TSK_HDB_HTYPE_SHA1_LEN + 1]; int i; static char hex[] = "0123456789abcdef"; if (2 * len > TSK_HDB_HTYPE_SHA1_LEN) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_hdb_lookup_raw: hash value too long\n"); return -1; } for (i = 0; i < len; i++) { hashbuf[2 * i] = hex[(hash[i] >> 4) & 0xf]; hashbuf[2 * i + 1] = hex[hash[i] & 0xf]; } hashbuf[2 * len] = '\0'; return tsk_hdb_lookup_str(hdb_info, hashbuf, flags, action, ptr); } /** * \ingroup hashdblib * Determine if the open hash database has an index. * * @param hdb_info Hash database to consider * @param htype Hash type that index should be of * * @return 1 if index exists and 0 if not */ uint8_t tsk_hdb_hasindex(TSK_HDB_INFO * hdb_info, uint8_t htype) { /* Check if the index is already open, and * try to open it if not */ if (hdb_info->idx_size == 0) { if (hdb_setupindex(hdb_info, htype)) return 0; else return 1; } return 1; } /** * \ingroup hashdblib * Open a hash database. * * @param db_file Path to database. * @param flags Flags for opening the database. * * @return Poiner to hash database state structure or NULL on error */ TSK_HDB_INFO * tsk_hdb_open(TSK_TCHAR * db_file, TSK_HDB_OPEN_ENUM flags) { TSK_HDB_INFO *hdb_info; size_t flen; FILE *hDb; uint8_t dbtype = 0; if ((flags & TSK_HDB_OPEN_IDXONLY) == 0) { /* Open the database file */ #ifdef TSK_WIN32 { HANDLE hWin; if ((hWin = CreateFile(db_file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error opening database file: %S", db_file); return NULL; } hDb = _fdopen(_open_osfhandle((intptr_t) hWin, _O_RDONLY), "r"); if (hDb == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error converting Windows handle to C handle"); return NULL; } } #else if (NULL == (hDb = fopen(db_file, "r"))) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error opening database file: %s", db_file); return NULL; } #endif /* Try to figure out what type of DB it is */ if (nsrl_test(hDb)) { dbtype = TSK_HDB_DBTYPE_NSRL_ID; } if (md5sum_test(hDb)) { if (dbtype != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error determining DB type (MD5sum)"); return NULL; } dbtype = TSK_HDB_DBTYPE_MD5SUM_ID; } if (hk_test(hDb)) { if (dbtype != 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error determining DB type (HK)"); return NULL; } dbtype = TSK_HDB_DBTYPE_HK_ID; } if (dbtype == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_HDB_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hdb_open: Error determining DB type"); return NULL; } fseeko(hDb, 0, SEEK_SET); } else { dbtype = TSK_HDB_DBTYPE_IDXONLY_ID; hDb = NULL; } if ((hdb_info = (TSK_HDB_INFO *) tsk_malloc(sizeof(TSK_HDB_INFO))) == NULL) return NULL; hdb_info->hDb = hDb; /* Get database specific information */ hdb_info->db_type = dbtype; switch (dbtype) { case TSK_HDB_DBTYPE_NSRL_ID: hdb_info->getentry = nsrl_getentry; hdb_info->makeindex = nsrl_makeindex; break; case TSK_HDB_DBTYPE_MD5SUM_ID: hdb_info->getentry = md5sum_getentry; hdb_info->makeindex = md5sum_makeindex; break; case TSK_HDB_DBTYPE_HK_ID: hdb_info->getentry = hk_getentry; hdb_info->makeindex = hk_makeindex; break; case TSK_HDB_DBTYPE_IDXONLY_ID: hdb_info->getentry = idxonly_getentry; hdb_info->makeindex = idxonly_makeindex; break; default: return NULL; } hdb_info->hash_type = 0; hdb_info->hash_len = 0; hdb_info->idx_fname = NULL; hdb_info->uns_fname = NULL; hdb_info->hIdxTmp = NULL; hdb_info->hIdx = NULL; hdb_info->idx_size = 0; hdb_info->idx_off = 0; hdb_info->idx_lbuf = NULL; /* Copy the database name into the structure */ flen = TSTRLEN(db_file) + 8; // + 32; hdb_info->db_fname = (TSK_TCHAR *) tsk_malloc(flen * sizeof(TSK_TCHAR)); if (hdb_info->db_fname == NULL) { free(hdb_info); return NULL; } TSTRNCPY(hdb_info->db_fname, db_file, flen); return hdb_info; } /** * \ingroup hashdblib * Close an open hash database. * * @param hdb_info database to close */ void tsk_hdb_close(TSK_HDB_INFO * hdb_info) { if (hdb_info->hIdx) fclose(hdb_info->hIdx); if (hdb_info->hIdxTmp) fclose(hdb_info->hIdxTmp); // @@@ Could delete temp file too... if (hdb_info->idx_lbuf != NULL) free(hdb_info->idx_lbuf); if (hdb_info->db_fname) free(hdb_info->db_fname); if (hdb_info->uns_fname) free(hdb_info->uns_fname); if (hdb_info->idx_fname) free(hdb_info->idx_fname); if (hdb_info->hDb) fclose(hdb_info->hDb); free(hdb_info); } /** * \ingroup hashdblib * Create an index for an open hash database. * @param a_hdb_info Open hash database to index * @param a_type Text of hash database type * @returns 1 on error */ uint8_t tsk_hdb_makeindex(TSK_HDB_INFO * a_hdb_info, TSK_TCHAR * a_type) { return a_hdb_info->makeindex(a_hdb_info, a_type); } sleuthkit-3.2.3/tsk3/hashdb/tsk_hashdb.h000644 000765 000024 00000012710 11643647440 020737 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved */ /** * \file tsk_hashdb.h * External header file for hash database support. * Note that this file is not meant to be directly included. * It is included by both libtsk.h and tsk_hashdb_i.h. */ /** * \defgroup hashdblib Hash Database Functions */ #ifndef _TSK_HDB_H #define _TSK_HDB_H #ifdef __cplusplus extern "C" { #endif /** * Flags used for lookups */ enum TSK_HDB_FLAG_ENUM { TSK_HDB_FLAG_QUICK = 0x01, ///< Quickly return if hash is found (do not return file name etc.) TSK_HDB_FLAG_EXT = 0x02 ///< Return other details besides only file name (not used }; typedef enum TSK_HDB_FLAG_ENUM TSK_HDB_FLAG_ENUM; /** * Hash algorithm types */ enum TSK_HDB_HTYPE_ENUM { TSK_HDB_HTYPE_MD5_ID = 1, ///< MD5 Algorithm TSK_HDB_HTYPE_SHA1_ID = 2, ///< SHA1 Algorithm }; typedef enum TSK_HDB_HTYPE_ENUM TSK_HDB_HTYPE_ENUM; #define TSK_HDB_HTYPE_MD5_STR "md5" ///< String name for MD5 algorithm #define TSK_HDB_HTYPE_SHA1_STR "sha1" ///< String name for SHA1 algorithm #define TSK_HDB_HTYPE_SHA1_LEN 40 ///< Length of SHA1 hash #define TSK_HDB_HTYPE_MD5_LEN 32 ///< Length of MD5 hash #define TSK_HDB_HTYPE_CRC32_LEN 8 ///< Length of CRC hash /** * Return the name of the hash algorithm, given its ID */ #define TSK_HDB_HTYPE_STR(x) \ ( ((x) & TSK_HDB_HTYPE_MD5_ID) ? (TSK_HDB_HTYPE_MD5_STR) : ( \ ( ((x) & TSK_HDB_HTYPE_SHA1_ID) ? TSK_HDB_HTYPE_SHA1_STR : "") ) ) /** * Return the length of a hash, given its ID */ #define TSK_HDB_HTYPE_LEN(x) \ ( ((x) & TSK_HDB_HTYPE_MD5_ID) ? (TSK_HDB_HTYPE_MD5_LEN) : ( \ ( ((x) & TSK_HDB_HTYPE_SHA1_ID) ? TSK_HDB_HTYPE_SHA1_LEN : 0) ) ) /** * Hash Database types */ enum TSK_HDB_DBTYPE_ENUM { TSK_HDB_DBTYPE_NSRL_ID = 1, ///< NIST NSRL format TSK_HDB_DBTYPE_MD5SUM_ID = 2, ///< md5sum format TSK_HDB_DBTYPE_HK_ID = 3, ///< hashkeeper format TSK_HDB_DBTYPE_IDXONLY_ID = 4 ///< Only the database index was opened -- original dbtype is unknown }; typedef enum TSK_HDB_DBTYPE_ENUM TSK_HDB_DBTYPE_ENUM; /* String versions of DB types */ #define TSK_HDB_DBTYPE_NSRL_STR "nsrl" ///< NSRL String name #define TSK_HDB_DBTYPE_NSRL_MD5_STR "nsrl-md5" ///< NSRL md5 string name #define TSK_HDB_DBTYPE_NSRL_SHA1_STR "nsrl-sha1" ///< NSRL SHA1 string name #define TSK_HDB_DBTYPE_MD5SUM_STR "md5sum" ///< md5sum db string n ame #define TSK_HDB_DBTYPE_HK_STR "hk" ///< hash keeper string name /// List of supported data base types #define TSK_HDB_DBTYPE_SUPPORT_STR "nsrl-md5, nsrl-sha1, md5sum, hk" typedef struct TSK_HDB_INFO TSK_HDB_INFO; typedef TSK_WALK_RET_ENUM(*TSK_HDB_LOOKUP_FN) (TSK_HDB_INFO *, const char *hash, const char *name, void *); /** * Holds information about an open hash database. Created by * hdb_open and used for making an index and looking up values. */ struct TSK_HDB_INFO { TSK_TCHAR *db_fname; ///< Name of the database TSK_TCHAR *uns_fname; ///< Name of unsorted index file FILE *hDb; ///< File handle to database (always open) FILE *hIdxTmp; ///< File handle to temp (unsorted) index file (only open during index creation) FILE *hIdx; ///< File handle to index (only open during lookups) TSK_OFF_T idx_size; ///< Size of index file uint16_t idx_off; ///< Offset in index file to first index entry size_t idx_llen; ///< Length of each line in index char *idx_lbuf; ///< Buffer to hold a line from the index TSK_TCHAR *idx_fname; ///< Name of index file TSK_HDB_HTYPE_ENUM hash_type; ///< Type of hash used in index uint16_t hash_len; ///< Length of hash TSK_HDB_DBTYPE_ENUM db_type; ///< Type of database uint8_t(*getentry) (TSK_HDB_INFO *, const char *, TSK_OFF_T, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); ///< \internal Database-specific function to find entry at a given offset uint8_t(*makeindex) (TSK_HDB_INFO *, TSK_TCHAR *); ///< \internal Database-specific function to make index }; /** * Options for opening a hash database */ enum TSK_HDB_OPEN_ENUM { TSK_HDB_OPEN_NONE = 0, ///< No special flags TSK_HDB_OPEN_IDXONLY = (0x1 << 0) ///< Open only the index -- do not look for the original DB }; typedef enum TSK_HDB_OPEN_ENUM TSK_HDB_OPEN_ENUM; extern TSK_HDB_INFO *tsk_hdb_open(TSK_TCHAR * db_file, TSK_HDB_OPEN_ENUM flags); extern void tsk_hdb_close(TSK_HDB_INFO * hdb); extern uint8_t tsk_hdb_hasindex(TSK_HDB_INFO *, uint8_t htype); extern uint8_t tsk_hdb_makeindex(TSK_HDB_INFO *, TSK_TCHAR *); /* Functions */ extern int8_t tsk_hdb_lookup_str(TSK_HDB_INFO *, const char *, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); extern int8_t tsk_hdb_lookup_raw(TSK_HDB_INFO *, uint8_t * hash, uint8_t len, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/hashdb/tsk_hashdb_i.h000644 000765 000024 00000005274 11643647440 021256 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved */ /** * \file tsk_hashdb_i.h * Contains the internal library definitions for the hash database functions. This should * be included by the code in the hash database library. */ #ifndef _TSK_HASHDB_I_H #define _TSK_HASHDB_I_H // Include the other internal TSK header files #include "tsk3/base/tsk_base_i.h" // include the external header file #include "tsk_hashdb.h" #include #include #include #include #include #ifdef TSK_WIN32 #include #include #endif #ifdef __cplusplus extern "C" { #endif #define TSK_HDB_MAXLEN 512 ///< Default buffer size used in many places #define TSK_HDB_OFF_LEN 16 ///< Number of digits used in offset field in index /** * Get the length of an index file line - 2 for comma and newline */ #define TSK_HDB_IDX_LEN(x) \ ( TSK_HDB_HTYPE_LEN(x) + TSK_HDB_OFF_LEN + 2) /** * String used in index header. It is one longer than a * sha-1 hash - so that it always sorts to the top */ #define TSK_HDB_IDX_HEAD_STR "00000000000000000000000000000000000000000" extern uint8_t tsk_hdb_idxinitialize(TSK_HDB_INFO *, TSK_TCHAR * dbname); extern uint8_t tsk_hdb_idxaddentry(TSK_HDB_INFO *, char *hvalue, TSK_OFF_T offset); extern uint8_t tsk_hdb_idxfinalize(TSK_HDB_INFO *); /* Functions */ extern uint8_t nsrl_test(FILE *); extern uint8_t nsrl_makeindex(TSK_HDB_INFO *, TSK_TCHAR * htype); extern uint8_t nsrl_getentry(TSK_HDB_INFO *, const char *, TSK_OFF_T, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); extern uint8_t md5sum_test(FILE *); extern uint8_t md5sum_makeindex(TSK_HDB_INFO *, TSK_TCHAR * htype); extern uint8_t md5sum_getentry(TSK_HDB_INFO *, const char *, TSK_OFF_T, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); extern uint8_t hk_test(FILE *); extern uint8_t hk_makeindex(TSK_HDB_INFO *, TSK_TCHAR * htype); extern uint8_t hk_getentry(TSK_HDB_INFO *, const char *, TSK_OFF_T, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); extern uint8_t idxonly_makeindex(TSK_HDB_INFO *, TSK_TCHAR * htype); extern uint8_t idxonly_getentry(TSK_HDB_INFO *, const char *, TSK_OFF_T, TSK_HDB_FLAG_ENUM, TSK_HDB_LOOKUP_FN, void *); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/.indent.pro000644 000765 000024 00000000036 11643647437 017720 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nlp -nut sleuthkit-3.2.3/tsk3/fs/dcalc_lib.c000644 000765 000024 00000014322 11643647440 017674 0ustar00carrierstaff000000 000000 /* ** blkcalc ** The Sleuth Kit ** ** Calculates the corresponding block number between 'blkls' and 'dd' images ** when given an 'blkls' block number, it determines the block number it ** had in a 'dd' image. When given a 'dd' image, it determines the ** value it would have in a 'blkls' image (if the block is unallocated) ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All Rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All Rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file dcalc_lib.c * Contains the library API functions used by the TSK blkcalc command * line tool. */ #include "tsk_fs_i.h" /** \internal * Structure to store data for callbacks. */ typedef struct { TSK_DADDR_T count; TSK_DADDR_T uncnt; uint8_t found; TSK_OFF_T flen; } BLKCALC_DATA; /* function used when -d is given ** ** keeps a count of unallocated blocks seen thus far ** ** If the specified block is allocated, an error is given, else the ** count of unalloc blocks is given ** ** This is called for all blocks (alloc and unalloc) */ static TSK_WALK_RET_ENUM count_dd_act(const TSK_FS_BLOCK * fs_block, void *ptr) { BLKCALC_DATA *data = (BLKCALC_DATA *) ptr; if (fs_block->flags & TSK_FS_BLOCK_FLAG_UNALLOC) data->uncnt++; if (data->count-- == 0) { if (fs_block->flags & TSK_FS_BLOCK_FLAG_UNALLOC) tsk_printf("%" PRIuDADDR "\n", data->uncnt); else printf ("ERROR: unit is allocated, it will not be in an blkls image\n"); data->found = 1; return TSK_WALK_STOP; } return TSK_WALK_CONT; } /* ** count how many unalloc blocks there are. ** ** This is called for unalloc blocks only */ static TSK_WALK_RET_ENUM count_blkls_act(const TSK_FS_BLOCK * fs_block, void *ptr) { BLKCALC_DATA *data = (BLKCALC_DATA *) ptr; if (data->count-- == 0) { tsk_printf("%" PRIuDADDR "\n", fs_block->addr); data->found = 1; return TSK_WALK_STOP; } return TSK_WALK_CONT; } /* SLACK SPACE call backs */ static TSK_WALK_RET_ENUM count_slack_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { BLKCALC_DATA *data = (BLKCALC_DATA *) ptr; if (tsk_verbose) tsk_fprintf(stderr, "count_slack_file_act: Remaining File: %" PRIuOFF " Buffer: %" PRIuSIZE "\n", data->flen, size); /* This is not the last data unit */ if (data->flen >= size) { data->flen -= size; } /* We have passed the end of the allocated space */ else if (data->flen == 0) { if (data->count-- == 0) { tsk_printf("%" PRIuDADDR "\n", addr); data->found = 1; return TSK_WALK_STOP; } } /* This is the last data unit and there is unused space */ else if (data->flen < size) { if (data->count-- == 0) { tsk_printf("%" PRIuDADDR "\n", addr); data->found = 1; return TSK_WALK_STOP; } data->flen = 0; } return TSK_WALK_CONT; } static TSK_WALK_RET_ENUM count_slack_inode_act(TSK_FS_FILE * fs_file, void *ptr) { BLKCALC_DATA *data = (BLKCALC_DATA *) ptr; if (tsk_verbose) tsk_fprintf(stderr, "count_slack_inode_act: Processing meta data: %" PRIuINUM "\n", fs_file->meta->addr); /* We will now do a file walk on the content */ if (TSK_FS_TYPE_ISNTFS(fs_file->fs_info->ftype) == 0) { data->flen = fs_file->meta->size; if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_SLACK, count_slack_file_act, ptr)) { /* ignore any errors */ if (tsk_verbose) tsk_fprintf(stderr, "Error walking file %" PRIuINUM, fs_file->meta->addr); tsk_error_reset(); } } /* For NTFS we go through each non-resident attribute */ else { int i, cnt; cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if (fs_attr->flags & TSK_FS_ATTR_NONRES) { data->flen = fs_attr->size; if (tsk_fs_file_walk_type(fs_file, fs_attr->type, fs_attr->id, TSK_FS_FILE_WALK_FLAG_SLACK, count_slack_file_act, ptr)) { /* ignore any errors */ if (tsk_verbose) tsk_fprintf(stderr, "Error walking file %" PRIuINUM, fs_file->meta->addr); tsk_error_reset(); } } } } return TSK_WALK_CONT; } /* Return 1 if block is not found, 0 if it was found, and -1 on error */ int8_t tsk_fs_blkcalc(TSK_FS_INFO * fs, TSK_FS_BLKCALC_FLAG_ENUM a_lclflags, TSK_DADDR_T a_cnt) { BLKCALC_DATA data; data.count = a_cnt; data.found = 0; if (a_lclflags == TSK_FS_BLKCALC_BLKLS) { if (tsk_fs_block_walk(fs, fs->first_block, fs->last_block, (TSK_FS_BLOCK_FLAG_UNALLOC | TSK_FS_BLOCK_FLAG_META | TSK_FS_BLOCK_FLAG_CONT), count_blkls_act, &data)) return -1; } else if (a_lclflags == TSK_FS_BLKCALC_DD) { if (tsk_fs_block_walk(fs, fs->first_block, fs->last_block, (TSK_FS_BLOCK_FLAG_ALLOC | TSK_FS_BLOCK_FLAG_UNALLOC | TSK_FS_BLOCK_FLAG_META | TSK_FS_BLOCK_FLAG_CONT), count_dd_act, &data)) return -1; } else if (a_lclflags == TSK_FS_BLKCALC_SLACK) { if (fs->inode_walk(fs, fs->first_inum, fs->last_inum, TSK_FS_META_FLAG_ALLOC, count_slack_inode_act, &data)) return -1; } if (data.found == 0) { tsk_printf("Block too large\n"); return 1; } else { return 0; } } sleuthkit-3.2.3/tsk3/fs/dcat_lib.c000644 000765 000024 00000015004 11643647440 017537 0ustar00carrierstaff000000 000000 /* ** blkcat ** The Sleuth Kit ** ** Given an image , block number, and size, display the contents ** of the block to stdout. ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ #include "tsk_fs_i.h" #include /** * \file dcat_lib.c * Contains the library API functions used by the TSK blkcat command * line tool. */ /** * \internal * Print block statistics to stdout * * @param fs File system to analyze */ static void stats(TSK_FS_INFO * fs) { tsk_printf("%d: Size of Addressable Unit\n", fs->block_size); } /** * Read a specific number of blocks and print the contents to STDOUT * * @param fs File system to analyze * @param lclflags flags * @param addr Starting block address to read from * @param read_num_units Number of blocks to read * * @return 1 on error and 0 on success */ uint8_t tsk_fs_blkcat(TSK_FS_INFO * fs, TSK_FS_BLKCAT_FLAG_ENUM lclflags, TSK_DADDR_T addr, TSK_DADDR_T read_num_units) { char *buf; ssize_t cnt; int i; if (lclflags & TSK_FS_BLKCAT_STAT) { stats(fs); return 0; } if (addr + read_num_units - 1 > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_blkcat: requested size is larger than last block in image (%" PRIuDADDR ")", fs->last_block); return 1; } #ifdef TSK_WIN32 if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkcat_lib: error setting stdout to binary: %s", strerror(errno)); return 1; } #endif if (lclflags & TSK_FS_BLKCAT_HTML) { tsk_printf("\n"); tsk_printf("\n"); tsk_printf("Unit: %" PRIuDADDR " Size: %" PRIuOFF " bytes\n", addr, read_num_units * fs->block_size); tsk_printf("\n"); tsk_printf("\n"); } if ((lclflags & TSK_FS_BLKCAT_HEX) && (lclflags & TSK_FS_BLKCAT_HTML)) tsk_printf("\n"); if ((buf = tsk_malloc(fs->block_size)) == NULL) return 1; for (i = 0; i < read_num_units; i++) { /* Read the block */ cnt = tsk_fs_read_block(fs, addr + i, buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "blkcat: Error reading block at %" PRIuDADDR, addr); return 1; } /* do a hexdump like printout */ if (lclflags & TSK_FS_BLKCAT_HEX) { TSK_OFF_T idx1, idx2; for (idx1 = 0; idx1 < fs->block_size; idx1 += 16) { /* Print the offset */ if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("", i * fs->block_size + idx1); else tsk_printf("%" PRIuOFF "\t", i * fs->block_size + idx1); /* Print the hex */ for (idx2 = 0; idx2 < 16; idx2++) { if ((lclflags & TSK_FS_BLKCAT_HTML) && (0 == (idx2 % 4))) tsk_printf(""); else tsk_printf(" "); } } /* Print the ASCII */ tsk_printf("\t"); for (idx2 = 0; idx2 < 16; idx2++) { if ((lclflags & TSK_FS_BLKCAT_HTML) && (0 == (idx2 % 4))) tsk_printf(""); else tsk_printf(" "); } } if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf(""); tsk_printf("\n"); } } /* print in all ASCII */ else if (lclflags & TSK_FS_BLKCAT_ASCII) { TSK_OFF_T idx; for (idx = 0; idx < fs->block_size; idx++) { if ((isprint((int) buf[idx])) || (buf[idx] == '\t')) { tsk_printf("%c", buf[idx]); } else if ((buf[idx] == '\n') || (buf[idx] == '\r')) { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("
"); tsk_printf("%c", buf[idx]); } else tsk_printf("."); } } /* print raw */ else { if (fwrite(buf, fs->block_size, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkcat_lib: error writing to stdout: %s", strerror(errno)); free(buf); return 1; } } } free(buf); if (lclflags & TSK_FS_BLKCAT_HEX) { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("
%" PRIuOFF ""); tsk_printf("%.2x", buf[idx2 + idx1] & 0xff); if (3 == (idx2 % 4)) { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf(""); if ((isascii((int) buf[idx2 + idx1])) && (!iscntrl((int) buf[idx2 + idx1]))) tsk_printf("%c", buf[idx2 + idx1]); else tsk_printf("."); if (3 == (idx2 % 4)) { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("
\n"); else tsk_printf("\n"); } else if (lclflags & TSK_FS_BLKCAT_ASCII) { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("
"); tsk_printf("\n"); } else { if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("
"); } if (lclflags & TSK_FS_BLKCAT_HTML) tsk_printf("\n\n"); return 0; } sleuthkit-3.2.3/tsk3/fs/dls_lib.c000644 000765 000024 00000015471 11643647440 017416 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. ** */ /** * \file dls_lib.c * Contains the library API functions used by the TSK blkls command * line tool. */ /* TCT: * * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA */ #include "tsk_fs_i.h" #ifdef TSK_WIN32 #include #endif /* call backs for listing details * * return 1 on error * */ static uint8_t print_list_head(TSK_FS_INFO * fs) { char hostnamebuf[BUFSIZ]; #ifndef TSK_WIN32 if (gethostname(hostnamebuf, sizeof(hostnamebuf) - 1) < 0) { if (tsk_verbose) tsk_fprintf(stderr, "blkls_lib: error getting hostname: %s\n", strerror(errno)); strcpy(hostnamebuf, "unknown"); } hostnamebuf[sizeof(hostnamebuf) - 1] = 0; #else strcpy(hostnamebuf, "unknown"); #endif /* * Identify table type and table origin. */ tsk_printf("class|host|image|first_time|unit\n"); tsk_printf("blkls|%s||%" PRIu64 "|%s\n", hostnamebuf, (uint64_t) time(NULL), fs->duname); tsk_printf("addr|alloc\n"); return 0; } static TSK_WALK_RET_ENUM print_list(const TSK_FS_BLOCK * fs_block, void *ptr) { tsk_printf("%" PRIuDADDR "|%s\n", fs_block->addr, (fs_block->flags & TSK_FS_BLOCK_FLAG_ALLOC) ? "a" : "f"); return TSK_WALK_CONT; } /* print_block - write data block to stdout */ static TSK_WALK_RET_ENUM print_block(const TSK_FS_BLOCK * fs_block, void *ptr) { if (tsk_verbose) tsk_fprintf(stderr, "write block %" PRIuDADDR "\n", fs_block->addr); if (fwrite(fs_block->buf, fs_block->fs_info->block_size, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkls_lib: error writing to stdout: %s", strerror(errno)); return TSK_WALK_ERROR; } return TSK_WALK_CONT; } /** \internal * Structure to store data for callbacks. */ typedef struct { TSK_OFF_T flen; } BLKLS_DATA; /* SLACK SPACE call backs */ static TSK_WALK_RET_ENUM slack_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { BLKLS_DATA *data = (BLKLS_DATA *) ptr; if (tsk_verbose) tsk_fprintf(stderr, "slack_file_act: File: %" PRIuINUM " Remaining File: %" PRIuOFF " Buffer: %u\n", fs_file->meta->addr, data->flen, size); /* This is not the last data unit */ if (data->flen >= size) { data->flen -= size; } /* We have passed the end of the allocated space */ else if (data->flen == 0) { if (fwrite(buf, size, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkls_lib: error writing to stdout: %s", strerror(errno)); return TSK_WALK_ERROR; } } /* This is the last data unit and there is unused space */ else if (data->flen < size) { /* Clear the used space and print it */ memset(buf, 0, (size_t) data->flen); if (fwrite(buf, size, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkls_lib: error writing to stdout: %s", strerror(errno)); return TSK_WALK_ERROR; } data->flen = 0; } return TSK_WALK_CONT; } /* Call back for inode_walk */ static TSK_WALK_RET_ENUM slack_inode_act(TSK_FS_FILE * fs_file, void *ptr) { BLKLS_DATA *data = (BLKLS_DATA *) ptr; if (tsk_verbose) tsk_fprintf(stderr, "slack_inode_act: Processing meta data: %" PRIuINUM "\n", fs_file->meta->addr); /* We will now do a file walk on the content and print the * data after the specified size of the file */ if (TSK_FS_TYPE_ISNTFS(fs_file->fs_info->ftype) == 0) { data->flen = fs_file->meta->size; if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_SLACK, slack_file_act, ptr)) { if (tsk_verbose) tsk_fprintf(stderr, "slack_inode_act: error walking file: %" PRIuINUM, fs_file->meta->addr); tsk_error_reset(); } } /* For NTFS we go through each non-resident attribute */ else { int i, cnt; cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if (fs_attr->flags & TSK_FS_ATTR_NONRES) { data->flen = fs_attr->size; if (tsk_fs_file_walk_type(fs_file, fs_attr->type, fs_attr->id, TSK_FS_FILE_WALK_FLAG_SLACK, slack_file_act, ptr)) { if (tsk_verbose) tsk_fprintf(stderr, "slack_inode_act: error walking file: %" PRIuINUM, fs_file->meta->addr); tsk_error_reset(); } } } } return TSK_WALK_CONT; } /* Return 1 on error and 0 on success */ uint8_t tsk_fs_blkls(TSK_FS_INFO * fs, TSK_FS_BLKLS_FLAG_ENUM a_blklsflags, TSK_DADDR_T bstart, TSK_DADDR_T blast, TSK_FS_BLOCK_FLAG_ENUM a_block_flags) { BLKLS_DATA data; if (a_blklsflags & TSK_FS_BLKLS_SLACK) { /* get the info on each allocated inode */ if (fs->inode_walk(fs, fs->first_inum, fs->last_inum, TSK_FS_META_FLAG_ALLOC, slack_inode_act, &data)) return 1; } else if (a_blklsflags & TSK_FS_BLKLS_LIST) { if (print_list_head(fs)) return 1; if (tsk_fs_block_walk(fs, bstart, blast, a_block_flags, print_list, &data)) return 1; } else { #ifdef TSK_WIN32 if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "blkls_lib: error setting stdout to binary: %s", strerror(errno)); return 1; } #endif if (tsk_fs_block_walk(fs, bstart, blast, a_block_flags, print_block, &data)) return 1; } return 0; } sleuthkit-3.2.3/tsk3/fs/dstat_lib.c000644 000765 000024 00000003743 11643647440 017752 0ustar00carrierstaff000000 000000 /* ** blkstat ** The Sleuth Kit ** ** Get the details about a data unit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file dstat_lib.c * Contains the library API functions used by the TSK blkstat command * line tool. */ #include "tsk_fs_i.h" #include "tsk_ffs.h" #include "tsk_ext2fs.h" #include "tsk_fatfs.h" static TSK_WALK_RET_ENUM blkstat_act(const TSK_FS_BLOCK * fs_block, void *ptr) { tsk_printf("%s: %" PRIuDADDR "\n", fs_block->fs_info->duname, fs_block->addr); tsk_printf("%sAllocated%s\n", (fs_block->flags & TSK_FS_BLOCK_FLAG_ALLOC) ? "" : "Not ", (fs_block->flags & TSK_FS_BLOCK_FLAG_META) ? " (Meta)" : ""); if (TSK_FS_TYPE_ISFFS(fs_block->fs_info->ftype)) { FFS_INFO *ffs = (FFS_INFO *) fs_block->fs_info; tsk_printf("Group: %" PRI_FFSGRP "\n", ffs->grp_num); } else if (TSK_FS_TYPE_ISEXT(fs_block->fs_info->ftype)) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs_block->fs_info; if (fs_block->addr >= ext2fs->first_data_block) tsk_printf("Group: %" PRI_EXT2GRP "\n", ext2fs->grp_num); } else if (TSK_FS_TYPE_ISFAT(fs_block->fs_info->ftype)) { FATFS_INFO *fatfs = (FATFS_INFO *) fs_block->fs_info; /* Does this have a cluster address? */ if (fs_block->addr >= fatfs->firstclustsect) { tsk_printf("Cluster: %" PRIuDADDR "\n", (2 + (fs_block->addr - fatfs->firstclustsect) / fatfs->csize)); } } return TSK_WALK_STOP; } uint8_t tsk_fs_blkstat(TSK_FS_INFO * fs, TSK_DADDR_T addr, TSK_FS_BLOCK_FLAG_ENUM flags) { return tsk_fs_block_walk(fs, addr, addr, flags, blkstat_act, NULL); } sleuthkit-3.2.3/tsk3/fs/ext2fs.c000644 000765 000024 00000220561 11643647440 017217 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002-2003 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /** *\file ext2fs.c * Contains the internal TSK ext2/ext3 file system functions. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ #include "tsk_fs_i.h" #include "tsk_ext2fs.h" /* ext2fs_group_load - load block group descriptor into cache * * return 1 on error and 0 on success * * */ static uint8_t ext2fs_group_load(EXT2FS_INFO * ext2fs, EXT2_GRPNUM_T grp_num) { ext2fs_gd *gd; TSK_OFF_T offs; ssize_t cnt; TSK_FS_INFO *fs = (TSK_FS_INFO *) ext2fs; /* * Sanity check */ if (grp_num < 0 || grp_num >= ext2fs->groups_count) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_group_load: invalid cylinder group number: %" PRI_EXT2GRP "", grp_num); return 1; } if (ext2fs->grp_buf == NULL) { if ((ext2fs->grp_buf = (ext2fs_gd *) tsk_malloc(sizeof(ext2fs_gd))) == NULL) { return 1; } } else if (ext2fs->grp_num == grp_num) { return 0; } gd = ext2fs->grp_buf; /* * We're not reading group descriptors often, so it is OK to do small * reads instead of cacheing group descriptors in a large buffer. */ offs = ext2fs->groups_offset + grp_num * sizeof(ext2fs_gd); cnt = tsk_fs_read(&ext2fs->fs_info, offs, (char *) gd, sizeof(ext2fs_gd)); if (cnt != sizeof(ext2fs_gd)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_group_load: Group descriptor %" PRI_EXT2GRP " at %" PRIuOFF, grp_num, offs); return 1; } /* Perform a sanity check on the data to make sure offsets are in range */ if ((tsk_getu32(fs->endian, gd->bg_block_bitmap) > fs->last_block) || (tsk_getu32(fs->endian, gd->bg_inode_bitmap) > fs->last_block) || (tsk_getu32(fs->endian, gd->bg_inode_table) > fs->last_block)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "extXfs_group_load: Group %" PRI_EXT2GRP " descriptor block locations too large at byte offset %" PRIuDADDR, grp_num, offs); return 1; } ext2fs->grp_num = grp_num; if (tsk_verbose) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; tsk_fprintf(stderr, "\tgroup %" PRI_EXT2GRP ": %" PRIu16 "/%" PRIu16 " free blocks/inodes\n", grp_num, tsk_getu16(fs->endian, gd->bg_free_blocks_count), tsk_getu16(fs->endian, gd->bg_free_inodes_count)); } return 0; } /* ext2fs_print_map - print a bitmap */ static void ext2fs_print_map(uint8_t * map, int len) { int i; for (i = 0; i < len; i++) { if (i > 0 && i % 10 == 0) putc('|', stderr); putc(isset(map, i) ? '1' : '.', stderr); } putc('\n', stderr); } /* ext2fs_bmap_load - look up block bitmap & load into cache * * return 1 on error and 0 on success * */ static uint8_t ext2fs_bmap_load(EXT2FS_INFO * ext2fs, EXT2_GRPNUM_T grp_num) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; ssize_t cnt; /* * Look up the group descriptor info. The load will do the sanity check. */ if ((ext2fs->grp_buf == NULL) || (ext2fs->grp_num != grp_num)) { if (ext2fs_group_load(ext2fs, grp_num)) { return 1; } } if (ext2fs->bmap_buf == NULL) { if ((ext2fs->bmap_buf = (uint8_t *) tsk_malloc(fs->block_size)) == NULL) { return 1; } } else if (ext2fs->bmap_grp_num == grp_num) return 0; /* * Look up the block allocation bitmap. */ if (tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap) > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_bmap_load: Block too large for image: %" PRIu32 "", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap)); return 1; } cnt = tsk_fs_read(fs, (TSK_DADDR_T) tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap) * fs->block_size, (char *) ext2fs->bmap_buf, ext2fs->fs_info.block_size); if (cnt != ext2fs->fs_info.block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_bmap_load: Bitmap group %" PRI_EXT2GRP " at %" PRIu32, grp_num, tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap)); } ext2fs->bmap_grp_num = grp_num; if (tsk_verbose > 1) ext2fs_print_map(ext2fs->bmap_buf, tsk_getu32(fs->endian, ext2fs->fs->s_blocks_per_group)); return 0; } /* ext2fs_imap_load - look up inode bitmap & load into cache * * return 0 on success and 1 on error * */ static uint8_t ext2fs_imap_load(EXT2FS_INFO * ext2fs, EXT2_GRPNUM_T grp_num) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; ssize_t cnt; /* * Look up the group descriptor info. */ if ((ext2fs->grp_buf == NULL) || (ext2fs->grp_num != grp_num)) { if (ext2fs_group_load(ext2fs, grp_num)) { return 1; } } /* Allocate the cache buffer and exit if map is already loaded */ if (ext2fs->imap_buf == NULL) { if ((ext2fs->imap_buf = (uint8_t *) tsk_malloc(fs->block_size)) == NULL) { return 1; } } else if (ext2fs->imap_grp_num == grp_num) { return 0; } /* * Look up the inode allocation bitmap. */ if (tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap) > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_imap_load: Block too large for image: %" PRIu32 "", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap)); } cnt = tsk_fs_read(fs, (TSK_DADDR_T) tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap) * fs->block_size, (char *) ext2fs->imap_buf, ext2fs->fs_info.block_size); if (cnt != ext2fs->fs_info.block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_imap_load: Inode bitmap %" PRI_EXT2GRP " at %" PRIu32, grp_num, tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap)); } ext2fs->imap_grp_num = grp_num; if (tsk_verbose > 1) ext2fs_print_map(ext2fs->imap_buf, tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group)); return 0; } /* ext2fs_dinode_load - look up disk inode & load into cache * * return 1 on error and 0 on success * */ static uint8_t ext2fs_dinode_load(EXT2FS_INFO * ext2fs, TSK_INUM_T inum) { ext2fs_inode *dino; EXT2_GRPNUM_T grp_num; TSK_OFF_T addr; ssize_t cnt; TSK_INUM_T rel_inum; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; /* * Sanity check. * Use last_num-1 to account for virtual Orphan directory in last_inum. */ if ((inum < fs->first_inum) || (inum > fs->last_inum - 1)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dinode_load: address: %" PRIuINUM, inum); return 1; } /* Allocate the buffer or return if already loaded */ if (ext2fs->dino_buf == NULL) { if ((ext2fs->dino_buf = (ext2fs_inode *) tsk_malloc(ext2fs->inode_size)) == NULL) { return 1; } } else if (ext2fs->dino_inum == inum) { return 0; } dino = ext2fs->dino_buf; /* * Look up the group descriptor for this inode. */ grp_num = (EXT2_GRPNUM_T) ((inum - fs->first_inum) / tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group)); if ((ext2fs->grp_buf == NULL) || (ext2fs->grp_num != grp_num)) { if (ext2fs_group_load(ext2fs, grp_num)) { return 1; } } /* * Look up the inode table block for this inode. */ rel_inum = (inum - 1) - tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group) * grp_num; addr = (TSK_OFF_T) tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_table) * (TSK_OFF_T) fs->block_size + rel_inum * (TSK_OFF_T) ext2fs->inode_size; cnt = tsk_fs_read(fs, addr, (char *) dino, ext2fs->inode_size); if (cnt != ext2fs->inode_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_dinode_load: Inode %" PRIuINUM " from %" PRIuOFF, inum, addr); return 1; } ext2fs->dino_inum = inum; if (tsk_verbose) tsk_fprintf(stderr, "%" PRIuINUM " m/l/s=%o/%d/%" PRIuOFF " u/g=%d/%d macd=%" PRIu32 "/%" PRIu32 "/%" PRIu32 "/%" PRIu32 "\n", inum, tsk_getu16(fs->endian, dino->i_mode), tsk_getu16(fs->endian, dino->i_nlink), (tsk_getu32(fs->endian, dino->i_size) + (tsk_getu16(fs->endian, dino->i_mode) & EXT2_IN_REG) ? (uint64_t) tsk_getu32(fs->endian, dino->i_size_high) << 32 : 0), tsk_getu16(fs->endian, dino->i_uid) + (tsk_getu16(fs->endian, dino->i_uid_high) << 16), tsk_getu16(fs->endian, dino->i_gid) + (tsk_getu16(fs->endian, dino->i_gid_high) << 16), tsk_getu32(fs->endian, dino->i_mtime), tsk_getu32(fs->endian, dino->i_atime), tsk_getu32(fs->endian, dino->i_ctime), tsk_getu32(fs->endian, dino->i_dtime)); return 0; } /* ext2fs_dinode_copy - copy cached disk inode into generic inode * * returns 1 on error and 0 on success * */ static uint8_t ext2fs_dinode_copy(EXT2FS_INFO * ext2fs, TSK_FS_META * fs_meta) { int i; ext2fs_inode *in = ext2fs->dino_buf; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; ext2fs_sb *sb = ext2fs->fs; EXT2_GRPNUM_T grp_num; TSK_INUM_T ibase = 0; TSK_DADDR_T *addr_ptr; if (ext2fs->dino_buf == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dinode_copy: dino_buf is NULL"); return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } // set the type switch (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_FMT) { case EXT2_IN_REG: fs_meta->type = TSK_FS_META_TYPE_REG; break; case EXT2_IN_DIR: fs_meta->type = TSK_FS_META_TYPE_DIR; break; case EXT2_IN_SOCK: fs_meta->type = TSK_FS_META_TYPE_SOCK; break; case EXT2_IN_LNK: fs_meta->type = TSK_FS_META_TYPE_LNK; break; case EXT2_IN_BLK: fs_meta->type = TSK_FS_META_TYPE_BLK; break; case EXT2_IN_CHR: fs_meta->type = TSK_FS_META_TYPE_CHR; break; case EXT2_IN_FIFO: fs_meta->type = TSK_FS_META_TYPE_FIFO; break; default: fs_meta->type = TSK_FS_META_TYPE_UNDEF; break; } // set the mode fs_meta->mode = 0; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_ISUID) fs_meta->mode |= TSK_FS_META_MODE_ISUID; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_ISGID) fs_meta->mode |= TSK_FS_META_MODE_ISGID; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_ISVTX) fs_meta->mode |= TSK_FS_META_MODE_ISVTX; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IRUSR) fs_meta->mode |= TSK_FS_META_MODE_IRUSR; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IWUSR) fs_meta->mode |= TSK_FS_META_MODE_IWUSR; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IXUSR) fs_meta->mode |= TSK_FS_META_MODE_IXUSR; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IRGRP) fs_meta->mode |= TSK_FS_META_MODE_IRGRP; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IWGRP) fs_meta->mode |= TSK_FS_META_MODE_IWGRP; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IXGRP) fs_meta->mode |= TSK_FS_META_MODE_IXGRP; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IROTH) fs_meta->mode |= TSK_FS_META_MODE_IROTH; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IWOTH) fs_meta->mode |= TSK_FS_META_MODE_IWOTH; if (tsk_getu16(fs->endian, in->i_mode) & EXT2_IN_IXOTH) fs_meta->mode |= TSK_FS_META_MODE_IXOTH; fs_meta->nlink = tsk_getu16(fs->endian, in->i_nlink); fs_meta->size = tsk_getu32(fs->endian, in->i_size); fs_meta->addr = ext2fs->dino_inum; /* the general size value in the inode is only 32-bits, * but the i_dir_acl value is used for regular files to * hold the upper 32-bits * * The RO_COMPAT_LARGE_FILE flag in the super block will identify * if there are any large files in the file system */ if ((fs_meta->type == TSK_FS_META_TYPE_REG) && (tsk_getu32(fs->endian, sb->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_LARGE_FILE)) { fs_meta->size += ((uint64_t) tsk_getu32(fs->endian, in->i_size_high) << 32); } fs_meta->uid = tsk_getu16(fs->endian, in->i_uid) + (tsk_getu16(fs->endian, in->i_uid_high) << 16); fs_meta->gid = tsk_getu16(fs->endian, in->i_gid) + (tsk_getu16(fs->endian, in->i_gid_high) << 16); fs_meta->mtime = tsk_getu32(fs->endian, in->i_mtime); fs_meta->atime = tsk_getu32(fs->endian, in->i_atime); fs_meta->ctime = tsk_getu32(fs->endian, in->i_ctime); fs_meta->crtime = 0; fs_meta->time2.ext2.dtime = tsk_getu32(fs->endian, in->i_dtime); fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; fs_meta->time2.ext2.dtime_nano = 0; fs_meta->seq = 0; if (fs_meta->link) { free(fs_meta->link); fs_meta->link = NULL; } if (fs_meta->content_len != EXT2FS_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, EXT2FS_FILE_CONTENT_LEN)) == NULL) { return 1; } } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; for (i = 0; i < EXT2FS_NDADDR + EXT2FS_NIADDR; i++) addr_ptr[i] = tsk_gets32(fs->endian, in->i_block[i]); /* set the link string * the size check prevents us from trying to allocate a huge amount of * memory for a bad inode value */ if ((fs_meta->type == TSK_FS_META_TYPE_LNK) && (fs_meta->size < EXT2FS_MAXPATHLEN) && (fs_meta->size >= 0)) { unsigned int count = 0; int i; if ((fs_meta->link = tsk_malloc((size_t) (fs_meta->size + 1))) == NULL) return 1; /* it is located directly in the pointers */ if (fs_meta->size < 4 * (EXT2FS_NDADDR + EXT2FS_NIADDR)) { unsigned int j; for (i = 0; i < (EXT2FS_NDADDR + EXT2FS_NIADDR) && count < fs_meta->size; i++) { char *a_ptr = (char *) &in->i_block[i]; for (j = 0; j < 4 && count < fs_meta->size; j++) { fs_meta->link[count++] = a_ptr[j]; } } fs_meta->link[count] = '\0'; /* clear the content pointer data to avoid the prog from reading them */ memset(fs_meta->content_ptr, 0, fs_meta->content_len); } /* it is in blocks */ else { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ext2fs->fs_info; char *data_buf; char *a_ptr = fs_meta->link; TSK_DADDR_T *addr_ptr = fs_meta->content_ptr;; if ((data_buf = tsk_malloc(fs->block_size)) == NULL) return 1; /* we only need to do the direct blocks due to the limit * on path length */ for (i = 0; i < EXT2FS_NDADDR && count < fs_meta->size; i++) { ssize_t cnt; int read_count = (fs_meta->size - count < fs->block_size) ? (int) (fs_meta->size - count) : (int) (fs->block_size); cnt = tsk_fs_read_block(fs, addr_ptr[i], data_buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_dinode_copy: symlink destination from %" PRIuDADDR, addr_ptr[i]); free(data_buf); return 1; } memcpy(a_ptr, data_buf, read_count); count += read_count; a_ptr = (char *) ((uintptr_t) a_ptr + count); } /* terminate the string */ *a_ptr = '\0'; free(data_buf); } /* Clean up name */ i = 0; while (fs_meta->link[i] != '\0') { if (TSK_IS_CNTRL(fs_meta->link[i])) fs_meta->link[i] = '^'; i++; } } /* Fill in the flags value */ grp_num = (EXT2_GRPNUM_T) ((ext2fs->dino_inum - fs->first_inum) / tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group)); if (ext2fs->imap_grp_num != grp_num) { if (ext2fs_imap_load(ext2fs, grp_num)) { return 1; } } ibase = grp_num * tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group) + fs->first_inum; /* * Apply the allocated/unallocated restriction. */ fs_meta->flags = (isset(ext2fs->imap_buf, ext2fs->dino_inum - ibase) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); /* * Apply the used/unused restriction. */ fs_meta->flags |= (fs_meta->ctime ? TSK_FS_META_FLAG_USED : TSK_FS_META_FLAG_UNUSED); return 0; } /* ext2fs_inode_lookup - lookup inode, external interface * * Returns 1 on error and 0 on success * */ static uint8_t ext2fs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_inode_lookup: fs_file is NULL"); return 1; } if (a_fs_file->meta == NULL) { if ((a_fs_file->meta = tsk_fs_meta_alloc(EXT2FS_FILE_CONTENT_LEN)) == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } // see if they are looking for the special "orphans" directory if (inum == TSK_FS_ORPHANDIR_INUM(fs)) { if (tsk_fs_dir_make_orphan_dir_meta(fs, a_fs_file->meta)) return 1; else return 0; } if (ext2fs_dinode_load(ext2fs, inum)) { return 1; } if (ext2fs_dinode_copy(ext2fs, a_fs_file->meta)) { return 1; } return 0; } /* ext2fs_inode_walk - inode iterator * * flags used: TSK_FS_META_FLAG_USED, TSK_FS_META_FLAG_UNUSED, * TSK_FS_META_FLAG_ALLOC, TSK_FS_META_FLAG_UNALLOC, TSK_FS_META_FLAG_ORPHAN * * Return 1 on error and 0 on success */ uint8_t ext2fs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB a_action, void *a_ptr) { char *myname = "extXfs_inode_walk"; EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; EXT2_GRPNUM_T grp_num; TSK_INUM_T inum; TSK_INUM_T end_inum_tmp; TSK_INUM_T ibase = 0; TSK_FS_FILE *fs_file; int myflags; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (start_inum < fs->first_inum || start_inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: start inode: %" PRIuINUM "", myname, start_inum); return 1; } if (end_inum < fs->first_inum || end_inum > fs->last_inum || end_inum < start_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: end inode: %" PRIuINUM "", myname, end_inum); return 1; } /* If ORPHAN is wanted, then make sure that the flags are correct */ if (flags & TSK_FS_META_FLAG_ORPHAN) { flags |= TSK_FS_META_FLAG_UNALLOC; flags &= ~TSK_FS_META_FLAG_ALLOC; flags |= TSK_FS_META_FLAG_USED; flags &= ~TSK_FS_META_FLAG_UNUSED; } else { if (((flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED flags are set, then set them * both */ if (((flags & TSK_FS_META_FLAG_USED) == 0) && ((flags & TSK_FS_META_FLAG_UNUSED) == 0)) { flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } } /* If we are looking for orphan files and have not yet filled * in the list of unalloc inodes that are pointed to, then fill * in the list */ if ((flags & TSK_FS_META_FLAG_ORPHAN) && (fs->list_inum_named == NULL)) { if (tsk_fs_dir_load_inum_named(fs) != TSK_OK) { strncat(tsk_errstr2, " - ext2fs_inode_walk: identifying inodes allocated by file names", TSK_ERRSTR_L); return 1; } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(EXT2FS_FILE_CONTENT_LEN)) == NULL) return 1; // we need to handle fs->last_inum specially because it is for the // virtual ORPHANS directory. Handle it outside of the loop. if (end_inum == TSK_FS_ORPHANDIR_INUM(fs)) end_inum_tmp = end_inum - 1; else end_inum_tmp = end_inum; /* * Iterate. */ for (inum = start_inum; inum <= end_inum_tmp; inum++) { int retval; /* * Be sure to use the proper group descriptor data. XXX Linux inodes * start at 1, as in Fortran. */ grp_num = (EXT2_GRPNUM_T) ((inum - 1) / tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group)); if ((ext2fs->imap_buf == NULL) || (ext2fs->imap_grp_num != grp_num)) { if (ext2fs_imap_load(ext2fs, grp_num)) { return 1; } ibase = grp_num * tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group) + 1; } /* In case we didn't need to load it the bitmap */ else if (inum == start_inum) { ibase = grp_num * tsk_getu32(fs->endian, ext2fs->fs->s_inodes_per_group) + 1; } /* * Apply the allocated/unallocated restriction. */ myflags = (isset(ext2fs->imap_buf, inum - ibase) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); if ((flags & myflags) != myflags) continue; if (ext2fs_dinode_load(ext2fs, inum)) { tsk_fs_file_close(fs_file); return 1; } /* * Apply the used/unused restriction. */ myflags |= (tsk_getu32(fs->endian, ext2fs->dino_buf->i_ctime) ? TSK_FS_META_FLAG_USED : TSK_FS_META_FLAG_UNUSED); if ((flags & myflags) != myflags) continue; /* If we want only orphans, then check if this * inode is in the seen list */ if ((myflags & TSK_FS_META_FLAG_UNALLOC) && (flags & TSK_FS_META_FLAG_ORPHAN) && (tsk_list_find(fs->list_inum_named, inum))) { continue; } /* * Fill in a file system-independent inode structure and pass control * to the application. */ if (ext2fs_dinode_copy(ext2fs, fs_file->meta)) { tsk_fs_meta_close(fs_file->meta); return 1; } retval = a_action(fs_file, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } // handle the virtual orphans folder if they asked for it if ((end_inum == TSK_FS_ORPHANDIR_INUM(fs)) && (flags & TSK_FS_META_FLAG_ALLOC) && (flags & TSK_FS_META_FLAG_USED)) { int retval; if (tsk_fs_dir_make_orphan_dir_meta(fs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } /* call action */ retval = a_action(fs_file, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } /* * Cleanup. */ tsk_fs_file_close(fs_file); return 0; } TSK_FS_BLOCK_FLAG_ENUM ext2fs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) a_fs; int flags; EXT2_GRPNUM_T grp_num; TSK_DADDR_T dbase = 0; /* first block number in group */ TSK_DADDR_T dmin = 0; /* first block after inodes */ // these blocks are not described in the group descriptors // sparse if (a_addr == 0) return TSK_FS_BLOCK_FLAG_CONT | TSK_FS_BLOCK_FLAG_ALLOC; if (a_addr < ext2fs->first_data_block) return TSK_FS_BLOCK_FLAG_META | TSK_FS_BLOCK_FLAG_ALLOC; grp_num = ext2_dtog_lcl(a_fs, ext2fs->fs, a_addr); /* Lookup bitmap if not loaded */ if ((ext2fs->bmap_buf == NULL) || (ext2fs->bmap_grp_num != grp_num)) { if (ext2fs_bmap_load(ext2fs, grp_num)) { return 0; } if (tsk_verbose) tsk_fprintf(stderr, "ext2_block_walk: loading group %" PRI_EXT2GRP " dbase %" PRIuDADDR " bmap +%" PRIuDADDR " imap +%" PRIuDADDR " inos +%" PRIuDADDR "..%" PRIuDADDR "\n", grp_num, dbase, (TSK_DADDR_T) tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_block_bitmap) - dbase, (TSK_DADDR_T) tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_inode_bitmap) - dbase, (TSK_DADDR_T) tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_inode_table) - dbase, dmin - 1 - dbase); } /* * Be sure to use the right group descriptor information. XXX There * appears to be an off-by-one discrepancy between bitmap offsets and * disk block numbers. * * Addendum: this offset is controlled by the super block's * s_first_data_block field. */ #define INODE_TABLE_SIZE(ext2fs) \ ((tsk_getu32(a_fs->endian, ext2fs->fs->s_inodes_per_group) * ext2fs->inode_size - 1) \ / a_fs->block_size + 1) dbase = ext2_cgbase_lcl(a_fs, ext2fs->fs, grp_num); dmin = tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_inode_table) + INODE_TABLE_SIZE(ext2fs); /* * Identify meta blocks * (any blocks that can't be allocated for file/directory data). * * XXX With sparse superblock placement, most block groups have the * block and inode bitmaps where one would otherwise find the backup * superblock and the backup group descriptor blocks. The inode * blocks are in the normal place, though. This leaves little gaps * between the bitmaps and the inode table - and ext2fs will use * those blocks for file/directory data blocks. So we must properly * account for those gaps between meta blocks. * * Thus, superblocks and group descriptor blocks are sometimes overlaid * by bitmap blocks. This means that one can still assume that the * locations of superblocks and group descriptor blocks are reserved. * They just happen to be reserved for something else :-) */ flags = (isset(ext2fs->bmap_buf, a_addr - dbase) ? TSK_FS_BLOCK_FLAG_ALLOC : TSK_FS_BLOCK_FLAG_UNALLOC); if ((a_addr >= dbase && a_addr < tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_block_bitmap)) || (a_addr == tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_block_bitmap)) || (a_addr == tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_inode_bitmap)) || (a_addr >= tsk_getu32(a_fs->endian, ext2fs->grp_buf->bg_inode_table) && a_addr < dmin)) flags |= TSK_FS_BLOCK_FLAG_META; else flags |= TSK_FS_BLOCK_FLAG_CONT; return flags; } /* ext2fs_block_walk - block iterator * * flags: TSK_FS_BLOCK_FLAG_ALLOC, TSK_FS_BLOCK_FLAG_UNALLOC, TSK_FS_BLOCK_FLAG_CONT, * TSK_FS_BLOCK_FLAG_META * * Return 1 on error and 0 on success */ uint8_t ext2fs_block_walk(TSK_FS_INFO * a_fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr) { char *myname = "extXfs_block_walk"; TSK_FS_BLOCK *fs_block; TSK_DADDR_T addr; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (a_start_blk < a_fs->first_block || a_start_blk > a_fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: start block: %" PRIuDADDR, myname, a_start_blk); return 1; } if (a_end_blk < a_fs->first_block || a_end_blk > a_fs->last_block || a_end_blk < a_start_blk) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: end block: %" PRIuDADDR, myname, a_end_blk); return 1; } /* Sanity check on a_flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } if ((fs_block = tsk_fs_block_alloc(a_fs)) == NULL) { return 1; } /* * Iterate. This is not as tricky as it could be, because the free list * map covers the entire disk partition, including blocks occupied by * group descriptor blocks, bit maps, and other non-data blocks. */ for (addr = a_start_blk; addr <= a_end_blk; addr++) { int retval; int myflags; myflags = ext2fs_block_getflags(a_fs, addr); // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_META) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_META))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_CONT) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; if (tsk_fs_block_get(a_fs, fs_block, addr) == NULL) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_block_walk: block %" PRIuDADDR, addr); tsk_fs_block_free(fs_block); return 1; } retval = a_action(fs_block, a_ptr); if (retval == TSK_WALK_STOP) { break; } else if (retval == TSK_WALK_ERROR) { tsk_fs_block_free(fs_block); return 1; } } /* * Cleanup. */ tsk_fs_block_free(fs_block); return 0; } static uint8_t ext2fs_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented yet for Ext3"); return 1; } /** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ static uint8_t ext2fs_fsstat(TSK_FS_INFO * fs, FILE * hFile) { unsigned int i; EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; ext2fs_sb *sb = ext2fs->fs; int ibpg; time_t tmptime; // clean up any error messages that are lying around tsk_error_reset(); tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: %s\n", (fs->ftype == TSK_FS_TYPE_EXT3) ? "Ext3" : "Ext2"); tsk_fprintf(hFile, "Volume Name: %s\n", sb->s_volume_name); tsk_fprintf(hFile, "Volume ID: %" PRIx64 "%" PRIx64 "\n", tsk_getu64(fs->endian, &sb->s_uuid[8]), tsk_getu64(fs->endian, &sb->s_uuid[0])); tmptime = tsk_getu32(fs->endian, sb->s_wtime); tsk_fprintf(hFile, "\nLast Written at: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); tmptime = tsk_getu32(fs->endian, sb->s_lastcheck); tsk_fprintf(hFile, "Last Checked at: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); tmptime = tsk_getu32(fs->endian, sb->s_mtime); tsk_fprintf(hFile, "\nLast Mounted at: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); /* State of the file system */ if (tsk_getu16(fs->endian, sb->s_state) & EXT2FS_STATE_VALID) tsk_fprintf(hFile, "Unmounted properly\n"); else tsk_fprintf(hFile, "Unmounted Improperly\n"); if (sb->s_last_mounted != '\0') tsk_fprintf(hFile, "Last mounted on: %s\n", sb->s_last_mounted); tsk_fprintf(hFile, "\nSource OS: "); switch (tsk_getu32(fs->endian, sb->s_creator_os)) { case EXT2FS_OS_LINUX: tsk_fprintf(hFile, "Linux\n"); break; case EXT2FS_OS_HURD: tsk_fprintf(hFile, "HURD\n"); break; case EXT2FS_OS_MASIX: tsk_fprintf(hFile, "MASIX\n"); break; case EXT2FS_OS_FREEBSD: tsk_fprintf(hFile, "FreeBSD\n"); break; case EXT2FS_OS_LITES: tsk_fprintf(hFile, "LITES\n"); break; default: tsk_fprintf(hFile, "%" PRIx32 "\n", tsk_getu32(fs->endian, sb->s_creator_os)); break; } if (tsk_getu32(fs->endian, sb->s_rev_level) == EXT2FS_REV_ORIG) tsk_fprintf(hFile, "Static Structure\n"); else tsk_fprintf(hFile, "Dynamic Structure\n"); /* add features */ if (tsk_getu32(fs->endian, sb->s_feature_compat)) { tsk_fprintf(hFile, "Compat Features: "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_DIR_PREALLOC) tsk_fprintf(hFile, "Dir Prealloc, "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_IMAGIC_INODES) tsk_fprintf(hFile, "iMagic inodes, "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_HAS_JOURNAL) tsk_fprintf(hFile, "Journal, "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_EXT_ATTR) tsk_fprintf(hFile, "Ext Attributes, "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_RESIZE_INO) tsk_fprintf(hFile, "Resize Inode, "); if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_DIR_INDEX) tsk_fprintf(hFile, "Dir Index"); tsk_fprintf(hFile, "\n"); } if (tsk_getu32(fs->endian, sb->s_feature_incompat)) { tsk_fprintf(hFile, "InCompat Features: "); if (tsk_getu32(fs->endian, sb->s_feature_incompat) & EXT2FS_FEATURE_INCOMPAT_COMPRESSION) tsk_fprintf(hFile, "Compression, "); if (tsk_getu32(fs->endian, sb->s_feature_incompat) & EXT2FS_FEATURE_INCOMPAT_FILETYPE) tsk_fprintf(hFile, "Filetype, "); if (tsk_getu32(fs->endian, sb->s_feature_incompat) & EXT2FS_FEATURE_INCOMPAT_RECOVER) tsk_fprintf(hFile, "Needs Recovery, "); if (tsk_getu32(fs->endian, sb->s_feature_incompat) & EXT2FS_FEATURE_INCOMPAT_JOURNAL_DEV) tsk_fprintf(hFile, "Journal Dev"); tsk_fprintf(hFile, "\n"); } if (tsk_getu32(fs->endian, sb->s_feature_ro_compat)) { tsk_fprintf(hFile, "Read Only Compat Features: "); if (tsk_getu32(fs->endian, sb->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER) tsk_fprintf(hFile, "Sparse Super, "); if (tsk_getu32(fs->endian, sb->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_LARGE_FILE) tsk_fprintf(hFile, "Has Large Files, "); if (tsk_getu32(fs->endian, sb->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_BTREE_DIR) tsk_fprintf(hFile, "Btree Dir"); tsk_fprintf(hFile, "\n"); } /* Print journal information */ if (tsk_getu32(fs->endian, sb->s_feature_compat) & EXT2FS_FEATURE_COMPAT_HAS_JOURNAL) { tsk_fprintf(hFile, "\nJournal ID: %" PRIx64 "%" PRIx64 "\n", tsk_getu64(fs->endian, &sb->s_journal_uuid[8]), tsk_getu64(fs->endian, &sb->s_journal_uuid[0])); if (tsk_getu32(fs->endian, sb->s_journal_inum) != 0) tsk_fprintf(hFile, "Journal Inode: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_journal_inum)); if (tsk_getu32(fs->endian, sb->s_journal_dev) != 0) tsk_fprintf(hFile, "Journal Device: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_journal_dev)); } tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Inode Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "Root Directory: %" PRIuINUM "\n", fs->root_inum); tsk_fprintf(hFile, "Free Inodes: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_free_inode_count)); if (tsk_getu32(fs->endian, sb->s_last_orphan)) { uint32_t or_in; tsk_fprintf(hFile, "Orphan Inodes: "); or_in = tsk_getu32(fs->endian, sb->s_last_orphan); while (or_in) { TSK_FS_FILE *fs_file; if ((or_in > fs->last_inum) || (or_in < fs->first_inum)) break; tsk_fprintf(hFile, "%" PRIu32 ", ", or_in); if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) { /* Ignore this error */ tsk_error_reset(); break; } /* Get the next one */ if (ext2fs_inode_lookup(fs, fs_file, or_in)) { /* Ignore this error */ tsk_error_reset(); break; } or_in = (uint32_t) fs_file->meta->time2.ext2.dtime; tsk_fs_file_close(fs_file); } tsk_fprintf(hFile, "\n"); } tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Block Range: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block); if (fs->last_block != fs->last_block_act) tsk_fprintf(hFile, "Total Range in Image: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block_act); tsk_fprintf(hFile, "Block Size: %u\n", fs->block_size); if (tsk_getu32(fs->endian, sb->s_first_data_block)) tsk_fprintf(hFile, "Reserved Blocks Before Block Groups: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_first_data_block)); tsk_fprintf(hFile, "Free Blocks: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_free_blocks_count)); tsk_fprintf(hFile, "\nBLOCK GROUP INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Number of Block Groups: %" PRI_EXT2GRP "\n", ext2fs->groups_count); tsk_fprintf(hFile, "Inodes per group: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_inodes_per_group)); tsk_fprintf(hFile, "Blocks per group: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->s_blocks_per_group)); /* number of blocks the inodes consume */ ibpg = (tsk_getu32(fs->endian, sb->s_inodes_per_group) * ext2fs->inode_size + fs->block_size - 1) / fs->block_size; for (i = 0; i < ext2fs->groups_count; i++) { TSK_DADDR_T cg_base; TSK_INUM_T inum; if (ext2fs_group_load(ext2fs, i)) { return 1; } tsk_fprintf(hFile, "\nGroup: %d:\n", i); inum = fs->first_inum + tsk_gets32(fs->endian, sb->s_inodes_per_group) * i; tsk_fprintf(hFile, " Inode Range: %" PRIuINUM " - ", inum); if ((inum + tsk_gets32(fs->endian, sb->s_inodes_per_group) - 1) < fs->last_inum) tsk_fprintf(hFile, "%" PRIuINUM "\n", inum + tsk_gets32(fs->endian, sb->s_inodes_per_group) - 1); else tsk_fprintf(hFile, "%" PRIuINUM "\n", fs->last_inum); cg_base = ext2_cgbase_lcl(fs, sb, i); tsk_fprintf(hFile, " Block Range: %" PRIuDADDR " - %" PRIuDADDR "\n", cg_base, ((ext2_cgbase_lcl(fs, sb, i + 1) - 1) < fs->last_block) ? (ext2_cgbase_lcl(fs, sb, i + 1) - 1) : fs->last_block); tsk_fprintf(hFile, " Layout:\n"); /* only print the super block data if we are not in a sparse * group */ if (((tsk_getu32(fs->endian, ext2fs->fs->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER) && (cg_base != tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap))) || ((tsk_getu32(fs->endian, ext2fs->fs->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER) == 0)) { TSK_OFF_T boff; /* the super block is the first 1024 bytes */ tsk_fprintf(hFile, " Super Block: %" PRIuDADDR " - %" PRIuDADDR "\n", cg_base, cg_base + ((sizeof(ext2fs_sb) + fs->block_size - 1) / fs->block_size) - 1); boff = roundup(sizeof(ext2fs_sb), fs->block_size); /* Group Descriptors */ tsk_fprintf(hFile, " Group Descriptor Table: %" PRIuDADDR " - ", (cg_base + (boff + fs->block_size - 1) / fs->block_size)); boff += (ext2fs->groups_count * sizeof(ext2fs_gd)); tsk_fprintf(hFile, "%" PRIuDADDR "\n", ((cg_base + (boff + fs->block_size - 1) / fs->block_size) - 1)); } /* The block bitmap is a full block */ tsk_fprintf(hFile, " Data bitmap: %" PRIu32 " - %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap), tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap)); /* The inode bitmap is a full block */ tsk_fprintf(hFile, " Inode bitmap: %" PRIu32 " - %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap), tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap)); tsk_fprintf(hFile, " Inode Table: %" PRIu32 " - %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_table), tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_table) + ibpg - 1); tsk_fprintf(hFile, " Data Blocks: "); /* If we are in a sparse group, display the other addresses */ if ((tsk_getu32(fs->endian, ext2fs->fs->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER) && (cg_base == tsk_getu32(fs->endian, ext2fs->grp_buf->bg_block_bitmap))) { /* it goes from the end of the inode bitmap to before the * table * * This hard coded aspect does not scale ... */ tsk_fprintf(hFile, "%" PRIu32 " - %" PRIu32 ", ", tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_bitmap) + 1, tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_table) - 1); } tsk_fprintf(hFile, "%" PRIuDADDR " - %" PRIuDADDR "\n", (uint64_t) tsk_getu32(fs->endian, ext2fs->grp_buf->bg_inode_table) + ibpg, ((ext2_cgbase_lcl(fs, sb, i + 1) - 1) < fs->last_block) ? (ext2_cgbase_lcl(fs, sb, i + 1) - 1) : fs->last_block); /* Print the free info */ /* The last group may not have a full number of blocks */ if (i != (ext2fs->groups_count - 1)) { tsk_fprintf(hFile, " Free Inodes: %" PRIu16 " (%" PRIu32 "%%)\n", tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_inodes_count), (100 * tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_inodes_count)) / tsk_getu32(fs->endian, sb->s_inodes_per_group)); tsk_fprintf(hFile, " Free Blocks: %" PRIu16 " (%" PRIu32 "%%)\n", tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_blocks_count), (100 * tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_blocks_count)) / tsk_getu32(fs->endian, sb->s_blocks_per_group)); } else { TSK_INUM_T inum_left; TSK_DADDR_T blk_left; inum_left = fs->last_inum % tsk_gets32(fs->endian, sb->s_inodes_per_group); if (inum_left == 0) inum_left = tsk_getu32(fs->endian, sb->s_inodes_per_group); tsk_fprintf(hFile, " Free Inodes: %" PRIu16 " (%d%%)\n", tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_inodes_count), (100 * tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_inodes_count)) / inum_left); /* Now blocks */ blk_left = fs->block_count % tsk_getu32(fs->endian, sb->s_blocks_per_group); if (blk_left == 0) blk_left = tsk_getu32(fs->endian, sb->s_blocks_per_group); tsk_fprintf(hFile, " Free Blocks: %" PRIu16 " (%d%%)\n", tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_blocks_count), (100 * tsk_getu16(fs->endian, ext2fs->grp_buf->bg_free_blocks_count)) / blk_left); } tsk_fprintf(hFile, " Total Directories: %" PRIu16 "\n", tsk_getu16(fs->endian, ext2fs->grp_buf->bg_used_dirs_count)); } return 0; } /************************* istat *******************************/ static void ext2fs_make_acl_str(char *str, int len, uint16_t perm) { int i = 0; if (perm & EXT2_PACL_PERM_READ) { snprintf(&str[i], len - 1, "Read"); i += 4; } if (perm & EXT2_PACL_PERM_WRITE) { if (i) { snprintf(&str[i], len - 1, ", "); i += 2; } snprintf(&str[i], len - 1, "Write"); i += 5; } if (perm & EXT2_PACL_PERM_EXEC) { if (i) { snprintf(&str[i], len - 1, ", "); i += 2; } snprintf(&str[i], len - 1, "Execute"); i += 7; } } typedef struct { FILE *hFile; int idx; } EXT2FS_PRINT_ADDR; /* Callback for istat to print the block addresses */ static TSK_WALK_RET_ENUM print_addr_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *a_ptr) { TSK_FS_INFO *fs = fs_file->fs_info; EXT2FS_PRINT_ADDR *print = (EXT2FS_PRINT_ADDR *) a_ptr; if (flags & TSK_FS_BLOCK_FLAG_CONT) { int i, s; /* cycle through the blocks if they exist */ for (i = 0, s = (int) size; s > 0; s -= fs->block_size, i++) { /* sparse file */ if (addr) tsk_fprintf(print->hFile, "%" PRIuDADDR " ", addr + i); else tsk_fprintf(print->hFile, "0 "); if (++(print->idx) == 8) { tsk_fprintf(print->hFile, "\n"); print->idx = 0; } } } return TSK_WALK_CONT; } /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File handle to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t ext2fs_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; TSK_FS_META *fs_meta; TSK_FS_FILE *fs_file; char ls[12]; EXT2FS_PRINT_ADDR print; const TSK_FS_ATTR *fs_attr_indir; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) { return 1; } fs_meta = fs_file->meta; tsk_fprintf(hFile, "inode: %" PRIuINUM "\n", inum); tsk_fprintf(hFile, "%sAllocated\n", (fs_meta->flags & TSK_FS_META_FLAG_ALLOC) ? "" : "Not "); tsk_fprintf(hFile, "Group: %" PRIuGID "\n", ext2fs->grp_num); // Note that if this is a "virtual file", then ext2fs->dino_buf may not be set. if (ext2fs->dino_buf) tsk_fprintf(hFile, "Generation Id: %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->dino_buf->i_generation)); if (fs_meta->link) tsk_fprintf(hFile, "symbolic link to: %s\n", fs_meta->link); tsk_fprintf(hFile, "uid / gid: %" PRIuUID " / %" PRIuGID "\n", fs_meta->uid, fs_meta->gid); tsk_fs_meta_make_ls(fs_meta, ls, sizeof(ls)); tsk_fprintf(hFile, "mode: %s\n", ls); if (ext2fs->dino_buf) { /* Print the device ids */ if ((fs_meta->type == TSK_FS_META_TYPE_BLK) || (fs_meta->type == TSK_FS_META_TYPE_CHR)) { tsk_fprintf(hFile, "Device Major: %" PRIu8 " Minor: %" PRIu8 "\n", ext2fs->dino_buf->i_block[0][1], ext2fs->dino_buf->i_block[0][0]); } if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags)) { tsk_fprintf(hFile, "Flags: "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_SECDEL) tsk_fprintf(hFile, "Secure Delete, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_UNRM) tsk_fprintf(hFile, "Undelete, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_COMP) tsk_fprintf(hFile, "Compressed, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_SYNC) tsk_fprintf(hFile, "Sync Updates, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_IMM) tsk_fprintf(hFile, "Immutable, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_APPEND) tsk_fprintf(hFile, "Append Only, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_NODUMP) tsk_fprintf(hFile, "Do Not Dump, "); if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_flags) & EXT2_IN_NOA) tsk_fprintf(hFile, "No A-Time, "); tsk_fprintf(hFile, "\n"); } } tsk_fprintf(hFile, "size: %" PRIuOFF "\n", fs_meta->size); tsk_fprintf(hFile, "num of links: %d\n", fs_meta->nlink); if (ext2fs->dino_buf) { /* Ext attribute are stored in a block with a header and a list * of entries that are aligned to 4-byte boundaries. The attr * value is stored at the end of the block. There are 4 null bytes * in between the headers and values */ if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_file_acl) != 0) { char *buf; ext2fs_ea_header *ea_head; ext2fs_ea_entry *ea_entry; ssize_t cnt; if ((buf = tsk_malloc(fs->block_size)) == NULL) { tsk_fs_file_close(fs_file); return 1; } tsk_fprintf(hFile, "\nExtended Attributes (Block: %" PRIu32 ")\n", tsk_getu32(fs->endian, ext2fs->dino_buf->i_file_acl)); /* Is the value too big? */ if (tsk_getu32(fs->endian, ext2fs->dino_buf->i_file_acl) > fs->last_block) { tsk_fprintf(hFile, "Extended Attributes block is larger than file system\n"); goto egress_ea; } cnt = tsk_fs_read(fs, (TSK_DADDR_T) tsk_getu32(fs->endian, ext2fs->dino_buf->i_file_acl) * fs->block_size, buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_istat: ACL block %" PRIu32, tsk_getu32(fs->endian, ext2fs->dino_buf->i_file_acl)); tsk_fs_file_close(fs_file); free(buf); return 1; } /* Check the header */ ea_head = (ext2fs_ea_header *) buf; if (tsk_getu32(fs->endian, ea_head->magic) != EXT2_EA_MAGIC) { tsk_fprintf(hFile, "Incorrect extended attribute header: %" PRIx32 "\n", tsk_getu32(fs->endian, ea_head->magic)); } /* Cycle through each entry - at the top of the block */ for (ea_entry = (ext2fs_ea_entry *) & ea_head->entry; ((uintptr_t) ea_entry < ((uintptr_t) buf + fs->block_size - sizeof(ext2fs_ea_entry))); ea_entry = (ext2fs_ea_entry *) ((uintptr_t) ea_entry + EXT2_EA_LEN(ea_entry->nlen))) { char name[256]; /* Stop if the first four bytes are NULL */ if ((ea_entry->nlen == 0) && (ea_entry->nidx == 0) && (tsk_getu16(fs->endian, ea_entry->val_off) == 0)) break; /* The Linux src does not allow this */ if (tsk_getu32(fs->endian, ea_entry->val_blk) != 0) { tsk_fprintf(hFile, "Attribute has non-zero value block - skipping\n"); continue; } /* Is the value location and size valid? */ if ((tsk_getu32(fs->endian, ea_entry->val_off) > fs->block_size) || ((tsk_getu16(fs->endian, ea_entry->val_off) + tsk_getu32(fs->endian, ea_entry->val_size)) > fs->block_size)) { continue; } /* Copy the name into a buffer - not NULL term */ strncpy(name, (char *) &ea_entry->name, ea_entry->nlen); name[ea_entry->nlen] = '\0'; /* User assigned attributes - setfattr / getfattr */ if ((ea_entry->nidx == EXT2_EA_IDX_USER) || (ea_entry->nidx == EXT2_EA_IDX_TRUSTED) || (ea_entry->nidx == EXT2_EA_IDX_SECURITY)) { char val[256]; strncpy(val, &buf[tsk_getu16(fs->endian, ea_entry->val_off)], tsk_getu32(fs->endian, ea_entry->val_size) > 256 ? 256 : tsk_getu32(fs->endian, ea_entry->val_size)); val[tsk_getu32(fs->endian, ea_entry->val_size) > 256 ? 256 : tsk_getu32(fs->endian, ea_entry->val_size)] = '\0'; if (ea_entry->nidx == EXT2_EA_IDX_USER) tsk_fprintf(hFile, "user.%s=%s\n", name, val); else if (ea_entry->nidx == EXT2_EA_IDX_TRUSTED) tsk_fprintf(hFile, "trust.%s=%s\n", name, val); else if (ea_entry->nidx == EXT2_EA_IDX_SECURITY) tsk_fprintf(hFile, "security.%s=%s\n", name, val); } /* POSIX ACL - setfacl / getfacl stuff */ else if ((ea_entry->nidx == EXT2_EA_IDX_POSIX_ACL_ACCESS) || (ea_entry->nidx == EXT2_EA_IDX_POSIX_ACL_DEFAULT)) { ext2fs_pos_acl_entry_lo *acl_lo; ext2fs_pos_acl_head *acl_head; if (ea_entry->nidx == EXT2_EA_IDX_POSIX_ACL_ACCESS) tsk_fprintf(hFile, "POSIX Access Control List Entries:\n"); else if (ea_entry->nidx == EXT2_EA_IDX_POSIX_ACL_DEFAULT) tsk_fprintf(hFile, "POSIX Default Access Control List Entries:\n"); /* examine the header */ acl_head = (ext2fs_pos_acl_head *) & buf[tsk_getu16(fs->endian, ea_entry->val_off)]; if (tsk_getu32(fs->endian, acl_head->ver) != 1) { tsk_fprintf(hFile, "Invalid ACL Header Version: %" PRIu32 "\n", tsk_getu32(fs->endian, acl_head->ver)); continue; } /* The first entry starts after the header */ acl_lo = (ext2fs_pos_acl_entry_lo *) ((uintptr_t) acl_head + sizeof(ext2fs_pos_acl_head)); /* Cycle through the values */ while ((uintptr_t) acl_lo < ((uintptr_t) buf + tsk_getu16(fs->endian, ea_entry->val_off) + tsk_getu32(fs->endian, ea_entry->val_size))) { char perm[64]; int len; /* Make a string from the permissions */ ext2fs_make_acl_str(perm, 64, tsk_getu16(fs->endian, acl_lo->perm)); switch (tsk_getu16(fs->endian, acl_lo->tag)) { case EXT2_PACL_TAG_USERO: tsk_fprintf(hFile, " uid: %" PRIuUID ": %s\n", fs_meta->uid, perm); len = sizeof(ext2fs_pos_acl_entry_sh); break; case EXT2_PACL_TAG_GRPO: tsk_fprintf(hFile, " gid: %" PRIuGID ": %s\n", fs_meta->gid, perm); len = sizeof(ext2fs_pos_acl_entry_sh); break; case EXT2_PACL_TAG_OTHER: tsk_fprintf(hFile, " other: %s\n", perm); len = sizeof(ext2fs_pos_acl_entry_sh); break; case EXT2_PACL_TAG_MASK: tsk_fprintf(hFile, " mask: %s\n", perm); len = sizeof(ext2fs_pos_acl_entry_sh); break; case EXT2_PACL_TAG_GRP: tsk_fprintf(hFile, " gid: %" PRIu32 ": %s\n", tsk_getu32(fs->endian, acl_lo->id), perm); len = sizeof(ext2fs_pos_acl_entry_lo); break; case EXT2_PACL_TAG_USER: tsk_fprintf(hFile, " uid: %" PRIu32 ": %s\n", tsk_getu32(fs->endian, acl_lo->id), perm); len = sizeof(ext2fs_pos_acl_entry_lo); break; default: tsk_fprintf(hFile, "Unknown ACL tag: %d\n", tsk_getu16(fs->endian, acl_lo->tag)); len = sizeof(ext2fs_pos_acl_entry_sh); break; } acl_lo = (ext2fs_pos_acl_entry_lo *) ((uintptr_t) acl_lo + len); } } else { tsk_fprintf(hFile, "Unsupported Extended Attr Type: %d\n", ea_entry->nidx); } } egress_ea: free(buf); } } if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted Inode Times:\n"); fs_meta->mtime -= sec_skew; fs_meta->atime -= sec_skew; fs_meta->ctime -= sec_skew; tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Inode Modified:\t%s", ctime(&fs_meta->ctime)); if (fs_meta->time2.ext2.dtime) { fs_meta->time2.ext2.dtime -= sec_skew; tsk_fprintf(hFile, "Deleted:\t%s", ctime(&fs_meta->time2.ext2.dtime)); fs_meta->time2.ext2.dtime += sec_skew; } fs_meta->mtime += sec_skew; fs_meta->atime += sec_skew; fs_meta->ctime += sec_skew; tsk_fprintf(hFile, "\nOriginal Inode Times:\n"); } else { tsk_fprintf(hFile, "\nInode Times:\n"); } tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Inode Modified:\t%s", ctime(&fs_meta->ctime)); if (fs_meta->time2.ext2.dtime) tsk_fprintf(hFile, "Deleted:\t%s", ctime(&fs_meta->time2.ext2.dtime)); if (numblock > 0) fs_meta->size = numblock * fs->block_size; tsk_fprintf(hFile, "\nDirect Blocks:\n"); print.idx = 0; print.hFile = hFile; if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_AONLY, print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading file: "); tsk_error_print(hFile); tsk_error_reset(); } else if (print.idx != 0) { tsk_fprintf(hFile, "\n"); } fs_attr_indir = tsk_fs_file_attr_get_type(fs_file, TSK_FS_ATTR_TYPE_UNIX_INDIR, 0, 0); if (fs_attr_indir) { tsk_fprintf(hFile, "\nIndirect Blocks:\n"); print.idx = 0; if (tsk_fs_attr_walk(fs_attr_indir, TSK_FS_FILE_WALK_FLAG_AONLY, print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading indirect attribute: "); tsk_error_print(hFile); tsk_error_reset(); } else if (print.idx != 0) { tsk_fprintf(hFile, "\n"); } } tsk_fs_file_close(fs_file); return 0; } /* ext2fs_close - close an ext2fs file system */ static void ext2fs_close(TSK_FS_INFO * fs) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; fs->tag = 0; free((char *) ext2fs->fs); if (ext2fs->dino_buf != NULL) free((char *) ext2fs->dino_buf); if (ext2fs->grp_buf != NULL) free((char *) ext2fs->grp_buf); if (ext2fs->bmap_buf != NULL) free((char *) ext2fs->bmap_buf); if (ext2fs->imap_buf != NULL) free((char *) ext2fs->imap_buf); if (fs->list_inum_named) { tsk_list_free(fs->list_inum_named); fs->list_inum_named = NULL; } free(ext2fs); } /** * \internal * Open part of a disk image as a Ext2/3 file system. * * @param img_info Disk image to analyze * @param offset Byte offset where file system starts * @param ftype Specific type of file system * @param test NOT USED * @returns NULL on error or if data is not an Ext2/3 file system */ TSK_FS_INFO * ext2fs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype, uint8_t test) { EXT2FS_INFO *ext2fs; unsigned int len; TSK_FS_INFO *fs; ssize_t cnt; // clean up any error messages that are lying around tsk_error_reset(); if (TSK_FS_TYPE_ISEXT(ftype) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS Type in ext2fs_open"); return NULL; } if ((ext2fs = (EXT2FS_INFO *) tsk_malloc(sizeof(*ext2fs))) == NULL) return NULL; fs = &(ext2fs->fs_info); fs->ftype = ftype; fs->flags = 0; fs->img_info = img_info; fs->offset = offset; fs->tag = TSK_FS_INFO_TAG; /* * Read the superblock. */ len = sizeof(ext2fs_sb); if ((ext2fs->fs = (ext2fs_sb *) tsk_malloc(len)) == NULL) { fs->tag = 0; free(ext2fs); return NULL; } cnt = tsk_fs_read(fs, EXT2FS_SBOFF, (char *) ext2fs->fs, len); if (cnt != len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ext2fs_open: superblock"); fs->tag = 0; free(ext2fs->fs); free(ext2fs); return NULL; } /* * Verify we are looking at an EXTxFS image */ if (tsk_fs_guessu16(fs, ext2fs->fs->s_magic, EXT2FS_FS_MAGIC)) { fs->tag = 0; free(ext2fs->fs); free(ext2fs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "not an EXTxFS file system (magic)"); return NULL; } if (tsk_verbose) { if (tsk_getu32(fs->endian, ext2fs->fs->s_feature_ro_compat) & EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER) tsk_fprintf(stderr, "File system has sparse super blocks\n"); tsk_fprintf(stderr, "First data block is %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->fs->s_first_data_block)); } /* If autodetect was given, look for the journal */ if (ftype == TSK_FS_TYPE_EXT_DETECT) { if (tsk_getu32(fs->endian, ext2fs->fs->s_feature_compat) & EXT2FS_FEATURE_COMPAT_HAS_JOURNAL) fs->ftype = TSK_FS_TYPE_EXT3; else fs->ftype = TSK_FS_TYPE_EXT2; } fs->duname = "Fragment"; /* we need to figure out if dentries are v1 or v2 */ if (tsk_getu32(fs->endian, ext2fs->fs->s_feature_incompat) & EXT2FS_FEATURE_INCOMPAT_FILETYPE) ext2fs->deentry_type = EXT2_DE_V2; else ext2fs->deentry_type = EXT2_DE_V1; /* * Calculate the meta data info */ fs->inum_count = tsk_getu32(fs->endian, ext2fs->fs->s_inodes_count) + 1; // we are adding 1 in this calc to account for Orphans directory fs->last_inum = fs->inum_count; fs->first_inum = EXT2FS_FIRSTINO; fs->root_inum = EXT2FS_ROOTINO; if (fs->inum_count < 10) { fs->tag = 0; free(ext2fs->fs); free(ext2fs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not an EXTxFS file system (inum count)"); return NULL; } /* Set the size of the inode, but default to our data structure * size if it is larger */ ext2fs->inode_size = tsk_getu16(fs->endian, ext2fs->fs->s_inode_size); if (ext2fs->inode_size < sizeof(ext2fs_inode)) { ext2fs->inode_size = sizeof(ext2fs_inode); if (tsk_verbose) tsk_fprintf(stderr, "SB inode size is too small, using default"); } /* * Calculate the block info */ fs->dev_bsize = img_info->sector_size; fs->block_count = tsk_getu32(fs->endian, ext2fs->fs->s_blocks_count); fs->first_block = 0; fs->last_block_act = fs->last_block = fs->block_count - 1; ext2fs->first_data_block = tsk_getu32(fs->endian, ext2fs->fs->s_first_data_block); if (tsk_getu32(fs->endian, ext2fs->fs->s_log_block_size) != tsk_getu32(fs->endian, ext2fs->fs->s_log_frag_size)) { fs->tag = 0; free(ext2fs->fs); free(ext2fs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "This file system has fragments that are a different size than blocks, which is not currently supported\nContact brian with details of the system that created this image"); return NULL; } fs->block_size = EXT2FS_MIN_BLOCK_SIZE << tsk_getu32(fs->endian, ext2fs->fs->s_log_block_size); // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; /* The group descriptors are located in the block following the * super block */ ext2fs->groups_offset = roundup((EXT2FS_SBOFF + sizeof(ext2fs_sb)), fs->block_size); ext2fs->groups_count = (EXT2_GRPNUM_T) ((tsk_getu32(fs->endian, ext2fs->fs->s_blocks_count) - ext2fs->first_data_block + tsk_getu32(fs->endian, ext2fs->fs->s_blocks_per_group) - 1) / tsk_getu32(fs->endian, ext2fs->fs->s_blocks_per_group)); /* Volume ID */ for (fs->fs_id_used = 0; fs->fs_id_used < 16; fs->fs_id_used++) { fs->fs_id[fs->fs_id_used] = ext2fs->fs->s_uuid[fs->fs_id_used]; } /* Set the generic function pointers */ fs->inode_walk = ext2fs_inode_walk; fs->block_walk = ext2fs_block_walk; fs->block_getflags = ext2fs_block_getflags; fs->get_default_attr_type = tsk_fs_unix_get_default_attr_type; fs->load_attrs = tsk_fs_unix_make_data_run; fs->file_add_meta = ext2fs_inode_lookup; fs->dir_open_meta = ext2fs_dir_open_meta; fs->fsstat = ext2fs_fsstat; fs->fscheck = ext2fs_fscheck; fs->istat = ext2fs_istat; fs->name_cmp = tsk_fs_unix_name_cmp; fs->close = ext2fs_close; /* Journal */ fs->journ_inum = tsk_getu32(fs->endian, ext2fs->fs->s_journal_inum); fs->jblk_walk = ext2fs_jblk_walk; fs->jentry_walk = ext2fs_jentry_walk; fs->jopen = ext2fs_jopen; /* initialize the caches */ /* inode map */ ext2fs->imap_buf = NULL; ext2fs->imap_grp_num = 0xffffffff; /* block map */ ext2fs->bmap_buf = NULL; ext2fs->bmap_grp_num = 0xffffffff; /* dinode */ ext2fs->dino_buf = NULL; ext2fs->dino_inum = 0xffffffff; /* group descriptor */ ext2fs->grp_buf = NULL; ext2fs->grp_num = 0xffffffff; fs->list_inum_named = NULL; /* * Print some stats. */ if (tsk_verbose) tsk_fprintf(stderr, "inodes %" PRIu32 " root ino %" PRIuINUM " blocks %" PRIu32 " blocks/group %" PRIu32 "\n", tsk_getu32(fs->endian, ext2fs->fs->s_inodes_count), fs->root_inum, tsk_getu32(fs->endian, ext2fs->fs->s_blocks_count), tsk_getu32(fs->endian, ext2fs->fs->s_blocks_per_group)); return (fs); } sleuthkit-3.2.3/tsk3/fs/ext2fs_dent.c000644 000765 000024 00000026161 11643647440 020231 0ustar00carrierstaff000000 000000 /* ** ext2fs_dent ** The Sleuth Kit ** ** File name layer support for an Ext2 / Ext3 FS ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2006 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILS ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file ext2fs_dent.c * Contains the internal TSK file name processing code for Ext2 / ext3 */ #include #include "tsk_fs_i.h" #include "tsk_ext2fs.h" static uint8_t ext2fs_dent_copy(EXT2FS_INFO * ext2fs, char *ext2_dent, TSK_FS_NAME * fs_name) { TSK_FS_INFO *fs = &(ext2fs->fs_info); if (ext2fs->deentry_type == EXT2_DE_V1) { ext2fs_dentry1 *dir = (ext2fs_dentry1 *) ext2_dent; fs_name->meta_addr = tsk_getu32(fs->endian, dir->inode); /* ext2 does not null terminate */ if (tsk_getu16(fs->endian, dir->name_len) >= fs_name->name_size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dent_copy: Name Space too Small %d %" PRIuSIZE "", tsk_getu16(fs->endian, dir->name_len), fs_name->name_size); return 1; } /* Copy and Null Terminate */ strncpy(fs_name->name, dir->name, tsk_getu16(fs->endian, dir->name_len)); fs_name->name[tsk_getu16(fs->endian, dir->name_len)] = '\0'; fs_name->type = TSK_FS_NAME_TYPE_UNDEF; } else { ext2fs_dentry2 *dir = (ext2fs_dentry2 *) ext2_dent; fs_name->meta_addr = tsk_getu32(fs->endian, dir->inode); /* ext2 does not null terminate */ if (dir->name_len >= fs_name->name_size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2_dent_copy: Name Space too Small %d %" PRIuSIZE "", dir->name_len, fs_name->name_size); return 1; } /* Copy and Null Terminate */ strncpy(fs_name->name, dir->name, dir->name_len); fs_name->name[dir->name_len] = '\0'; switch (dir->type) { case EXT2_DE_REG: fs_name->type = TSK_FS_NAME_TYPE_REG; break; case EXT2_DE_DIR: fs_name->type = TSK_FS_NAME_TYPE_DIR; break; case EXT2_DE_CHR: fs_name->type = TSK_FS_NAME_TYPE_CHR; break; case EXT2_DE_BLK: fs_name->type = TSK_FS_NAME_TYPE_BLK; break; case EXT2_DE_FIFO: fs_name->type = TSK_FS_NAME_TYPE_FIFO; break; case EXT2_DE_SOCK: fs_name->type = TSK_FS_NAME_TYPE_SOCK; break; case EXT2_DE_LNK: fs_name->type = TSK_FS_NAME_TYPE_LNK; break; case EXT2_DE_UNKNOWN: default: fs_name->type = TSK_FS_NAME_TYPE_UNDEF; break; } } fs_name->flags = 0; return 0; } /* * @param a_is_del Set to 1 if block is from a deleted directory. */ static TSK_RETVAL_ENUM ext2fs_dent_parse_block(EXT2FS_INFO * ext2fs, TSK_FS_DIR * a_fs_dir, uint8_t a_is_del, TSK_LIST ** list_seen, char *buf, int len) { TSK_FS_INFO *fs = &(ext2fs->fs_info); int dellen = 0; int idx; uint16_t reclen; uint32_t inode; char *dirPtr; TSK_FS_NAME *fs_name; int minreclen = 4; if ((fs_name = tsk_fs_name_alloc(EXT2FS_MAXNAMLEN + 1, 0)) == NULL) return TSK_ERR; /* update each time by the actual length instead of the ** recorded length so we can view the deleted entries */ for (idx = 0; idx <= len - EXT2FS_DIRSIZ_lcl(1); idx += minreclen) { unsigned int namelen; dirPtr = &buf[idx]; if (ext2fs->deentry_type == EXT2_DE_V1) { ext2fs_dentry1 *dir = (ext2fs_dentry1 *) dirPtr; inode = tsk_getu32(fs->endian, dir->inode); namelen = tsk_getu16(fs->endian, dir->name_len); reclen = tsk_getu16(fs->endian, dir->rec_len); } else { ext2fs_dentry2 *dir = (ext2fs_dentry2 *) dirPtr; inode = tsk_getu32(fs->endian, dir->inode); namelen = dir->name_len; reclen = tsk_getu16(fs->endian, dir->rec_len); } minreclen = EXT2FS_DIRSIZ_lcl(namelen); /* ** Check if we may have a valid directory entry. If we don't, ** then increment to the next word and try again. */ if ((inode > fs->last_inum) || // inode is unsigned (namelen > EXT2FS_MAXNAMLEN) || (namelen == 0) || // namelen is unsigned (reclen < minreclen) || (reclen % 4) || (idx + reclen > len)) { minreclen = 4; if (dellen > 0) dellen -= 4; continue; } /* Before we process an entry in unallocated space, make * sure that it also ends in the unalloc space */ if ((dellen) && (dellen < minreclen)) { minreclen = 4; dellen -= 4; continue; } if (ext2fs_dent_copy(ext2fs, dirPtr, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } /* Do we have a deleted entry? */ if ((dellen > 0) || (inode == 0) || (a_is_del)) { fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; if (dellen > 0) dellen -= minreclen; } /* We have a non-deleted entry */ else { fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; } if (tsk_fs_dir_add(a_fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } /* If the actual length is shorter then the ** recorded length, then the next entry(ies) have been ** deleted. Set dellen to the length of data that ** has been deleted ** ** Because we aren't guaranteed with Ext2FS that the next ** entry begins right after this one, we will check to ** see if the difference is less than a possible entry ** before we waste time searching it */ if (dellen <= 0) { if (reclen - minreclen >= EXT2FS_DIRSIZ_lcl(1)) dellen = reclen - minreclen; else minreclen = reclen; } } tsk_fs_name_free(fs_name); return TSK_OK; } /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM ext2fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) a_fs; char *dirbuf, *dirptr; TSK_OFF_T size; TSK_FS_LOAD_FILE load_file; TSK_FS_DIR *fs_dir; TSK_LIST *list_seen = NULL; /* If we get corruption in one of the blocks, then continue processing. * retval_final will change when corruption is detected. Errors are * returned immediately. */ TSK_RETVAL_ENUM retval_tmp; TSK_RETVAL_ENUM retval_final = TSK_OK; if (a_addr < a_fs->first_inum || a_addr > a_fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dir_open_meta: inode value: %" PRIuINUM "\n", a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dir_open_meta: NULL fs_attr argument given"); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "ext2fs_dir_open_meta: Processing directory %" PRIuINUM "\n", a_addr); fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else { if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(a_fs, a_addr, 128)) == NULL) { return TSK_ERR; } } // handle the orphan directory if its contents were requested if (a_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { return tsk_fs_dir_find_orphans(a_fs, fs_dir); } if ((fs_dir->fs_file = tsk_fs_file_open_meta(a_fs, NULL, a_addr)) == NULL) { tsk_error_reset(); strncat(tsk_errstr2, " - ext2fs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_COR; } size = roundup(fs_dir->fs_file->meta->size, a_fs->block_size); if ((dirbuf = tsk_malloc((size_t) size)) == NULL) { return TSK_ERR; } /* make a copy of the directory contents that we can process */ load_file.left = load_file.total = (size_t) size; load_file.base = load_file.cur = dirbuf; if (tsk_fs_file_walk(fs_dir->fs_file, TSK_FS_FILE_WALK_FLAG_SLACK, tsk_fs_load_file_action, (void *) &load_file)) { tsk_error_reset(); strncat(tsk_errstr2, " - ext2fs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(dirbuf); return TSK_COR; } /* Not all of the directory was copied, so we exit */ if (load_file.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_dir_open_meta: Error reading directory contents: %" PRIuINUM "\n", a_addr); free(dirbuf); return TSK_COR; } dirptr = dirbuf; while ((int64_t) size > 0) { int len = (a_fs->block_size < size) ? a_fs->block_size : (int) size; retval_tmp = ext2fs_dent_parse_block(ext2fs, fs_dir, (fs_dir->fs_file->meta-> flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, &list_seen, dirptr, len); if (retval_tmp == TSK_ERR) { retval_final = TSK_ERR; break; } else if (retval_tmp == TSK_COR) { retval_final = TSK_COR; } size -= len; dirptr = (char *) ((uintptr_t) dirptr + len); } free(dirbuf); // if we are listing the root directory, add the Orphan directory entry if (a_addr == a_fs->root_inum) { TSK_FS_NAME *fs_name = tsk_fs_name_alloc(256, 0); if (fs_name == NULL) return TSK_ERR; if (tsk_fs_dir_make_orphan_dir_name(a_fs, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); } return retval_final; } sleuthkit-3.2.3/tsk3/fs/ext2fs_journal.c000644 000765 000024 00000045537 11643647440 020761 0ustar00carrierstaff000000 000000 /* @@@ UNALLOC only if seq is less - alloc can be less than block if it wrapped around ... ** ext2fs_journal ** The Sleuth Kit ** ** Journaling code for TSK_FS_INFO_TYPE_EXT_3 image ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2004-2005 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** \file ext2fs_journal.c * Contains the internal TSK Ext3 journal walking code. */ #include "tsk_fs_i.h" #include "tsk_ext2fs.h" /* Everything in the journal is in big endian */ #define big_tsk_getu32(x) \ (uint32_t)((((uint8_t *)x)[3] << 0) + \ (((uint8_t *)x)[2] << 8) + \ (((uint8_t *)x)[1] << 16) + \ (((uint8_t *)x)[0] << 24) ) /* * */ static TSK_WALK_RET_ENUM load_sb_action(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { TSK_FS_INFO *fs = fs_file->fs_info; ext2fs_journ_sb *sb; EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; EXT2FS_JINFO *jinfo = ext2fs->jinfo; if (size < 1024) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "FS block size is less than 1024, not supported in journal yet"); return TSK_WALK_ERROR; } sb = (ext2fs_journ_sb *) buf; if (big_tsk_getu32(sb->magic) != EXT2_JMAGIC) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Journal inode %" PRIuINUM " does not have a valid magic value: %" PRIx32, jinfo->j_inum, big_tsk_getu32(sb->magic)); return TSK_WALK_ERROR; } jinfo->bsize = big_tsk_getu32(sb->bsize); jinfo->first_block = big_tsk_getu32(sb->first_blk); jinfo->last_block = big_tsk_getu32(sb->num_blk) - 1; jinfo->start_blk = big_tsk_getu32(sb->start_blk); jinfo->start_seq = big_tsk_getu32(sb->start_seq); return TSK_WALK_STOP; } /* Place journal data in *fs * * Return 0 on success and 1 on error * */ uint8_t ext2fs_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; EXT2FS_JINFO *jinfo; // clean up any error messages that are lying around tsk_error_reset(); if (!fs) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jopen: fs is null"); return 1; } ext2fs->jinfo = jinfo = (EXT2FS_JINFO *) tsk_malloc(sizeof(EXT2FS_JINFO)); if (jinfo == NULL) { return 1; } jinfo->j_inum = inum; jinfo->fs_file = tsk_fs_file_open_meta(fs, NULL, inum); if (!jinfo->fs_file) { free(jinfo); return 1; // error("error finding journal inode %" PRIu32, inum); } if (tsk_fs_file_walk(jinfo->fs_file, 0, load_sb_action, NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error loading ext3 journal"); tsk_fs_file_close(jinfo->fs_file); free(jinfo); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "journal opened at inode %" PRIuINUM " bsize: %" PRIu32 " First JBlk: %" PRIuDADDR " Last JBlk: %" PRIuDADDR "\n", inum, jinfo->bsize, jinfo->first_block, jinfo->last_block); return 0; } /* Limitations: does not use the action or any flags * * return 0 on success and 1 on error * */ uint8_t ext2fs_jentry_walk(TSK_FS_INFO * fs, int flags, TSK_FS_JENTRY_WALK_CB action, void *ptr) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; EXT2FS_JINFO *jinfo = ext2fs->jinfo; char *journ; TSK_FS_LOAD_FILE buf1; TSK_DADDR_T i; int b_desc_seen = 0; // clean up any error messages that are lying around tsk_error_reset(); if ((jinfo == NULL) || (jinfo->fs_file == NULL) || (jinfo->fs_file->meta == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jentry_walk: journal is not open"); return 1; } if (jinfo->fs_file->meta->size != (jinfo->last_block + 1) * jinfo->bsize) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jentry_walk: journal file size is different from \nsize reported in journal super block"); return 1; } /* Load the journal into a buffer */ buf1.left = buf1.total = (size_t) jinfo->fs_file->meta->size; journ = buf1.cur = buf1.base = tsk_malloc(buf1.left); if (journ == NULL) { return 1; } if (tsk_fs_file_walk(jinfo->fs_file, 0, tsk_fs_load_file_action, (void *) &buf1)) { free(journ); return 1; } if (buf1.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jentry_walk: Buffer not fully copied"); free(journ); return 1; } /* Process the journal * Cycle through each block */ tsk_printf("JBlk\tDescriptrion\n"); /* Note that 'i' is incremented when we find a descriptor block and * process its contents. */ for (i = 0; i < jinfo->last_block; i++) { ext2fs_journ_head *head; /* if there is no magic, then it is a normal block * These should be accounted for when we see its corresponding * descriptor. We get the 'unknown' when its desc has * been reused, it is in the next batch to be overwritten, * or if it has not been used before */ head = (ext2fs_journ_head *) & journ[i * jinfo->bsize]; if (big_tsk_getu32(head->magic) != EXT2_JMAGIC) { if (i < jinfo->first_block) { tsk_printf("%" PRIuDADDR ":\tUnused\n", i); } #if 0 /* For now, we ignore the case of the iitial entries before a descriptor, it is too hard ... */ else if (b_desc_seen == 0) { ext2fs_journ_head *head2 = NULL; TSK_DADDR_T a; int next_head = 0, next_seq = 0; ext2fs_journ_dentry *dentry; /* This occurs when the log cycled around * We need to find out where the descriptor is * and where we need to end */ b_desc_seen = 1; for (a = i; a < jinfo->last_block; a++) { head2 = (ext2fs_journ_head *) & journ[a * jinfo->bsize]; if ((big_tsk_getu32(head2->magic) == EXT2_JMAGIC)) { next_head = a; next_seq = big_tsk_getu32(head2->entry_seq); break; } } if (next_head == 0) { tsk_printf("%" PRIuDADDR ":\tFS Block Unknown\n", i); } /* Find the last descr in the journ */ for (a = jinfo->last_block; a > i; a--) { head2 = (ext2fs_journ_head *) & journ[a * jinfo->bsize]; if ((big_tsk_getu32(head2->magic) == EXT2_JMAGIC) && (big_tsk_getu32(head2->entry_type) == EXT2_J_ETYPE_DESC) && (next_seq == big_tsk_getu32(head2->entry_seq))) { break; // @@@@ We should abort if we reach a commit before descriptor } } /* We did not find a descriptor in the journ! * print unknown for the rest of the journ */ if (a == i) { tsk_printf("%" PRIuDADDR ":\tFS Block Unknown\n", i); continue; } dentry = (ext2fs_journ_dentry *) ((uintptr_t) head2 + sizeof(ext2fs_journ_head));; /* Cycle through the descriptor entries */ while ((uintptr_t) dentry <= ((uintptr_t) head2 + jinfo->bsize - sizeof(ext2fs_journ_head))) { /* Only start to look after the index in the desc has looped */ if (++a <= jinfo->last_block) { ext2fs_journ_head *head3; /* Look at the block that this entry refers to */ head3 = (ext2fs_journ_head *) & journ[i * jinfo->bsize]; if ((big_tsk_getu32(head3->magic) == EXT2_JMAGIC)) { i--; break; } /* If it doesn't have the magic, then it is a * journal entry and we print the FS info */ tsk_printf("%" PRIuDADDR ":\tFS Block %" PRIu32 "\n", i, big_tsk_getu32(dentry->fs_blk)); /* Our counter is over the end of the journ */ if (++i > jinfo->last_block) break; } /* Increment to the next */ if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_LAST) break; /* If the SAMEID value is set, then we advance by the size of the entry, otherwise add 16 for the ID */ else if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_SAMEID) dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry)); else dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry) + 16); } } #endif else { tsk_printf("%" PRIuDADDR ":\tUnallocated FS Block Unknown\n", i); } } /* The super block */ else if ((big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_SB1) || (big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_SB2)) { tsk_printf("%" PRIuDADDR ":\tSuperblock (seq: %" PRIu32 ")\n", i, big_tsk_getu32(head->entry_seq)); } /* Revoke Block */ else if (big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_REV) { tsk_printf("%" PRIuDADDR ":\t%sRevoke Block (seq: %" PRIu32 ")\n", i, ((i < jinfo->start_blk) || (big_tsk_getu32(head->entry_seq) < jinfo->start_seq)) ? "Unallocated " : "Allocated ", big_tsk_getu32(head->entry_seq)); } /* The commit is the end of the entries */ else if (big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_COM) { tsk_printf("%" PRIuDADDR ":\t%sCommit Block (seq: %" PRIu32 ")\n", i, ((i < jinfo->start_blk) || (big_tsk_getu32(head->entry_seq) < jinfo->start_seq)) ? "Unallocated " : "Allocated ", big_tsk_getu32(head->entry_seq)); } /* The descriptor describes the FS blocks that follow it */ else if (big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_DESC) { ext2fs_journ_dentry *dentry; ext2fs_journ_head *head2; int unalloc = 0; b_desc_seen = 1; /* Is this an unallocated journ block or sequence */ if ((i < jinfo->start_blk) || (big_tsk_getu32(head->entry_seq) < jinfo->start_seq)) unalloc = 1; tsk_printf("%" PRIuDADDR ":\t%sDescriptor Block (seq: %" PRIu32 ")\n", i, (unalloc) ? "Unallocated " : "Allocated ", big_tsk_getu32(head->entry_seq)); dentry = (ext2fs_journ_dentry *) ((uintptr_t) head + sizeof(ext2fs_journ_head));; /* Cycle through the descriptor entries to account for the journal blocks */ while ((uintptr_t) dentry <= ((uintptr_t) head + jinfo->bsize - sizeof(ext2fs_journ_head))) { /* Our counter is over the end of the journ */ if (++i > jinfo->last_block) break; /* Look at the block that this entry refers to */ head2 = (ext2fs_journ_head *) & journ[i * jinfo->bsize]; if ((big_tsk_getu32(head2->magic) == EXT2_JMAGIC) && (big_tsk_getu32(head2->entry_seq) >= big_tsk_getu32(head->entry_seq))) { i--; break; } /* If it doesn't have the magic, then it is a * journal entry and we print the FS info */ tsk_printf("%" PRIuDADDR ":\t%sFS Block %" PRIu32 "\n", i, (unalloc) ? "Unallocated " : "Allocated ", big_tsk_getu32(dentry->fs_blk)); /* Increment to the next */ if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_LAST) break; /* If the SAMEID value is set, then we advance by the size of the entry, otherwise add 16 for the ID */ else if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_SAMEID) dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry)); else dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry) + 16); } } } free(journ); return 0; } /* * Limitations for 1st version: start must equal end and action is ignored * * Return 0 on success and 1 on error */ uint8_t ext2fs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int flags, TSK_FS_JBLK_WALK_CB action, void *ptr) { EXT2FS_INFO *ext2fs = (EXT2FS_INFO *) fs; EXT2FS_JINFO *jinfo = ext2fs->jinfo; char *journ; TSK_FS_LOAD_FILE buf1; TSK_DADDR_T i; ext2fs_journ_head *head; // clean up any error messages that are lying around tsk_error_reset(); if ((jinfo == NULL) || (jinfo->fs_file == NULL) || (jinfo->fs_file->meta == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jblk_walk: journal is not open"); return 1; } if (jinfo->last_block < end) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jblk_walk: end is too large "); return 1; } if (start != end) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_blk_walk: only start == end is currently supported"); return 1; } if (jinfo->fs_file->meta->size != (jinfo->last_block + 1) * jinfo->bsize) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jblk_walk: journal file size is different from size reported in journal super block"); return 1; } /* Load into buffer and then process it * Only get the minimum needed */ buf1.left = buf1.total = (size_t) ((end + 1) * jinfo->bsize); journ = buf1.cur = buf1.base = tsk_malloc(buf1.left); if (journ == NULL) { return 1; } if (tsk_fs_file_walk(jinfo->fs_file, 0, tsk_fs_load_file_action, (void *) &buf1)) { free(journ); return 1; } if (buf1.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jblk_walk: Buffer not fully copied"); free(journ); return 1; } head = (ext2fs_journ_head *) & journ[end * jinfo->bsize]; /* Check if our target block is a journal data structure. * * If not, * we need to look for its descriptor to see if it has been * escaped */ if (big_tsk_getu32(head->magic) != EXT2_JMAGIC) { /* cycle backwards until we find a desc block */ for (i = end - 1; i >= 0; i--) { ext2fs_journ_dentry *dentry; TSK_DADDR_T diff; head = (ext2fs_journ_head *) & journ[i * jinfo->bsize]; if (big_tsk_getu32(head->magic) != EXT2_JMAGIC) continue; /* If we get a commit, then any desc we find will not * be for our block, so forget about it */ if (big_tsk_getu32(head->entry_type) == EXT2_J_ETYPE_COM) break; /* Skip any other data structure types */ if (big_tsk_getu32(head->entry_type) != EXT2_J_ETYPE_DESC) continue; /* We now have the previous descriptor * * NOTE: We have no clue if this is the correct * descriptor if it is not the current 'run' of * transactions, but this is the best we can do */ diff = end - i; dentry = (ext2fs_journ_dentry *) (&journ[i * jinfo->bsize] + sizeof(ext2fs_journ_head)); while ((uintptr_t) dentry <= ((uintptr_t) & journ[(i + 1) * jinfo->bsize] - sizeof(ext2fs_journ_head))) { if (--diff == 0) { if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_ESC) { journ[end * jinfo->bsize] = 0xC0; journ[end * jinfo->bsize + 1] = 0x3B; journ[end * jinfo->bsize + 2] = 0x39; journ[end * jinfo->bsize + 3] = 0x98; } break; } /* If the SAMEID value is set, then we advance by the size of the entry, otherwise add 16 for the ID */ if (big_tsk_getu32(dentry->flag) & EXT2_J_DENTRY_SAMEID) dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry)); else dentry = (ext2fs_journ_dentry *) ((uintptr_t) dentry + sizeof(ext2fs_journ_dentry) + 16); } break; } } if (fwrite(&journ[end * jinfo->bsize], jinfo->bsize, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "ext2fs_jblk_walk: error writing buffer block"); free(journ); return 1; } free(journ); return 0; } sleuthkit-3.2.3/tsk3/fs/fatfs.c000644 000765 000024 00000154206 11643647440 017111 0ustar00carrierstaff000000 000000 /* ** fatfs ** The Sleuth Kit ** ** Content and meta data layer support for the FAT file system ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** ** Unicode added with support from I.D.E.A.L. Technology Corp (Aug '05) ** */ /** * \file fatfs.c * Contains the internal TSK FAT file system code to handle basic file system * processing for opening file system, processing sectors, and directory entries. */ #include "tsk_fs_i.h" #include "tsk_fatfs.h" /* * Implementation NOTES * * TSK_FS_META contains the first cluster. file_walk will return sector * values though because the cluster numbers do not start until after * the FAT. That makes it very hard to address the first few blocks! * * Inodes numbers do not exist in FAT. To make up for this we will count * directory entries as the inodes. As the root directory does not have * any records in FAT, we will give it times of 0 and call it inode 2 to * keep consistent with UNIX. After that, each 32-byte slot is numbered * as though it were a directory entry (even if it is not). Therefore, * when an inode walk is performed, not all inode values will be displayed * even when '-e' is given for ils. * * Progs like 'ils -e' are very slow because we have to look at each * block to see if it is a file system structure. */ /* TTL is 0 if the entry has not been used. TTL of 1 means it was the * most recently used, and TTL of FAT_CACHE_N means it was the least * recently used. This function has a LRU replacement algo */ // return -1 on error, or cache index on success (0 to FAT_CACHE_N) static int getFATCacheIdx(FATFS_INFO * fatfs, TSK_DADDR_T sect) { int i, cidx; ssize_t cnt; TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; // see if we already have it in the cache for (i = 0; i < FAT_CACHE_N; i++) { if ((fatfs->fatc_ttl[i] > 0) && (sect >= fatfs->fatc_addr[i]) && (sect < (fatfs->fatc_addr[i] + FAT_CACHE_S))) { int a; // update the TTLs to push i to the front for (a = 0; a < FAT_CACHE_N; a++) { if (fatfs->fatc_ttl[a] == 0) continue; if (fatfs->fatc_ttl[a] < fatfs->fatc_ttl[i]) fatfs->fatc_ttl[a]++; } fatfs->fatc_ttl[i] = 1; // fprintf(stdout, "FAT Hit: %d\n", sect); // fflush(stdout); return i; } } // fprintf(stdout, "FAT Miss: %d\n", (int)sect); // fflush(stdout); // Look for an unused entry or an entry with a TTL of FAT_CACHE_N cidx = 0; for (i = 0; i < FAT_CACHE_N; i++) { if ((fatfs->fatc_ttl[i] == 0) || (fatfs->fatc_ttl[i] >= FAT_CACHE_N)) { cidx = i; } } // fprintf(stdout, "FAT Removing: %d\n", (int)fatfs->fatc_addr[cidx]); // fflush(stdout); // read the data cnt = tsk_fs_read(fs, sect * fs->block_size, fatfs->fatc_buf[cidx], FAT_CACHE_B); if (cnt != FAT_CACHE_B) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "getFATCacheIdx: FAT: %" PRIuDADDR, sect); return -1; } // update the TTLs if (fatfs->fatc_ttl[cidx] == 0) // special case for unused entry fatfs->fatc_ttl[cidx] = FAT_CACHE_N + 1; for (i = 0; i < FAT_CACHE_N; i++) { if (fatfs->fatc_ttl[i] == 0) continue; if (fatfs->fatc_ttl[i] < fatfs->fatc_ttl[cidx]) fatfs->fatc_ttl[i]++; } fatfs->fatc_ttl[cidx] = 1; fatfs->fatc_addr[cidx] = sect; return cidx; } /* * Set *value to the entry in the File Allocation Table (FAT) * for the given cluster * * *value is in clusters and may need to be coverted to * sectors by the calling function * * Invalid values in the FAT (i.e. greater than the largest * cluster have a value of 0 returned and a 0 return value. * * Return 1 on error and 0 on success */ uint8_t fatfs_getFAT(FATFS_INFO * fatfs, TSK_DADDR_T clust, TSK_DADDR_T * value) { uint8_t *a_ptr; uint16_t tmp16; TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; TSK_DADDR_T sect, offs; ssize_t cnt; int cidx; /* Sanity Check */ if (clust > fatfs->lastclust) { /* silently ignore requests for the unclustered sectors... */ if ((clust == fatfs->lastclust + 1) && ((fatfs->firstclustsect + fatfs->csize * fatfs->clustcnt - 1) != fs->last_block)) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_getFAT: Ignoring request for non-clustered sector\n"); return 0; } tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_getFAT: invalid cluster address: %" PRIuDADDR, clust); return 1; } switch (fatfs->fs_info.ftype) { case TSK_FS_TYPE_FAT12: if (clust & 0xf000) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_getFAT: TSK_FS_TYPE_FAT12 Cluster %" PRIuDADDR " too large", clust); return 1; } /* id the sector in the FAT */ sect = fatfs->firstfatsect + ((clust + (clust >> 1)) >> fatfs->ssize_sh); /* Load the FAT if we don't have it */ // see if it is in the cache if (-1 == (cidx = getFATCacheIdx(fatfs, sect))) return 1; /* get the offset into the cache */ offs = ((sect - fatfs->fatc_addr[cidx]) << fatfs->ssize_sh) + (clust + (clust >> 1)) % fatfs->ssize; /* special case when the 12-bit value goes across the cache * we load the cache to start at this sect. The cache * size must therefore be at least 2 sectors large */ if (offs == (FAT_CACHE_B - 1)) { // read the data -- TTLs will already have been updated cnt = tsk_fs_read(fs, sect * fs->block_size, fatfs->fatc_buf[cidx], FAT_CACHE_B); if (cnt != FAT_CACHE_B) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_getFAT: TSK_FS_TYPE_FAT12 FAT overlap: %" PRIuDADDR, sect); return 1; } fatfs->fatc_addr[cidx] = sect; offs = (clust + (clust >> 1)) % fatfs->ssize; } /* get pointer to entry in current buffer */ a_ptr = (uint8_t *) fatfs->fatc_buf[cidx] + offs; tmp16 = tsk_getu16(fs->endian, a_ptr); /* slide it over if it is one of the odd clusters */ if (clust & 1) tmp16 >>= 4; *value = tmp16 & FATFS_12_MASK; /* sanity check */ if ((*value > (fatfs->lastclust)) && (*value < (0x0ffffff7 & FATFS_12_MASK))) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_getFAT: TSK_FS_TYPE_FAT12 cluster (%" PRIuDADDR ") too large (%" PRIuDADDR ") - resetting\n", clust, *value); *value = 0; } return 0; case TSK_FS_TYPE_FAT16: /* Get sector in FAT for cluster and load it if needed */ sect = fatfs->firstfatsect + ((clust << 1) >> fatfs->ssize_sh); if (-1 == (cidx = getFATCacheIdx(fatfs, sect))) return 1; /* get pointer to entry in the cache buffer */ a_ptr = (uint8_t *) fatfs->fatc_buf[cidx] + ((sect - fatfs->fatc_addr[cidx]) << fatfs->ssize_sh) + ((clust << 1) % fatfs->ssize); *value = tsk_getu16(fs->endian, a_ptr) & FATFS_16_MASK; /* sanity check */ if ((*value > (fatfs->lastclust)) && (*value < (0x0ffffff7 & FATFS_16_MASK))) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_getFAT: contents of TSK_FS_TYPE_FAT16 entry %" PRIuDADDR " too large - resetting\n", clust); *value = 0; } return 0; case TSK_FS_TYPE_FAT32: /* Get sector in FAT for cluster and load if needed */ sect = fatfs->firstfatsect + ((clust << 2) >> fatfs->ssize_sh); if (-1 == (cidx = getFATCacheIdx(fatfs, sect))) return 1; /* get pointer to entry in current buffer */ a_ptr = (uint8_t *) fatfs->fatc_buf[cidx] + ((sect - fatfs->fatc_addr[cidx]) << fatfs->ssize_sh) + (clust << 2) % fatfs->ssize; *value = tsk_getu32(fs->endian, a_ptr) & FATFS_32_MASK; /* sanity check */ if ((*value > fatfs->lastclust) && (*value < (0x0ffffff7 & FATFS_32_MASK))) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_getFAT: contents of entry %" PRIuDADDR " too large - resetting\n", clust); *value = 0; } return 0; default: tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_getFAT: Unknown FAT type: %d", fatfs->fs_info.ftype); return 1; } } /* Return 1 if allocated, 0 if unallocated, and -1 if error */ int8_t fatfs_is_clustalloc(FATFS_INFO * fatfs, TSK_DADDR_T clust) { TSK_DADDR_T content; if (fatfs_getFAT(fatfs, clust, &content)) return -1; else if (content == FATFS_UNALLOC) return 0; else return 1; } /* * Identifies if a sector is allocated * * If it is less than the data area, then it is allocated * else the FAT table is consulted * * Return 1 if allocated, 0 if unallocated, and -1 if error */ int8_t fatfs_is_sectalloc(FATFS_INFO * fatfs, TSK_DADDR_T sect) { TSK_FS_INFO *fs = (TSK_FS_INFO *) fatfs; /* If less than the first cluster sector, then it is allocated * otherwise check the FAT */ if (sect < fatfs->firstclustsect) return 1; /* If we are in the unused area, then we are "unalloc" */ if ((sect <= fs->last_block) && (sect >= (fatfs->firstclustsect + fatfs->csize * fatfs->clustcnt))) return 0; return fatfs_is_clustalloc(fatfs, FATFS_SECT_2_CLUST(fatfs, sect)); } TSK_FS_BLOCK_FLAG_ENUM fatfs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { FATFS_INFO *fatfs = (FATFS_INFO *) a_fs; int flags = 0; // FATs and boot sector if (a_addr < fatfs->firstdatasect) { flags = TSK_FS_BLOCK_FLAG_META | TSK_FS_BLOCK_FLAG_ALLOC; } // root directory for FAT12/16 else if (a_addr < fatfs->firstclustsect) { flags = TSK_FS_BLOCK_FLAG_CONT | TSK_FS_BLOCK_FLAG_ALLOC; } else { int retval; flags = TSK_FS_BLOCK_FLAG_CONT; /* Identify its allocation status */ retval = fatfs_is_sectalloc(fatfs, a_addr); if (retval != -1) { if (retval == 1) flags |= TSK_FS_BLOCK_FLAG_ALLOC; else flags |= TSK_FS_BLOCK_FLAG_UNALLOC; } } return flags; } /************************************************************************** * * BLOCK WALKING * *************************************************************************/ /* ** Walk the sectors of the partition. ** ** NOTE: This is by SECTORS and not CLUSTERS ** _flags: TSK_FS_BLOCK_FLAG_ALLOC, TSK_FS_BLOCK_FLAG_UNALLOC, TSK_FS_BLOCK_FLAG_META ** TSK_FS_BLOCK_FLAG_CONT ** */ uint8_t fatfs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr) { char *myname = "fatfs_block_walk"; FATFS_INFO *fatfs = (FATFS_INFO *) fs; char *data_buf = NULL; ssize_t cnt; TSK_FS_BLOCK *fs_block; TSK_DADDR_T addr; int myflags; unsigned int i; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (a_start_blk < fs->first_block || a_start_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start block: %" PRIuDADDR "", myname, a_start_blk); return 1; } if (a_end_blk < fs->first_block || a_end_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End block: %" PRIuDADDR "", myname, a_end_blk); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_block_walk: Block Walking %" PRIuDADDR " to %" PRIuDADDR "\n", a_start_blk, a_end_blk); /* Sanity check on a_flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } /* cycle through the sectors. We do the sectors before the first * cluster seperate from the data area */ addr = a_start_blk; /* Before the data area beings (FAT, root directory etc.) */ if ((a_start_blk < fatfs->firstclustsect) && (a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC)) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_block_walk: Walking non-data area (pre %" PRIuDADDR "\n", fatfs->firstclustsect); if ((data_buf = (char *) tsk_malloc(fs->block_size * 8)) == NULL) { tsk_fs_block_free(fs_block); return 1; } /* Read 8 sectors at a time to be faster */ for (; addr < fatfs->firstclustsect && addr <= a_end_blk;) { cnt = tsk_fs_read_block(fs, addr, data_buf, fs->block_size * 8); if (cnt != fs->block_size * 8) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_block_walk: pre-data area block: %" PRIuDADDR, addr); free(data_buf); tsk_fs_block_free(fs_block); return 1; } /* Process the sectors until we get to the clusters, * end of target, or end of buffer */ for (i = 0; i < 8 && (addr) <= a_end_blk && (addr) < fatfs->firstclustsect; i++, addr++) { int retval; myflags = TSK_FS_BLOCK_FLAG_ALLOC; /* stuff before the first data sector is the * FAT and boot sector */ if (addr < fatfs->firstdatasect) myflags |= TSK_FS_BLOCK_FLAG_META; /* This must be the root directory for FAT12/16 */ else myflags |= TSK_FS_BLOCK_FLAG_CONT; // test this sector (we already tested ALLOC) if ((myflags & TSK_FS_BLOCK_FLAG_META) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_META))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_CONT) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT))) continue; tsk_fs_block_set(fs, fs_block, addr, myflags | TSK_FS_BLOCK_FLAG_RAW, &data_buf[i * fs->block_size]); retval = a_action(fs_block, a_ptr); if (retval == TSK_WALK_STOP) { free(data_buf); tsk_fs_block_free(fs_block); return 0; } else if (retval == TSK_WALK_ERROR) { free(data_buf); tsk_fs_block_free(fs_block); return 1; } } } free(data_buf); /* Was that it? */ if (addr >= a_end_blk) { tsk_fs_block_free(fs_block); return 0; } } /* Reset the first sector to the start of the data area if we did * not examine it - the next calculation will screw up otherwise */ else if (addr < fatfs->firstclustsect) { addr = fatfs->firstclustsect; } /* Now we read in the clusters in cluster-sized chunks, * sectors are too small */ /* Determine the base sector of the cluster where the first * sector is located */ addr = FATFS_CLUST_2_SECT(fatfs, (FATFS_SECT_2_CLUST(fatfs, addr))); if ((data_buf = tsk_malloc(fs->block_size * fatfs->csize)) == NULL) { tsk_fs_block_free(fs_block); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_block_walk: Walking data area blocks (%" PRIuDADDR " to %" PRIuDADDR ")\n", addr, a_end_blk); for (; addr <= a_end_blk; addr += fatfs->csize) { int retval; size_t read_size; /* Identify its allocation status */ retval = fatfs_is_sectalloc(fatfs, addr); if (retval == -1) { free(data_buf); tsk_fs_block_free(fs_block); return 1; } else if (retval == 1) { myflags = TSK_FS_BLOCK_FLAG_ALLOC; } else { myflags = TSK_FS_BLOCK_FLAG_UNALLOC; } /* At this point, there should be no more meta - just content */ myflags |= TSK_FS_BLOCK_FLAG_CONT; // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_CONT) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; /* The final cluster may not be full */ if (a_end_blk - addr + 1 < fatfs->csize) read_size = (size_t) (a_end_blk - addr + 1); else read_size = fatfs->csize; cnt = tsk_fs_read_block (fs, addr, data_buf, fs->block_size * read_size); if (cnt != fs->block_size * read_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_block_walk: block: %" PRIuDADDR, addr); free(data_buf); tsk_fs_block_free(fs_block); return 1; } /* go through each sector in the cluster */ for (i = 0; i < read_size; i++) { int retval; if (addr + i < a_start_blk) continue; else if (addr + i > a_end_blk) break; tsk_fs_block_set(fs, fs_block, addr + i, myflags | TSK_FS_BLOCK_FLAG_RAW, &data_buf[i * fs->block_size]); retval = a_action(fs_block, a_ptr); if (retval == TSK_WALK_STOP) { free(data_buf); tsk_fs_block_free(fs_block); return 0; } else if (retval == TSK_WALK_ERROR) { free(data_buf); tsk_fs_block_free(fs_block); return 1; } } } free(data_buf); tsk_fs_block_free(fs_block); return 0; } /* return 1 on error and 0 on success */ static uint8_t fatfs_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for FAT yet"); return 1; /* Check that allocated dentries point to start of allcated cluster chain */ /* Size of file is consistent with cluster chain length */ /* Allocated cluster chains have a corresponding alloc dentry */ /* Non file dentries have no clusters */ /* Only one volume label */ /* Dump Bad Sector Addresses */ /* Dump unused sector addresses * Reserved area, end of FAT, end of Data Area */ } /** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ static uint8_t fatfs_fsstat(TSK_FS_INFO * fs, FILE * hFile) { unsigned int i; int a; TSK_DADDR_T next, snext, sstart, send; FATFS_INFO *fatfs = (FATFS_INFO *) fs; fatfs_sb *sb = fatfs->sb; char *data_buf; fatfs_dentry *de; ssize_t cnt; // clean up any error messages that are lying around tsk_error_reset(); if ((data_buf = (char *) tsk_malloc(fs->block_size)) == NULL) { return 1; } /* Read the root directory sector so that we can get the volume * label from it */ cnt = tsk_fs_read_block(fs, fatfs->rootsect, data_buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_fsstat: root directory: %" PRIuDADDR, fatfs->rootsect); free(data_buf); return 1; } /* Find the dentry that is set as the volume label */ de = (fatfs_dentry *) data_buf; for (i = 0; i < fatfs->ssize; i += sizeof(*de)) { if (de->attrib == FATFS_ATTR_VOLUME) break; de++; } /* If we didn't find it, then reset de */ if (de->attrib != FATFS_ATTR_VOLUME) de = NULL; /* Print the general file system information */ tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: FAT"); if (fs->ftype == TSK_FS_TYPE_FAT12) tsk_fprintf(hFile, "12\n"); else if (fs->ftype == TSK_FS_TYPE_FAT16) tsk_fprintf(hFile, "16\n"); else if (fs->ftype == TSK_FS_TYPE_FAT32) tsk_fprintf(hFile, "32\n"); else tsk_fprintf(hFile, "\n"); tsk_fprintf(hFile, "\nOEM Name: %c%c%c%c%c%c%c%c\n", sb->oemname[0], sb->oemname[1], sb->oemname[2], sb->oemname[3], sb->oemname[4], sb->oemname[5], sb->oemname[6], sb->oemname[7]); if (fatfs->fs_info.ftype != TSK_FS_TYPE_FAT32) { tsk_fprintf(hFile, "Volume ID: 0x%" PRIx32 "\n", tsk_getu32(fs->endian, sb->a.f16.vol_id)); tsk_fprintf(hFile, "Volume Label (Boot Sector): %c%c%c%c%c%c%c%c%c%c%c\n", sb->a.f16.vol_lab[0], sb->a.f16.vol_lab[1], sb->a.f16.vol_lab[2], sb->a.f16.vol_lab[3], sb->a.f16.vol_lab[4], sb->a.f16.vol_lab[5], sb->a.f16.vol_lab[6], sb->a.f16.vol_lab[7], sb->a.f16.vol_lab[8], sb->a.f16.vol_lab[9], sb->a.f16.vol_lab[10]); if ((de) && (de->name)) { tsk_fprintf(hFile, "Volume Label (Root Directory): %c%c%c%c%c%c%c%c%c%c%c\n", de->name[0], de->name[1], de->name[2], de->name[3], de->name[4], de->name[5], de->name[6], de->name[7], de->ext[0], de->ext[1], de->ext[2]); } else { tsk_fprintf(hFile, "Volume Label (Root Directory):\n"); } tsk_fprintf(hFile, "File System Type Label: %c%c%c%c%c%c%c%c\n", sb->a.f16.fs_type[0], sb->a.f16.fs_type[1], sb->a.f16.fs_type[2], sb->a.f16.fs_type[3], sb->a.f16.fs_type[4], sb->a.f16.fs_type[5], sb->a.f16.fs_type[6], sb->a.f16.fs_type[7]); } else { char *fat_fsinfo_buf; fatfs_fsinfo *fat_info; if ((fat_fsinfo_buf = (char *) tsk_malloc(sizeof(fatfs_fsinfo))) == NULL) { free(data_buf); return 1; } tsk_fprintf(hFile, "Volume ID: 0x%" PRIx32 "\n", tsk_getu32(fs->endian, sb->a.f32.vol_id)); tsk_fprintf(hFile, "Volume Label (Boot Sector): %c%c%c%c%c%c%c%c%c%c%c\n", sb->a.f32.vol_lab[0], sb->a.f32.vol_lab[1], sb->a.f32.vol_lab[2], sb->a.f32.vol_lab[3], sb->a.f32.vol_lab[4], sb->a.f32.vol_lab[5], sb->a.f32.vol_lab[6], sb->a.f32.vol_lab[7], sb->a.f32.vol_lab[8], sb->a.f32.vol_lab[9], sb->a.f32.vol_lab[10]); if ((de) && (de->name)) { tsk_fprintf(hFile, "Volume Label (Root Directory): %c%c%c%c%c%c%c%c%c%c%c\n", de->name[0], de->name[1], de->name[2], de->name[3], de->name[4], de->name[5], de->name[6], de->name[7], de->ext[0], de->ext[1], de->ext[2]); } else { tsk_fprintf(hFile, "Volume Label (Root Directory):\n"); } tsk_fprintf(hFile, "File System Type Label: %c%c%c%c%c%c%c%c\n", sb->a.f32.fs_type[0], sb->a.f32.fs_type[1], sb->a.f32.fs_type[2], sb->a.f32.fs_type[3], sb->a.f32.fs_type[4], sb->a.f32.fs_type[5], sb->a.f32.fs_type[6], sb->a.f32.fs_type[7]); /* Process the FS info */ if (tsk_getu16(fs->endian, sb->a.f32.fsinfo)) { cnt = tsk_fs_read_block(fs, (TSK_DADDR_T) tsk_getu16(fs->endian, sb->a.f32.fsinfo), fat_fsinfo_buf, sizeof(fatfs_fsinfo)); if (cnt != sizeof(fatfs_fsinfo)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_fsstat: TSK_FS_TYPE_FAT32 FSINFO block: %" PRIuDADDR, (TSK_DADDR_T) tsk_getu16(fs->endian, sb->a.f32.fsinfo)); free(data_buf); free(fat_fsinfo_buf); return 1; } fat_info = (fatfs_fsinfo *) fat_fsinfo_buf; tsk_fprintf(hFile, "Next Free Sector (FS Info): %" PRIuDADDR "\n", FATFS_CLUST_2_SECT(fatfs, tsk_getu32(fs->endian, fat_info->nextfree))); tsk_fprintf(hFile, "Free Sector Count (FS Info): %" PRIu32 "\n", (tsk_getu32(fs->endian, fat_info->freecnt) * fatfs->csize)); free(fat_fsinfo_buf); } } free(data_buf); tsk_fprintf(hFile, "\nSectors before file system: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->prevsect)); tsk_fprintf(hFile, "\nFile System Layout (in sectors)\n"); tsk_fprintf(hFile, "Total Range: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block); if (fs->last_block != fs->last_block_act) tsk_fprintf(hFile, "Total Range in Image: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block_act); tsk_fprintf(hFile, "* Reserved: 0 - %" PRIuDADDR "\n", fatfs->firstfatsect - 1); tsk_fprintf(hFile, "** Boot Sector: 0\n"); if (fatfs->fs_info.ftype == TSK_FS_TYPE_FAT32) { tsk_fprintf(hFile, "** FS Info Sector: %" PRIu16 "\n", tsk_getu16(fs->endian, sb->a.f32.fsinfo)); tsk_fprintf(hFile, "** Backup Boot Sector: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->a.f32.bs_backup)); } for (i = 0; i < fatfs->numfat; i++) { TSK_DADDR_T base = fatfs->firstfatsect + i * (fatfs->sectperfat); tsk_fprintf(hFile, "* FAT %d: %" PRIuDADDR " - %" PRIuDADDR "\n", i, base, (base + fatfs->sectperfat - 1)); } tsk_fprintf(hFile, "* Data Area: %" PRIuDADDR " - %" PRIuDADDR "\n", fatfs->firstdatasect, fs->last_block); if (fatfs->fs_info.ftype != TSK_FS_TYPE_FAT32) { TSK_DADDR_T x = fatfs->csize * fatfs->clustcnt; tsk_fprintf(hFile, "** Root Directory: %" PRIuDADDR " - %" PRIuDADDR "\n", fatfs->firstdatasect, fatfs->firstclustsect - 1); tsk_fprintf(hFile, "** Cluster Area: %" PRIuDADDR " - %" PRIuDADDR "\n", fatfs->firstclustsect, (fatfs->firstclustsect + x - 1)); if ((fatfs->firstclustsect + x - 1) != fs->last_block) { tsk_fprintf(hFile, "** Non-clustered: %" PRIuDADDR " - %" PRIuDADDR "\n", (fatfs->firstclustsect + x), fs->last_block); } } else { TSK_LIST *list_seen = NULL; TSK_DADDR_T x = fatfs->csize * (fatfs->lastclust - 1); TSK_DADDR_T clust, clust_p; tsk_fprintf(hFile, "** Cluster Area: %" PRIuDADDR " - %" PRIuDADDR "\n", fatfs->firstclustsect, (fatfs->firstclustsect + x - 1)); clust_p = fatfs->rootsect; clust = FATFS_SECT_2_CLUST(fatfs, fatfs->rootsect); while ((clust) && (0 == FATFS_ISEOF(clust, FATFS_32_MASK))) { TSK_DADDR_T nxt; clust_p = clust; /* Make sure we do not get into an infinite loop */ if (tsk_list_find(list_seen, clust)) { if (tsk_verbose) tsk_fprintf(stderr, "Loop found while determining root directory size\n"); break; } if (tsk_list_add(&list_seen, clust)) { tsk_list_free(list_seen); list_seen = NULL; return 1; } if (fatfs_getFAT(fatfs, clust, &nxt)) break; clust = nxt; } tsk_list_free(list_seen); list_seen = NULL; tsk_fprintf(hFile, "*** Root Directory: %" PRIuDADDR " - %" PRIuDADDR "\n", fatfs->rootsect, (FATFS_CLUST_2_SECT(fatfs, clust_p + 1) - 1)); if ((fatfs->firstclustsect + x - 1) != fs->last_block) { tsk_fprintf(hFile, "** Non-clustered: %" PRIuDADDR " - %" PRIuDADDR "\n", (fatfs->firstclustsect + x), fs->last_block); } } tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "Root Directory: %" PRIuINUM "\n", fs->root_inum); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %" PRIu16 "\n", fatfs->ssize); tsk_fprintf(hFile, "Cluster Size: %" PRIu32 "\n", (uint32_t) fatfs->csize << fatfs->ssize_sh); tsk_fprintf(hFile, "Total Cluster Range: 2 - %" PRIuDADDR "\n", fatfs->lastclust); /* cycle via cluster and look at each cluster in the FAT * for clusters marked as bad */ cnt = 0; for (i = 2; i <= fatfs->lastclust; i++) { TSK_DADDR_T entry; TSK_DADDR_T sect; /* Get the FAT table entry */ if (fatfs_getFAT(fatfs, i, &entry)) break; if (FATFS_ISBAD(entry, fatfs->mask) == 0) { continue; } if (cnt == 0) tsk_fprintf(hFile, "Bad Sectors: "); sect = FATFS_CLUST_2_SECT(fatfs, i); for (a = 0; a < fatfs->csize; a++) { tsk_fprintf(hFile, "%" PRIuDADDR " ", sect + a); if ((++cnt % 8) == 0) tsk_fprintf(hFile, "\n"); } } if ((cnt > 0) && ((cnt % 8) != 0)) tsk_fprintf(hFile, "\n"); /* Display the FAT Table */ tsk_fprintf(hFile, "\nFAT CONTENTS (in sectors)\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); /* 'sstart' marks the first sector of the current run to print */ sstart = fatfs->firstclustsect; /* cycle via cluster and look at each cluster in the FAT to make runs */ for (i = 2; i <= fatfs->lastclust; i++) { /* 'send' marks the end sector of the current run, which will extend * when the current cluster continues to the next */ send = FATFS_CLUST_2_SECT(fatfs, i + 1) - 1; /* get the next cluster */ if (fatfs_getFAT(fatfs, i, &next)) break; snext = FATFS_CLUST_2_SECT(fatfs, next); /* we are also using the next sector (clust) */ if ((next & fatfs->mask) == (i + 1)) { continue; } /* The next clust is either further away or the clust is available, * print it if is further away */ else if ((next & fatfs->mask)) { if (FATFS_ISEOF(next, fatfs->mask)) tsk_fprintf(hFile, "%" PRIuDADDR "-%" PRIuDADDR " (%" PRIuDADDR ") -> EOF\n", sstart, send, send - sstart + 1); else if (FATFS_ISBAD(next, fatfs->mask)) tsk_fprintf(hFile, "%" PRIuDADDR "-%" PRIuDADDR " (%" PRIuDADDR ") -> BAD\n", sstart, send, send - sstart + 1); else tsk_fprintf(hFile, "%" PRIuDADDR "-%" PRIuDADDR " (%" PRIuDADDR ") -> %" PRIuDADDR "\n", sstart, send, send - sstart + 1, snext); } /* reset the starting counter */ sstart = send + 1; } return 0; } /************************* istat *******************************/ /* Callback a_action for file_walk to print the sector addresses * of a file */ typedef struct { FILE *hFile; int idx; int istat_seen; } FATFS_PRINT_ADDR; static TSK_WALK_RET_ENUM print_addr_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM a_flags, void *a_ptr) { FATFS_PRINT_ADDR *print = (FATFS_PRINT_ADDR *) a_ptr; tsk_fprintf(print->hFile, "%" PRIuDADDR " ", addr); if (++(print->idx) == 8) { tsk_fprintf(print->hFile, "\n"); print->idx = 0; } print->istat_seen = 1; return TSK_WALK_CONT; } /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File handle to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t fatfs_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { TSK_FS_META *fs_meta; TSK_FS_FILE *fs_file; TSK_FS_META_NAME_LIST *fs_name_list; FATFS_INFO *fatfs = (FATFS_INFO *) fs; FATFS_PRINT_ADDR print; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) { return 1; } fs_meta = fs_file->meta; tsk_fprintf(hFile, "Directory Entry: %" PRIuINUM "\n", inum); tsk_fprintf(hFile, "%sAllocated\n", (fs_meta->flags & TSK_FS_META_FLAG_UNALLOC) ? "Not " : ""); tsk_fprintf(hFile, "File Attributes: "); /* This should only be null if we have the root directory or special file */ if (fatfs->dep == NULL) { if (inum == FATFS_ROOTINO) tsk_fprintf(hFile, "Directory\n"); else if (fs_file->meta->type == TSK_FS_META_TYPE_VIRT) tsk_fprintf(hFile, "Virtual\n"); else tsk_fprintf(hFile, "File\n"); } else if ((fatfs->dep->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { tsk_fprintf(hFile, "Long File Name\n"); } else { if (fatfs->dep->attrib & FATFS_ATTR_DIRECTORY) tsk_fprintf(hFile, "Directory"); else if (fatfs->dep->attrib & FATFS_ATTR_VOLUME) tsk_fprintf(hFile, "Volume Label"); else tsk_fprintf(hFile, "File"); if (fatfs->dep->attrib & FATFS_ATTR_READONLY) tsk_fprintf(hFile, ", Read Only"); if (fatfs->dep->attrib & FATFS_ATTR_HIDDEN) tsk_fprintf(hFile, ", Hidden"); if (fatfs->dep->attrib & FATFS_ATTR_SYSTEM) tsk_fprintf(hFile, ", System"); if (fatfs->dep->attrib & FATFS_ATTR_ARCHIVE) tsk_fprintf(hFile, ", Archive"); tsk_fprintf(hFile, "\n"); } tsk_fprintf(hFile, "Size: %" PRIuOFF "\n", fs_meta->size); if (fs_meta->name2) { fs_name_list = fs_meta->name2; tsk_fprintf(hFile, "Name: %s\n", fs_name_list->name); } if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted Directory Entry Times:\n"); fs_meta->mtime -= sec_skew; fs_meta->atime -= sec_skew; fs_meta->crtime -= sec_skew; tsk_fprintf(hFile, "Written:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_meta->crtime)); fs_meta->mtime += sec_skew; fs_meta->atime += sec_skew; fs_meta->crtime += sec_skew; tsk_fprintf(hFile, "\nOriginal Directory Entry Times:\n"); } else tsk_fprintf(hFile, "\nDirectory Entry Times:\n"); tsk_fprintf(hFile, "Written:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_meta->crtime)); tsk_fprintf(hFile, "\nSectors:\n"); /* A bad hack to force a specified number of blocks */ if (numblock > 0) fs_meta->size = numblock * fs->block_size; print.istat_seen = 0; print.idx = 0; print.hFile = hFile; if (tsk_fs_file_walk(fs_file, (TSK_FS_FILE_WALK_FLAG_AONLY | TSK_FS_FILE_WALK_FLAG_SLACK), print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading file\n"); tsk_error_print(hFile); tsk_error_reset(); } else if (print.idx != 0) { tsk_fprintf(hFile, "\n"); } tsk_fs_file_close(fs_file); return 0; } /* return 1 on error and 0 on success */ uint8_t fatfs_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "FAT does not have a journal\n"); return 1; } /* return 1 on error and 0 on success */ uint8_t fatfs_jentry_walk(TSK_FS_INFO * fs, int a_flags, TSK_FS_JENTRY_WALK_CB a_action, void *a_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "FAT does not have a journal\n"); return 1; } /* return 1 on error and 0 on success */ uint8_t fatfs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int a_flags, TSK_FS_JBLK_WALK_CB a_action, void *a_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "FAT does not have a journal\n"); return 1; } static TSK_FS_ATTR_TYPE_ENUM fatfs_get_default_attr_type(const TSK_FS_FILE * a_file) { return TSK_FS_ATTR_TYPE_DEFAULT; } /* fatfs_close - close an fatfs file system */ static void fatfs_close(TSK_FS_INFO * fs) { FATFS_INFO *fatfs = (FATFS_INFO *) fs; fs->tag = 0; free(fatfs->dinodes); if (fatfs->dir_buf) free(fatfs->dir_buf); if (fatfs->par_buf) free(fatfs->par_buf); tsk_list_free(fs->list_inum_named); fs->list_inum_named = NULL; free(fatfs->sb); free(fs); } /** * \internal * Open part of a disk image as a FAT file system. * * @param img_info Disk image to analyze * @param offset Byte offset where FAT file system starts * @param ftype Specific type of FAT file system * @param test NOT USED * @returns NULL on error or if data is not a FAT file system */ TSK_FS_INFO * fatfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype, uint8_t test) { char *myname = "fatfs_open"; FATFS_INFO *fatfs; unsigned int len; TSK_FS_INFO *fs; fatfs_sb *fatsb; TSK_DADDR_T sectors; ssize_t cnt; int i; uint8_t used_backup_boot = 0; // set to 1 if we used the backup boot sector // clean up any error messages that are lying around tsk_error_reset(); if (TSK_FS_TYPE_ISFAT(ftype) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Invalid FS Type", myname); return NULL; } if ((fatfs = (FATFS_INFO *) tsk_malloc(sizeof(*fatfs))) == NULL) return NULL; fs = &(fatfs->fs_info); fs->ftype = ftype; fs->img_info = img_info; fs->offset = offset; fs->tag = TSK_FS_INFO_TAG; /* * Read the super block. */ len = sizeof(fatfs_sb); fatsb = fatfs->sb = (fatfs_sb *) tsk_malloc(len); if (fatsb == NULL) { fs->tag = 0; free(fatfs); return NULL; } /* Look for the boot sector. We loop because * we will try the backup if the first fails. * Only FAT32 has a backup though...*/ for (i = 0; i < 2; i++) { TSK_OFF_T sb_off; if (i == 0) sb_off = 0; else sb_off = 6 * img_info->sector_size; // the backup is located in sector 6 cnt = tsk_fs_read(fs, sb_off, (char *) fatsb, len); if (cnt != len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: boot sector", myname); fs->tag = 0; free(fatfs->sb); free(fatfs); return NULL; } /* Check the magic value and ID endian ordering */ if (tsk_fs_guessu16(fs, fatsb->magic, FATFS_FS_MAGIC)) { // if the magic value is 0, then we will try the backup if ((i == 0) && (tsk_getu16(TSK_LIT_ENDIAN, fatsb->magic) == 0)) { continue; } else { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a FATFS file system (magic)"); return NULL; } } // found the magic else { if (sb_off) used_backup_boot = 1; break; } } fs->dev_bsize = img_info->sector_size; /* Calculate block sizes and layout info */ // sector size fatfs->ssize = tsk_getu16(fs->endian, fatsb->ssize); if (fatfs->ssize == 512) { fatfs->ssize_sh = 9; } else if (fatfs->ssize == 1024) { fatfs->ssize_sh = 10; } else if (fatfs->ssize == 2048) { fatfs->ssize_sh = 11; } else if (fatfs->ssize == 4096) { fatfs->ssize_sh = 12; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error: sector size (%d) is not a multiple of device size (%d)\nDo you have a disk image instead of a partition image?", fatfs->ssize, fs->dev_bsize); fs->tag = 0; free(fatsb); free(fatfs); return NULL; } // cluster size fatfs->csize = fatsb->csize; if ((fatfs->csize != 0x01) && (fatfs->csize != 0x02) && (fatfs->csize != 0x04) && (fatfs->csize != 0x08) && (fatfs->csize != 0x10) && (fatfs->csize != 0x20) && (fatfs->csize != 0x40) && (fatfs->csize != 0x80)) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a FATFS file system (cluster size)"); return NULL; } // number of FAT tables fatfs->numfat = fatsb->numfat; if ((fatfs->numfat == 0) || (fatfs->numfat > 8)) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a FATFS file system (number of FATs)"); return NULL; } /* We can't do a sanity check on this b.c. TSK_FS_TYPE_FAT32 has a value of 0 */ /* num of root entries */ fatfs->numroot = tsk_getu16(fs->endian, fatsb->numroot); /* if sectors16 is 0, then the number of sectors is stored in sectors32 */ if (0 == (sectors = tsk_getu16(fs->endian, fatsb->sectors16))) sectors = tsk_getu32(fs->endian, fatsb->sectors32); /* if secperfat16 is 0, then read sectperfat32 */ if (0 == (fatfs->sectperfat = tsk_getu16(fs->endian, fatsb->sectperfat16))) fatfs->sectperfat = tsk_getu32(fs->endian, fatsb->a.f32.sectperfat32); if (fatfs->sectperfat == 0) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a FATFS file system (invalid sectors per FAT)"); return NULL; } fatfs->firstfatsect = tsk_getu16(fs->endian, fatsb->reserved); if ((fatfs->firstfatsect == 0) || (fatfs->firstfatsect > sectors)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a FATFS file system (invalid first FAT sector %" PRIuDADDR ")", fatfs->firstfatsect); fs->tag = 0; free(fatsb); free(fatfs); return NULL; } /* Calculate the block info * * The sector of the begining of the data area - which is * after all of the FATs * * For TSK_FS_TYPE_FAT12 and TSK_FS_TYPE_FAT16, the data area starts with the root * directory entries and then the first cluster. For TSK_FS_TYPE_FAT32, * the data area starts with clusters and the root directory * is somewhere in the data area */ fatfs->firstdatasect = fatfs->firstfatsect + fatfs->sectperfat * fatfs->numfat; /* The sector where the first cluster is located. It will be used * to translate cluster addresses to sector addresses * * For TSK_FS_TYPE_FAT32, the first cluster is the start of the data area and * it is after the root directory for TSK_FS_TYPE_FAT12 and TSK_FS_TYPE_FAT16. At this * point in the program, numroot is set to 0 for TSK_FS_TYPE_FAT32 */ fatfs->firstclustsect = fatfs->firstdatasect + ((fatfs->numroot * 32 + fatfs->ssize - 1) / fatfs->ssize); /* total number of clusters */ fatfs->clustcnt = (sectors - fatfs->firstclustsect) / fatfs->csize; /* the first cluster is #2, so the final cluster is: */ fatfs->lastclust = 1 + fatfs->clustcnt; /* identify the FAT type by the total number of data clusters * this calculation is from the MS FAT Overview Doc * * A FAT file system made by another OS could use different values */ if (ftype == TSK_FS_TYPE_FAT_DETECT) { if (fatfs->clustcnt < 4085) { ftype = TSK_FS_TYPE_FAT12; } else if (fatfs->clustcnt < 65525) { ftype = TSK_FS_TYPE_FAT16; } else { ftype = TSK_FS_TYPE_FAT32; } fatfs->fs_info.ftype = ftype; } /* Some sanity checks */ else { if ((ftype == TSK_FS_TYPE_FAT12) && (fatfs->clustcnt >= 4085)) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Too many sectors for TSK_FS_TYPE_FAT12: try auto-detect mode"); return NULL; } } if ((ftype == TSK_FS_TYPE_FAT32) && (fatfs->numroot != 0)) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid TSK_FS_TYPE_FAT32 image (numroot != 0)"); return NULL; } if ((ftype != TSK_FS_TYPE_FAT32) && (fatfs->numroot == 0)) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FAT image (numroot == 0, and not TSK_FS_TYPE_FAT32)"); return NULL; } /* additional sanity checks if we think we are using the backup boot sector. * The scenario to prevent here is if fat_open is called 6 sectors before the real start * of the file system, then we want to detect that it was not a backup that we saw. */ if (used_backup_boot) { // only FAT32 has backup boot sectors.. if (ftype != TSK_FS_TYPE_FAT32) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FAT image (Used what we thought was a backup boot sector, but it is not TSK_FS_TYPE_FAT32)"); return NULL; } if (fatfs->numroot > 1) { uint8_t buf1[512]; uint8_t buf2[512]; int i2; int numDiffs; cnt = tsk_fs_read(fs, fatfs->firstfatsect * fatfs->ssize, (char *) buf1, 512); if (cnt != 512) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: FAT1", myname); fs->tag = 0; free(fatfs->sb); free(fatfs); return NULL; } cnt = tsk_fs_read(fs, (fatfs->firstfatsect + fatfs->sectperfat)*fatfs->ssize, (char *) buf2, 512); if (cnt != 512) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: FAT2", myname); fs->tag = 0; free(fatfs->sb); free(fatfs); return NULL; } numDiffs = 0; for (i2 = 0; i2 < 512; i2++) { if (buf1[i2] != buf2[i2]) { numDiffs++; } } if (numDiffs > 25) { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FAT image (Too many differences between FATS from guessing (%d diffs))", numDiffs); return NULL; } } } /* Set the mask to use on the cluster values */ if (ftype == TSK_FS_TYPE_FAT12) { fatfs->mask = FATFS_12_MASK; } else if (ftype == TSK_FS_TYPE_FAT16) { fatfs->mask = FATFS_16_MASK; } else if (ftype == TSK_FS_TYPE_FAT32) { fatfs->mask = FATFS_32_MASK; } else { fs->tag = 0; free(fatsb); free(fatfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Unknown FAT type in fatfs_open: %d\n", ftype); return NULL; } fs->duname = "Sector"; /* the root directories are always after the FAT for TSK_FS_TYPE_FAT12 and TSK_FS_TYPE_FAT16, * but are dynamically located for TSK_FS_TYPE_FAT32 */ if (ftype == TSK_FS_TYPE_FAT32) fatfs->rootsect = FATFS_CLUST_2_SECT(fatfs, tsk_getu32(fs->endian, fatsb->a.f32.rootclust)); else fatfs->rootsect = fatfs->firstdatasect; for (i = 0; i < FAT_CACHE_N; i++) { fatfs->fatc_addr[i] = 0; fatfs->fatc_ttl[i] = 0; } /* allocate a cluster-sized buffer for inodes */ if ((fatfs->dinodes = (char *) tsk_malloc(fatfs->csize << fatfs->ssize_sh)) == NULL) { fs->tag = 0; free(fatsb); free(fatfs); return NULL; } /* * block calculations : although there are no blocks in fat, we will * use these fields for sector calculations */ fs->first_block = 0; fs->block_count = sectors; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = fatfs->ssize; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; /* * inode calculations */ /* maximum number of dentries in a sector & cluster */ fatfs->dentry_cnt_se = fatfs->ssize / sizeof(fatfs_dentry); fatfs->dentry_cnt_cl = fatfs->dentry_cnt_se * fatfs->csize; fs->root_inum = FATFS_ROOTINO; fs->first_inum = FATFS_FIRSTINO; // Add on extras for Orphan and special files fs->last_inum = (FATFS_SECT_2_INODE(fatfs, fs->last_block_act + 1) - 1) + FATFS_NUM_SPECFILE; fs->inum_count = fs->last_inum - fs->first_inum + 1; /* Volume ID */ for (fs->fs_id_used = 0; fs->fs_id_used < 4; fs->fs_id_used++) { if (ftype == TSK_FS_TYPE_FAT32) fs->fs_id[fs->fs_id_used] = fatsb->a.f32.vol_id[fs->fs_id_used]; else fs->fs_id[fs->fs_id_used] = fatsb->a.f16.vol_id[fs->fs_id_used]; } /* * Set the function pointers */ fs->block_walk = fatfs_block_walk; fs->block_getflags = fatfs_block_getflags; fs->inode_walk = fatfs_inode_walk; fs->istat = fatfs_istat; fs->file_add_meta = fatfs_inode_lookup; fs->get_default_attr_type = fatfs_get_default_attr_type; fs->load_attrs = fatfs_make_data_run; fs->dir_open_meta = fatfs_dir_open_meta; fs->name_cmp = fatfs_name_cmp; fs->fsstat = fatfs_fsstat; fs->fscheck = fatfs_fscheck; fs->close = fatfs_close; fs->jblk_walk = fatfs_jblk_walk; fs->jentry_walk = fatfs_jentry_walk; fs->jopen = fatfs_jopen; fs->journ_inum = 0; // initialize the caches fs->list_inum_named = NULL; return (fs); } sleuthkit-3.2.3/tsk3/fs/fatfs_dent.c000644 000765 000024 00000064235 11643647440 020125 0ustar00carrierstaff000000 000000 /* ** fatfs_dent ** The Sleuth Kit ** ** file name layer support for the FAT file system ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** ** Unicode added with support from I.D.E.A.L. Technology Corp (Aug '05) ** */ /** * \file fatfs_dent.c * Contains the internal TSK FAT file name processing code. */ #include "tsk_fs_i.h" #include "tsk_fatfs.h" /* * DESIGN NOTES * * the basic goal of this code is to parse directory entry structures for * file names. The main function is fatfs_parse_buf, which parses * a buffer and stores the entries in FS_DIR. That structure is then * used by dir_get() or dir_walk() to provide the data back to the user. * * One of the odd aspects of this code is that the 'inode' values are * the 'slot-address'. Refer to the document on how FAT was implemented * for more details. This means that we need to search for the actual * 'inode' address for the '.' and '..' entries though! The search * for '..' is quite painful if this code is called from a random * location. It does save what the parent is though, so the search * only has to be done once per session. */ /* Special data structure allocated for each directory to hold the long * file name entries until all entries have been found */ typedef struct { uint8_t name[FATFS_MAXNAMLEN_UTF8]; /* buffer for lfn - in reverse order */ uint16_t start; /* current start of name */ uint8_t chk; /* current checksum */ uint8_t seq; /* seq of first entry in lfn */ } FATFS_LFN; /* * name_walk callback used when finding the parent directory. It * forces the walking process to stop when we hit a target directory. * A list of directory to parent directory mappings is built up during * the walk and this function is used to stop that building process. */ static TSK_WALK_RET_ENUM find_parent_act(TSK_FS_FILE * fs_file, const char *a_path, void *ptr) { TSK_INUM_T par_inum = *(TSK_INUM_T *) ptr; if ((fs_file->meta == NULL) || (fs_file->meta->type != TSK_FS_META_TYPE_DIR)) return TSK_WALK_CONT; if (fs_file->meta->addr == par_inum) return TSK_WALK_STOP; return TSK_WALK_CONT; } uint8_t fatfs_dir_buf_add(FATFS_INFO * fatfs, TSK_INUM_T par_inum, TSK_INUM_T dir_inum) { size_t q; for (q = 0; q < fatfs->dir_buf_next; q++) { if (fatfs->dir_buf[q] == dir_inum) { return 0; } } // make sure we have room if (fatfs->dir_buf_next == fatfs->dir_buf_size) { fatfs->dir_buf_size += 256; if ((fatfs->dir_buf = (TSK_INUM_T *) tsk_realloc(fatfs->dir_buf, fatfs->dir_buf_size * sizeof(TSK_INUM_T))) == NULL) { return 1; } if ((fatfs->par_buf = (TSK_INUM_T *) tsk_realloc(fatfs->par_buf, fatfs->dir_buf_size * sizeof(TSK_INUM_T))) == NULL) { return 1; } } //add them fatfs->dir_buf[fatfs->dir_buf_next] = dir_inum; fatfs->par_buf[fatfs->dir_buf_next] = par_inum; fatfs->dir_buf_next++; return 0; } /* * Process the contents of a directory and add them to FS_DIR. * * @param fatfs File system information structure * @param a_fs_dir Structure to store the files in. * @param list_seen List of directory inodes that have been seen thus far in * directory walking (can be a pointer to a NULL pointer on first call). * @param buf Buffer that contains the directory contents. * @param len Length of buffer in bytes (must be a multiple of sector size) * @param addrs Array where each element is the original address of the * corresponding block in buf (size of array is number of blocks in directory). * * @return -1 on error, 0 on success, and 1 to stop */ static TSK_RETVAL_ENUM fatfs_dent_parse_buf(FATFS_INFO * fatfs, TSK_FS_DIR * a_fs_dir, char *buf, TSK_OFF_T len, TSK_DADDR_T * addrs) { unsigned int idx, sidx; int a, b; TSK_INUM_T inode, ibase; fatfs_dentry *dep; TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; int sectalloc; TSK_FS_NAME *fs_name; FATFS_LFN lfninfo; if (buf == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dent_parse_buf: buffer is NULL"); return TSK_ERR; } dep = (fatfs_dentry *) buf; if ((fs_name = tsk_fs_name_alloc(FATFS_MAXNAMLEN_UTF8, 32)) == NULL) { return TSK_ERR; } memset(&lfninfo, 0, sizeof(FATFS_LFN)); lfninfo.start = FATFS_MAXNAMLEN_UTF8 - 1; for (sidx = 0; sidx < (unsigned int) (len / fatfs->ssize); sidx++) { /* Get the base inode for this sector */ ibase = FATFS_SECT_2_INODE(fatfs, addrs[sidx]); if (ibase > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_parse: inode address is too large"); tsk_fs_name_free(fs_name); return TSK_COR; } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_dent_parse_buf: Parsing sector %" PRIuDADDR "\n", addrs[sidx]); if ((sectalloc = fatfs_is_sectalloc(fatfs, addrs[sidx])) == -1) { if (tsk_verbose) { tsk_fprintf(stderr, "fatfs_dent_parse_buf: Error looking up sector allocation: %" PRIuDADDR "\n", addrs[sidx]); tsk_error_print(stderr); } tsk_error_reset(); continue; } /* cycle through the directory entries */ for (idx = 0; idx < fatfs->dentry_cnt_se; idx++, dep++) { fatfs_dentry *dir; /* is it a valid dentry? */ if (0 == fatfs_isdentry(fatfs, dep, (sectalloc)?1:0)) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_dent_parse_buf: Entry %u is invalid\n", idx); continue; } /* Copy the directory entry into the TSK_FS_NAME structure */ dir = (fatfs_dentry *) dep; inode = ibase + idx; /* Take care of the name * Copy a long name to a buffer and take action if it * is a small name */ if ((dir->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { fatfs_dentry_lfn *dirl = (fatfs_dentry_lfn *) dir; /* Store the name in dinfo until we get the 8.3 name * Use the checksum to identify a new sequence * */ if (((dirl->seq & FATFS_LFN_SEQ_FIRST) && (dirl->seq != FATFS_SLOT_DELETED)) || (dirl->chksum != lfninfo.chk)) { // @@@ Do a partial output here /* Reset the values */ lfninfo.seq = dirl->seq & FATFS_LFN_SEQ_MASK; lfninfo.chk = dirl->chksum; lfninfo.start = FATFS_MAXNAMLEN_UTF8 - 1; } else if (dirl->seq != lfninfo.seq - 1) { // @@@ Check the sequence number - the checksum is correct though... } /* Copy the UTF16 values starting at end of buffer */ for (a = 3; a >= 0; a--) { if ((lfninfo.start > 0)) lfninfo.name[lfninfo.start--] = dirl->part3[a]; } for (a = 11; a >= 0; a--) { if ((lfninfo.start > 0)) lfninfo.name[lfninfo.start--] = dirl->part2[a]; } for (a = 9; a >= 0; a--) { if ((lfninfo.start > 0)) lfninfo.name[lfninfo.start--] = dirl->part1[a]; } // Skip ahead until we get a new sequence num or the 8.3 name continue; } /* Special case for volume label: name does not have an * extension and we add a note at the end that it is a label */ else if ((dir->attrib & FATFS_ATTR_VOLUME) == FATFS_ATTR_VOLUME) { a = 0; for (b = 0; b < 8; b++) { if ((dir->name[b] >= 0x20) && (dir->name[b] != 0xff)) { fs_name->name[a++] = dir->name[b]; } else { fs_name->name[a++] = '^'; } } for (b = 0; b < 3; b++) { if ((dir->ext[b] >= 0x20) && (dir->ext[b] != 0xff)) { fs_name->name[a++] = dir->ext[b]; } else { fs_name->name[a++] = '^'; } } fs_name->name[a] = '\0'; /* Append a string to show it is a label */ if (a + 22 < FATFS_MAXNAMLEN_UTF8) { char *volstr = " (Volume Label Entry)"; strncat(fs_name->name, volstr, FATFS_MAXNAMLEN_UTF8 - a); } // make sure we only copied ASCII in fatfs_cleanup_ascii(fs_name->name); } /* A short (8.3) entry */ else { char *name_ptr; // The dest location for the short name /* if we have a lfn, copy it into fs_name->name * and put the short name in fs_name->shrt_name */ if (lfninfo.start != FATFS_MAXNAMLEN_UTF8 - 1) { int retVal; /* @@@ Check the checksum */ /* Convert the UTF16 to UTF8 */ UTF16 *name16 = (UTF16 *) ((uintptr_t) & lfninfo.name[lfninfo. start + 1]); UTF8 *name8 = (UTF8 *) fs_name->name; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & lfninfo.name[FATFS_MAXNAMLEN_UTF8], &name8, (UTF8 *) ((uintptr_t) name8 + FATFS_MAXNAMLEN_UTF8), TSKlenientConversion); if (retVal != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_parse: Error converting FAT LFN to UTF8: %d", retVal); continue; } /* Make sure it is NULL Terminated */ if ((uintptr_t) name8 > (uintptr_t) fs_name->name + FATFS_MAXNAMLEN_UTF8) fs_name->name[FATFS_MAXNAMLEN_UTF8 - 1] = '\0'; else *name8 = '\0'; lfninfo.start = FATFS_MAXNAMLEN_UTF8 - 1; name_ptr = fs_name->shrt_name; // put 8.3 into shrt_name } /* We don't have a LFN, so put the short name in * fs_name->name */ else { fs_name->shrt_name[0] = '\0'; name_ptr = fs_name->name; // put 8.3 into normal location } /* copy in the short name into the place specified above. * Skip spaces and put in the . */ a = 0; for (b = 0; b < 8; b++) { if ((dir->name[b] != 0) && (dir->name[b] != 0xff) && (dir->name[b] != 0x20)) { if ((b == 0) && (dir->name[0] == FATFS_SLOT_DELETED)) { name_ptr[a++] = '_'; } else if ((dir->lowercase & FATFS_CASE_LOWER_BASE) && (dir->name[b] >= 'A') && (dir->name[b] <= 'Z')) { name_ptr[a++] = dir->name[b] + 32; } else { name_ptr[a++] = dir->name[b]; } } } for (b = 0; b < 3; b++) { if ((dir->ext[b] != 0) && (dir->ext[b] != 0xff) && (dir->ext[b] != 0x20)) { if (b == 0) name_ptr[a++] = '.'; if ((dir->lowercase & FATFS_CASE_LOWER_EXT) && (dir->ext[b] >= 'A') && (dir->ext[b] <= 'Z')) name_ptr[a++] = dir->ext[b] + 32; else name_ptr[a++] = dir->ext[b]; } } name_ptr[a] = '\0'; //make sure the short name has only ASCII fatfs_cleanup_ascii(name_ptr); } /* file type: FAT only knows DIR and FILE */ if ((dir->attrib & FATFS_ATTR_DIRECTORY) == FATFS_ATTR_DIRECTORY) fs_name->type = TSK_FS_NAME_TYPE_DIR; else fs_name->type = TSK_FS_NAME_TYPE_REG; /* Get inode */ fs_name->meta_addr = inode; /* Handle the . and .. entries specially * The current inode 'address' they have is for the current * slot in the cluster, but it needs to refer to the original * slot */ if (TSK_FS_ISDOT(fs_name->name)) { if (fs_name->name[1] == '\0') { inode = fs_name->meta_addr = a_fs_dir->fs_file->meta->addr; } /* for the parent directory, look up in the list that * is maintained in fafs_info */ else if (fs_name->name[1] == '.') { size_t q; uint8_t dir_found = 0; for (q = 0; q < fatfs->dir_buf_next; q++) { if (fatfs->dir_buf[q] == a_fs_dir->fs_file->meta->addr) { inode = fs_name->meta_addr = fatfs->par_buf[q]; dir_found = 1; break; } } if ((dir_found == 0) && (fs->isOrphanHunting)) { /* if we are currently scanning the fs to determine the orphan files, * then we do not care about the value of '..' and this can only cause * infinite loop problems */ inode = fs_name->meta_addr = 0; dir_found = 1; } if ((dir_found == 0) && (addrs[0] == fatfs->firstdatasect)) { /* if we are currently in the root directory, we aren't going to find * a parent. This shouldn't happen, but could result in an infinite loop. */ inode = fs_name->meta_addr = 0; dir_found = 1; } if (dir_found == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_dent_parse_buf: Walking directory to find parent\n"); /* The parent directory is not in the list. We are going to walk * the directory until we hit this directory. This process will * populate the buffer table and we will then rescan it */ if (tsk_fs_dir_walk(fs, fs->root_inum, TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_UNALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE, find_parent_act, (void *) &a_fs_dir->fs_file->meta->addr)) { return 0; } if (tsk_verbose) fprintf(stderr, "fatfs_dent_parse_buf: Finished walking directory to find parent\n"); for (q = 0; q < fatfs->dir_buf_next; q++) { if (fatfs->dir_buf[q] == a_fs_dir->fs_file->meta->addr) { inode = fs_name->meta_addr = fatfs->par_buf[q]; dir_found = 1; break; } } // if we did not find it, then it was probably // from the orphan directory... if (dir_found == 0) inode = fs_name->meta_addr = TSK_FS_ORPHANDIR_INUM(fs); } } } else { /* Save the (non-. or ..) directory to parent directory info to local * structures so that we can later fill into the inode * info for '..' entries */ if (fs_name->type == TSK_FS_NAME_TYPE_DIR) { if (fatfs_dir_buf_add(fatfs, a_fs_dir->fs_file->meta->addr, inode)) return TSK_ERR; } } /* The allocation status of an entry is based on the allocation * status of the sector it is in and the flag. Deleted directories * do not always clear the flags of each entry */ if (sectalloc == 1) { fs_name->flags = (dep->name[0] == FATFS_SLOT_DELETED) ? TSK_FS_NAME_FLAG_UNALLOC : TSK_FS_NAME_FLAG_ALLOC; } else { fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; } tsk_fs_dir_add(a_fs_dir, fs_name); } } tsk_fs_name_free(fs_name); return TSK_OK; } /************************************************************************** * * dent_walk * *************************************************************************/ /* values used to copy the directory contents into a buffer */ typedef struct { /* ptr to the current location in a local buffer */ char *curdirptr; /* number of bytes left in curdirptr */ size_t dirleft; /* ptr to a local buffer for the stack of sector addresses */ TSK_DADDR_T *addrbuf; /* num of entries allocated to addrbuf */ size_t addrsize; /* The current index in the addrbuf stack */ size_t addridx; } FATFS_LOAD_DIR; /** * file walk callback that is used to load directory contents * into a buffer */ static TSK_WALK_RET_ENUM fatfs_dent_action(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { FATFS_LOAD_DIR *load = (FATFS_LOAD_DIR *) ptr; /* how much of the buffer are we copying */ size_t len = (load->dirleft < size) ? load->dirleft : size; /* Copy the sector into a buffer and increment the pointers */ memcpy(load->curdirptr, buf, len); load->curdirptr = (char *) ((uintptr_t) load->curdirptr + len); load->dirleft -= len; /* fill in the stack of addresses of sectors * * if we are at the last entry, then realloc more */ if (load->addridx == load->addrsize) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dent_walk: Trying to put more sector address in stack than were allocated (%lu)", (long) load->addridx); return TSK_WALK_ERROR; } /* Add this sector to the stack */ load->addrbuf[load->addridx++] = addr; if (load->dirleft) return TSK_WALK_CONT; else return TSK_WALK_STOP; } /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM fatfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { TSK_OFF_T size, len; FATFS_INFO *fatfs = (FATFS_INFO *) a_fs; char *dirbuf; TSK_DADDR_T *addrbuf; FATFS_LOAD_DIR load; int retval; TSK_FS_DIR *fs_dir; if ((a_addr < a_fs->first_inum) || (a_addr > a_fs->last_inum)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dir_open_meta: invalid a_addr value: %" PRIuINUM "\n", a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dir_open_meta: NULL fs_attr argument given"); return TSK_ERR; } fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else { if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(a_fs, a_addr, 128)) == NULL) { return TSK_ERR; } } // handle the orphan directory if its contents were requested if (a_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { return tsk_fs_dir_find_orphans(a_fs, fs_dir); } fs_dir->fs_file = tsk_fs_file_open_meta(a_fs, NULL, a_addr); if (fs_dir->fs_file == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dir_open_meta: %" PRIuINUM " is not a valid inode", a_addr); return TSK_COR; } size = fs_dir->fs_file->meta->size; len = roundup(size, fatfs->ssize); if (tsk_verbose) tsk_fprintf(stderr, "fatfs_dir_open_meta: Processing directory %" PRIuINUM "\n", a_addr); if (size == 0) { if (tsk_verbose) tsk_fprintf(stderr, "fatfs_dir_open_meta: directory has 0 size\n"); return TSK_OK; } /* Make a copy of the directory contents using file_walk */ if ((dirbuf = tsk_malloc((size_t) len)) == NULL) { return TSK_ERR; } load.curdirptr = dirbuf; load.dirleft = (size_t) size; /* We are going to save the address of each sector in the directory * in a stack - they are needed to determine the inode address. */ load.addrsize = (size_t) (len / fatfs->ssize); addrbuf = (TSK_DADDR_T *) tsk_malloc(load.addrsize * sizeof(TSK_DADDR_T)); if (addrbuf == NULL) { free(dirbuf); return TSK_ERR; } /* Set the variables that are used during the copy */ load.addridx = 0; load.addrbuf = addrbuf; /* save the directory contents into dirbuf */ if (tsk_fs_file_walk(fs_dir->fs_file, TSK_FS_FILE_WALK_FLAG_SLACK, fatfs_dent_action, (void *) &load)) { strncat(tsk_errstr2, " - fatfs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(dirbuf); free(addrbuf); return TSK_COR; } /* We did not copy the entire directory, which occurs if an error occured */ if (load.dirleft > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dir_open_meta: Error reading directory %" PRIuINUM, a_addr); /* Free the local buffers */ free(dirbuf); free(addrbuf); return TSK_COR; } if (tsk_verbose) fprintf(stderr, "fatfs_dir_open_meta: Parsing directory %" PRIuINUM "\n", a_addr); retval = fatfs_dent_parse_buf(fatfs, fs_dir, dirbuf, len, addrbuf); free(dirbuf); free(addrbuf); // if we are listing the root directory, add the Orphan directory and special FAT file entries if (a_addr == a_fs->root_inum) { TSK_FS_NAME *fs_name = tsk_fs_name_alloc(256, 0); if (fs_name == NULL) return TSK_ERR; // MBR Entry strncpy(fs_name->name, FATFS_MBRNAME, fs_name->name_size); fs_name->meta_addr = FATFS_MBRINO(a_fs); fs_name->type = TSK_FS_NAME_TYPE_VIRT; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } // FAT1 Entry strncpy(fs_name->name, FATFS_FAT1NAME, fs_name->name_size); fs_name->meta_addr = FATFS_FAT1INO(a_fs); fs_name->type = TSK_FS_NAME_TYPE_VIRT; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } // FAT2 Entry strncpy(fs_name->name, FATFS_FAT2NAME, fs_name->name_size); fs_name->meta_addr = FATFS_FAT2INO(a_fs); fs_name->type = TSK_FS_NAME_TYPE_VIRT; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } // orphan directory if (tsk_fs_dir_make_orphan_dir_name(a_fs, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); } return retval; } int fatfs_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { return strcasecmp(s1, s2); } sleuthkit-3.2.3/tsk3/fs/fatfs_meta.c000644 000765 000024 00000207525 11643647440 020122 0ustar00carrierstaff000000 000000 /* ** fatfs ** The Sleuth Kit ** ** Content and meta data layer support for the FAT file system ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** ** Unicode added with support from I.D.E.A.L. Technology Corp (Aug '05) ** */ /** * \file fatfs_meta.c * Contains the internal TSK FAT file system code to handle metadata structures. */ #include "tsk_fs_i.h" #include "tsk_fatfs.h" /* * Identify if the dentry is a valid 8.3 name * * returns 1 if it is, 0 if it does not */ static uint8_t is_83_name(fatfs_dentry * de) { if (!de) return 0; /* The IS_NAME macro will fail if the value is 0x05, which is only * valid in name[0], similarly with '.' */ if ((de->name[0] != FATFS_SLOT_E5) && (de->name[0] != '.') && (FATFS_IS_83_NAME(de->name[0]) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[0] is invalid\n"); return 0; } // the name cannot start with 0x20 else if (de->name[0] == 0x20) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[0] has 0x20\n"); return 0; } /* the second name field can only be . if the first one is a . */ if (de->name[1] == '.') { if (de->name[0] != '.') { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[1] is .\n"); return 0; } } else if (FATFS_IS_83_NAME(de->name[1]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[1] is invalid\n"); return 0; } if (FATFS_IS_83_NAME(de->name[2]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[2] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->name[3]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[3] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->name[4]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[4] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->name[5]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[5] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->name[6]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[6] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->name[7]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: name[7] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->ext[0]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: ext[0] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->ext[1]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: ext[1] is invalid\n"); return 0; } else if (FATFS_IS_83_NAME(de->ext[2]) == 0) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: ext[2] is invalid\n"); return 0; } /* Ensure that if we get a "space", that the rest of the * name is spaces. This is not in the spec, but is how * windows operates and serves as a good check to remove * false positives. We do not do this check for the * volume label though. */ if ((de->attrib & FATFS_ATTR_VOLUME) != FATFS_ATTR_VOLUME) { if (((de->name[1] == 0x20) && (de->name[2] != 0x20)) || ((de->name[2] == 0x20) && (de->name[3] != 0x20)) || ((de->name[3] == 0x20) && (de->name[4] != 0x20)) || ((de->name[4] == 0x20) && (de->name[5] != 0x20)) || ((de->name[5] == 0x20) && (de->name[6] != 0x20)) || ((de->name[6] == 0x20) && (de->name[7] != 0x20)) || ((de->ext[1] == 0x20) && (de->ext[2] != 0x20))) { if (tsk_verbose) fprintf(stderr, "fatfs_is_83_name: space before non-space\n"); return 0; } } return 1; } /* ** Convert the DOS time to the UNIX version ** ** UNIX stores the time in seconds from 1970 in UTC ** FAT dates are the actual date with the year relative to 1980 ** */ static time_t dos2unixtime(uint16_t date, uint16_t time, uint8_t timetens) { struct tm tm1; time_t ret; if (date == 0) return 0; memset(&tm1, 0, sizeof(struct tm)); tm1.tm_sec = ((time & FATFS_SEC_MASK) >> FATFS_SEC_SHIFT) * 2; if ((tm1.tm_sec < 0) || (tm1.tm_sec > 60)) tm1.tm_sec = 0; // the ctimetens value has a range of 0 to 199 if (timetens > 100) tm1.tm_sec++; tm1.tm_min = ((time & FATFS_MIN_MASK) >> FATFS_MIN_SHIFT); if ((tm1.tm_min < 0) || (tm1.tm_min > 59)) tm1.tm_min = 0; tm1.tm_hour = ((time & FATFS_HOUR_MASK) >> FATFS_HOUR_SHIFT); if ((tm1.tm_hour < 0) || (tm1.tm_hour > 23)) tm1.tm_hour = 0; tm1.tm_mday = ((date & FATFS_DAY_MASK) >> FATFS_DAY_SHIFT); if ((tm1.tm_mday < 1) || (tm1.tm_mday > 31)) tm1.tm_mday = 0; tm1.tm_mon = ((date & FATFS_MON_MASK) >> FATFS_MON_SHIFT) - 1; if ((tm1.tm_mon < 0) || (tm1.tm_mon > 11)) tm1.tm_mon = 0; /* There is a limit to the year because the UNIX time value is * a 32-bit value * the maximum UNIX time is Tue Jan 19 03:14:07 2038 */ tm1.tm_year = ((date & FATFS_YEAR_MASK) >> FATFS_YEAR_SHIFT) + 80; if ((tm1.tm_year < 0) || (tm1.tm_year > 137)) tm1.tm_year = 0; /* set the daylight savings variable to -1 so that mktime() figures * it out */ tm1.tm_isdst = -1; ret = mktime(&tm1); if (ret < 0) { if (tsk_verbose) tsk_fprintf(stderr, "dos2unixtime: Error running mktime(): %d:%d:%d %d/%d/%d", ((time & FATFS_HOUR_MASK) >> FATFS_HOUR_SHIFT), ((time & FATFS_MIN_MASK) >> FATFS_MIN_SHIFT), ((time & FATFS_SEC_MASK) >> FATFS_SEC_SHIFT) * 2, ((date & FATFS_MON_MASK) >> FATFS_MON_SHIFT) - 1, ((date & FATFS_DAY_MASK) >> FATFS_DAY_SHIFT), ((date & FATFS_YEAR_MASK) >> FATFS_YEAR_SHIFT) + 80); return 0; } return ret; } /* timetens is number of tenths of a second for a 2 second range (values 0 to 199) */ static uint32_t dos2nanosec(uint8_t timetens) { timetens %= 100; return timetens * 10000000; } /* * convert the attribute list in FAT to a UNIX mode */ static TSK_FS_META_TYPE_ENUM attr2type(uint16_t attr) { if (attr & FATFS_ATTR_DIRECTORY) return TSK_FS_META_TYPE_DIR; else return TSK_FS_META_TYPE_REG; } static int attr2mode(uint16_t attr) { int mode; /* every file is executable */ mode = (TSK_FS_META_MODE_IXUSR | TSK_FS_META_MODE_IXGRP | TSK_FS_META_MODE_IXOTH); if ((attr & FATFS_ATTR_READONLY) == 0) mode |= (TSK_FS_META_MODE_IRUSR | TSK_FS_META_MODE_IRGRP | TSK_FS_META_MODE_IROTH); if ((attr & FATFS_ATTR_HIDDEN) == 0) mode |= (TSK_FS_META_MODE_IWUSR | TSK_FS_META_MODE_IWGRP | TSK_FS_META_MODE_IWOTH); return mode; } /** * Cleans up a char string so that it is only ASCII. We do this * before we copy something into a TSK buffer that is supposed * to be UTF-8. If it is not ASCII and it is from a single-byte * data structure, then we we clean it up because we dont' know * what the actual encoding is (or if it is corrupt). * @param name Name to cleanup */ void fatfs_cleanup_ascii(char *name) { int i; for (i = 0; name[i] != '\0'; i++) { if ((unsigned char)(name[i]) > 0x7e) { name[i] = '^'; } } } /** * \internal * Copy the contents of a raw directry entry into a TSK_FS_INFO structure. * * @param fatfs File system that directory entry is from * @param fs_meta Generic inode structure to copy data into * @param in Directory entry to copy data from * @param sect Sector address where directory entry is from -- used * to determine allocation status. * @param inum Address of the inode. * * @returns 1 on error and 0 on success. Errors should only occur for * Unicode conversion problems and when this occurs the name will be * NULL terminated (but with unknown contents). * */ static TSK_RETVAL_ENUM fatfs_dinode_copy(FATFS_INFO * fatfs, TSK_FS_META * fs_meta, fatfs_dentry * in, TSK_DADDR_T sect, TSK_INUM_T inum) { int retval; int i; TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; TSK_DADDR_T *addr_ptr; if (fs_meta->content_len < FATFS_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, FATFS_FILE_CONTENT_LEN)) == NULL) { return 1; } } fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } fs_meta->mode = attr2mode(in->attrib); fs_meta->type = attr2type(in->attrib); fs_meta->addr = inum; /* Use the allocation status of the sector to determine if the * dentry is allocated or not */ retval = fatfs_is_sectalloc(fatfs, sect); if (retval == -1) { return TSK_ERR; } else if (retval == 1) { fs_meta->flags = ((in->name[0] == FATFS_SLOT_DELETED) ? TSK_FS_META_FLAG_UNALLOC : TSK_FS_META_FLAG_ALLOC); } else { fs_meta->flags = TSK_FS_META_FLAG_UNALLOC; } /* Slot has not been used yet */ fs_meta->flags |= ((in->name[0] == FATFS_SLOT_EMPTY) ? TSK_FS_META_FLAG_UNUSED : TSK_FS_META_FLAG_USED); if ((in->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { /* LFN entries don't have these values */ fs_meta->nlink = 0; fs_meta->size = 0; fs_meta->mtime = 0; fs_meta->atime = 0; fs_meta->ctime = 0; fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; } else { /* There is no notion of link in FAT, just deleted or not */ fs_meta->nlink = (in->name[0] == FATFS_SLOT_DELETED) ? 0 : 1; fs_meta->size = (TSK_OFF_T) tsk_getu32(fs->endian, in->size); /* If these are valid dates, then convert to a unix date format */ if (FATFS_ISDATE(tsk_getu16(fs->endian, in->wdate))) fs_meta->mtime = dos2unixtime(tsk_getu16(fs->endian, in->wdate), tsk_getu16(fs->endian, in->wtime), 0); else fs_meta->mtime = 0; fs_meta->mtime_nano = 0; if (FATFS_ISDATE(tsk_getu16(fs->endian, in->adate))) fs_meta->atime = dos2unixtime(tsk_getu16(fs->endian, in->adate), 0, 0); else fs_meta->atime = 0; fs_meta->atime_nano = 0; /* cdate is the creation date in FAT and there is no change, * so we just put in into change and set create to 0. The other * front-end code knows how to handle it and display it */ if (FATFS_ISDATE(tsk_getu16(fs->endian, in->cdate))) { fs_meta->crtime = dos2unixtime(tsk_getu16(fs->endian, in->cdate), tsk_getu16(fs->endian, in->ctime), in->ctimeten); fs_meta->crtime_nano = dos2nanosec(in->ctimeten); } else { fs_meta->crtime = 0; fs_meta->crtime_nano = 0; } // FAT does not have a changed time fs_meta->ctime = 0; fs_meta->ctime_nano = 0; } /* Values that do not exist in FAT */ fs_meta->uid = 0; fs_meta->gid = 0; fs_meta->seq = 0; /* We will be copying a name, so allocate a structure */ if (fs_meta->name2 == NULL) { if ((fs_meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return TSK_ERR; fs_meta->name2->next = NULL; } /* If we have a LFN entry, then we need to convert the three * parts of the name to UTF-8 and copy it into the name structure . */ if ((in->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { fatfs_dentry_lfn *lfn = (fatfs_dentry_lfn *) in; /* Convert the first part of the name */ UTF8 *name8 = (UTF8 *) fs_meta->name2->name; UTF16 *name16 = (UTF16 *) lfn->part1; int retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & lfn->part1[10], &name8, (UTF8 *) ((uintptr_t) fs_meta->name2->name + sizeof(fs_meta->name2->name)), TSKlenientConversion); if (retVal != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dinode_copy: Error converting FAT LFN (1) to UTF8: %d", retVal); *name8 = '\0'; return TSK_COR; } /* Convert the second part of the name */ name16 = (UTF16 *) lfn->part2; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & lfn->part2[12], &name8, (UTF8 *) ((uintptr_t) fs_meta->name2->name + sizeof(fs_meta->name2->name)), TSKlenientConversion); if (retVal != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dinode_copy: Error converting FAT LFN (2) to UTF8: %d", retVal); *name8 = '\0'; return TSK_COR; } /* Convert the third part of the name */ name16 = (UTF16 *) lfn->part3; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & lfn->part3[4], &name8, (UTF8 *) ((uintptr_t) fs_meta->name2->name + sizeof(fs_meta->name2->name)), TSKlenientConversion); if (retVal != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_dinode_copy: Error converting FAT LFN (3) to UTF8: %d", retVal); *name8 = '\0'; return TSK_COR; } /* Make sure it is NULL Terminated */ if ((uintptr_t) name8 > (uintptr_t) fs_meta->name2->name + sizeof(fs_meta->name2->name)) fs_meta->name2->name[sizeof(fs_meta->name2->name) - 1] = '\0'; else *name8 = '\0'; } /* If the entry is for a volume label, then copy the name and * append a special label */ else if ((in->attrib & FATFS_ATTR_VOLUME) == FATFS_ATTR_VOLUME) { int a; i = 0; for (a = 0; a < 8; a++) { if ((in->name[a] != 0x00) && (in->name[a] != 0xff)) fs_meta->name2->name[i++] = in->name[a]; } for (a = 0; a < 3; a++) { if ((in->ext[a] != 0x00) && (in->ext[a] != 0xff)) fs_meta->name2->name[i++] = in->ext[a]; } fs_meta->name2->name[i] = '\0'; /* clean up non-ASCII because we are * copying it into a buffer that is supposed to be UTF-8 and * we don't know what encoding it is actually in or if it is * simply junk. */ fatfs_cleanup_ascii(fs_meta->name2->name); } /* If the entry is a normal short entry, then copy the name * and add the '.' for the extension */ else { for (i = 0; (i < 8) && (in->name[i] != 0) && (in->name[i] != ' '); i++) { if ((i == 0) && (in->name[0] == FATFS_SLOT_DELETED)) fs_meta->name2->name[0] = '_'; else if ((in->lowercase & FATFS_CASE_LOWER_BASE) && (in->name[i] >= 'A') && (in->name[i] <= 'Z')) fs_meta->name2->name[i] = in->name[i] + 32; else fs_meta->name2->name[i] = in->name[i]; } if ((in->ext[0]) && (in->ext[0] != ' ')) { int a; fs_meta->name2->name[i++] = '.'; for (a = 0; (a < 3) && (in->ext[a] != 0) && (in->ext[a] != ' '); a++, i++) { if ((in->lowercase & FATFS_CASE_LOWER_EXT) && (in->ext[a] >= 'A') && (in->ext[a] <= 'Z')) fs_meta->name2->name[i] = in->ext[a] + 32; else fs_meta->name2->name[i] = in->ext[a]; } } fs_meta->name2->name[i] = '\0'; /* clean up non-ASCII because we are * copying it into a buffer that is supposed to be UTF-8 and * we don't know what encoding it is actually in or if it is * simply junk. */ fatfs_cleanup_ascii(fs_meta->name2->name); } /* Clean up name to remove control characters */ i = 0; while (fs_meta->name2->name[i] != '\0') { if (TSK_IS_CNTRL(fs_meta->name2->name[i])) fs_meta->name2->name[i] = '^'; i++; } /* get the starting cluster */ addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; if ((in->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { addr_ptr[0] = 0; } else { addr_ptr[0] = FATFS_DENTRY_CLUST(fs, in) & fatfs->mask; } /* FAT does not store a size for its directories so make one based * on the number of allocated sectors */ if ((in->attrib & FATFS_ATTR_DIRECTORY) && ((in->attrib & FATFS_ATTR_LFN) != FATFS_ATTR_LFN)) { if (fs_meta->flags & TSK_FS_META_FLAG_ALLOC) { TSK_LIST *list_seen = NULL; /* count the total number of clusters in this file */ TSK_DADDR_T clust = FATFS_DENTRY_CLUST(fs, in); int cnum = 0; while ((clust) && (0 == FATFS_ISEOF(clust, fatfs->mask))) { TSK_DADDR_T nxt; /* Make sure we do not get into an infinite loop */ if (tsk_list_find(list_seen, clust)) { if (tsk_verbose) tsk_fprintf(stderr, "Loop found while determining directory size\n"); break; } if (tsk_list_add(&list_seen, clust)) { tsk_list_free(list_seen); list_seen = NULL; return TSK_ERR; } cnum++; if (fatfs_getFAT(fatfs, clust, &nxt)) break; else clust = nxt; } tsk_list_free(list_seen); list_seen = NULL; fs_meta->size = (TSK_OFF_T) ((cnum * fatfs->csize) << fatfs->ssize_sh); } /* if the dir is unallocated, then assume 0 or cluster size * Ideally, we would have a smart algo here to do recovery * and look for dentries. However, we do not have that right * now and if we do not add this special check then it can * assume that an allocated file cluster chain belongs to the * directory */ else { // if the first cluster is allocated, then set size to be 0 if (fatfs_is_clustalloc(fatfs, FATFS_DENTRY_CLUST(fs, in)) == 1) fs_meta->size = 0; else fs_meta->size = fatfs->csize << fatfs->ssize_sh; } } return TSK_OK; } /** * \internal * Create an FS_INODE structure for the root directory. FAT does * not have a directory entry for the root directory, but this * function collects the needed data to make one. * * @param fatfs File system to analyze * @param fs_meta Inode structure to copy root directory information into. * @return 1 on error and 0 on success */ uint8_t fatfs_make_root(FATFS_INFO * fatfs, TSK_FS_META * fs_meta) { // TSK_FS_INFO *fs = (TSK_FS_INFO *) fatfs; TSK_DADDR_T *addr_ptr; fs_meta->type = (TSK_FS_META_TYPE_DIR); fs_meta->mode = 0; fs_meta->nlink = 1; fs_meta->addr = FATFS_ROOTINO; fs_meta->flags = (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_ALLOC); fs_meta->uid = fs_meta->gid = 0; fs_meta->mtime = fs_meta->atime = fs_meta->ctime = fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; if (fs_meta->name2 == NULL) { if ((fs_meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return 1; fs_meta->name2->next = NULL; } fs_meta->name2->name[0] = '\0'; fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; /* TSK_FS_TYPE_FAT12 and TSK_FS_TYPE_FAT16 don't use the FAT for root directory, so * we will have to fake it. */ if (fatfs->fs_info.ftype != TSK_FS_TYPE_FAT32) { TSK_DADDR_T snum; /* Other code will have to check this as a special condition */ addr_ptr[0] = 1; /* difference between end of FAT and start of clusters */ snum = fatfs->firstclustsect - fatfs->firstdatasect; /* number of bytes */ fs_meta->size = snum << fatfs->ssize_sh; } else { /* Get the number of allocated clusters */ TSK_DADDR_T cnum; TSK_DADDR_T clust; TSK_LIST *list_seen = NULL; /* base cluster */ clust = FATFS_SECT_2_CLUST(fatfs, fatfs->rootsect); addr_ptr[0] = clust; cnum = 0; while ((clust) && (0 == FATFS_ISEOF(clust, FATFS_32_MASK))) { TSK_DADDR_T nxt; /* Make sure we do not get into an infinite loop */ if (tsk_list_find(list_seen, clust)) { if (tsk_verbose) tsk_fprintf(stderr, "Loop found while determining root directory size\n"); break; } if (tsk_list_add(&list_seen, clust)) { tsk_list_free(list_seen); list_seen = NULL; return 1; } cnum++; if (fatfs_getFAT(fatfs, clust, &nxt)) break; else clust = nxt; } tsk_list_free(list_seen); list_seen = NULL; fs_meta->size = (cnum * fatfs->csize) << fatfs->ssize_sh; } return 0; } /** * \internal * Create an FS_INODE structure for the master boot record. * * @param fatfs File system to analyze * @param fs_meta Inode structure to copy file information into. * @return 1 on error and 0 on success */ uint8_t fatfs_make_mbr(FATFS_INFO * fatfs, TSK_FS_META * fs_meta) { TSK_DADDR_T *addr_ptr; TSK_FS_INFO *fs = (TSK_FS_INFO *) fatfs; fs_meta->type = TSK_FS_META_TYPE_VIRT; fs_meta->mode = 0; fs_meta->nlink = 1; fs_meta->addr = FATFS_MBRINO(fs); fs_meta->flags = (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_ALLOC); fs_meta->uid = fs_meta->gid = 0; fs_meta->mtime = fs_meta->atime = fs_meta->ctime = fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; if (fs_meta->name2 == NULL) { if ((fs_meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return 1; fs_meta->name2->next = NULL; } strncpy(fs_meta->name2->name, FATFS_MBRNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; addr_ptr[0] = 0; fs_meta->size = 512; return 0; } /** * \internal * Create an FS_INODE structure for the FAT tables. * * @param fatfs File system to analyze * @param a_which 1 or 2 to choose between defining FAT1 or FAT2 * @param fs_meta Inode structure to copy file information into. * @return 1 on error and 0 on success */ uint8_t fatfs_make_fat(FATFS_INFO * fatfs, uint8_t a_which, TSK_FS_META * fs_meta) { TSK_FS_INFO *fs = (TSK_FS_INFO *) fatfs; TSK_DADDR_T *addr_ptr; fs_meta->type = TSK_FS_META_TYPE_VIRT; fs_meta->mode = 0; fs_meta->nlink = 1; fs_meta->flags = (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_ALLOC); fs_meta->uid = fs_meta->gid = 0; fs_meta->mtime = fs_meta->atime = fs_meta->ctime = fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; if (fs_meta->name2 == NULL) { if ((fs_meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return 1; fs_meta->name2->next = NULL; } if (a_which == 1) { fs_meta->addr = FATFS_FAT1INO(fs); strncpy(fs_meta->name2->name, FATFS_FAT1NAME, TSK_FS_META_NAME_LIST_NSIZE); addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; addr_ptr[0] = fatfs->firstfatsect; } else if (a_which == 2) { fs_meta->addr = FATFS_FAT2INO(fs); strncpy(fs_meta->name2->name, FATFS_FAT2NAME, TSK_FS_META_NAME_LIST_NSIZE); addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; addr_ptr[0] = fatfs->firstfatsect + fatfs->sectperfat; } else { ////@@@ } fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } fs_meta->size = fatfs->sectperfat * fs->block_size; return 0; } /* * Is the pointed to buffer a directory entry buffer? * * @param a_basic 1 if only basic tests should be performed. * Returns 1 if it is, 0 if not */ uint8_t fatfs_isdentry(FATFS_INFO * fatfs, fatfs_dentry * de, uint8_t a_basic) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & fatfs->fs_info; if (!de) return 0; /* LFN have their own checks, which are pretty weak since most * fields are UTF16 */ if ((de->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) { fatfs_dentry_lfn *de_lfn = (fatfs_dentry_lfn *) de; if ((de_lfn->seq > (FATFS_LFN_SEQ_FIRST | 0x0f)) && (de_lfn->seq != FATFS_SLOT_DELETED)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: LFN seq\n"); return 0; } return 1; } else { // the basic test is only for the 'essential data'. if (a_basic == 0) { if (de->lowercase & ~(FATFS_CASE_LOWER_ALL)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: lower case all\n"); return 0; } else if (de->attrib & ~(FATFS_ATTR_ALL)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: attribute all\n"); return 0; } // verify we do not have too many flags set if (de->attrib & FATFS_ATTR_NORMAL) { if ((de->attrib & FATFS_ATTR_VOLUME) || (de->attrib & FATFS_ATTR_DIRECTORY)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: Normal and Vol/Dir\n"); return 0; } } if (de->attrib & FATFS_ATTR_VOLUME) { if ((de->attrib & FATFS_ATTR_DIRECTORY) || (de->attrib & FATFS_ATTR_READONLY) || (de->attrib & FATFS_ATTR_ARCHIVE)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: Vol and Dir/RO/Arch\n"); return 0; } } /* The ctime, cdate, and adate fields are optional and * therefore 0 is a valid value */ if ((tsk_getu16(fs->endian, de->ctime) != 0) && (FATFS_ISTIME(tsk_getu16(fs->endian, de->ctime)) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: ctime\n"); return 0; } else if ((tsk_getu16(fs->endian, de->wtime) != 0) && (FATFS_ISTIME(tsk_getu16(fs->endian, de->wtime)) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: wtime\n"); return 0; } else if ((tsk_getu16(fs->endian, de->cdate) != 0) && (FATFS_ISDATE(tsk_getu16(fs->endian, de->cdate)) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: cdate\n"); return 0; } else if (de->ctimeten > 200) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: ctimeten\n"); return 0; } else if ((tsk_getu16(fs->endian, de->adate) != 0) && (FATFS_ISDATE(tsk_getu16(fs->endian, de->adate)) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: adate\n"); return 0; } else if ((tsk_getu16(fs->endian, de->wdate) != 0) && (FATFS_ISDATE(tsk_getu16(fs->endian, de->wdate)) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: wdate\n"); return 0; } } /* verify the starting cluster is small enough */ if ((FATFS_DENTRY_CLUST(fs, de) > (fatfs->lastclust)) && (FATFS_ISEOF(FATFS_DENTRY_CLUST(fs, de), fatfs->mask) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: start cluster\n"); return 0; } /* Verify the file size is smaller than the data area */ else if (tsk_getu32(fs->endian, de->size) > ((fatfs->clustcnt * fatfs->csize) << fatfs->ssize_sh)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: size\n"); return 0; } else if ((tsk_getu32(fs->endian, de->size) > 0) && (FATFS_DENTRY_CLUST(fs, de) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: non-zero size and NULL starting cluster\n"); return 0; } else if (is_83_name(de) == 0) return 0; // basic sanity check on values else if ((tsk_getu16(fs->endian, de->ctime) == 0) && (tsk_getu16(fs->endian, de->wtime) == 0) && (tsk_getu16(fs->endian, de->cdate) == 0) && (tsk_getu16(fs->endian, de->adate) == 0) && (tsk_getu16(fs->endian, de->wdate) == 0) && (FATFS_DENTRY_CLUST(fs, de) == 0) && (tsk_getu32(fs->endian, de->size) == 0)) { if (tsk_verbose) fprintf(stderr, "fatfs_isdentry: nearly all values zero\n"); return 0; } return 1; } } /************************************************************************** * * INODE WALKING * *************************************************************************/ /* Mark the sector used in the bitmap */ static TSK_WALK_RET_ENUM inode_walk_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM a_flags, void *a_ptr) { setbit((uint8_t *) a_ptr, addr); return TSK_WALK_CONT; } /* The inode_walk call back for each file. we want only the directories */ static TSK_WALK_RET_ENUM inode_walk_dent_act(TSK_FS_FILE * fs_file, const char *a_path, void *a_ptr) { if ((fs_file->meta == NULL) || (fs_file->meta->type != TSK_FS_META_TYPE_DIR)) return TSK_WALK_CONT; /* Get the sector addresses & ignore any errors */ if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_SLACK | TSK_FS_FILE_WALK_FLAG_AONLY, inode_walk_file_act, a_ptr)) { tsk_error_reset(); } return TSK_WALK_CONT; } /* * walk the inodes * * Flags that are used: TSK_FS_META_FLAG_ALLOC, TSK_FS_META_FLAG_UNALLOC, * TSK_FS_META_FLAG_USED, TSK_FS_META_FLAG_UNUSED, TSK_FS_META_FLAG_ORPHAN * */ uint8_t fatfs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_action, void *a_ptr) { char *myname = "fatfs_inode_walk"; FATFS_INFO *fatfs = (FATFS_INFO *) fs; TSK_INUM_T end_inum_tmp; TSK_FS_FILE *fs_file; TSK_DADDR_T sect, ssect, lsect; fatfs_dentry *dep; unsigned int myflags, didx; uint8_t *sect_alloc; ssize_t cnt; uint8_t done = 0; char *dinode_buf = NULL; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (start_inum < fs->first_inum || start_inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start inode: %" PRIuINUM "", myname, start_inum); return 1; } else if (end_inum < fs->first_inum || end_inum > fs->last_inum || end_inum < start_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End inode: %" PRIuINUM "", myname, end_inum); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_inode_walk: Inode Walking %" PRIuINUM " to %" PRIuINUM "\n", start_inum, end_inum); /* If ORPHAN is wanted, then make sure that the a_flags are correct */ if (a_flags & TSK_FS_META_FLAG_ORPHAN) { a_flags |= TSK_FS_META_FLAG_UNALLOC; a_flags &= ~TSK_FS_META_FLAG_ALLOC; a_flags |= TSK_FS_META_FLAG_USED; a_flags &= ~TSK_FS_META_FLAG_UNUSED; } else { if (((a_flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED a_flags are set, then set them * both */ if (((a_flags & TSK_FS_META_FLAG_USED) == 0) && ((a_flags & TSK_FS_META_FLAG_UNUSED) == 0)) { a_flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } } /* If we are looking for orphan files and have not yet filled * in the list of unalloc inodes that are pointed to, then fill * in the list */ if ((a_flags & TSK_FS_META_FLAG_ORPHAN) && (fs->list_inum_named == NULL)) { if (tsk_fs_dir_load_inum_named(fs) != TSK_OK) { strncat(tsk_errstr2, " - fatfs_inode_walk: identifying inodes allocated by file names", TSK_ERRSTR_L); return 1; } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(FATFS_FILE_CONTENT_LEN)) == NULL) return 1; // handle the root directory if (start_inum == FATFS_ROOTINO) { if (((TSK_FS_META_FLAG_ALLOC & a_flags) == TSK_FS_META_FLAG_ALLOC) && ((TSK_FS_META_FLAG_USED & a_flags) == TSK_FS_META_FLAG_USED) && ((TSK_FS_META_FLAG_ORPHAN & a_flags) == 0)) { int retval; if (fatfs_make_root(fatfs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } retval = a_action(fs_file, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } /* advance it so that it is a valid starting point */ start_inum++; // exit if that is all that was requested if (start_inum == end_inum) { tsk_fs_file_close(fs_file); return 0; } } /* We will be looking at each sector to see if it contains directory * entries. We can make mistakes and ignore sectors that have valid * entries in them. To make sure we at least get all sectors that * are allocated by directories in the directory tree, we will * run name_walk and then a file walk on each dir. * We'll be make sure to print those. We skip this for ORPHAN hunting * because it doesn't help and can introduce infinite loop situations * inode_walk was called by the function that determines which inodes * are orphans. */ if (tsk_verbose) tsk_fprintf(stderr, "fatfs_inode_walk: Walking directories to collect sector info\n"); if ((sect_alloc = (uint8_t *) tsk_malloc((size_t) ((fs->block_count + 7) / 8))) == NULL) { tsk_fs_file_close(fs_file); return 1; } if ((a_flags & TSK_FS_META_FLAG_ORPHAN) == 0) { // Do a file_walk on the root directory to get its layout if (fatfs_make_root(fatfs, fs_file->meta)) { tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_SLACK | TSK_FS_FILE_WALK_FLAG_AONLY, inode_walk_file_act, (void *) sect_alloc)) { tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } // now get the rest of the directories. if (tsk_fs_dir_walk(fs, fs->root_inum, TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE | TSK_FS_DIR_WALK_FLAG_NOORPHAN, inode_walk_dent_act, (void *) sect_alloc)) { strncat(tsk_errstr2, " - fatfs_inode_walk: mapping directories", TSK_ERRSTR_L); tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } } /* start analyzing each sector * * Perform a test on the first 32 bytes of each sector to identify if * the sector contains directory entries. If it does, then continue * to analyze it. If not, then read the next sector */ /* identify the starting and ending inodes sector addrs */ /* we need to handle end_inum specially if it is for the * virtual ORPHANS directory or virtual FAT files. * Handle these outside of the loop. */ if (end_inum > fs->last_inum - FATFS_NUM_SPECFILE) end_inum_tmp = fs->last_inum - FATFS_NUM_SPECFILE; else end_inum_tmp = end_inum; ssect = FATFS_INODE_2_SECT(fatfs, start_inum); lsect = FATFS_INODE_2_SECT(fatfs, end_inum_tmp); if (ssect > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_walk: Starting inode in sector too big for image: %" PRIuDADDR, ssect); tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } else if (lsect > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_walk: Ending inode in sector too big for image: %" PRIuDADDR, lsect); tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } if ((dinode_buf = tsk_malloc(fatfs->csize * fatfs->ssize)) == NULL) { tsk_fs_file_close(fs_file); free(sect_alloc); return 1; } sect = ssect; while (sect <= lsect) { int clustalloc; // 1 if current sector / cluster is allocated size_t sect_proc; // number of sectors read for this loop size_t sidx; // sector index for loop /* This occurs for the root directory of TSK_FS_TYPE_FAT12/16 * * We are going to process the image in clusters, so take care of the root * directory seperately. */ if (sect < fatfs->firstclustsect) { // there are no orphans in the root directory if ((a_flags & TSK_FS_META_FLAG_ORPHAN) != 0) { sect = fatfs->firstclustsect; continue; } clustalloc = 1; /* read the sector */ cnt = tsk_fs_read_block(fs, sect, dinode_buf, fatfs->ssize); if (cnt != fatfs->ssize) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_inode_walk (root dir): sector: %" PRIuDADDR, sect); tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 1; } sect_proc = 1; } /* For the data area, we will read in cluster-sized chunks */ else { /* get the base sector for the cluster in which the first inode exists */ sect = FATFS_CLUST_2_SECT(fatfs, (FATFS_SECT_2_CLUST(fatfs, sect))); /* if the cluster is not allocated, then do not go into it if we * only want allocated/link entries * If it is allocated, then go into it no matter what */ clustalloc = fatfs_is_sectalloc(fatfs, sect); if (clustalloc == -1) { tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 1; } else if ((clustalloc == 0) && ((a_flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { sect += fatfs->csize; continue; } /* If it is allocated, but we know it is not allocated to a * directory then skip it. NOTE: This will miss unallocated * entries in slack space of the file... */ if ((clustalloc == 1) && (isset(sect_alloc, sect) == 0)) { sect += fatfs->csize; continue; } /* The final cluster may not be full */ if (lsect - sect + 1 < fatfs->csize) sect_proc = (size_t) (lsect - sect + 1); else sect_proc = fatfs->csize; /* read the full cluster */ cnt = tsk_fs_read_block (fs, sect, dinode_buf, sect_proc << fatfs->ssize_sh); if (cnt != (sect_proc << fatfs->ssize_sh)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_inode_walk: sector: %" PRIuDADDR, sect); tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 1; } } // cycle through the sectors read for (sidx = 0; sidx < sect_proc; sidx++) { TSK_INUM_T inum; uint8_t isInDir; dep = (fatfs_dentry *) & dinode_buf[sidx << fatfs->ssize_sh]; /* if we know it is not part of a directory and it is not valid dentires, * then skip it */ isInDir = isset(sect_alloc, sect); if ((isInDir == 0) && (fatfs_isdentry(fatfs, dep, 0) == 0)) { sect++; continue; } /* See if the last inode in this sector is smaller than the starting one */ if (FATFS_SECT_2_INODE(fatfs, sect + 1) < start_inum) { sect++; continue; } /* get the base inode address of this sector */ inum = FATFS_SECT_2_INODE(fatfs, sect); if (tsk_verbose) tsk_fprintf(stderr, "fatfs_inode_walk: Processing sector %" PRIuDADDR " starting at inode %" PRIuINUM "\n", sect, inum); /* cycle through the directory entries */ for (didx = 0; didx < fatfs->dentry_cnt_se; didx++, inum++, dep++) { int retval; TSK_RETVAL_ENUM retval2; /* If less, then move on */ if (inum < start_inum) continue; /* If we are done, then exit from the loops */ if (inum > end_inum_tmp) { done = 1; break; } /* if this is a long file name entry, then skip it and * wait for the short name */ if ((dep->attrib & FATFS_ATTR_LFN) == FATFS_ATTR_LFN) continue; /* we don't care about . and .. entries because they * are redundant of other 'inode' entries */ if (((dep->attrib & FATFS_ATTR_DIRECTORY) == FATFS_ATTR_DIRECTORY) && (dep->name[0] == '.')) continue; /* Allocation status * This is determined first by the sector allocation status * an then the dentry flag. When a directory is deleted, the * contents are not always set to unallocated */ if (clustalloc == 1) { myflags = ((dep->name[0] == FATFS_SLOT_DELETED) ? TSK_FS_META_FLAG_UNALLOC : TSK_FS_META_FLAG_ALLOC); } else { myflags = TSK_FS_META_FLAG_UNALLOC; } if ((a_flags & myflags) != myflags) continue; /* Slot has not been used yet */ myflags |= ((dep->name[0] == FATFS_SLOT_EMPTY) ? TSK_FS_META_FLAG_UNUSED : TSK_FS_META_FLAG_USED); if ((a_flags & myflags) != myflags) continue; /* If we want only orphans, then check if this * inode is in the seen list */ if ((myflags & TSK_FS_META_FLAG_UNALLOC) && (a_flags & TSK_FS_META_FLAG_ORPHAN) && (tsk_list_find(fs->list_inum_named, inum))) { continue; } /* Do a final sanity check */ if (0 == fatfs_isdentry(fatfs, dep, isInDir)) continue; if ((retval2 = fatfs_dinode_copy(fatfs, fs_file->meta, dep, sect, inum)) != TSK_OK) { /* Ignore this error and continue */ if (retval2 == TSK_COR) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); continue; } else { tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 1; } } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_inode_walk: Directory Entry %" PRIuINUM " (%u) at sector %" PRIuDADDR "\n", inum, didx, sect); retval = a_action(fs_file, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); free(sect_alloc); free(dinode_buf); return 1; } } /* dentries */ sect++; if (done) break; } if (done) break; } free(sect_alloc); free(dinode_buf); dinode_buf = NULL; // handle the virtual orphans folder and FAT files if they asked for them if ((end_inum > fs->last_inum - FATFS_NUM_SPECFILE) && (a_flags & TSK_FS_META_FLAG_ALLOC) && (a_flags & TSK_FS_META_FLAG_USED) && ((a_flags & TSK_FS_META_FLAG_ORPHAN) == 0)) { TSK_INUM_T inum; // cycle through the special files for (inum = fs->last_inum - FATFS_NUM_SPECFILE + 1; inum <= end_inum; inum++) { int retval; tsk_fs_meta_reset(fs_file->meta); if (inum == FATFS_MBRINO(fs)) { if (fatfs_make_mbr(fatfs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } } else if (inum == FATFS_FAT1INO(fs)) { if (fatfs_make_fat(fatfs, 1, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } } else if (inum == FATFS_FAT2INO(fs)) { if (fatfs_make_fat(fatfs, 2, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } } else if (inum == TSK_FS_ORPHANDIR_INUM(fs)) { if (tsk_fs_dir_make_orphan_dir_meta(fs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } } retval = a_action(fs_file, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } } tsk_fs_file_close(fs_file); return 0; } /* end of inode_walk */ /* * return the contents of a specific inode * * 1 is returned if an error occurs or if the entry is not * a valid inode */ uint8_t fatfs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { FATFS_INFO *fatfs = (FATFS_INFO *) fs; ssize_t cnt; TSK_DADDR_T sect; size_t off; TSK_RETVAL_ENUM retval; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity check. */ if (inum < fs->first_inum || inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_lookup: %" PRIuINUM " too large/small", inum); return 1; } if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_lookup: fs_file is NULL"); return 1; } if (a_fs_file->meta == NULL) { if ((a_fs_file->meta = tsk_fs_meta_alloc(FATFS_FILE_CONTENT_LEN)) == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } /* As there is no real root inode in FAT, use the made up one */ if (inum == FATFS_ROOTINO) { fatfs->dep = NULL; if (fatfs_make_root(fatfs, a_fs_file->meta)) return 1; else return 0; } else if (inum == FATFS_MBRINO(fs)) { fatfs->dep = NULL; if (fatfs_make_mbr(fatfs, a_fs_file->meta)) return 1; else return 0; } else if (inum == FATFS_FAT1INO(fs)) { fatfs->dep = NULL; if (fatfs_make_fat(fatfs, 1, a_fs_file->meta)) return 1; else return 0; } else if (inum == FATFS_FAT2INO(fs)) { fatfs->dep = NULL; if (fatfs_make_fat(fatfs, 2, a_fs_file->meta)) return 1; else return 0; } else if (inum == TSK_FS_ORPHANDIR_INUM(fs)) { fatfs->dep = NULL; if (tsk_fs_dir_make_orphan_dir_meta(fs, a_fs_file->meta)) return 1; else return 0; } /* Get the sector that this inode would be in and its offset */ sect = FATFS_INODE_2_SECT(fatfs, inum); off = FATFS_INODE_2_OFF(fatfs, inum); if (sect > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_lookup: Inode %" PRIuINUM " in sector too big for image: %" PRIuDADDR, inum, sect); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "fatfs_inode_lookup: reading sector %" PRIuDADDR " for inode %" PRIuINUM "\n", sect, inum); cnt = tsk_fs_read_block(fs, sect, fatfs->dinodes, fatfs->ssize); if (cnt != fatfs->ssize) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "fatfs_inode_lookup: block: %" PRIuDADDR, sect); return 1; } fatfs->dep = (fatfs_dentry *) & fatfs->dinodes[off]; if (fatfs_isdentry(fatfs, fatfs->dep, 1)) { if ((retval = fatfs_dinode_copy(fatfs, a_fs_file->meta, fatfs->dep, sect, inum)) != TSK_OK) { /* If there was a unicode conversion error, * then still return the inode */ if (retval == TSK_ERR) { return 1; } else { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); } } return 0; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_inode_lookup: %" PRIuINUM " is not an inode", inum); return 1; } } /** \internal * Process the file and load up the clusters into the FS_DATA attribute * in fs_meta. The run will list the starting sector and length in sectors * * @param a_fs_file File to process and structore to store results in * * @returns 1 on error and 0 on success */ uint8_t fatfs_make_data_run(TSK_FS_FILE * a_fs_file) { TSK_FS_INFO *fs; TSK_DADDR_T clust; TSK_OFF_T size_remain; TSK_FS_ATTR *fs_attr = NULL; TSK_FS_META *fs_meta; FATFS_INFO *fatfs; if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_make_data_run: called with NULL pointers"); return 1; } fs_meta = a_fs_file->meta; fs = a_fs_file->fs_info; fatfs = (FATFS_INFO *) fs; clust = ((TSK_DADDR_T *) fs_meta->content_ptr)[0]; size_remain = roundup(fs_meta->size, fatfs->csize * fs->block_size); // see if we have already loaded the runs if ((fs_meta->attr != NULL) && (fs_meta->attr_state == TSK_FS_META_ATTR_STUDIED)) { return 0; } else if (fs_meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } // not sure why this would ever happen, but... else if (fs_meta->attr != NULL) { tsk_fs_attrlist_markunused(fs_meta->attr); } else if (fs_meta->attr == NULL) { fs_meta->attr = tsk_fs_attrlist_alloc(); } // sanity check on input if ((clust > (fatfs->lastclust)) && (FATFS_ISEOF(clust, fatfs->mask) == 0)) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_error_reset(); if (a_fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_make_data_run: Starting cluster address too large: %" PRIuDADDR, clust); return 1; } /* We need to handle the special files specially because they * are not in the FAT. Except for FAT32 root dirs, those are normal. */ if ((a_fs_file->meta->addr == FATFS_ROOTINO) && (fs->ftype != TSK_FS_TYPE_FAT32) && (clust == 1)) { TSK_FS_ATTR_RUN *data_run; if (tsk_verbose) tsk_fprintf(stderr, "fatfs_make_data_run: Loading root directory\n"); // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) { return 1; } data_run->addr = fatfs->rootsect; data_run->len = fatfs->firstclustsect - fatfs->firstdatasect; if ((fs_attr = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { return 1; } // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, data_run->len * fs->block_size, data_run->len * fs->block_size, data_run->len * fs->block_size, 0, 0)) { return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } // see if it is one of the special files else if ((a_fs_file->meta->addr > fs->last_inum - FATFS_NUM_SPECFILE) && (a_fs_file->meta->addr != TSK_FS_ORPHANDIR_INUM(fs))) { TSK_FS_ATTR_RUN *data_run; if (tsk_verbose) tsk_fprintf(stderr, "fatfs_make_data_run: Loading special file: %" PRIuINUM "\n", a_fs_file->meta->addr); // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) { return 1; } data_run->addr = clust; data_run->len = a_fs_file->meta->size / fs->block_size; if ((fs_attr = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { return 1; } // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, data_run->len * fs->block_size, data_run->len * fs->block_size, data_run->len * fs->block_size, 0, 0)) { return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /* A deleted file that we want to recover * In this case, we could get a lot of errors because of inconsistent * data. TO make it clear that these are from a recovery, we set most * error codes to _RECOVER so that they can be more easily suppressed. */ else if (fs_meta->flags & TSK_FS_META_FLAG_UNALLOC) { TSK_DADDR_T sbase; TSK_DADDR_T startclust = clust; TSK_OFF_T recoversize = fs_meta->size; int retval; TSK_FS_ATTR_RUN *data_run = NULL; TSK_FS_ATTR_RUN *data_run_head = NULL; TSK_OFF_T full_len_s = 0; uint8_t canRecover = 1; // set to 0 if recovery is not possible if (tsk_verbose) tsk_fprintf(stderr, "fatfs_make_data_run: Processing deleted file %" PRIuINUM " in recovery mode\n", fs_meta->addr); /* We know the size and the starting cluster * * We are going to take the clusters from the starting cluster * onwards and skip the clusters that are current allocated */ /* Sanity checks on the starting cluster */ /* Convert the cluster addr to a sector addr */ sbase = FATFS_CLUST_2_SECT(fatfs, startclust); if (sbase > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_RECOVER; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_make_data_run: Starting cluster address too large (recovery): %" PRIuDADDR, sbase); fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } else { /* If the starting cluster is already allocated then we can't * recover it */ retval = fatfs_is_clustalloc(fatfs, startclust); if (retval != 0) { canRecover = 0; } } /* Part 1 is to make sure there are enough unallocated clusters * for the size of the file */ clust = startclust; size_remain = recoversize; // we could make this negative so sign it for the comparison while (((int64_t) size_remain > 0) && (canRecover)) { int retval; sbase = FATFS_CLUST_2_SECT(fatfs, clust); /* Are we past the end of the FS? * that means we could not find enough unallocated clusters * for the file size */ if (sbase > fs->last_block) { canRecover = 0; if (tsk_verbose) tsk_fprintf(stderr, "Could not find enough unallocated sectors to recover with - aborting\n"); break; } /* Skip allocated clusters */ retval = fatfs_is_clustalloc(fatfs, clust); if (retval == -1) { canRecover = 0; break; } else if (retval == 1) { clust++; continue; } /* We can use this sector */ // see if we need a new run if ((data_run == NULL) || (data_run->addr + data_run->len != sbase)) { TSK_FS_ATTR_RUN *data_run_tmp = tsk_fs_attr_run_alloc(); if (data_run_tmp == NULL) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_fs_attr_run_free(data_run_head); return 1; } if (data_run_head == NULL) { data_run_head = data_run_tmp; data_run_tmp->offset = 0; } else if (data_run != NULL) { data_run->next = data_run_tmp; data_run_tmp->offset = data_run->offset + data_run->len; } data_run = data_run_tmp; data_run->len = 0; data_run->addr = sbase; } data_run->len += fatfs->csize; full_len_s += fatfs->csize; size_remain -= (fatfs->csize << fatfs->ssize_sh); clust++; } // Get a FS_DATA structure and add the runlist to it if ((fs_attr = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } if (canRecover) { /* We can recover the file */ // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run_head, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, fs_meta->size, fs_meta->size, roundup(fs_meta->size, fatfs->csize * fs->block_size), 0, 0)) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; } // create a one cluster run else { TSK_FS_ATTR_RUN *data_run_tmp = tsk_fs_attr_run_alloc(); if (data_run_tmp == NULL) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } data_run_tmp->addr = sbase; data_run_tmp->len = fatfs->csize; // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run_tmp, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, fs_meta->size, fs_meta->size, roundup(fs_meta->size, fatfs->csize * fs->block_size), 0, 0)) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; } return 0; } /* Normal cluster chain walking */ else { TSK_LIST *list_seen = NULL; TSK_FS_ATTR_RUN *data_run = NULL; TSK_FS_ATTR_RUN *data_run_head = NULL; TSK_OFF_T full_len_s = 0; TSK_DADDR_T sbase; if (tsk_verbose) tsk_fprintf(stderr, "fatfs_make_data_run: Processing file %" PRIuINUM " in normal mode\n", fs_meta->addr); /* Cycle through the cluster chain */ while ((clust & fatfs->mask) > 0 && (int64_t) size_remain > 0 && (0 == FATFS_ISEOF(clust, fatfs->mask))) { /* Convert the cluster addr to a sector addr */ sbase = FATFS_CLUST_2_SECT(fatfs, clust); if (sbase > fs->last_block) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "fatfs_make_data_run: Invalid sector address in FAT (too large): %" PRIuDADDR, sbase); return 1; } // see if we need a new run if ((data_run == NULL) || (data_run->addr + data_run->len != sbase)) { TSK_FS_ATTR_RUN *data_run_tmp = tsk_fs_attr_run_alloc(); if (data_run_tmp == NULL) { tsk_fs_attr_run_free(data_run_head); fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } if (data_run_head == NULL) { data_run_head = data_run_tmp; data_run_tmp->offset = 0; } else if (data_run != NULL) { data_run->next = data_run_tmp; data_run_tmp->offset = data_run->offset + data_run->len; } data_run = data_run_tmp; data_run->len = 0; data_run->addr = sbase; } data_run->len += fatfs->csize; full_len_s += fatfs->csize; size_remain -= (fatfs->csize * fs->block_size); if ((int64_t) size_remain > 0) { TSK_DADDR_T nxt; if (fatfs_getFAT(fatfs, clust, &nxt)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "file walk: Inode: %" PRIuINUM " cluster: %" PRIuDADDR, fs_meta->addr, clust); fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_fs_attr_run_free(data_run_head); tsk_list_free(list_seen); list_seen = NULL; return 1; } clust = nxt; /* Make sure we do not get into an infinite loop */ if (tsk_list_find(list_seen, clust)) { if (tsk_verbose) tsk_fprintf(stderr, "Loop found while processing file\n"); break; } if (tsk_list_add(&list_seen, clust)) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_list_free(list_seen); list_seen = NULL; return 1; } } } // add the run list to the inode structure if ((fs_attr = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run_head, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, fs_meta->size, fs_meta->size, roundup(fs_meta->size, fatfs->csize * fs->block_size), 0, 0)) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } tsk_list_free(list_seen); list_seen = NULL; fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } } sleuthkit-3.2.3/tsk3/fs/ffind_lib.c000644 000765 000024 00000006505 11643647440 017720 0ustar00carrierstaff000000 000000 /* ** ffind (file find) ** The Sleuth Kit ** ** Find the file that uses the specified inode (including deleted files) ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file ffind_lib.c * Contains the library API functions used by the TSK ffind command * line tool. */ #include "tsk_fs_i.h" /* NTFS has an optimized version of this function */ extern uint8_t ntfs_find_file(TSK_FS_INFO *, TSK_INUM_T, uint32_t, uint8_t, uint16_t, uint8_t, int, TSK_FS_DIR_WALK_CB, void *ptr); /** \internal * Structure to store data for callbacks. */ typedef struct { TSK_INUM_T inode; uint8_t flags; uint8_t found; } FFIND_DATA; static TSK_WALK_RET_ENUM find_file_act(TSK_FS_FILE * fs_file, const char *a_path, void *ptr) { FFIND_DATA *data = (FFIND_DATA *) ptr; /* We found it! */ if (fs_file->name->meta_addr == data->inode) { data->found = 1; if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC) tsk_printf("* "); tsk_printf("/%s%s\n", a_path, fs_file->name->name); if (!(data->flags & TSK_FS_FFIND_ALL)) { return TSK_WALK_STOP; } } return TSK_WALK_CONT; } /* Return 0 on success and 1 on error */ uint8_t tsk_fs_ffind(TSK_FS_INFO * fs, TSK_FS_FFIND_FLAG_ENUM lclflags, TSK_INUM_T a_inode, TSK_FS_ATTR_TYPE_ENUM type, uint8_t type_used, uint16_t id, uint8_t id_used, TSK_FS_DIR_WALK_FLAG_ENUM flags) { FFIND_DATA data; data.found = 0; data.flags = lclflags; data.inode = a_inode; /* Since we start the walk on the root inode, then this will not show ** up in the above functions, so do it now */ if (data.inode == fs->root_inum) { if (flags & TSK_FS_DIR_WALK_FLAG_ALLOC) { tsk_printf("/\n"); data.found = 1; if (!(lclflags & TSK_FS_FFIND_ALL)) return 0; } } if (TSK_FS_TYPE_ISNTFS(fs->ftype)) { if (ntfs_find_file(fs, data.inode, type, type_used, id, id_used, flags, find_file_act, &data)) return 1; } else { if (tsk_fs_dir_walk(fs, fs->root_inum, flags, find_file_act, &data)) return 1; } if (data.found == 0) { /* With FAT, we can at least give the name of the file and call * it orphan */ if (TSK_FS_TYPE_ISFAT(fs->ftype)) { TSK_FS_FILE *fs_file = tsk_fs_file_open_meta(fs, NULL, data.inode); if ((fs_file != NULL) && (fs_file->meta != NULL) && (fs_file->meta->name2 != NULL)) { if (fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_printf("* "); tsk_printf("%s/%s\n", TSK_FS_ORPHAN_STR, fs_file->meta->name2->name); } if (fs_file) tsk_fs_file_close(fs_file); } else { tsk_printf("File name not found for inode\n"); } } return 0; } sleuthkit-3.2.3/tsk3/fs/ffs.c000644 000765 000024 00000213051 11643647440 016556 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002-2003 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** * \file ffs.c * Contains the internal TSK UFS / FFS file system functions */ #include "tsk_fs_i.h" #include "tsk_ffs.h" /* ffs_group_load - load cylinder group descriptor info into cache * * return 1 on error and 0 on success * */ static uint8_t ffs_group_load(FFS_INFO * ffs, FFS_GRPNUM_T grp_num) { TSK_DADDR_T addr; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ffs->fs_info; /* * Sanity check */ if (grp_num < 0 || grp_num >= ffs->groups_count) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_group_load: invalid cylinder group number: %" PRI_FFSGRP "", grp_num); return 1; } /* * Allocate/read cylinder group info on the fly. Trust that a cylinder * group always fits within a logical disk block (as promised in the * 4.4BSD include file). */ if (ffs->grp_buf == NULL) { if ((ffs->grp_buf = tsk_malloc(ffs->ffsbsize_b)) == NULL) return 1; } addr = cgtod_lcl(fs, ffs->fs.sb1, grp_num); if (ffs->grp_addr != addr) { ffs_cgd *cg; ssize_t cnt; cnt = tsk_fs_read_block(fs, addr, ffs->grp_buf, ffs->ffsbsize_b); if (cnt != ffs->ffsbsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_group_load: Group %" PRI_FFSGRP " at %" PRIuDADDR, grp_num, addr); return 1; } ffs->grp_addr = addr; /* Perform a sanity check on the data to make sure offsets are in range */ cg = (ffs_cgd *) ffs->grp_buf; if ((tsk_gets32(fs->endian, cg->cg_iusedoff) > ffs->ffsbsize_b) || (tsk_gets32(fs->endian, cg->cg_freeoff) > ffs->ffsbsize_b)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_CORRUPT; snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_group_load: Group %" PRI_FFSGRP " descriptor offsets too large at %" PRIuDADDR, grp_num, addr); return 1; } } ffs->grp_num = grp_num; return 0; } /* * ffs_dinode_load - read disk inode and load into local cache (ffs->dino_buf) * * Return 0 on success and 1 on error */ static uint8_t ffs_dinode_load(FFS_INFO * ffs, TSK_INUM_T inum) { TSK_DADDR_T addr; TSK_OFF_T offs; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ffs->fs_info; /* * Sanity check. * Use last_num-1 to account for virtual Orphan directory in last_inum. */ if (inum < fs->first_inum || inum > fs->last_inum - 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dinode_load: address: %" PRIuINUM, inum); return 1; } /* * Allocate/read the inode table buffer on the fly. */ if (ffs->itbl_buf == NULL) { if ((ffs->itbl_buf = tsk_malloc(ffs->ffsbsize_b)) == NULL) return 1; } /* UFS2 is different because it does not initialize all inodes * when the file system is created. Therefore we need to check * the group descriptor to find out if this is in the valid * range */ if (fs->ftype == TSK_FS_TYPE_FFS2) { ffs_cgd2 *cg2; FFS_GRPNUM_T grp_num; if (ffs->dino_buf == NULL) { ffs->dino_buf = (char *) tsk_malloc(sizeof(ffs_inode2)); if (ffs->dino_buf == NULL) return 1; } else if (ffs->dino_inum == inum) { return 0; } /* Lookup the cylinder group descriptor if it isn't * cached */ grp_num = (FFS_GRPNUM_T) itog_lcl(fs, ffs->fs.sb1, inum); if ((ffs->grp_buf == NULL) || (grp_num != ffs->grp_num)) { if (ffs_group_load(ffs, grp_num)) { return 1; } } cg2 = (ffs_cgd2 *) ffs->grp_buf; /* If the inode is not init, then do not worry about it */ if ((inum - grp_num * tsk_getu32(fs->endian, ffs->fs.sb2->cg_inode_num)) >= tsk_getu32(fs->endian, cg2->cg_initediblk)) { memset((char *) ffs->dino_buf, 0, sizeof(ffs_inode2)); } else { ssize_t cnt; /* Get the base and offset addr for the inode in the tbl */ addr = itod_lcl(fs, ffs->fs.sb1, inum); if (ffs->itbl_addr != addr) { cnt = tsk_fs_read_block (fs, addr, ffs->itbl_buf, ffs->ffsbsize_b); if (cnt != ffs->ffsbsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_dinode_load: FFS2 inode table at %" PRIuDADDR, addr); return 1; } ffs->itbl_addr = addr; } offs = itoo_lcl(fs, ffs->fs.sb2, inum) * sizeof(ffs_inode2); memcpy((char *) ffs->dino_buf, ffs->itbl_buf + offs, sizeof(ffs_inode2)); } } else { if (ffs->dino_buf == NULL) { ffs->dino_buf = (char *) tsk_malloc(sizeof(ffs_inode1)); if (ffs->dino_buf == NULL) return 1; } else if (ffs->dino_inum == inum) { return 0; } addr = itod_lcl(fs, ffs->fs.sb1, inum); if (ffs->itbl_addr != addr) { ssize_t cnt; cnt = tsk_fs_read_block(fs, addr, ffs->itbl_buf, ffs->ffsbsize_b); if (cnt != ffs->ffsbsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_dinode_load: FFS1 inode table at %" PRIuDADDR, addr); return 1; } ffs->itbl_addr = addr; } offs = itoo_lcl(fs, ffs->fs.sb1, inum) * sizeof(ffs_inode1); memcpy((char *) ffs->dino_buf, ffs->itbl_buf + offs, sizeof(ffs_inode1)); } ffs->dino_inum = inum; return 0; } static TSK_FS_META_TYPE_ENUM ffsmode2tsktype(uint16_t a_mode) { switch (a_mode & FFS_IN_FMT) { case FFS_IN_REG: return TSK_FS_META_TYPE_REG; case FFS_IN_DIR: return TSK_FS_META_TYPE_DIR; case FFS_IN_SOCK: return TSK_FS_META_TYPE_SOCK; case FFS_IN_LNK: return TSK_FS_META_TYPE_LNK; case FFS_IN_BLK: return TSK_FS_META_TYPE_BLK; case FFS_IN_CHR: return TSK_FS_META_TYPE_CHR; case FFS_IN_FIFO: return TSK_FS_META_TYPE_FIFO; case FFS_IN_SHAD: return TSK_FS_META_TYPE_SHAD; case FFS_IN_WHT: return TSK_FS_META_TYPE_WHT; default: return TSK_FS_META_TYPE_UNDEF; } } static uint16_t ffsmode2tskmode(uint16_t a_mode) { uint16_t mode = 0; if (a_mode & FFS_IN_ISUID) mode |= TSK_FS_META_MODE_ISUID; if (a_mode & FFS_IN_ISGID) mode |= TSK_FS_META_MODE_ISGID; if (a_mode & FFS_IN_ISVTX) mode |= TSK_FS_META_MODE_ISVTX; if (a_mode & FFS_IN_IRUSR) mode |= TSK_FS_META_MODE_IRUSR; if (a_mode & FFS_IN_IWUSR) mode |= TSK_FS_META_MODE_IWUSR; if (a_mode & FFS_IN_IXUSR) mode |= TSK_FS_META_MODE_IXUSR; if (a_mode & FFS_IN_IRGRP) mode |= TSK_FS_META_MODE_IRGRP; if (a_mode & FFS_IN_IWGRP) mode |= TSK_FS_META_MODE_IWGRP; if (a_mode & FFS_IN_IXGRP) mode |= TSK_FS_META_MODE_IXGRP; if (a_mode & FFS_IN_IROTH) mode |= TSK_FS_META_MODE_IROTH; if (a_mode & FFS_IN_IWOTH) mode |= TSK_FS_META_MODE_IWOTH; if (a_mode & FFS_IN_IXOTH) mode |= TSK_FS_META_MODE_IXOTH; return mode; } /* ffs_dinode_copy - copy cached disk inode to generic inode * * Return 1 on error and 0 on success */ static uint8_t ffs_dinode_copy(FFS_INFO * ffs, TSK_FS_META * fs_meta) { int i, j; unsigned int count; TSK_FS_INFO *fs = &(ffs->fs_info); FFS_GRPNUM_T grp_num; ffs_cgd *cg; unsigned char *inosused = NULL; TSK_INUM_T ibase; if (ffs->dino_buf == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dinode_copy: dino_buf is NULL"); return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } fs_meta->flags = 0; fs_meta->seq = 0; /* If the symlink field is set from a previous run, then free it */ if (fs_meta->link) { free(fs_meta->link); fs_meta->link = NULL; } fs_meta->addr = ffs->dino_inum; /* OpenBSD and FreeBSD style */ if (fs->ftype == TSK_FS_TYPE_FFS1) { ffs_inode1 *in = (ffs_inode1 *) ffs->dino_buf; TSK_DADDR_T *addr_ptr; fs_meta->mode = ffsmode2tskmode(tsk_getu16(fs->endian, in->di_mode)); fs_meta->type = ffsmode2tsktype(tsk_getu16(fs->endian, in->di_mode)); fs_meta->nlink = tsk_gets16(fs->endian, in->di_nlink); fs_meta->size = tsk_getu64(fs->endian, in->di_size); fs_meta->uid = tsk_getu32(fs->endian, in->di_uid); fs_meta->gid = tsk_getu32(fs->endian, in->di_gid); fs_meta->mtime = tsk_gets32(fs->endian, in->di_mtime); fs_meta->atime = tsk_gets32(fs->endian, in->di_atime); fs_meta->ctime = tsk_gets32(fs->endian, in->di_ctime); fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; if (fs_meta->content_len < FFS_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, FFS_FILE_CONTENT_LEN)) == NULL) { return 1; } } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; for (i = 0; i < FFS_NDADDR; i++) addr_ptr[i] = tsk_gets32(fs->endian, in->di_db[i]); for (i = 0; i < FFS_NIADDR; i++) addr_ptr[FFS_NDADDR + i] = tsk_gets32(fs->endian, in->di_ib[i]); /* set the link string (if the file is a link) * The size check is a sanity check so that we don't try and allocate * a huge amount of memory for a bad inode value */ if ((fs_meta->type == TSK_FS_META_TYPE_LNK) && (fs_meta->size < FFS_MAXPATHLEN) && (fs_meta->size >= 0)) { int i; fs_meta->link = tsk_malloc((size_t) fs_meta->size + 1); if (fs_meta->link == NULL) { return 1; } count = 0; /* index into the link array */ /* it is located directly in the pointers */ if (fs_meta->size < 4 * (FFS_NDADDR + FFS_NIADDR)) { char *ptr; /* Direct block pointer locations */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_db[i]; for (j = 0; j < 4 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } /* indirect block pointers */ for (i = 0; i < FFS_NIADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_ib[i]; for (j = 0; j < 4 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } fs_meta->link[count] = '\0'; /* clear the values to avoid other code from reading them */ memset(fs_meta->content_ptr, 0, fs_meta->content_len); } /* it is in blocks (the regular way) */ else { char *buf; char *ptr = fs_meta->link; if ((buf = (char *) tsk_malloc(fs->block_size)) == NULL) { return 1; } /* there is a max link length of 1000, so we should never * need the indirect blocks */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ssize_t cnt; TSK_DADDR_T *addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; /* Do we need the entire block, or just part of it? */ int read_count = (fs_meta->size - count < fs->block_size) ? (int) fs_meta->size - count : fs->block_size; cnt = tsk_fs_read_block(fs, addr_ptr[i], buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_dinode_copy: FFS1A symlink dest at %" PRIuDADDR, addr_ptr[i]); free(buf); return 1; } memcpy(ptr, buf, read_count); count += read_count; ptr = (char *) ((uintptr_t) ptr + read_count); } /* terminate the string */ *ptr = '\0'; /* Clean up name */ i = 0; while (fs_meta->link[i] != '\0') { if (TSK_IS_CNTRL(fs_meta->link[i])) fs_meta->link[i] = '^'; i++; } free(buf); } } /* end of symlink */ } /* TSK_FS_TYPE_FFS1B - Solaris */ else if (fs->ftype == TSK_FS_TYPE_FFS1B) { ffs_inode1b *in = (ffs_inode1b *) ffs->dino_buf; TSK_DADDR_T *addr_ptr; fs_meta->mode = ffsmode2tskmode(tsk_getu16(fs->endian, in->di_mode)); fs_meta->type = ffsmode2tsktype(tsk_getu16(fs->endian, in->di_mode)); fs_meta->nlink = tsk_gets16(fs->endian, in->di_nlink); fs_meta->size = tsk_getu64(fs->endian, in->di_size); fs_meta->uid = tsk_getu32(fs->endian, in->di_uid); fs_meta->gid = tsk_getu32(fs->endian, in->di_gid); fs_meta->mtime = tsk_gets32(fs->endian, in->di_mtime); fs_meta->atime = tsk_gets32(fs->endian, in->di_atime); fs_meta->ctime = tsk_gets32(fs->endian, in->di_ctime); fs_meta->crtime = 0; fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = fs_meta->crtime_nano = 0; if (fs_meta->content_len < FFS_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, FFS_FILE_CONTENT_LEN)) == NULL) { return 1; } } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; for (i = 0; i < FFS_NDADDR; i++) addr_ptr[i] = tsk_gets32(fs->endian, in->di_db[i]); for (i = 0; i < FFS_NIADDR; i++) addr_ptr[FFS_NDADDR + i] = tsk_gets32(fs->endian, in->di_ib[i]); if ((fs_meta->type == TSK_FS_META_TYPE_LNK) && (fs_meta->size < FFS_MAXPATHLEN) && (fs_meta->size >= 0)) { count = 0; /* index into the link array */ /* it is located directly in the pointers */ if (fs_meta->size < 4 * (FFS_NDADDR + FFS_NIADDR)) { char *ptr; /* Direct block pointer locations */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_db[i]; for (j = 0; j < 4 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } /* indirect block pointers */ for (i = 0; i < FFS_NIADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_ib[i]; for (j = 0; j < 4 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } fs_meta->link[count] = '\0'; /* clear the values to avoid other code from reading them */ memset(fs_meta->content_ptr, 0, fs_meta->content_len); } /* it is in blocks (the regular way) */ else { char *buf; char *ptr; if ((buf = (char *) tsk_malloc(fs->block_size)) == NULL) return 1; fs_meta->link = ptr = tsk_malloc((size_t) fs_meta->size + 1); if (fs_meta->link == NULL) { free(buf); return 1; } /* there is a max link length of 1000, so we should never * need the indirect blocks */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ssize_t cnt; TSK_DADDR_T *addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; /* Do we need the entire block, or just part of it? */ int read_count = (fs_meta->size - count < fs->block_size) ? (int) fs_meta->size - count : fs->block_size; cnt = tsk_fs_read_block(fs, addr_ptr[i], buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_dinode_copy: FFS1B symlink dest at %" PRIuDADDR, addr_ptr[i]); free(buf); return 1; } memcpy(ptr, buf, read_count); count += read_count; ptr = (char *) ((uintptr_t) ptr + read_count); } /* terminate the string */ *ptr = '\0'; free(buf); } } } else if (fs->ftype == TSK_FS_TYPE_FFS2) { ffs_inode2 *in = (ffs_inode2 *) ffs->dino_buf; TSK_DADDR_T *addr_ptr; fs_meta->mode = ffsmode2tskmode(tsk_getu16(fs->endian, in->di_mode)); fs_meta->type = ffsmode2tsktype(tsk_getu16(fs->endian, in->di_mode)); fs_meta->nlink = tsk_gets16(fs->endian, in->di_nlink); fs_meta->size = tsk_getu64(fs->endian, in->di_size); fs_meta->uid = tsk_getu32(fs->endian, in->di_uid); fs_meta->gid = tsk_getu32(fs->endian, in->di_gid); fs_meta->mtime = (time_t) tsk_gets64(fs->endian, in->di_mtime); fs_meta->atime = (time_t) tsk_gets64(fs->endian, in->di_atime); fs_meta->ctime = (time_t) tsk_gets64(fs->endian, in->di_ctime); fs_meta->crtime = 0; fs_meta->mtime_nano = tsk_getu32(fs->endian, in->di_mtimensec); fs_meta->atime_nano = tsk_getu32(fs->endian, in->di_atimensec); fs_meta->ctime_nano = tsk_getu32(fs->endian, in->di_ctimensec); fs_meta->crtime_nano = tsk_getu32(fs->endian, in->di_crtimensec); if (fs_meta->content_len < FFS_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, FFS_FILE_CONTENT_LEN)) == NULL) { return 1; } } addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; for (i = 0; i < FFS_NDADDR; i++) addr_ptr[i] = tsk_gets64(fs->endian, in->di_db[i]); for (i = 0; i < FFS_NIADDR; i++) addr_ptr[FFS_NDADDR + i] = tsk_gets64(fs->endian, in->di_ib[i]); /* set the link string (if the file is a link) * The size check is a sanity check so that we don't try and allocate * a huge amount of memory for a bad inode value */ if ((fs_meta->type == TSK_FS_META_TYPE_LNK) && (fs_meta->size < FFS_MAXPATHLEN) && (fs_meta->size >= 0)) { fs_meta->link = tsk_malloc((size_t) fs_meta->size + 1); if (fs_meta->link == NULL) { return 1; } count = 0; /* index into the link array */ /* it is located directly in the pointers * Only the new style inode has this "fast link" */ if (fs_meta->size < 8 * (FFS_NDADDR + FFS_NIADDR)) { char *ptr; /* Direct block pointer locations */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_db[i]; for (j = 0; j < 8 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } /* indirect block pointers */ for (i = 0; i < FFS_NIADDR && count < fs_meta->size; i++) { ptr = (char *) &in->di_ib[i]; for (j = 0; j < 8 && count < fs_meta->size; j++) fs_meta->link[count++] = ptr[j]; } fs_meta->link[count] = '\0'; /* clear the values to avoid other code from reading them */ memset(fs_meta->content_ptr, 0, fs_meta->content_len); } /* it is in blocks (the regular way) */ else { char *buf; char *ptr = fs_meta->link; if ((buf = (char *) tsk_malloc(fs->block_size)) == NULL) { return 1; } /* there is a max link length of 1000, so we should never * need the indirect blocks */ for (i = 0; i < FFS_NDADDR && count < fs_meta->size; i++) { ssize_t cnt; TSK_DADDR_T *addr_ptr = fs_meta->content_ptr; /* Do we need the entire block, or just part of it? */ int read_count = (fs_meta->size - count < fs->block_size) ? (int) fs_meta->size - count : fs->block_size; cnt = tsk_fs_read_block(fs, addr_ptr[i], buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_dinode_copy: FFS2 symlink dest at %" PRIuDADDR, addr_ptr[i]); free(buf); return 1; } memcpy(ptr, buf, read_count); count += read_count; ptr = (char *) ((uintptr_t) ptr + read_count); } /* terminate the string */ *ptr = '\0'; free(buf); } } /* end of symlink */ } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dinode_copy: Unknown FFS Type"); return 1; } /* set the flags */ grp_num = (FFS_GRPNUM_T) itog_lcl(fs, ffs->fs.sb1, ffs->dino_inum); if ((ffs->grp_buf == NULL) || (grp_num != ffs->grp_num)) { if (ffs_group_load(ffs, grp_num)) return 1; } cg = (ffs_cgd *) ffs->grp_buf; inosused = (unsigned char *) cg_inosused_lcl(fs, cg); ibase = grp_num * tsk_gets32(fs->endian, ffs->fs.sb1->cg_inode_num); /* get the alloc flag */ fs_meta->flags = (isset(inosused, ffs->dino_inum - ibase) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); /* used/unused */ fs_meta->flags |= (fs_meta->ctime ? TSK_FS_META_FLAG_USED : TSK_FS_META_FLAG_UNUSED); return 0; } /* ffs_inode_lookup - lookup inode, external interface * * Return 1 on error * * */ static uint8_t ffs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { FFS_INFO *ffs = (FFS_INFO *) fs; if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_inode_lookup: fs_file is NULL"); return 1; } /* copy it to the TSK_FS_META structure */ if (a_fs_file->meta == NULL) { a_fs_file->meta = tsk_fs_meta_alloc(FFS_FILE_CONTENT_LEN); if (a_fs_file->meta == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } // see if they are looking for the special "orphans" directory if (inum == TSK_FS_ORPHANDIR_INUM(fs)) { if (tsk_fs_dir_make_orphan_dir_meta(fs, a_fs_file->meta)) return 1; else return 0; } /* Lookup the inode and store it in ffs */ if (ffs_dinode_load(ffs, inum)) return 1; if (ffs_dinode_copy(ffs, a_fs_file->meta)) return 1; return 0; } /************************************************************************** * * INODE WALKING * **************************************************************************/ /* ffs_inode_walk - inode iterator * * flags used: TSK_FS_META_FLAG_USED, TSK_FS_META_FLAG_UNUSED, * TSK_FS_META_FLAG_ALLOC, TSK_FS_META_FLAG_UNALLOC, TSK_FS_META_FLAG_ORPHAN * * return 1 on error and 0 on success */ uint8_t ffs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB action, void *ptr) { char *myname = "ffs_inode_walk"; FFS_INFO *ffs = (FFS_INFO *) fs; FFS_GRPNUM_T grp_num; ffs_cgd *cg = NULL; TSK_INUM_T inum; unsigned char *inosused = NULL; TSK_FS_FILE *fs_file; int myflags; TSK_INUM_T ibase = 0; TSK_INUM_T end_inum_tmp; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (start_inum < fs->first_inum || start_inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start inode: %" PRIuINUM "", myname, start_inum); return 1; } else if (end_inum < fs->first_inum || end_inum > fs->last_inum || end_inum < start_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End inode: %" PRIuINUM "", myname, end_inum); return 1; } /* If ORPHAN is wanted, then make sure that the flags are correct */ if (a_flags & TSK_FS_META_FLAG_ORPHAN) { a_flags |= TSK_FS_META_FLAG_UNALLOC; a_flags &= ~TSK_FS_META_FLAG_ALLOC; a_flags |= TSK_FS_META_FLAG_USED; a_flags &= ~TSK_FS_META_FLAG_UNUSED; } else { if (((a_flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED flags are set, then set them * both */ if (((a_flags & TSK_FS_META_FLAG_USED) == 0) && ((a_flags & TSK_FS_META_FLAG_UNUSED) == 0)) { a_flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } } /* If we are looking for orphan files and have not yet filled * in the list of unalloc inodes that are pointed to, then fill * in the list * */ if ((a_flags & TSK_FS_META_FLAG_ORPHAN) && (fs->list_inum_named == NULL)) { if (tsk_fs_dir_load_inum_named(fs) != TSK_OK) { strncat(tsk_errstr2, " - ffs_inode_walk: identifying inodes allocated by file names", TSK_ERRSTR_L); return 1; } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(FFS_FILE_CONTENT_LEN)) == NULL) return 1; // we need to handle fs->last_inum specially because it is for the // virtual ORPHANS directory. Handle it outside of the loop. if (end_inum == TSK_FS_ORPHANDIR_INUM(fs)) end_inum_tmp = end_inum - 1; else end_inum_tmp = end_inum; /* * Iterate. This is easy because inode numbers are contiguous, unlike * data blocks which are interleaved with cylinder group blocks. */ for (inum = start_inum; inum <= end_inum_tmp; inum++) { int retval; /* * Be sure to use the proper cylinder group data. */ grp_num = itog_lcl(fs, ffs->fs.sb1, inum); if ((ffs->grp_buf == NULL) || (grp_num != ffs->grp_num)) { if (ffs_group_load(ffs, grp_num)) return 1; cg = NULL; } /* Load up the cached one if the needed one was already loaded or if a new was just loaded */ if (cg == NULL) { cg = (ffs_cgd *) ffs->grp_buf; inosused = (unsigned char *) cg_inosused_lcl(fs, cg); ibase = grp_num * tsk_gets32(fs->endian, ffs->fs.sb1->cg_inode_num); } /* * Apply the allocated/unallocated restriction. */ myflags = (isset(inosused, inum - ibase) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); if ((a_flags & myflags) != myflags) continue; if (ffs_dinode_load(ffs, inum)) { tsk_fs_file_close(fs_file); return 1; } if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { /* both inode forms are the same for the required fields */ ffs_inode1 *in1 = (ffs_inode1 *) ffs->dino_buf; /* * Apply the used/unused restriction. */ myflags |= (tsk_gets32(fs->endian, in1->di_ctime) ? TSK_FS_META_FLAG_USED : TSK_FS_META_FLAG_UNUSED); if ((a_flags & myflags) != myflags) continue; } else { ffs_inode2 *in2 = (ffs_inode2 *) ffs->dino_buf; /* * Apply the used/unused restriction. */ myflags |= (tsk_gets64(fs->endian, in2->di_ctime) ? TSK_FS_META_FLAG_USED : TSK_FS_META_FLAG_UNUSED); if ((a_flags & myflags) != myflags) continue; } /* If we want only orphans, then check if this * inode is in the seen list */ if ((myflags & TSK_FS_META_FLAG_UNALLOC) && (a_flags & TSK_FS_META_FLAG_ORPHAN) && (tsk_list_find(fs->list_inum_named, inum))) { continue; } /* * Fill in a file system-independent inode structure and pass control * to the application. */ if (ffs_dinode_copy(ffs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } retval = action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } // handle the virtual orphans folder if they asked for it if ((end_inum == TSK_FS_ORPHANDIR_INUM(fs)) && (a_flags & TSK_FS_META_FLAG_ALLOC) && (a_flags & TSK_FS_META_FLAG_USED)) { int retval; if (tsk_fs_dir_make_orphan_dir_meta(fs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } /* call action */ retval = action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } /* * Cleanup. */ tsk_fs_file_close(fs_file); return 0; } TSK_FS_BLOCK_FLAG_ENUM ffs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { FFS_INFO *ffs = (FFS_INFO *) a_fs; FFS_GRPNUM_T grp_num; ffs_cgd *cg = 0; TSK_DADDR_T frag_base = 0; TSK_DADDR_T dblock_addr = 0; /* first data block in group */ TSK_DADDR_T sblock_addr = 0; /* super block in group */ unsigned char *freeblocks = NULL; int flags; // sparse if (a_addr == 0) return TSK_FS_BLOCK_FLAG_CONT | TSK_FS_BLOCK_FLAG_ALLOC; grp_num = dtog_lcl(a_fs, ffs->fs.sb1, a_addr); if (ffs_group_load(ffs, grp_num)) { return 0; } cg = (ffs_cgd *) ffs->grp_buf; freeblocks = (unsigned char *) cg_blksfree_lcl(a_fs, cg); // get the base fragment for the group frag_base = cgbase_lcl(a_fs, ffs->fs.sb1, grp_num); // address of first data block in group dblock_addr = cgdmin_lcl(a_fs, ffs->fs.sb1, grp_num); // address of super block in group sblock_addr = cgsblock_lcl(a_fs, ffs->fs.sb1, grp_num); /* get the flags for this fragment * * Beware: FFS stores file data in the blocks between the start of a * cylinder group and the start of its super block. */ flags = (isset(freeblocks, a_addr - frag_base) ? TSK_FS_BLOCK_FLAG_UNALLOC : TSK_FS_BLOCK_FLAG_ALLOC); if (a_addr >= sblock_addr && a_addr < dblock_addr) flags |= TSK_FS_BLOCK_FLAG_META; else flags |= TSK_FS_BLOCK_FLAG_CONT; return flags; } /************************************************************************** * * BLOCK WALKING * **************************************************************************/ /* ffs_block_walk - block iterator * * flags: TSK_FS_BLOCK_FLAG_ALLOC, TSK_FS_BLOCK_FLAG_UNALLOC, TSK_FS_BLOCK_FLAG_CONT, * TSK_FS_BLOCK_FLAG_META * * return 1 on error and 0 on success */ uint8_t ffs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB action, void *ptr) { char *myname = "ffs_block_walk"; FFS_INFO *ffs = (FFS_INFO *) fs; TSK_FS_BLOCK *fs_block; TSK_DADDR_T addr; char *cache_blk_buf; // buffer used for local read cache TSK_DADDR_T cache_addr; // base address in local cache int cache_len_f; // amount of data read into cache (in fragments) // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks on input bounds */ if (a_start_blk < fs->first_block || a_start_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start block: %" PRIuDADDR "", myname, a_start_blk); return 1; } if (a_end_blk < fs->first_block || a_end_blk > fs->last_block || a_end_blk < a_start_blk) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End block: %" PRIuDADDR "", myname, a_end_blk); return 1; } /* Sanity check on flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } /* Other initialization */ if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } if ((cache_blk_buf = tsk_malloc(ffs->ffsbsize_b)) == NULL) { return 1; } cache_len_f = 0; cache_addr = 0; /* Cycle through the fragment range requested */ for (addr = a_start_blk; addr <= a_end_blk; addr++) { int retval; int myflags = ffs_block_getflags(fs, addr); if ((tsk_verbose) && (myflags & TSK_FS_BLOCK_FLAG_META) && (myflags & TSK_FS_BLOCK_FLAG_UNALLOC)) tsk_fprintf(stderr, "impossible: unallocated meta block %" PRIuDADDR, addr); // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_META) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_META))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_CONT) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; /* we read in block-sized chunks and cache the result for later * calls. See if this fragment is in our cache */ if ((cache_len_f == 0) || (addr >= cache_addr + cache_len_f)) { ssize_t cnt; int frags; /* Ideally, we want to read in block sized chunks, verify we can do that */ frags = (a_end_blk > addr + ffs->ffsbsize_f - 1 ? ffs->ffsbsize_f : (int) (a_end_blk + 1 - addr)); cnt = tsk_fs_read_block(fs, addr, cache_blk_buf, fs->block_size * frags); if (cnt != fs->block_size * frags) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_block_walk: Block %" PRIuDADDR, addr); tsk_fs_block_free(fs_block); free(cache_blk_buf); return 1; } cache_len_f = frags; cache_addr = addr; } // call the callback tsk_fs_block_set(fs, fs_block, addr, myflags | TSK_FS_BLOCK_FLAG_RAW, &cache_blk_buf[(addr - cache_addr) * fs->block_size]); retval = action(fs_block, ptr); if (retval == TSK_WALK_STOP) { break; } else if (retval == TSK_WALK_ERROR) { tsk_fs_block_free(fs_block); free(cache_blk_buf); return 1; } } /* Cleanup */ tsk_fs_block_free(fs_block); free(cache_blk_buf); return 0; } /* * return 1 on error and 0 on success */ static uint8_t ffs_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for ffs yet"); return 1; } /** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ static uint8_t ffs_fsstat(TSK_FS_INFO * fs, FILE * hFile) { unsigned int i; time_t tmptime; ffs_csum1 *csum1 = NULL; ffs_cgd *cgd = NULL; FFS_INFO *ffs = (FFS_INFO *) fs; ffs_sb1 *sb1 = ffs->fs.sb1; ffs_sb2 *sb2 = ffs->fs.sb2; int flags; // clean up any error messages that are lying around tsk_error_reset(); tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { tsk_fprintf(hFile, "File System Type: UFS 1\n"); tmptime = tsk_getu32(fs->endian, sb1->wtime); tsk_fprintf(hFile, "Last Written: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); tsk_fprintf(hFile, "Last Mount Point: %s\n", sb1->last_mnt); flags = sb1->fs_flags; } else { tsk_fprintf(hFile, "File System Type: UFS 2\n"); tmptime = tsk_getu32(fs->endian, sb2->wtime); tsk_fprintf(hFile, "Last Written: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); tsk_fprintf(hFile, "Last Mount Point: %s\n", sb2->last_mnt); tsk_fprintf(hFile, "Volume Name: %s\n", sb2->volname); tsk_fprintf(hFile, "System UID: %" PRIu64 "\n", tsk_getu64(fs->endian, sb2->swuid)); flags = tsk_getu32(fs->endian, sb2->fs_flags); } if (flags) { int cnt = 0; tsk_fprintf(hFile, "Flags: "); if (flags & FFS_SB_FLAG_UNCLEAN) tsk_fprintf(hFile, "%s Unclean", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_SOFTDEP) tsk_fprintf(hFile, "%s Soft Dependencies", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_NEEDFSCK) tsk_fprintf(hFile, "%s Needs fsck", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_INDEXDIR) tsk_fprintf(hFile, "%s Index directories", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_ACL) tsk_fprintf(hFile, "%s ACLs", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_MULTILABEL) tsk_fprintf(hFile, "%s TrustedBSD MAC Multi-label", (cnt++ == 0 ? "" : ",")); if (flags & FFS_SB_FLAG_UPDATED) tsk_fprintf(hFile, "%s Updated Flag Location", (cnt++ == 0 ? "" : ",")); tsk_fprintf(hFile, "\n"); } tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Inode Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "Root Directory: %" PRIuINUM "\n", fs->root_inum); if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { tsk_fprintf(hFile, "Num of Avail Inodes: %" PRIu32 "\n", tsk_getu32(fs->endian, sb1->cstotal.ino_free)); tsk_fprintf(hFile, "Num of Directories: %" PRIu32 "\n", tsk_getu32(fs->endian, sb1->cstotal.dir_num)); } else { tsk_fprintf(hFile, "Num of Avail Inodes: %" PRIu64 "\n", tsk_getu64(fs->endian, sb2->cstotal.ino_free)); tsk_fprintf(hFile, "Num of Directories: %" PRIu64 "\n", tsk_getu64(fs->endian, sb2->cstotal.dir_num)); } tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Fragment Range: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block); if (fs->last_block != fs->last_block_act) tsk_fprintf(hFile, "Total Range in Image: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block_act); tsk_fprintf(hFile, "Block Size: %u\n", ffs->ffsbsize_b); tsk_fprintf(hFile, "Fragment Size: %u\n", fs->block_size); if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { tsk_fprintf(hFile, "Num of Avail Full Blocks: %" PRIu32 "\n", tsk_getu32(fs->endian, sb1->cstotal.blk_free)); tsk_fprintf(hFile, "Num of Avail Fragments: %" PRIu32 "\n", tsk_getu32(fs->endian, sb1->cstotal.frag_free)); } else { tsk_fprintf(hFile, "Num of Avail Full Blocks: %" PRIu64 "\n", tsk_getu64(fs->endian, sb2->cstotal.blk_free)); tsk_fprintf(hFile, "Num of Avail Fragments: %" PRIu64 "\n", tsk_getu64(fs->endian, sb2->cstotal.frag_free)); } tsk_fprintf(hFile, "\nCYLINDER GROUP INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Number of Cylinder Groups: %" PRIu32 "\n", ffs->groups_count); tsk_fprintf(hFile, "Inodes per group: %" PRId32 "\n", tsk_gets32(fs->endian, sb1->cg_inode_num)); tsk_fprintf(hFile, "Fragments per group: %" PRId32 "\n", tsk_gets32(fs->endian, sb1->cg_frag_num)); /* UFS 1 and 2 use the same ssize field and use the same csum1 */ if (tsk_getu32(fs->endian, sb1->cg_ssize_b)) { ssize_t cnt; csum1 = (ffs_csum1 *) tsk_malloc(tsk_getu32(fs->endian, sb1->cg_ssize_b)); if (csum1 == NULL) return 1; if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { cnt = tsk_fs_read_block(fs, (TSK_DADDR_T) tsk_getu32(fs->endian, sb1->cg_saddr), (char *) csum1, tsk_getu32(fs->endian, sb1->cg_ssize_b)); if (cnt != tsk_getu32(fs->endian, sb1->cg_ssize_b)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_fsstat: FFS1 group descriptor at %" PRIu32, tsk_getu32(fs->endian, sb1->cg_saddr)); return 1; } } else { cnt = tsk_fs_read_block (fs, (TSK_DADDR_T) tsk_getu64(fs->endian, sb2->cg_saddr), (char *) csum1, tsk_getu32(fs->endian, sb2->cg_ssize_b)); if (cnt != tsk_getu32(fs->endian, sb2->cg_ssize_b)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_fsstat: FFS2 group descriptor at %" PRIu64, tsk_getu64(fs->endian, sb2->cg_saddr)); return 1; } } } for (i = 0; i < ffs->groups_count; i++) { if (ffs_group_load(ffs, i)) return 1; cgd = (ffs_cgd *) ffs->grp_buf; tsk_fprintf(hFile, "\nGroup %d:\n", i); if (cgd) { if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { tmptime = tsk_getu32(fs->endian, cgd->wtime); } else { ffs_cgd2 *cgd2 = (ffs_cgd2 *) cgd; tmptime = (uint32_t) tsk_getu64(fs->endian, cgd2->wtime); } tsk_fprintf(hFile, " Last Written: %s", (tmptime > 0) ? asctime(localtime(&tmptime)) : "empty"); } tsk_fprintf(hFile, " Inode Range: %" PRIu32 " - %" PRIu32 "\n", (tsk_gets32(fs->endian, sb1->cg_inode_num) * i), ((uint32_t) ((tsk_gets32(fs->endian, sb1->cg_inode_num) * (i + 1)) - 1) < fs->last_inum) ? (uint32_t) ((tsk_gets32(fs->endian, sb1->cg_inode_num) * (i + 1)) - 1) : (uint32_t) fs->last_inum); tsk_fprintf(hFile, " Fragment Range: %" PRIuDADDR " - %" PRIuDADDR "\n", cgbase_lcl(fs, sb1, i), ((cgbase_lcl(fs, sb1, i + 1) - 1) < fs->last_block) ? (cgbase_lcl(fs, sb1, i + 1) - 1) : fs->last_block); /* The first group is special because the first 16 sectors are * reserved for the boot block. * the next contains the primary Super Block */ if (!i) { tsk_fprintf(hFile, " Boot Block: 0 - %" PRIu32 "\n", (uint32_t) (15 * 512 / fs->block_size)); tsk_fprintf(hFile, " Super Block: %" PRIu32 " - %" PRIu32 "\n", (uint32_t) (16 * 512 / fs->block_size), (uint32_t) ((16 * 512 / fs->block_size) + ffs->ffsbsize_f - 1)); } tsk_fprintf(hFile, " Super Block: %" PRIuDADDR " - %" PRIuDADDR "\n", cgsblock_lcl(fs, sb1, i), (cgsblock_lcl(fs, sb1, i) + ffs->ffsbsize_f - 1)); tsk_fprintf(hFile, " Group Desc: %" PRIuDADDR " - %" PRIuDADDR "\n", cgtod_lcl(fs, sb1, i), (cgtod_lcl(fs, sb1, i) + ffs->ffsbsize_f - 1)); if (fs->ftype == TSK_FS_TYPE_FFS2) { tsk_fprintf(hFile, " Inode Table: %" PRIuDADDR " - %" PRIuDADDR "\n", cgimin_lcl(fs, sb1, i), (cgimin_lcl(fs, sb1, i) + ((roundup (tsk_gets32(fs->endian, sb1->cg_inode_num) * sizeof(ffs_inode2), fs->block_size) / fs->block_size) - 1))); } else { tsk_fprintf(hFile, " Inode Table: %" PRIuDADDR " - %" PRIuDADDR "\n", cgimin_lcl(fs, sb1, i), (cgimin_lcl(fs, sb1, i) + ((roundup (tsk_gets32(fs->endian, sb1->cg_inode_num) * sizeof(ffs_inode1), fs->block_size) / fs->block_size) - 1))); } tsk_fprintf(hFile, " Data Fragments: "); /* For all groups besides the first, the space before the * super block is also used for data */ if (i) tsk_fprintf(hFile, "%" PRIuDADDR " - %" PRIuDADDR ", ", cgbase_lcl(fs, sb1, i), cgsblock_lcl(fs, sb1, i) - 1); tsk_fprintf(hFile, "%" PRIuDADDR " - %" PRIuDADDR "\n", cgdmin_lcl(fs, sb1, i), ((cgbase_lcl(fs, sb1, i + 1) - 1) < fs->last_block) ? (cgbase_lcl(fs, sb1, i + 1) - 1) : fs->last_block); if ((csum1) && ((i + 1) * sizeof(ffs_csum1) < tsk_getu32(fs->endian, sb1->cg_ssize_b))) { tsk_fprintf(hFile, " Global Summary (from the superblock summary area):\n"); tsk_fprintf(hFile, " Num of Dirs: %" PRIu32 "\n", tsk_getu32(fs->endian, &csum1[i].dir_num)); tsk_fprintf(hFile, " Num of Avail Blocks: %" PRIu32 "\n", tsk_getu32(fs->endian, &csum1[i].blk_free)); tsk_fprintf(hFile, " Num of Avail Inodes: %" PRIu32 "\n", tsk_getu32(fs->endian, &csum1[i].ino_free)); tsk_fprintf(hFile, " Num of Avail Frags: %" PRIu32 "\n", tsk_getu32(fs->endian, &csum1[i].frag_free)); } if (cgd) { tsk_fprintf(hFile, " Local Summary (from the group descriptor):\n"); tsk_fprintf(hFile, " Num of Dirs: %" PRIu32 "\n", tsk_getu32(fs->endian, &cgd->cs.dir_num)); tsk_fprintf(hFile, " Num of Avail Blocks: %" PRIu32 "\n", tsk_getu32(fs->endian, &cgd->cs.blk_free)); tsk_fprintf(hFile, " Num of Avail Inodes: %" PRIu32 "\n", tsk_getu32(fs->endian, &cgd->cs.ino_free)); tsk_fprintf(hFile, " Num of Avail Frags: %" PRIu32 "\n", tsk_getu32(fs->endian, &cgd->cs.frag_free)); tsk_fprintf(hFile, " Last Block Allocated: %" PRIuDADDR "\n", tsk_getu32(fs->endian, &cgd->last_alloc_blk) + cgbase_lcl(fs, sb1, i)); tsk_fprintf(hFile, " Last Fragment Allocated: %" PRIuDADDR "\n", tsk_getu32(fs->endian, &cgd->last_alloc_frag) + cgbase_lcl(fs, sb1, i)); tsk_fprintf(hFile, " Last Inode Allocated: %" PRIu32 "\n", tsk_getu32(fs->endian, &cgd->last_alloc_ino) + (tsk_gets32(fs->endian, sb1->cg_inode_num) * i)); } } return 0; } /************************* istat *******************************/ typedef struct { FILE *hFile; int idx; } FFS_PRINT_ADDR; static TSK_WALK_RET_ENUM print_addr_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM a_flags, void *ptr) { TSK_FS_INFO *fs = fs_file->fs_info; FFS_PRINT_ADDR *print = (FFS_PRINT_ADDR *) ptr; if (a_flags & TSK_FS_BLOCK_FLAG_CONT) { int i, s; /* cycle through the fragments if they exist */ for (i = 0, s = (int) size; s > 0; s -= fs->block_size, i++) { /* sparse file */ if (addr) tsk_fprintf(print->hFile, "%" PRIuDADDR " ", addr + i); else tsk_fprintf(print->hFile, "0 "); if (++(print->idx) == 8) { tsk_fprintf(print->hFile, "\n"); print->idx = 0; } } } return TSK_WALK_CONT; } /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File handle to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t ffs_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { FFS_INFO *ffs = (FFS_INFO *) fs; TSK_FS_META *fs_meta; TSK_FS_FILE *fs_file; char ls[12]; FFS_PRINT_ADDR print; const TSK_FS_ATTR *fs_attr_indir; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) { return 1; } fs_meta = fs_file->meta; tsk_fprintf(hFile, "inode: %" PRIuINUM "\n", inum); tsk_fprintf(hFile, "%sAllocated\n", (fs_meta->flags & TSK_FS_META_FLAG_ALLOC) ? "" : "Not "); tsk_fprintf(hFile, "Group: %" PRI_FFSGRP "\n", ffs->grp_num); if (fs_meta->link) tsk_fprintf(hFile, "symbolic link to: %s\n", fs_meta->link); tsk_fprintf(hFile, "uid / gid: %" PRIuUID " / %" PRIuGID "\n", fs_meta->uid, fs_meta->gid); tsk_fs_meta_make_ls(fs_meta, ls, sizeof(ls)); tsk_fprintf(hFile, "mode: %s\n", ls); tsk_fprintf(hFile, "size: %" PRIuOFF "\n", fs_meta->size); tsk_fprintf(hFile, "num of links: %u\n", fs_meta->nlink); if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted Inode Times:\n"); fs_meta->mtime -= sec_skew; fs_meta->atime -= sec_skew; fs_meta->ctime -= sec_skew; tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Inode Modified:\t%s", ctime(&fs_meta->ctime)); fs_meta->mtime += sec_skew; fs_meta->atime += sec_skew; fs_meta->ctime += sec_skew; tsk_fprintf(hFile, "\nOriginal Inode Times:\n"); } else { tsk_fprintf(hFile, "\nInode Times:\n"); } tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_meta->atime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_meta->mtime)); tsk_fprintf(hFile, "Inode Modified:\t%s", ctime(&fs_meta->ctime)); // we won't have dino_buf for "virtual" files if ((fs->ftype == TSK_FS_TYPE_FFS2) && (ffs->dino_buf)) { ffs_inode2 *in = (ffs_inode2 *) ffs->dino_buf; /* Are there extended attributes */ if (tsk_getu32(fs->endian, in->di_extsize) > 0) { ffs_extattr *ea; uint32_t size; char name[257]; char *blk_buf; if ((blk_buf = tsk_malloc(ffs->ffsbsize_b)) == NULL) { tsk_fs_file_close(fs_file); return 1; } size = tsk_getu32(fs->endian, in->di_extsize); tsk_fprintf(hFile, "\nExtended Attributes:\n"); tsk_fprintf(hFile, "Size: %" PRIu32 " (%" PRIu64 ", %" PRIu64 ")\n", size, tsk_getu64(fs->endian, in->di_extb[0]), tsk_getu64(fs->endian, in->di_extb[1])); /* Process first block */ // @@@ Incorporate values into this as well if ((tsk_getu64(fs->endian, in->di_extb[0]) >= fs->first_block) && (tsk_getu64(fs->endian, in->di_extb[0]) <= fs->last_block)) { uintptr_t end; ssize_t cnt; cnt = tsk_fs_read_block(fs, tsk_getu64(fs->endian, in->di_extb[0]), blk_buf, ffs->ffsbsize_b); if (cnt != ffs->ffsbsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_istat: FFS2 extended attribute 0 at %" PRIu64, tsk_getu64(fs->endian, in->di_extb[0])); tsk_fs_file_close(fs_file); free(blk_buf); return 1; } ea = (ffs_extattr *) blk_buf; if (size > ffs->ffsbsize_b) { end = (uintptr_t) ea + ffs->ffsbsize_b; size -= ffs->ffsbsize_b; } else { end = (uintptr_t) ea + size; size = 0; } for (; (uintptr_t) ea < end; ea = (ffs_extattr *) ((uintptr_t) ea + tsk_getu32(fs->endian, ea->reclen))) { memcpy(name, ea->name, ea->nlen); name[ea->nlen] = '\0'; tsk_fprintf(hFile, "%s\n", name); } } if ((tsk_getu64(fs->endian, in->di_extb[1]) >= fs->first_block) && (tsk_getu64(fs->endian, in->di_extb[1]) <= fs->last_block)) { uintptr_t end; ssize_t cnt; cnt = tsk_fs_read_block(fs, tsk_getu64(fs->endian, in->di_extb[1]), blk_buf, ffs->ffsbsize_b); if (cnt != ffs->ffsbsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ffs_istat: FFS2 extended attribute 1 at %" PRIu64, tsk_getu64(fs->endian, in->di_extb[1])); tsk_fs_file_close(fs_file); free(blk_buf); return 1; } ea = (ffs_extattr *) blk_buf; if (size > ffs->ffsbsize_b) end = (uintptr_t) ea + ffs->ffsbsize_b; else end = (uintptr_t) ea + size; for (; (uintptr_t) ea < end; ea = (ffs_extattr *) ((uintptr_t) ea + tsk_getu32(fs->endian, ea->reclen))) { memcpy(name, ea->name, ea->nlen); name[ea->nlen] = '\0'; tsk_fprintf(hFile, "%s\n", name); } } free(blk_buf); } } /* A bad hack to force a specified number of blocks */ if (numblock > 0) fs_meta->size = numblock * ffs->ffsbsize_b; tsk_fprintf(hFile, "\nDirect Blocks:\n"); print.idx = 0; print.hFile = hFile; if (tsk_fs_file_walk(fs_file, TSK_FS_FILE_WALK_FLAG_AONLY, print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading blocks in file\n"); tsk_error_print(hFile); tsk_fs_file_close(fs_file); return 1; } if (print.idx != 0) tsk_fprintf(hFile, "\n"); fs_attr_indir = tsk_fs_file_attr_get_type(fs_file, TSK_FS_ATTR_TYPE_UNIX_INDIR, 0, 0); if (fs_attr_indir) { tsk_fprintf(hFile, "\nIndirect Blocks:\n"); print.idx = 0; if (tsk_fs_attr_walk(fs_attr_indir, TSK_FS_FILE_WALK_FLAG_AONLY, print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading indirect attribute: "); tsk_error_print(hFile); tsk_error_reset(); } else if (print.idx != 0) { tsk_fprintf(hFile, "\n"); } } tsk_fs_file_close(fs_file); return 0; } /* Return 1 on error and 0 on success */ uint8_t ffs_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "UFS does not have a journal"); return 1; } uint8_t ffs_jentry_walk(TSK_FS_INFO * fs, int a_flags, TSK_FS_JENTRY_WALK_CB action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "UFS does not have a journal"); return 1; } uint8_t ffs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int a_flags, TSK_FS_JBLK_WALK_CB action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "UFS does not have a journal"); return 1; } /* ffs_close - close a fast file system */ static void ffs_close(TSK_FS_INFO * fs) { FFS_INFO *ffs = (FFS_INFO *) fs; fs->tag = 0; if (ffs->grp_buf) free(ffs->grp_buf); if (ffs->itbl_buf) free(ffs->itbl_buf); if (ffs->dino_buf) free(ffs->dino_buf); if (fs->list_inum_named) { tsk_list_free(fs->list_inum_named); fs->list_inum_named = NULL; } free((char *) ffs->fs.sb1); free(ffs); } /** * \internal * Open part of a disk image as a FFS/UFS file system. * * @param img_info Disk image to analyze * @param offset Byte offset where file system starts * @param ftype Specific type of file system * @returns NULL on error or if data is not a FFS file system */ TSK_FS_INFO * ffs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype) { char *myname = "ffs_open"; FFS_INFO *ffs; unsigned int len; TSK_FS_INFO *fs; ssize_t cnt; // clean up any error messages that are lying around tsk_error_reset(); if (TSK_FS_TYPE_ISFFS(ftype) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS Type in ffs_open"); return NULL; } if ((ffs = (FFS_INFO *) tsk_malloc(sizeof(*ffs))) == NULL) return NULL; fs = &(ffs->fs_info); fs->ftype = ftype; fs->flags = 0; fs->duname = "Fragment"; fs->tag = TSK_FS_INFO_TAG; fs->img_info = img_info; fs->offset = offset; /* Both sbs are the same size */ len = roundup(sizeof(ffs_sb1), img_info->sector_size); ffs->fs.sb1 = (ffs_sb1 *) tsk_malloc(len); if (ffs->fs.sb1 == NULL) { fs->tag = 0; free(ffs); return NULL; } /* check the magic and figure out the endian ordering */ /* Try UFS2 first - I read somewhere that some upgrades * kept the original UFS1 superblock in addition to * the new one */ cnt = tsk_fs_read (fs, (TSK_OFF_T) UFS2_SBOFF, (char *) ffs->fs.sb2, sizeof(ffs_sb2)); if (cnt != sizeof(ffs_sb2)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Superblock at %" PRIuDADDR, myname, (TSK_OFF_T) UFS2_SBOFF); fs->tag = 0; free(ffs->fs.sb1); free(ffs); return NULL; } /* If that didn't work, try the 256KB UFS2 location */ if (tsk_fs_guessu32(fs, ffs->fs.sb2->magic, UFS2_FS_MAGIC)) { cnt = tsk_fs_read (fs, (TSK_OFF_T) UFS2_SBOFF2, (char *) ffs->fs.sb2, sizeof(ffs_sb2)); if (cnt != sizeof(ffs_sb2)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: Superblock at %" PRIuDADDR, myname, (TSK_OFF_T) UFS2_SBOFF2); fs->tag = 0; free(ffs->fs.sb1); free(ffs); return NULL; } /* Try UFS1 if that did not work */ if (tsk_fs_guessu32(fs, ffs->fs.sb2->magic, UFS2_FS_MAGIC)) { cnt = tsk_fs_read (fs, (TSK_OFF_T) UFS1_SBOFF, (char *) ffs->fs.sb1, len); if (cnt != len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: Superblock at %" PRIuDADDR, myname, (TSK_OFF_T) UFS1_SBOFF); fs->tag = 0; free(ffs->fs.sb1); free(ffs); return NULL; } if (tsk_fs_guessu32(fs, ffs->fs.sb1->magic, UFS1_FS_MAGIC)) { fs->tag = 0; free(ffs->fs.sb1); free(ffs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "No UFS Magic Found"); return NULL; } else { // @@@ NEED TO DIFFERENTIATE BETWEEN A & B - UID/GID location in inode fs->ftype = TSK_FS_TYPE_FFS1; } } else { fs->ftype = TSK_FS_TYPE_FFS2; } } else { fs->ftype = TSK_FS_TYPE_FFS2; } /* * Translate some filesystem-specific information to generic form. */ if (fs->ftype == TSK_FS_TYPE_FFS2) { fs->block_count = tsk_gets64(fs->endian, ffs->fs.sb2->frag_num); fs->block_size = tsk_gets32(fs->endian, ffs->fs.sb2->fsize_b); ffs->ffsbsize_b = tsk_gets32(fs->endian, ffs->fs.sb2->bsize_b); ffs->ffsbsize_f = tsk_gets32(fs->endian, ffs->fs.sb2->bsize_frag); ffs->groups_count = tsk_gets32(fs->endian, ffs->fs.sb2->cg_num); } else { fs->block_count = tsk_gets32(fs->endian, ffs->fs.sb1->frag_num); fs->block_size = tsk_gets32(fs->endian, ffs->fs.sb1->fsize_b); ffs->ffsbsize_b = tsk_gets32(fs->endian, ffs->fs.sb1->bsize_b); ffs->ffsbsize_f = tsk_gets32(fs->endian, ffs->fs.sb1->bsize_frag); ffs->groups_count = tsk_gets32(fs->endian, ffs->fs.sb1->cg_num); } /* * Block calculations */ fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->dev_bsize = img_info->sector_size; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; if ((fs->block_size % 512) || (ffs->ffsbsize_b % 512)) { fs->tag = 0; free(ffs->fs.sb1); free(ffs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a UFS FS (invalid fragment or block size)"); return NULL; } if ((ffs->ffsbsize_b / fs->block_size) != ffs->ffsbsize_f) { fs->tag = 0; free(ffs->fs.sb1); free(ffs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a UFS FS (frag / block size mismatch)"); return NULL; } // Inode / meta data calculations if (fs->ftype == TSK_FS_TYPE_FFS2) { fs->inum_count = ffs->groups_count * tsk_gets32(fs->endian, ffs->fs.sb2->cg_inode_num) + 1; // we are adding 1 in this calc to account for Orphans directory } else { fs->inum_count = ffs->groups_count * tsk_gets32(fs->endian, ffs->fs.sb1->cg_inode_num) + 1; // we are adding 1 in this calc to account for Orphans directory } fs->root_inum = FFS_ROOTINO; fs->first_inum = FFS_FIRSTINO; fs->last_inum = fs->inum_count - 1; /* Volume ID - in the same place for both types */ for (fs->fs_id_used = 0; fs->fs_id_used < 8; fs->fs_id_used++) { fs->fs_id[fs->fs_id_used] = ffs->fs.sb1->fs_id[fs->fs_id_used]; } // set the function pointers fs->inode_walk = ffs_inode_walk; fs->block_walk = ffs_block_walk; fs->block_getflags = ffs_block_getflags; fs->get_default_attr_type = tsk_fs_unix_get_default_attr_type; fs->load_attrs = tsk_fs_unix_make_data_run; fs->name_cmp = tsk_fs_unix_name_cmp; fs->file_add_meta = ffs_inode_lookup; fs->dir_open_meta = ffs_dir_open_meta; fs->fsstat = ffs_fsstat; fs->fscheck = ffs_fscheck; fs->istat = ffs_istat; fs->close = ffs_close; fs->jblk_walk = ffs_jblk_walk; fs->jentry_walk = ffs_jentry_walk; fs->jopen = ffs_jopen; fs->journ_inum = 0; // initialize caches ffs->grp_buf = NULL; ffs->grp_num = 0xffffffff; ffs->grp_addr = 0; ffs->dino_buf = NULL; ffs->dino_inum = 0xffffffff; ffs->itbl_buf = NULL; ffs->itbl_addr = 0; fs->list_inum_named = NULL; /* * Print some stats. */ if (tsk_verbose) tsk_fprintf(stderr, "inodes %" PRIuINUM " root ino %" PRIuINUM " cyl groups %" PRId32 " blocks %" PRIuDADDR "\n", fs->inum_count, fs->root_inum, ffs->groups_count, fs->block_count); return (fs); } sleuthkit-3.2.3/tsk3/fs/ffs_dent.c000644 000765 000024 00000026111 11643647440 017567 0ustar00carrierstaff000000 000000 /* ** ffs_dent ** The Sleuth Kit ** ** File name layer for a FFS/UFS image ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2006 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file ffs_dent.c * Contains the internal TSK UFS/FFS file name (directory entry) processing functions */ #include #include "tsk_fs_i.h" #include "tsk_ffs.h" static uint8_t ffs_dent_copy(FFS_INFO * ffs, char *ffs_dent, TSK_FS_NAME * fs_name) { TSK_FS_INFO *a_fs = &(ffs->fs_info); /* this one has the type field */ if ((a_fs->ftype == TSK_FS_TYPE_FFS1) || (a_fs->ftype == TSK_FS_TYPE_FFS2)) { ffs_dentry1 *dir = (ffs_dentry1 *) ffs_dent; fs_name->meta_addr = tsk_getu32(a_fs->endian, dir->d_ino); if (fs_name->name_size != FFS_MAXNAMLEN) { if (tsk_fs_name_realloc(fs_name, FFS_MAXNAMLEN)) return 1; } /* ffs null terminates so we can strncpy */ strncpy(fs_name->name, dir->d_name, fs_name->name_size); switch (dir->d_type) { case FFS_DT_REG: fs_name->type = TSK_FS_NAME_TYPE_REG; break; case FFS_DT_DIR: fs_name->type = TSK_FS_NAME_TYPE_DIR; break; case FFS_DT_CHR: fs_name->type = TSK_FS_NAME_TYPE_CHR; break; case FFS_DT_BLK: fs_name->type = TSK_FS_NAME_TYPE_BLK; break; case FFS_DT_FIFO: fs_name->type = TSK_FS_NAME_TYPE_FIFO; break; case FFS_DT_SOCK: fs_name->type = TSK_FS_NAME_TYPE_SOCK; break; case FFS_DT_LNK: fs_name->type = TSK_FS_NAME_TYPE_LNK; break; case FFS_DT_WHT: fs_name->type = TSK_FS_NAME_TYPE_WHT; break; case FFS_DT_UNKNOWN: default: fs_name->type = TSK_FS_NAME_TYPE_UNDEF; break; } } else if (a_fs->ftype == TSK_FS_TYPE_FFS1B) { ffs_dentry2 *dir = (ffs_dentry2 *) ffs_dent; fs_name->meta_addr = tsk_getu32(a_fs->endian, dir->d_ino); if (fs_name->name_size != FFS_MAXNAMLEN) { if (tsk_fs_name_realloc(fs_name, FFS_MAXNAMLEN)) return 1; } /* ffs null terminates so we can strncpy */ strncpy(fs_name->name, dir->d_name, fs_name->name_size); fs_name->type = TSK_FS_NAME_TYPE_UNDEF; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dent_copy: Unknown FS type"); return 1; } fs_name->flags = 0; return 0; } /* * @param a_is_del Set to 1 if block is from a deleted directory. */ static TSK_RETVAL_ENUM ffs_dent_parse_block(FFS_INFO * ffs, TSK_FS_DIR * fs_dir, uint8_t a_is_del, char *buf, unsigned int len) { unsigned int idx; unsigned int inode = 0, dellen = 0, reclen = 0; unsigned int minreclen = 4; TSK_FS_INFO *fs = &(ffs->fs_info); char *dirPtr; TSK_FS_NAME *fs_name; if ((fs_name = tsk_fs_name_alloc(FFS_MAXNAMLEN + 1, 0)) == NULL) return TSK_ERR; /* update each time by the actual length instead of the ** recorded length so we can view the deleted entries */ for (idx = 0; idx <= len - FFS_DIRSIZ_lcl(1); idx += minreclen) { unsigned int namelen = 0; dirPtr = (char *) &buf[idx]; /* copy to local variables */ if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS2)) { ffs_dentry1 *dir = (ffs_dentry1 *) dirPtr; inode = tsk_getu32(fs->endian, dir->d_ino); namelen = dir->d_namlen; reclen = tsk_getu16(fs->endian, dir->d_reclen); } /* TSK_FS_TYPE_FFS1B */ else if (fs->ftype == TSK_FS_TYPE_FFS1B) { ffs_dentry2 *dir = (ffs_dentry2 *) dirPtr; inode = tsk_getu32(fs->endian, dir->d_ino); namelen = tsk_getu16(fs->endian, dir->d_namlen); reclen = tsk_getu16(fs->endian, dir->d_reclen); } /* what is the minimum size needed for this entry */ minreclen = FFS_DIRSIZ_lcl(namelen); /* Perform a couple sanity checks ** OpenBSD never zeros the inode number, but solaris ** does. These checks will hopefully catch all non ** entries */ if ((inode > fs->last_inum) || // inode is unsigned (namelen > FFS_MAXNAMLEN) || // namelen is unsigned (namelen == 0) || (reclen < minreclen) || (reclen % 4) || (idx + reclen > len)) { /* we don't have a valid entry, so skip ahead 4 */ minreclen = 4; if (dellen > 0) dellen -= 4; continue; } /* Before we process an entry in unallocated space, make * sure that it also ends in the unalloc space */ if ((dellen) && (dellen < minreclen)) { minreclen = 4; dellen -= 4; continue; } /* the entry is valid */ if (ffs_dent_copy(ffs, dirPtr, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } /* Do we have a deleted entry? (are we in a deleted space) */ if ((dellen > 0) || (inode == 0) || (a_is_del)) { fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; if (dellen) dellen -= minreclen; } else { fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } /* If we have some slack and an entry could exist in it, the set dellen */ if (dellen <= 0) { if (reclen - minreclen >= FFS_DIRSIZ_lcl(1)) dellen = reclen - minreclen; else minreclen = reclen; } } tsk_fs_name_free(fs_name); return TSK_OK; } /* end ffs_dent_parse_block */ /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM ffs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { TSK_OFF_T size; FFS_INFO *ffs = (FFS_INFO *) a_fs; char *dirbuf; int nchnk, cidx; TSK_FS_LOAD_FILE load_file; TSK_FS_DIR *fs_dir; /* If we get corruption in one of the blocks, then continue processing. * retval_final will change when corruption is detected. Errors are * returned immediately. */ TSK_RETVAL_ENUM retval_tmp; TSK_RETVAL_ENUM retval_final = TSK_OK; if (a_addr < a_fs->first_inum || a_addr > a_fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dir_open_meta: Invalid inode value: %" PRIuINUM, a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dir_open_meta: NULL fs_attr argument given"); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "ffs_dir_open_meta: Processing directory %" PRIuINUM "\n", a_addr); fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else { if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(a_fs, a_addr, 128)) == NULL) { return TSK_ERR; } } // handle the orphan directory if its contents were requested if (a_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { return tsk_fs_dir_find_orphans(a_fs, fs_dir); } if ((fs_dir->fs_file = tsk_fs_file_open_meta(a_fs, NULL, a_addr)) == NULL) { tsk_error_reset(); strncat(tsk_errstr2, " - ffs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_COR; } /* make a copy of the directory contents that we can process */ /* round up cause we want the slack space too */ size = roundup(fs_dir->fs_file->meta->size, FFS_DIRBLKSIZ); if ((dirbuf = tsk_malloc((size_t) size)) == NULL) { return TSK_ERR; } load_file.total = load_file.left = (size_t) size; load_file.base = load_file.cur = dirbuf; if (tsk_fs_file_walk(fs_dir->fs_file, TSK_FS_FILE_WALK_FLAG_SLACK, tsk_fs_load_file_action, (void *) &load_file)) { tsk_error_reset(); strncat(tsk_errstr2, " - ffs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(dirbuf); return TSK_COR; } /* Not all of the directory was copied, so we return */ if (load_file.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ffs_dir_open_meta: Error reading directory %" PRIuINUM, a_addr); free(dirbuf); return TSK_COR; } /* Directory entries are written in chunks of DIRBLKSIZ ** determine how many chunks of this size we have to read to ** get a full block ** ** Entries do not cross over the DIRBLKSIZ boundary */ nchnk = (int) (size) / (FFS_DIRBLKSIZ) + 1; for (cidx = 0; cidx < nchnk && (int64_t) size > 0; cidx++) { int len = (FFS_DIRBLKSIZ < size) ? FFS_DIRBLKSIZ : (int) size; retval_tmp = ffs_dent_parse_block(ffs, fs_dir, (fs_dir->fs_file->meta-> flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, dirbuf + cidx * FFS_DIRBLKSIZ, len); if (retval_tmp == TSK_ERR) { retval_final = TSK_ERR; break; } else if (retval_tmp == TSK_COR) { retval_final = TSK_COR; } size -= len; } free(dirbuf); // if we are listing the root directory, add the Orphan directory entry if (a_addr == a_fs->root_inum) { TSK_FS_NAME *fs_name = tsk_fs_name_alloc(256, 0); if (fs_name == NULL) return TSK_ERR; if (tsk_fs_dir_make_orphan_dir_name(a_fs, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); } return retval_final; } sleuthkit-3.2.3/tsk3/fs/fls_lib.c000644 000765 000024 00000015436 11643647440 017421 0ustar00carrierstaff000000 000000 /* ** fls ** The Sleuth Kit ** ** Given an image and directory inode, display the file names and ** directories that exist (both active and deleted) ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** \file fls_lib.c * Contains the library code associated with the TSK fls tool to list files in a directory. */ #include "tsk_fs_i.h" /** \internal * Structure to store data for callbacks. */ typedef struct { /* Time skew of the system in seconds */ int32_t sec_skew; /*directory prefix for printing mactime output */ char *macpre; int flags; } FLS_DATA; /* this is a wrapper type function that takes care of the runtime * flags * * fs_attr should be set to NULL for all non-NTFS file systems */ static void printit(TSK_FS_FILE * fs_file, const char *a_path, const TSK_FS_ATTR * fs_attr, const FLS_DATA * fls_data) { unsigned int i; if ((!(fls_data->flags & TSK_FS_FLS_FULL)) && (a_path)) { uint8_t printed = 0; // lazy way to find out how many dirs there could be for (i = 0; a_path[i] != '\0'; i++) { if ((a_path[i] == '/') && (i != 0)) { tsk_fprintf(stdout, "+"); printed = 1; } } if (printed) tsk_fprintf(stdout, " "); } if (fls_data->flags & TSK_FS_FLS_MAC) { tsk_fs_name_print_mac(stdout, fs_file, a_path, fs_attr, fls_data->macpre, fls_data->sec_skew); } else if (fls_data->flags & TSK_FS_FLS_LONG) { tsk_fs_name_print_long(stdout, fs_file, a_path, fs_file->fs_info, fs_attr, TSK_FS_FLS_FULL & fls_data->flags ? 1 : 0, fls_data->sec_skew); } else { tsk_fs_name_print(stdout, fs_file, a_path, fs_file->fs_info, fs_attr, TSK_FS_FLS_FULL & fls_data->flags ? 1 : 0); tsk_printf("\n"); } } /* * call back action function for dent_walk */ static TSK_WALK_RET_ENUM print_dent_act(TSK_FS_FILE * fs_file, const char *a_path, void *ptr) { FLS_DATA *fls_data = (FLS_DATA *) ptr; /* only print dirs if TSK_FS_FLS_DIR is set and only print everything ** else if TSK_FS_FLS_FILE is set (or we aren't sure what it is) */ if (((fls_data->flags & TSK_FS_FLS_DIR) && ((fs_file->meta) && (fs_file->meta->type == TSK_FS_META_TYPE_DIR))) || ((fls_data->flags & TSK_FS_FLS_FILE) && (((fs_file->meta) && (fs_file->meta->type != TSK_FS_META_TYPE_DIR)) || (!fs_file->meta)))) { /* Make a special case for NTFS so we can identify all of the * alternate data streams! */ if ((TSK_FS_TYPE_ISNTFS(fs_file->fs_info->ftype)) && (fs_file->meta)) { uint8_t printed = 0; int i, cnt; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if (fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) { printed = 1; if (fs_file->meta->type == TSK_FS_META_TYPE_DIR) { /* we don't want to print the ..:blah stream if * the -a flag was not given */ if ((fs_file->name->name[0] == '.') && (fs_file->name->name[1]) && (fs_file->name->name[2] == '\0') && ((fls_data->flags & TSK_FS_FLS_DOT) == 0)) { continue; } } printit(fs_file, a_path, fs_attr, fls_data); } else if (fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_IDXROOT) { printed = 1; /* If it is . or .. only print it if the flags say so, * we continue with other streams though in case the * directory has a data stream */ if (!((TSK_FS_ISDOT(fs_file->name->name)) && ((fls_data->flags & TSK_FS_FLS_DOT) == 0))) printit(fs_file, a_path, fs_attr, fls_data); } } /* A user reported that an allocated file had the standard * attributes, but no $Data. We should print something */ if (printed == 0) { printit(fs_file, a_path, NULL, fls_data); } } else { /* skip it if it is . or .. and we don't want them */ if (!((TSK_FS_ISDOT(fs_file->name->name)) && ((fls_data->flags & TSK_FS_FLS_DOT) == 0))) printit(fs_file, a_path, NULL, fls_data); } } return TSK_WALK_CONT; } /* Returns 0 on success and 1 on error */ uint8_t tsk_fs_fls(TSK_FS_INFO * fs, TSK_FS_FLS_FLAG_ENUM lclflags, TSK_INUM_T inode, TSK_FS_DIR_WALK_FLAG_ENUM flags, TSK_TCHAR * tpre, int32_t skew) { FLS_DATA data; data.flags = lclflags; data.sec_skew = skew; #ifdef TSK_WIN32 { char *cpre; size_t clen; UTF8 *ptr8; UTF16 *ptr16; int retval; if (tpre != NULL) { clen = TSTRLEN(tpre) * 4; cpre = (char *) tsk_malloc(clen); if (cpre == NULL) { return 1; } ptr8 = (UTF8 *) cpre; ptr16 = (UTF16 *) tpre; retval = tsk_UTF16toUTF8_lclorder((const UTF16 **) &ptr16, (UTF16 *) & ptr16[TSTRLEN(tpre) + 1], &ptr8, (UTF8 *) ((uintptr_t) ptr8 + clen), TSKlenientConversion); if (retval != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error converting fls mactime pre-text to UTF-8 %d\n", retval); return 1; } data.macpre = cpre; } else { data.macpre = NULL; cpre = NULL; } retval = tsk_fs_dir_walk(fs, inode, flags, print_dent_act, &data); if (cpre) free(cpre); return retval; } #else data.macpre = tpre; return tsk_fs_dir_walk(fs, inode, flags, print_dent_act, &data); #endif } sleuthkit-3.2.3/tsk3/fs/fs_attr.c000644 000765 000024 00000117724 11643647440 017454 0ustar00carrierstaff000000 000000 /* ** fs_attr ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file fs_attr.c * Functions to allocate and add structures to maintain generic file * system attributes and run lists. */ /* * The TSK_FS_ATTR structure is motivated by NTFS. NTFS (and others) allow * one to have more than one data area per file. Furthermore, there is * more than one way to store the data (resident in the MFT entry or * in the Data Area runs). To handle this in * a generic format, the TSK_FS_ATTR structure was created. * * TSK_FS_ATTR structures have a type and id that describe it and then * a flag identifies it as a resident stream or a non-resident run * They form a linked list and are added to the TSK_FS_META structure */ #include "tsk_fs_i.h" /** * \internal * Allocate a run list entry. * * @returns NULL on error */ TSK_FS_ATTR_RUN * tsk_fs_attr_run_alloc() { TSK_FS_ATTR_RUN *fs_attr_run = (TSK_FS_ATTR_RUN *) tsk_malloc(sizeof(TSK_FS_ATTR_RUN)); if (fs_attr_run == NULL) return NULL; return fs_attr_run; } /** * \internal * Free a list of data_runs * * @param fs_attr_run Head of list to free */ void tsk_fs_attr_run_free(TSK_FS_ATTR_RUN * fs_attr_run) { TSK_FS_ATTR_RUN *fs_attr_run_prev; while (fs_attr_run) { fs_attr_run_prev = fs_attr_run; fs_attr_run = fs_attr_run->next; fs_attr_run_prev->next = NULL; free(fs_attr_run_prev); } } /** * \internal * Allocates and initializes a new structure. * * @param type The type of attribute to create (Resident or Non-resident) * @returns NULL on error */ TSK_FS_ATTR * tsk_fs_attr_alloc(TSK_FS_ATTR_FLAG_ENUM type) { TSK_FS_ATTR *fs_attr = (TSK_FS_ATTR *) tsk_malloc(sizeof(TSK_FS_ATTR)); if (fs_attr == NULL) { return NULL; } fs_attr->name_size = 128; if ((fs_attr->name = (char *) tsk_malloc(fs_attr->name_size)) == NULL) { free(fs_attr); return NULL; } if (type == TSK_FS_ATTR_NONRES) { fs_attr->flags = (TSK_FS_ATTR_NONRES | TSK_FS_ATTR_INUSE); } else if (type == TSK_FS_ATTR_RES) { fs_attr->rd.buf_size = 1024; fs_attr->rd.buf = (uint8_t *) tsk_malloc(fs_attr->rd.buf_size); if (fs_attr->rd.buf == NULL) { free(fs_attr->name); return NULL; } fs_attr->flags = (TSK_FS_ATTR_RES | TSK_FS_ATTR_INUSE); } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_alloc: Invalid Type: %d\n", type); return NULL; } return fs_attr; } /** * \internal * Free a single TSK_FS_ATTR structure. This does not free the linked list. * * @param a_fs_attr Structure to free. */ void tsk_fs_attr_free(TSK_FS_ATTR * a_fs_attr) { if (a_fs_attr == NULL) return; if (a_fs_attr->nrd.run) tsk_fs_attr_run_free(a_fs_attr->nrd.run); a_fs_attr->nrd.run = NULL; if (a_fs_attr->rd.buf) free(a_fs_attr->rd.buf); a_fs_attr->rd.buf = NULL; if (a_fs_attr->name) free(a_fs_attr->name); a_fs_attr->name = NULL; free(a_fs_attr); } /** * \internal * Clear the run_lists fields of a single FS_DATA structure * * @param a_fs_attr Structure to clear for reuse */ void tsk_fs_attr_clear(TSK_FS_ATTR * a_fs_attr) { a_fs_attr->size = a_fs_attr->type = a_fs_attr->id = a_fs_attr->flags = 0; if (a_fs_attr->nrd.run) { tsk_fs_attr_run_free(a_fs_attr->nrd.run); a_fs_attr->nrd.run = NULL; a_fs_attr->nrd.run_end = NULL; a_fs_attr->nrd.allocsize = 0; a_fs_attr->nrd.initsize = 0; } } /** * Add a name to an existing FS_DATA structure. Will reallocate * space for the name if needed. * * @param fs_attr Structure to add name to * @param name UTF-8 name to add * * @return 1 on error and 0 on success */ static uint8_t fs_attr_put_name(TSK_FS_ATTR * fs_attr, const char *name) { if ((name == NULL) || (strlen(name) == 0)) { if (fs_attr->name_size > 0) { free(fs_attr->name); fs_attr->name_size = 0; } fs_attr->name = NULL; return 0; } if (fs_attr->name_size < (strlen(name) + 1)) { fs_attr->name = tsk_realloc(fs_attr->name, strlen(name) + 1); if (fs_attr->name == NULL) return 1; fs_attr->name_size = strlen(name) + 1; } strncpy(fs_attr->name, name, fs_attr->name_size); return 0; } /** * \internal * Copy resident data to an attribute. * * @param a_fs_attr Attribute to add data to (cannot be NULL) * @param name Name of the attribute to set * @param type Type of the attribute to set * @param id Id of the attribute to set * @param res_data Pointer to where resident data is located (data will * be copied from here into FS_DATA) * @param len Length of resident data * @return 1 on error and 0 on success */ uint8_t tsk_fs_attr_set_str(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR * a_fs_attr, const char *name, TSK_FS_ATTR_TYPE_ENUM type, uint16_t id, void *res_data, size_t len) { if (a_fs_attr == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null fs_attr in tsk_fs_attr_set_str"); return 1; } a_fs_attr->fs_file = a_fs_file; a_fs_attr->flags = (TSK_FS_ATTR_INUSE | TSK_FS_ATTR_RES); a_fs_attr->type = type; a_fs_attr->id = id; a_fs_attr->nrd.compsize = 0; if (fs_attr_put_name(a_fs_attr, name)) { return 1; } if (a_fs_attr->rd.buf_size < len) { a_fs_attr->rd.buf = (uint8_t *) tsk_realloc((char *) a_fs_attr->rd.buf, len); if (a_fs_attr->rd.buf == NULL) return 1; a_fs_attr->rd.buf_size = len; } memset(a_fs_attr->rd.buf, 0, a_fs_attr->rd.buf_size); memcpy(a_fs_attr->rd.buf, res_data, len); a_fs_attr->size = len; return 0; } /** * \internal * Set the needed fields along with an initial run list for a data attribute. To add more * runs, use ...._add_run(). * * @param a_fs File system the run comes from. * @param a_fs_attr The data attribute to initialize and add the run to * @param a_data_run_new The set of runs to add (can be NULL). * @param name Name of the attribute (can be NULL) * @param type Type of attribute to add run to * @param id Id of attribute to add run to * @param size Total size of the attribute (can be larger than length of initial run being added) * @param init_size Number of bytes in attribute that have been initialized (less then or equal to size) * (note that this sets the initialized size for the attribute and it will not be updated as more runs are added). * @param alloc_size Allocated size of the attribute (>= size). Identifies the slack space. * (note that this sets the allocated size for the attribute and it will not be updated as more runs are added). * @param flags Flags about compression, sparse etc. of data * @param compsize Compression unit size (in case it needs to be created) * * @returns 1 on error and 0 on success */ uint8_t tsk_fs_attr_set_run(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * a_data_run_new, const char *name, TSK_FS_ATTR_TYPE_ENUM type, uint16_t id, TSK_OFF_T size, TSK_OFF_T init_size, TSK_OFF_T alloc_size, TSK_FS_ATTR_FLAG_ENUM flags, uint32_t compsize) { TSK_FS_INFO *fs; if ((a_fs_file == NULL) || (a_fs_file->meta == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null fs_file in tsk_fs_attr_set_run"); return 1; } if (a_fs_attr == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null fs_attr in tsk_fs_attr_set_run"); return 1; } fs = a_fs_file->fs_info; if (alloc_size < size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_set_run: alloc_size (%" PRIuOFF ") is less than size (%" PRIuOFF ")", alloc_size, size); return 1; } a_fs_attr->fs_file = a_fs_file; a_fs_attr->flags = (TSK_FS_ATTR_INUSE | TSK_FS_ATTR_NONRES | flags); a_fs_attr->type = type; a_fs_attr->id = id; a_fs_attr->size = size; a_fs_attr->nrd.allocsize = alloc_size; a_fs_attr->nrd.initsize = init_size; a_fs_attr->nrd.compsize = compsize; if (fs_attr_put_name(a_fs_attr, name)) { return 1; } /* Add the a_data_run_new to the attribute. */ /* We support the ODD case where the run is NULL. In this case, * we set the attribute size info, but set everything else to NULL. */ if (a_data_run_new == NULL) { a_fs_attr->nrd.run = NULL; a_fs_attr->nrd.run_end = NULL; return 0; } /* * If this is not in the begining, then we need to make a filler * to account for the cluster numbers we haven't seen yet * * This commonly happens when we process an MFT entry that * is not a base entry and it is referenced in an $ATTR_LIST * * The $DATA attribute in the non-base have a non-zero * a_data_run_new->offset. */ if (a_data_run_new->offset != 0) { TSK_FS_ATTR_RUN *fill_run = tsk_fs_attr_run_alloc(); fill_run->flags = TSK_FS_ATTR_RUN_FLAG_FILLER; fill_run->offset = 0; fill_run->addr = 0; fill_run->len = a_data_run_new->offset; fill_run->next = a_data_run_new; a_data_run_new = fill_run; } a_fs_attr->nrd.run = a_data_run_new; // update the pointer to the end of the list a_fs_attr->nrd.run_end = a_data_run_new; while (a_fs_attr->nrd.run_end->next) { a_fs_attr->nrd.run_end = a_fs_attr->nrd.run_end->next; } return 0; } static void dump_attr(TSK_FS_ATTR *a_fs_attr) { TSK_FS_ATTR_RUN *cur_run; cur_run = a_fs_attr->nrd.run; fprintf(stderr, "Attribute Run Dump:\n"); for (cur_run = a_fs_attr->nrd.run; cur_run; cur_run = cur_run->next) { fprintf(stderr, " %"PRIuDADDR" to %"PRIuDADDR" %sFiller\n", cur_run->offset, cur_run->offset + cur_run->len - 1, (cur_run->flags & TSK_FS_ATTR_RUN_FLAG_FILLER)?"":"Not"); } } /** * \internal * Add a set of consecutive runs to an attribute. This will add and remove FILLER entries * as needed and update internal variables. * * @param a_fs File system run is from * @param fs_attr Attribute to add run to * @param a_data_run_new The set of runs to add. * * @returns 1 on error and 0 on succes */ uint8_t tsk_fs_attr_add_run(TSK_FS_INFO * a_fs, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * a_data_run_new) { TSK_FS_ATTR_RUN *data_run_cur, *data_run_prev; TSK_DADDR_T run_len; tsk_error_reset(); if (a_fs_attr == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_add_run: Error, a_fs_attr is NULL"); return 1; } // we only support the case of a null run if it is the only run... if (a_data_run_new == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_add_run: Error, a_data_run_new is NULL (%" PRIuINUM ")", a_fs_attr->fs_file->meta->addr); return 1; } run_len = 0; data_run_cur = a_data_run_new; while (data_run_cur) { run_len += data_run_cur->len; data_run_cur = data_run_cur->next; } /* First thing, is to check if we can just add it to the end */ if ((a_fs_attr->nrd.run_end) && (a_fs_attr->nrd.run_end->offset + a_fs_attr->nrd.run_end->len == a_data_run_new->offset)) { a_fs_attr->nrd.run_end->next = a_data_run_new; // update the pointer to the end of the list while (a_fs_attr->nrd.run_end->next) a_fs_attr->nrd.run_end = a_fs_attr->nrd.run_end->next; /* return head of a_fs_attr list */ return 0; } // cycle through existing runs and see if we can add this into a filler spot data_run_cur = a_fs_attr->nrd.run; data_run_prev = NULL; while (data_run_cur) { if (tsk_verbose) tsk_fprintf(stderr, "tsk_fs_attr_add: %" PRIuOFF "@%" PRIuOFF " (Filler: %s)\n", data_run_cur->offset, data_run_cur->len, (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) ? "Yes" : "No"); /* Do we replace this filler spot? */ if (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) { /* This should never happen because we always add * the filler to start from VCN 0 */ if (data_run_cur->offset > a_data_run_new->offset) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_add_run: could not add data_run b.c. offset (%" PRIuOFF ") is larger than FILLER (%" PRIuOFF ") (%" PRIuINUM ")", a_data_run_new->offset, data_run_cur->offset, a_fs_attr->fs_file->meta->addr); dump_attr(a_fs_attr); return 1; } /* Check if the new run starts inside of this filler. */ if (data_run_cur->offset + data_run_cur->len > a_data_run_new->offset) { TSK_FS_ATTR_RUN *endrun; /* if the new starts at the same as the filler, * replace the pointer */ if (data_run_cur->offset == a_data_run_new->offset) { if (data_run_prev) data_run_prev->next = a_data_run_new; else a_fs_attr->nrd.run = a_data_run_new; } /* The new run does not start at the begining of * the filler, so make a new start filler */ else { TSK_FS_ATTR_RUN *newfill = tsk_fs_attr_run_alloc(); if (newfill == NULL) return 1; if (data_run_prev) data_run_prev->next = newfill; else a_fs_attr->nrd.run = newfill; newfill->next = a_data_run_new; newfill->len = a_data_run_new->offset - data_run_cur->offset; newfill->offset = data_run_cur->offset; newfill->flags = TSK_FS_ATTR_RUN_FLAG_FILLER; data_run_cur->len -= newfill->len; } /* get to the end of the run that we are trying to add */ endrun = a_data_run_new; while (endrun->next) endrun = endrun->next; /* if the filler is the same size as the * new one, replace it */ if (run_len == data_run_cur->len) { endrun->next = data_run_cur->next; // update the pointer to the end of the list (if we are the end) if (endrun->next == NULL) a_fs_attr->nrd.run_end = endrun; free(data_run_cur); } /* else adjust the last filler entry */ else { endrun->next = data_run_cur; data_run_cur->len -= run_len; data_run_cur->offset = a_data_run_new->offset + a_data_run_new->len; } return 0; } } data_run_prev = data_run_cur; data_run_cur = data_run_cur->next; } /* * There is no filler holding the location of this run, so * we will add it to the end of the list * * we got here because it did not fit in the current list or * because the current list is NULL * * At this point data_run_prev is the end of the existing list or * 0 if there is no list */ /* This is an error condition. * It means that we cycled through the existing runs, * ended at a VCN that is larger than what we are adding, * and never found a filler entry to insert it into... */ if ((data_run_prev) && (data_run_prev->offset + data_run_prev->len > a_data_run_new->offset)) { /* MAYBE this is because of a duplicate entry .. */ if ((data_run_prev->addr == a_data_run_new->addr) && (data_run_prev->len == a_data_run_new->len)) { // @@@ Sould be we freeing this....? What if the caller tries to write to it? tsk_fs_attr_run_free(a_data_run_new); return 0; } tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "fs_attr_add_run: error adding additional run (%" PRIuINUM "): No filler entry for %" PRIuDADDR ". Final: %" PRIuDADDR, a_fs_attr->fs_file->meta->addr, a_data_run_new->offset, data_run_prev->offset + data_run_prev->len); dump_attr(a_fs_attr); return 1; } /* we should add it right here */ else if (((data_run_prev) && (data_run_prev->offset + data_run_prev->len == a_data_run_new->offset)) || (a_data_run_new->offset == 0)) { if (data_run_prev) data_run_prev->next = a_data_run_new; else a_fs_attr->nrd.run = a_data_run_new; } /* we need to make a filler before it */ else { TSK_FS_ATTR_RUN *tmprun = tsk_fs_attr_run_alloc(); if (tmprun == NULL) return 1; if (data_run_prev) { data_run_prev->next = tmprun; tmprun->offset = data_run_prev->offset + data_run_prev->len; } else { a_fs_attr->nrd.run = tmprun; } tmprun->len = a_data_run_new->offset - tmprun->offset; tmprun->flags = TSK_FS_ATTR_RUN_FLAG_FILLER; tmprun->next = a_data_run_new; } // update the pointer to the end of the list a_fs_attr->nrd.run_end = a_data_run_new; while (a_fs_attr->nrd.run_end->next) a_fs_attr->nrd.run_end = a_fs_attr->nrd.run_end->next; return 0; } /** * Append a data run to the end of the attribute and update its offset * value. This ignores the offset in the data run and blindly appends. * * @param a_fs File system run is from * @param a_fs_attr Data attribute to append to * @param a_data_run Data run to append. */ void tsk_fs_attr_append_run(TSK_FS_INFO * a_fs, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * a_data_run) { TSK_FS_ATTR_RUN *data_run_cur; if ((a_fs_attr == NULL) || (a_data_run == NULL)) { return; } if (a_fs_attr->nrd.run == NULL) { a_fs_attr->nrd.run = a_data_run; a_data_run->offset = 0; } else { // just in case this was not updated if ((a_fs_attr->nrd.run_end == NULL) || (a_fs_attr->nrd.run_end->next != NULL)) { data_run_cur = a_fs_attr->nrd.run; while (data_run_cur->next) { data_run_cur = data_run_cur->next; } a_fs_attr->nrd.run_end = data_run_cur; } a_fs_attr->nrd.run_end->next = a_data_run; a_data_run->offset = a_fs_attr->nrd.run_end->offset + a_fs_attr->nrd.run_end->len; } // update the rest of the offsets in the run (if any exist) data_run_cur = a_data_run; while (data_run_cur->next) { data_run_cur->next->offset = data_run_cur->offset + data_run_cur->len; a_fs_attr->nrd.run_end = data_run_cur->next; data_run_cur = data_run_cur->next; } } /** \internal * Processes a resident TSK_FS_ATTR structure and calls the callback with the associated * data. The size of the buffer in the callback will be block_size at max. * * @param a_fs File system being analyzed * @param fs_attr Resident data structure to be walked * @param a_flags Flags for walking * @param a_action Callback action * @param a_ptr Pointer to data that is passed to callback * @returns 1 on error or 0 on success */ static uint8_t tsk_fs_attr_walk_res(const TSK_FS_ATTR * fs_attr, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr) { char *buf = NULL; int myflags; int retval; size_t buf_len = 0; TSK_OFF_T off; size_t read_len; TSK_FS_INFO *fs; fs = fs_attr->fs_file->fs_info; if ((fs_attr->flags & TSK_FS_ATTR_RES) == 0) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk_res: called with non-resident data"); return 1; } /* Allocate a buffer that is at most a block size in length */ buf_len = (size_t) fs_attr->size; if (buf_len > fs->block_size) buf_len = fs->block_size; if ((a_flags & TSK_FS_FILE_WALK_FLAG_AONLY) == 0) { if ((buf = tsk_malloc(buf_len)) == NULL) { return 1; } } myflags = TSK_FS_BLOCK_FLAG_CONT | TSK_FS_BLOCK_FLAG_ALLOC | TSK_FS_BLOCK_FLAG_RES; // Call the callback in (at max) block-sized chunks. retval = TSK_WALK_CONT; for (off = 0; off < fs_attr->size; off += read_len) { if (fs_attr->size - off > buf_len) read_len = buf_len; else read_len = (size_t) (fs_attr->size - off); if (buf) { // wipe rest of buffer if we are not going to read into all of it if (read_len != buf_len) memset(&buf[read_len], 0, buf_len - read_len); memcpy(buf, &fs_attr->rd.buf[off], read_len); } retval = a_action(fs_attr->fs_file, off, 0, buf, read_len, myflags, a_ptr); if (retval != TSK_WALK_CONT) break; } if (buf) free(buf); if (retval == TSK_WALK_ERROR) return 1; else return 0; } /** \internal * Processes a non-resident TSK_FS_ATTR structure and calls the callback with the associated * data. * * @param fs_attr Resident data structure to be walked * @param a_flags Flags for walking * @param a_action Callback action * @param a_ptr Pointer to data that is passed to callback * @returns 1 on error or 0 on success */ static uint8_t tsk_fs_attr_walk_nonres(const TSK_FS_ATTR * fs_attr, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr) { char *buf = NULL; TSK_OFF_T tot_size; TSK_OFF_T off = 0; TSK_FS_ATTR_RUN *fs_attr_run; int retval; uint32_t skip_remain; TSK_FS_INFO *fs = fs_attr->fs_file->fs_info; uint8_t stop_loop = 0; if ((fs_attr->flags & TSK_FS_ATTR_NONRES) == 0) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk_nonres: called with non-non-resident data"); return 1; } /* if we want the slack space too, then use the allocsize */ if (a_flags & TSK_FS_FILE_WALK_FLAG_SLACK) tot_size = fs_attr->nrd.allocsize; else tot_size = fs_attr->size; skip_remain = fs_attr->nrd.skiplen; if ((a_flags & TSK_FS_FILE_WALK_FLAG_AONLY) == 0) { if ((buf = (char *) tsk_malloc(fs->block_size)) == NULL) { return 1; } } /* cycle through the number of runs we have */ retval = TSK_WALK_CONT; for (fs_attr_run = fs_attr->nrd.run; fs_attr_run; fs_attr_run = fs_attr_run->next) { TSK_DADDR_T addr, len_idx; addr = fs_attr_run->addr; /* cycle through each block in the run */ for (len_idx = 0; len_idx < fs_attr_run->len; len_idx++) { TSK_FS_BLOCK_FLAG_ENUM myflags; /* If the address is too large then give an error */ if (addr + len_idx > fs->last_block) { if (fs_attr->fs_file->meta-> flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid address in run (too large): %" PRIuDADDR "", addr + len_idx); return 1; } // load the buffer if they want more than just the address if ((a_flags & TSK_FS_FILE_WALK_FLAG_AONLY) == 0) { /* sparse files just get 0s */ if (fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) { memset(buf, 0, fs->block_size); } /* FILLER entries exist when the source file system can store run * info out of order and we did not get all of the run info. We * return 0s if data is read from this type of run. */ else if (fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) { memset(buf, 0, fs->block_size); if (tsk_verbose) fprintf(stderr, "tsk_fs_attr_walk_nonres: File %" PRIuINUM " has FILLER entry, using 0s\n", fs_attr->fs_file->meta->addr); } // we return 0s for reads past the initsize else if ((off >= fs_attr->nrd.initsize) && ((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) == 0)) { memset(buf, 0, fs->block_size); } else { ssize_t cnt; cnt = tsk_fs_read_block (fs, addr + len_idx, buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "tsk_fs_file_walk: Error reading block at %" PRIuDADDR, addr + len_idx); return 1; } if ((off + fs->block_size > fs_attr->nrd.initsize) && ((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) == 0)) { memset(&buf[fs_attr->nrd.initsize - off], 0, fs->block_size - (size_t) (fs_attr->nrd.initsize - off)); } } } /* Need to account for the skip length, which is the number of bytes * in the start of the attribute that are skipped and that are not * included in the overall length. We will seek past those and not * return those in the action. We just read a block size so check * if there is data to be returned in this buffer. */ if (skip_remain >= fs->block_size) { skip_remain -= fs->block_size; } else { size_t ret_len; /* Do we want to return a full block, or just the end? */ if ((TSK_OFF_T) fs->block_size - skip_remain < tot_size - off) ret_len = fs->block_size - skip_remain; else ret_len = (size_t) (tot_size - off); /* Only do sparse or FILLER clusters if NOSPARSE is not set */ if ((fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) || (fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) || (off > fs_attr->nrd.initsize)) { myflags = fs->block_getflags(fs, 0); myflags |= TSK_FS_BLOCK_FLAG_SPARSE; if ((a_flags & TSK_FS_FILE_WALK_FLAG_NOSPARSE) == 0) { retval = a_action(fs_attr->fs_file, off, 0, &buf[skip_remain], ret_len, myflags, a_ptr); } } else { myflags = fs->block_getflags(fs, addr + len_idx); myflags |= TSK_FS_BLOCK_FLAG_RAW; retval = a_action(fs_attr->fs_file, off, addr + len_idx, &buf[skip_remain], ret_len, myflags, a_ptr); } off += ret_len; skip_remain = 0; if (retval != TSK_WALK_CONT) { stop_loop = 1; break; } if (off >= tot_size) { stop_loop = 1; break; } } } if (stop_loop) break; } if (buf) free(buf); if (retval == TSK_WALK_ERROR) return 1; else return 0; } /** * \ingroup fslib * Process an attribute and call a callback function with its contents. The callback will be * called with chunks of data that are fs->block_size or less. The address given in the callback * will be correct only for raw files (when the raw file contents were stored in the block). For * compressed and sparse attributes, the address may be zero. * * @param a_fs_attr Attribute to process * @param a_flags Flags to use while processing attribute * @param a_action Callback action to call with content * @param a_ptr Pointer that will passed to callback * @returns 1 on error and 0 on success. */ uint8_t tsk_fs_attr_walk(const TSK_FS_ATTR * a_fs_attr, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr) { TSK_FS_INFO *fs; // clean up any error messages that are lying around tsk_error_reset(); // check the FS_INFO, FS_FILE structures if ((a_fs_attr == NULL) || (a_fs_attr->fs_file == NULL) || (a_fs_attr->fs_file->meta == NULL) || (a_fs_attr->fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_walk: called with NULL pointers"); return 1; } fs = a_fs_attr->fs_file->fs_info; if (fs->tag != TSK_FS_INFO_TAG) { // || (a_fs_attr->id != TSK_FS_ATTR_ID)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_walk: called with unallocated structures"); return 1; } if (a_fs_attr->flags & TSK_FS_ATTR_COMP) { if (a_fs_attr->w == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_walk: compressed attribute found, but special function not defined"); return 1; } return a_fs_attr->w(a_fs_attr, a_flags, a_action, a_ptr); } // resident data if (a_fs_attr->flags & TSK_FS_ATTR_RES) { return tsk_fs_attr_walk_res(a_fs_attr, a_flags, a_action, a_ptr); } // non-resident data else if (a_fs_attr->flags & TSK_FS_ATTR_NONRES) { return tsk_fs_attr_walk_nonres(a_fs_attr, a_flags, a_action, a_ptr); } tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_walk: called with unknown attribute type: %x", a_fs_attr->flags); return 1; } /** * \ingroup fslib * Read the contents of a given attribute using a typical read() type interface. * 0s are returned for missing runs. * * @param a_fs_attr The attribute to read. * @param a_offset The byte offset to start reading from. * @param a_buf The buffer to read the data into. * @param a_len The number of bytes to read from the file. * @param a_flags Flags to use while reading * @returns The number of bytes read or -1 on error (incl if offset is past end of file). */ ssize_t tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, char *a_buf, size_t a_len, TSK_FS_FILE_READ_FLAG_ENUM a_flags) { TSK_FS_INFO *fs; if ((a_fs_attr == NULL) || (a_fs_attr->fs_file == NULL) || (a_fs_attr->fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_read: Attribute has null pointers."); return -1; } fs = a_fs_attr->fs_file->fs_info; /* for compressed data, call the specialized function */ if (a_fs_attr->flags & TSK_FS_ATTR_COMP) { if (a_fs_attr->r == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_read: Attribute has compressed type set, but no compressed read function defined"); return -1; } return a_fs_attr->r(a_fs_attr, a_offset, a_buf, a_len); } /* For resident data, copy data from the local buffer */ else if (a_fs_attr->flags & TSK_FS_ATTR_RES) { size_t len_toread; if (a_offset >= a_fs_attr->size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_read - %" PRIuOFF, a_offset); return -1; } len_toread = a_len; if (a_offset + a_len > a_fs_attr->size) { len_toread = (size_t) (a_fs_attr->size - a_offset); memset(&a_buf[len_toread], 0, a_len - len_toread); } memcpy(a_buf, &a_fs_attr->rd.buf[a_offset], len_toread); return (ssize_t) len_toread; } /* For non-resident data, load the needed block and copy the data */ else if (a_fs_attr->flags & TSK_FS_ATTR_NONRES) { TSK_FS_ATTR_RUN *data_run_cur; TSK_DADDR_T blkoffset_toread; // block offset of where we want to start reading from size_t byteoffset_toread; // byte offset in blkoffset_toread of where we want to start reading from size_t len_remain; // length remaining to copy size_t len_toread; // length total to copy if (((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) && (a_offset >= a_fs_attr->nrd.allocsize)) || (!(a_flags & TSK_FS_FILE_READ_FLAG_SLACK) && (a_offset >= a_fs_attr->size))) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_read - %" PRIuOFF, a_offset); return -1; } blkoffset_toread = a_offset / fs->block_size; byteoffset_toread = (size_t) (a_offset % fs->block_size); // determine how many bytes we can copy len_toread = a_len; if (a_flags & TSK_FS_FILE_READ_FLAG_SLACK) { if (a_offset + a_len > a_fs_attr->nrd.allocsize) len_toread = (size_t) (a_fs_attr->nrd.allocsize - a_offset); } else { if (a_offset + a_len > a_fs_attr->size) len_toread = (size_t) (a_fs_attr->size - a_offset); } // wipe the buffer we won't read into if (len_toread < a_len) memset(&a_buf[len_toread], 0, a_len - len_toread); len_remain = len_toread; // cycle through the run until we find where we can start to process the clusters for (data_run_cur = a_fs_attr->nrd.run; data_run_cur; data_run_cur = data_run_cur->next) { TSK_DADDR_T blkoffset_inrun; size_t len_inrun; // we are done if (len_remain <= 0) break; // See if this run contains the starting offset they requested if (data_run_cur->offset + data_run_cur->len <= blkoffset_toread) continue; // block offset into this run if (data_run_cur->offset < blkoffset_toread) blkoffset_inrun = blkoffset_toread - data_run_cur->offset; else blkoffset_inrun = 0; // see if we need to read the rest of this run and into the next or if it is all here len_inrun = len_remain; if ((data_run_cur->len - blkoffset_inrun) * fs->block_size - byteoffset_toread < len_remain) len_inrun = (size_t) ((data_run_cur->len - blkoffset_inrun) * fs->block_size - byteoffset_toread); /* sparse files/runs just get 0s */ if (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) { memset(&a_buf[len_toread - len_remain], 0, len_inrun); } /* FILLER entries exist when the source file system can store run * info out of order and we did not get all of the run info. We * return 0s if data is read from this type of run. */ else if (data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) { memset(&a_buf[len_toread - len_remain], 0, len_inrun); if (tsk_verbose) fprintf(stderr, "tsk_fs_attr_read_type: File %" PRIuINUM " has FILLER entry, using 0s\n", (a_fs_attr->fs_file->meta) ? a_fs_attr->fs_file-> meta->addr : 0); } // we return 0s for reads past the initsize (unless they want slack space) else if (((TSK_OFF_T) ((data_run_cur->offset + blkoffset_inrun) * fs->block_size + byteoffset_toread) >= a_fs_attr->nrd.initsize) && ((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) == 0)) { memset(&a_buf[len_toread - len_remain], 0, len_inrun); if (tsk_verbose) fprintf(stderr, "tsk_fs_attr_read: Returning 0s for read past end of initsize (%" PRIuINUM ")\n", ((a_fs_attr->fs_file) && (a_fs_attr->fs_file->meta)) ? a_fs_attr-> fs_file->meta->addr : 0); } else { TSK_OFF_T fs_offset_b; ssize_t cnt; // calcuate the byte offset in the file system fs_offset_b = (data_run_cur->addr + blkoffset_inrun) * fs->block_size; // add the byte offset in the block fs_offset_b += byteoffset_toread; // reset this in case we need to also read from the next run byteoffset_toread = 0; cnt = tsk_fs_read(fs, fs_offset_b, &a_buf[len_toread - len_remain], len_inrun); if (cnt != len_inrun) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "tsk_fs_attr_read_type: offset: %" PRIuOFF " Len: %" PRIuSIZE "", fs_offset_b, len_inrun); return cnt; } // see if part of the data is in the non-initialized space if (((TSK_OFF_T) ((data_run_cur->offset + blkoffset_inrun) * fs->block_size + byteoffset_toread + len_inrun) > a_fs_attr->nrd.initsize) && ((a_flags & TSK_FS_FILE_READ_FLAG_SLACK) == 0)) { size_t uninit_off = a_fs_attr->nrd.initsize - ((data_run_cur->offset + blkoffset_inrun) * fs->block_size + byteoffset_toread); memset(&a_buf[len_toread - len_remain + uninit_off], 0, len_inrun - uninit_off); } } len_remain -= len_inrun; } return (ssize_t) (len_toread - len_remain); } tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attr_read: Unknown attribute type: %x", a_fs_attr->flags); return -1; } sleuthkit-3.2.3/tsk3/fs/fs_attrlist.c000644 000765 000024 00000030507 11643647440 020341 0ustar00carrierstaff000000 000000 /* ** fs_attrlist ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2008 Brian Carrier. All Rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /** * \file fs_attrlist.c * File that contains functions to process TSK_FS_ATTRLIST structures, which * hold a linked list of TSK_FS_ATTR attribute structures. */ #include "tsk_fs_i.h" /** \internal * Allocate a new data list structure * * @returns Pointer to new list structure or NULL on error */ TSK_FS_ATTRLIST * tsk_fs_attrlist_alloc() { TSK_FS_ATTRLIST *fs_attrlist; if ((fs_attrlist = (TSK_FS_ATTRLIST *) tsk_malloc(sizeof(TSK_FS_ATTRLIST))) == NULL) return NULL; return fs_attrlist; } /** \internal * Free a list and the attributes inside of it */ void tsk_fs_attrlist_free(TSK_FS_ATTRLIST * a_fs_attrlist) { TSK_FS_ATTR *fs_attr_cur, *fs_attr_tmp; if (a_fs_attrlist == NULL) return; fs_attr_cur = a_fs_attrlist->head; while (fs_attr_cur) { fs_attr_tmp = fs_attr_cur->next; tsk_fs_attr_free(fs_attr_cur); fs_attr_cur = fs_attr_tmp; } free(a_fs_attrlist); } /** \internal * Add a new attribute to the list. * * @param a_fs_attrlist List structure to add to * @param a_fs_attr Data attribute to add * @returns 1 on error and 0 on success */ uint8_t tsk_fs_attrlist_add(TSK_FS_ATTRLIST * a_fs_attrlist, TSK_FS_ATTR * a_fs_attr) { if (a_fs_attrlist == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null list in tsk_fs_attrlist_add"); return 1; } // verify INUSE is set a_fs_attr->flags |= TSK_FS_ATTR_INUSE; if (a_fs_attrlist->head == NULL) { a_fs_attrlist->head = a_fs_attr; } else { TSK_FS_ATTR *fs_attr_cur; fs_attr_cur = a_fs_attrlist->head; while (fs_attr_cur) { // check if it already exists if ((fs_attr_cur->type == a_fs_attr->type) && (fs_attr_cur->id == a_fs_attr->id)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "datalist_add: Type %d and Id %d already in list", a_fs_attr->type, a_fs_attr->id); return 1; } if (fs_attr_cur->next == NULL) { fs_attr_cur->next = a_fs_attr; break; } fs_attr_cur = fs_attr_cur->next; } } return 0; } /** * \internal * Return either an empty element in the list or create a new one at the end * * Preference is given to finding one of the same type to prevent * excessive malloc's, but if one is not found then a different * type is used: type = [TSK_FS_ATTR_NONRES | TSK_FS_ATTR_RES] * * @param a_fs_attrlist Attribute list to search * @param a_atype Preference for attribute type to reuse * @return NULL on error or attribute in list to use */ TSK_FS_ATTR * tsk_fs_attrlist_getnew(TSK_FS_ATTRLIST * a_fs_attrlist, TSK_FS_ATTR_FLAG_ENUM a_atype) { TSK_FS_ATTR *fs_attr_cur; TSK_FS_ATTR *fs_attr_ok = NULL; if (a_fs_attrlist == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null list in tsk_fs_attrlist_getnew()"); return NULL; } if ((a_atype != TSK_FS_ATTR_NONRES) && (a_atype != TSK_FS_ATTR_RES)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid Type in tsk_fs_attrlist_getnew()"); return NULL; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if (fs_attr_cur->flags == 0) { if (a_atype == TSK_FS_ATTR_NONRES) { if (fs_attr_cur->nrd.run) break; else if (!fs_attr_ok) fs_attr_ok = fs_attr_cur; } /* we want one with an allocated buf */ else { if (fs_attr_cur->rd.buf_size) break; else if (!fs_attr_ok) fs_attr_ok = fs_attr_cur; } } } /* if we fell out then check fs_attr_tmp */ if (!fs_attr_cur) { if (fs_attr_ok) fs_attr_cur = fs_attr_ok; else { /* make a new one */ if ((fs_attr_cur = tsk_fs_attr_alloc(a_atype)) == NULL) return NULL; // add it to the list if (tsk_fs_attrlist_add(a_fs_attrlist, fs_attr_cur)) return NULL; } } fs_attr_cur->flags = (TSK_FS_ATTR_INUSE | a_atype); return fs_attr_cur; } /** \internal * Cycle through the attributes and mark them as unused. Does not free anything. * @param a_fs_attrlist Attribute list too mark. */ void tsk_fs_attrlist_markunused(TSK_FS_ATTRLIST * a_fs_attrlist) { TSK_FS_ATTR *fs_attr_cur; if (a_fs_attrlist == NULL) return; fs_attr_cur = a_fs_attrlist->head; while (fs_attr_cur) { tsk_fs_attr_clear(fs_attr_cur); fs_attr_cur = fs_attr_cur->next; } } /** * \internal * Search the attribute list of TSK_FS_ATTR structures for an entry with a given * type (no ID). If more than one entry with the same type exists, the one with * the lowest ID will be returned. * * @param a_fs_attrlist Data list structure to search in * @param a_type Type of attribute to find * * @return NULL is returned on error and if an entry could not be found. * tsk_errno will be set to TSK_ERR_FS_ATTR_NOTFOUND if entry could not be found. */ const TSK_FS_ATTR * tsk_fs_attrlist_get(const TSK_FS_ATTRLIST * a_fs_attrlist, TSK_FS_ATTR_TYPE_ENUM a_type) { TSK_FS_ATTR *fs_attr_cur; TSK_FS_ATTR *fs_attr_ok = NULL; if (!a_fs_attrlist) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get: Null list pointer"); tsk_errstr2[0] = '\0'; return NULL; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if ((fs_attr_cur->flags & TSK_FS_ATTR_INUSE) && (fs_attr_cur->type == a_type)) { /* If we are looking for NTFS $Data, * then return default when we see it */ if ((fs_attr_cur->type == TSK_FS_ATTR_TYPE_NTFS_DATA) && (fs_attr_cur->name == NULL)) { return fs_attr_cur; } // make sure we return the lowest if multiple exist if ((fs_attr_ok == NULL) || (fs_attr_ok->id > fs_attr_cur->id)) fs_attr_ok = fs_attr_cur; } } if (!fs_attr_ok) { tsk_errno = TSK_ERR_FS_ATTR_NOTFOUND; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get: Attribute %d not found", a_type); return NULL; } else { return fs_attr_ok; } } /** * \internal * Search the attribute list of TSK_FS_ATTR structures for an entry with a given * type and id. * * @param a_fs_attrlist Data list structure to search in * @param a_type Type of attribute to find * @param a_id Id of attribute to find. * * @return NULL is returned on error and if an entry could not be found. * tsk_errno will be set to TSK_ERR_FS_ATTR_NOTFOUND if entry could not be found. */ const TSK_FS_ATTR * tsk_fs_attrlist_get_id(const TSK_FS_ATTRLIST * a_fs_attrlist, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id) { TSK_FS_ATTR *fs_attr_cur; if (!a_fs_attrlist) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_id: Null list pointer"); tsk_errstr2[0] = '\0'; return NULL; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if ((fs_attr_cur->flags & TSK_FS_ATTR_INUSE) && (fs_attr_cur->type == a_type) && (fs_attr_cur->id == a_id)) return fs_attr_cur; } tsk_errno = TSK_ERR_FS_ATTR_NOTFOUND; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_id: Attribute %d-%d not found", a_type, a_id); return NULL; } /** * \internal * Search the attribute list of TSK_FS_ATTR structures for an entry with a given * type (no ID) and a given name. If more than one entry with the same type exists, * the one with the lowest ID will be returned. * * @param a_fs_attrlist Data list structure to search in * @param a_type Type of attribute to find * @param name Name of the attribute to find (NULL for an entry with no name) * * @return NULL is returned on error and if an entry could not be found. * tsk_errno will be set to TSK_ERR_FS_ATTR_NOTFOUND if entry could not be found. */ const TSK_FS_ATTR * tsk_fs_attrlist_get_name_type(const TSK_FS_ATTRLIST * a_fs_attrlist, TSK_FS_ATTR_TYPE_ENUM a_type, const char *name) { TSK_FS_ATTR *fs_attr_cur; TSK_FS_ATTR *fs_attr_ok = NULL; if (!a_fs_attrlist) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_name_type: Null list pointer"); tsk_errstr2[0] = '\0'; return NULL; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if ((fs_attr_cur->flags & TSK_FS_ATTR_INUSE) && (fs_attr_cur->type == a_type)) { if (((name == NULL) && (fs_attr_cur->name == NULL)) || ((name) && (fs_attr_cur->name) && (!strcmp(fs_attr_cur->name, name)))) { /* If we are looking for NTFS $Data, * then return default when we see it */ if ((fs_attr_cur->type == TSK_FS_ATTR_TYPE_NTFS_DATA) && (fs_attr_cur->name == NULL)) { return fs_attr_cur; } // make sure we return the lowest if multiple exist if ((fs_attr_ok == NULL) || (fs_attr_ok->id > fs_attr_cur->id)) fs_attr_ok = fs_attr_cur; } } } if (!fs_attr_ok) { tsk_errno = TSK_ERR_FS_ATTR_NOTFOUND; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get: Attribute %d not found", a_type); return NULL; } else { return fs_attr_ok; } } /** * \internal * Return the a_idx'th attribute in the attribute list. * * @param a_fs_attrlist Data list structure to search in * @param a_idx 0-based index of attribute to return * * @return NULL is returned on error and if an entry could not be found. * tsk_errno will be set to TSK_ERR_FS_ATTR_NOTFOUND if entry could not be found. */ const TSK_FS_ATTR * tsk_fs_attrlist_get_idx(const TSK_FS_ATTRLIST * a_fs_attrlist, int a_idx) { TSK_FS_ATTR *fs_attr_cur; int i = 0; if (!a_fs_attrlist) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_idx: Null list pointer"); tsk_errstr2[0] = '\0'; return NULL; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if (fs_attr_cur->flags & TSK_FS_ATTR_INUSE) { if (i == a_idx) { return fs_attr_cur; } i++; } } tsk_errno = TSK_ERR_FS_ATTR_NOTFOUND; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_idx: Attribute index %d not found", a_idx); return NULL; } /** * \internal * Return the number of attributes in the attribute list * * @param a_fs_attrlist Data list structure to analyze * * @return the number of attributes and 0 if error (if argument is NULL) */ int tsk_fs_attrlist_get_len(const TSK_FS_ATTRLIST * a_fs_attrlist) { TSK_FS_ATTR *fs_attr_cur; int len = 0; if (!a_fs_attrlist) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_attrlist_get_len: Null list pointer"); tsk_errstr2[0] = '\0'; return 0; } for (fs_attr_cur = a_fs_attrlist->head; fs_attr_cur; fs_attr_cur = fs_attr_cur->next) { if (fs_attr_cur->flags & TSK_FS_ATTR_INUSE) len++; } return len; } sleuthkit-3.2.3/tsk3/fs/fs_block.c000644 000765 000024 00000013413 11643647440 017562 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2008 Brian Carrier, Basis Technology. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file fs_block.c * Contains functions to allocate, free, and read data into a TSK_FS_BLOCK structure. */ #include #include "tsk_fs_i.h" /** * \internal * Allocate a TSK_FS_BLOCK structure. * @param a_fs File system to create block for * @returns NULL on error */ TSK_FS_BLOCK * tsk_fs_block_alloc(TSK_FS_INFO * a_fs) { TSK_FS_BLOCK *fs_block; fs_block = (TSK_FS_BLOCK *) tsk_malloc(sizeof(TSK_FS_BLOCK)); if (fs_block == NULL) return NULL; fs_block->buf = (char *) tsk_malloc(a_fs->block_size); if (fs_block->buf == NULL) { free(fs_block); return NULL; } fs_block->tag = TSK_FS_BLOCK_TAG; fs_block->addr = 0; fs_block->flags = 0; fs_block->fs_info = a_fs; return fs_block; } /** * \ingroup fslib * Free the memory associated with the TSK_FS_BLOCK structure. * @param a_fs_block Block to free */ void tsk_fs_block_free(TSK_FS_BLOCK * a_fs_block) { if (a_fs_block->buf) free(a_fs_block->buf); a_fs_block->tag = 0; free(a_fs_block); } /** * \ingroup fslib * Get the contents and flags of a specific file system block. Note that if the block contains * compressed data, then this function will return the compressed data with the RAW flag set. * The uncompressed data can be obtained only from the file-level functions. * * @param a_fs The file system to read the block from. * @param a_fs_block The structure to write the block data into or NULL to have one created. * @param a_addr The file system address to read. * @return The TSK_FS_BLOCK with the data or NULL on error. (If a_fs_block was not NULL, this will * be the same structure). */ TSK_FS_BLOCK * tsk_fs_block_get(TSK_FS_INFO * a_fs, TSK_FS_BLOCK * a_fs_block, TSK_DADDR_T a_addr) { TSK_OFF_T offs; ssize_t cnt; size_t len; if (a_fs == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_get: fs unallocated"); return NULL; } if (a_fs_block == NULL) { a_fs_block = tsk_fs_block_alloc(a_fs); } else if ((a_fs_block->tag != TSK_FS_BLOCK_TAG) || (a_fs_block->buf == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_get: fs_block unallocated"); return NULL; } len = a_fs->block_size; if (a_addr > a_fs->last_block_act) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; if (a_addr <= a_fs->last_block) snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_get: Address missing in partial image: %" PRIuDADDR ")", a_addr); else snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_get: Address is too large for image: %" PRIuDADDR ")", a_addr); return NULL; } a_fs_block->fs_info = a_fs; a_fs_block->addr = a_addr; a_fs_block->flags = a_fs->block_getflags(a_fs, a_addr); a_fs_block->flags |= TSK_FS_BLOCK_FLAG_RAW; offs = (TSK_OFF_T) a_addr *a_fs->block_size; cnt = tsk_img_read(a_fs->img_info, a_fs->offset + offs, a_fs_block->buf, len); if (cnt != len) { return NULL; } return a_fs_block; } /** * \internal * Set the fields of a FS_BLOCk structure. This is internally used to set the data from a * larger buffer so that larger disk reads can occur. * * @param a_fs File system * @param a_fs_block Block to load data into * @param a_addr Address where data is from * @param a_flags Flags for data * @param a_buf Buffer to copy data from and into a_fs_block (block_size will be copied) * @returns 1 on error, 0 on success */ int tsk_fs_block_set(TSK_FS_INFO * a_fs, TSK_FS_BLOCK * a_fs_block, TSK_DADDR_T a_addr, TSK_FS_BLOCK_FLAG_ENUM a_flags, char *a_buf) { if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_set: fs_info unallocated"); return 1; } if ((a_fs_block->tag != TSK_FS_BLOCK_TAG) || (a_fs_block->buf == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_set: fs_block unallocated"); return 1; } a_fs_block->fs_info = a_fs; memcpy(a_fs_block->buf, a_buf, a_fs->block_size); a_fs_block->addr = a_addr; a_fs_block->flags = a_flags; return 0; } /** * \ingroup fslib * * Cycle through a range of file system blocks and call the callback function * with the contents and allocation status of each. * * @param a_fs File system to analyze * @param a_start_blk Block address to start walking from * @param a_end_blk Block address to walk to * @param a_flags Flags used during walk to determine which blocks to call callback with * @param a_action Callback function * @param a_ptr Pointer that will be passed to callback * @returns 1 on error and 0 on success */ uint8_t tsk_fs_block_walk(TSK_FS_INFO * a_fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr) { if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_block_walk: FS_INFO structure is not allocated"); return 1; } return a_fs->block_walk(a_fs, a_start_blk, a_end_blk, a_flags, a_action, a_ptr); } sleuthkit-3.2.3/tsk3/fs/fs_dir.c000644 000765 000024 00000077360 11643647440 017261 0ustar00carrierstaff000000 000000 /* * fs_dir * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2008-2009 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 * */ /** * \file fs_dir.c * Create, manage, etc. the TSK_FS_DIR structures. */ #include "tsk_fs_i.h" #include "tsk_fatfs.h" /** \internal * Allocate a FS_DIR structure to load names into. * * @param a_addr Address of this directory. * @param a_cnt target number of FS_DENT entries to fit in * @returns NULL on error */ TSK_FS_DIR * tsk_fs_dir_alloc(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr, size_t a_cnt) { TSK_FS_DIR *fs_dir; size_t i; // allocate and initialize the structure if ((fs_dir = (TSK_FS_DIR *) tsk_malloc(sizeof(TSK_FS_DIR))) == NULL) { return NULL; } fs_dir->names_alloc = a_cnt; fs_dir->names_used = 0; if ((fs_dir->names = (TSK_FS_NAME *) tsk_malloc(sizeof(TSK_FS_NAME) * fs_dir->names_alloc)) == NULL) { free(fs_dir); return NULL; } fs_dir->fs_info = a_fs; fs_dir->addr = a_addr; fs_dir->tag = TSK_FS_DIR_TAG; for (i = 0; i < a_cnt; i++) { fs_dir->names[i].tag = TSK_FS_NAME_TAG; } return fs_dir; } /** \internal * Make the buffer in the FS_DIR structure larger. * * @param a_fs_dir Structure to enhance * @param a_cnt target number of FS_DENT entries to fit in * @returns 1 on error and 0 on success */ uint8_t tsk_fs_dir_realloc(TSK_FS_DIR * a_fs_dir, size_t a_cnt) { size_t prev_cnt, i; if ((a_fs_dir == NULL) || (a_fs_dir->tag != TSK_FS_DIR_TAG)) return 1; if (a_fs_dir->names_alloc >= a_cnt) return 0; prev_cnt = a_fs_dir->names_alloc; a_fs_dir->names_alloc = a_cnt; if ((a_fs_dir->names = (TSK_FS_NAME *) tsk_realloc((void *) a_fs_dir->names, sizeof(TSK_FS_NAME) * a_fs_dir->names_alloc)) == NULL) { return 1; } memset(&a_fs_dir->names[prev_cnt], 0, (a_cnt - prev_cnt) * sizeof(TSK_FS_NAME)); for (i = prev_cnt; i < a_cnt; i++) { a_fs_dir->names[i].tag = TSK_FS_NAME_TAG; } return 0; } /** \internal * Reset the structures in a FS_DIR so that it can be reused. * @param a_fs_dir FS_DIR structure to re-use */ void tsk_fs_dir_reset(TSK_FS_DIR * a_fs_dir) { if ((a_fs_dir == NULL) || (a_fs_dir->tag != TSK_FS_DIR_TAG)) return; if (a_fs_dir->fs_file) { tsk_fs_file_close(a_fs_dir->fs_file); a_fs_dir->fs_file = NULL; } a_fs_dir->names_used = 0; a_fs_dir->addr = 0; } /** \internal * Copy the contents of one directory structure to another. * Note that this currently does not copy the FS_FILE info. * It is only used to make a copy of the orphan directory. * It does not check for duplicate entries. * @returns 1 on error */ static uint8_t tsk_fs_dir_copy(const TSK_FS_DIR * a_src_dir, TSK_FS_DIR * a_dst_dir) { size_t i; a_dst_dir->names_used = 0; // make sure we got the room if (a_src_dir->names_used > a_dst_dir->names_alloc) { if (tsk_fs_dir_realloc(a_dst_dir, a_src_dir->names_used)) return 1; } for (i = 0; i < a_src_dir->names_used; i++) { if (tsk_fs_name_copy(&a_dst_dir->names[i], &a_src_dir->names[i])) return 1; } a_dst_dir->names_used = a_src_dir->names_used; a_dst_dir->addr = a_src_dir->addr; return 0; } /** \internal * Add a FS_DENT structure to a FS_DIR structure by copying its * contents into the internal buffer. Checks for * duplicates and expands buffer as needed. * @param a_fs_dir DIR to add to * @param a_fs_name DENT to add * @returns 1 on error (memory allocation problems) and 0 on success */ uint8_t tsk_fs_dir_add(TSK_FS_DIR * a_fs_dir, const TSK_FS_NAME * a_fs_name) { TSK_FS_NAME *fs_name_dest = NULL; size_t i; // see if we already have it in the buffer / queue for (i = 0; i < a_fs_dir->names_used; i++) { if ((a_fs_name->meta_addr == a_fs_dir->names[i].meta_addr) && (strcmp(a_fs_name->name, a_fs_dir->names[i].name) == 0)) { if (tsk_verbose) tsk_fprintf(stderr, "tsk_fs_dir_add: removing duplicate entry: %s (%" PRIuINUM ")\n", a_fs_name->name, a_fs_name->meta_addr); /* We do not check type because then we cannot detect NTFS orphan file * duplicates that are added as "-/r" while a similar entry exists as "r/r" (a_fs_name->type == a_fs_dir->names[i].type)) { */ // if the one in the list is unalloc and we have an alloc, replace it if ((a_fs_dir->names[i].flags & TSK_FS_NAME_FLAG_UNALLOC) && (a_fs_name->flags & TSK_FS_NAME_FLAG_ALLOC)) { fs_name_dest = &a_fs_dir->names[i]; // free the memory - not the most effecient, but prevents // duplicate code. if (fs_name_dest->name) { free(fs_name_dest->name); fs_name_dest->name = NULL; fs_name_dest->name_size = 0; } if (fs_name_dest->shrt_name) { free(fs_name_dest->shrt_name); fs_name_dest->shrt_name = NULL; fs_name_dest->shrt_name_size = 0; } break; } else { return 0; } } } if (fs_name_dest == NULL) { // make sure we got the room if (a_fs_dir->names_used >= a_fs_dir->names_alloc) { if (tsk_fs_dir_realloc(a_fs_dir, a_fs_dir->names_used + 256)) return 1; } fs_name_dest = &a_fs_dir->names[a_fs_dir->names_used++]; } if (tsk_fs_name_copy(fs_name_dest, a_fs_name)) return 1; // add the parent address if (a_fs_dir->addr) fs_name_dest->par_addr = a_fs_dir->addr; return 0; } /** \ingroup fslib * Open a directory (using its metadata addr) so that each of the files in it can be accessed. * @param a_fs File system to analyze * @param a_addr Metadata address of the directory to open * @returns NULL on error */ TSK_FS_DIR * tsk_fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr) { TSK_FS_DIR *fs_dir = NULL; TSK_RETVAL_ENUM retval; if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG) || (a_fs->dir_open_meta == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_open_meta: called with NULL or unallocated structures"); return NULL; } retval = a_fs->dir_open_meta(a_fs, &fs_dir, a_addr); if (retval != TSK_OK) return NULL; return fs_dir; } /** \ingroup fslib * Open a directory (using its path) so that each of the files in it can be accessed. * @param a_fs File system to analyze * @param a_dir Path of the directory to open * @returns NULL on error */ TSK_FS_DIR * tsk_fs_dir_open(TSK_FS_INFO * a_fs, const char *a_dir) { TSK_INUM_T inum; int8_t retval; TSK_FS_DIR *fs_dir; TSK_FS_NAME *fs_name; if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_open: called with NULL or unallocated structures"); return NULL; } // allocate a structure to store the name in if ((fs_name = tsk_fs_name_alloc(128, 32)) == NULL) { return NULL; } retval = tsk_fs_path2inum(a_fs, a_dir, &inum, fs_name); if (retval == -1) { return NULL; } else if (retval == 1) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_open: path not found: %s", a_dir); return NULL; } fs_dir = tsk_fs_dir_open_meta(a_fs, inum); // add the name structure on to it if ((fs_dir) && (fs_dir->fs_file)) fs_dir->fs_file->name = fs_name; return fs_dir; } /** \ingroup fslib * Close the directory that was opened with tsk_fs_dir_open() * @param a_fs_dir Directory to close */ void tsk_fs_dir_close(TSK_FS_DIR * a_fs_dir) { size_t i; if ((a_fs_dir == NULL) || (a_fs_dir->tag != TSK_FS_DIR_TAG)) { return; } for (i = 0; i < a_fs_dir->names_used; i++) { if (a_fs_dir->names[i].name) { free(a_fs_dir->names[i].name); a_fs_dir->names[i].name = NULL; a_fs_dir->names[i].name_size = 0; } if (a_fs_dir->names[i].shrt_name) { free(a_fs_dir->names[i].shrt_name); a_fs_dir->names[i].shrt_name = NULL; a_fs_dir->names[i].shrt_name_size = 0; } } free(a_fs_dir->names); if (a_fs_dir->fs_file) { tsk_fs_file_close(a_fs_dir->fs_file); a_fs_dir->fs_file = NULL; } a_fs_dir->tag = 0; free(a_fs_dir); } /** \ingroup fslib * Returns the number of files and subdirectories in a directory. * @param a_fs_dir Directory to get information about * @returns Number of files and subdirectories (or 0 on error) */ size_t tsk_fs_dir_getsize(const TSK_FS_DIR * a_fs_dir) { if ((a_fs_dir == NULL) || (a_fs_dir->tag != TSK_FS_DIR_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_getsize: called with NULL or unallocated structures"); return 0; } return a_fs_dir->names_used; } /** \ingroup fslib * Return a specific file or subdirectory from an open directory. * @param a_fs_dir Directory to analyze * @param a_idx Index of file in directory to open (0-based) * @returns NULL on error */ TSK_FS_FILE * tsk_fs_dir_get(const TSK_FS_DIR * a_fs_dir, size_t a_idx) { TSK_FS_NAME *fs_name; TSK_FS_FILE *fs_file; if ((a_fs_dir == NULL) || (a_fs_dir->tag != TSK_FS_DIR_TAG) || (a_fs_dir->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_get: called with NULL or unallocated structures"); return NULL; } if (a_fs_dir->names_used <= a_idx) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_get: Index (%" PRIuSIZE ") too large (%" PRIuSIZE ")", a_idx, a_fs_dir->names_used); return NULL; } // allocate a structure to return if ((fs_file = tsk_fs_file_alloc(a_fs_dir->fs_info)) == NULL) return NULL; fs_name = &(a_fs_dir->names[a_idx]); // copy the name into another structure that we can return and later free if ((fs_file->name = tsk_fs_name_alloc(fs_name->name ? strlen(fs_name->name) + 1 : 0, fs_name->shrt_name ? strlen(fs_name->shrt_name) + 1 : 0)) == NULL) { return NULL; } if (tsk_fs_name_copy(fs_file->name, fs_name)) return NULL; /* load the fs_meta structure if possible. * Must have non-zero inode addr or have allocated name (if inode is 0) */ if (((fs_name->meta_addr) || (fs_name->flags & TSK_FS_NAME_FLAG_ALLOC))) { if (a_fs_dir->fs_info->file_add_meta(a_fs_dir->fs_info, fs_file, fs_name->meta_addr)) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); } } return fs_file; } #define MAX_DEPTH 128 #define DIR_STRSZ 4096 /** \internal * used to keep state between calls to dir_walk_lcl */ typedef struct { /* Recursive path stuff */ /* how deep in the directory tree are we */ unsigned int depth; /* pointer in dirs string to where '/' is for given depth */ char *didx[MAX_DEPTH]; /* The current directory name string */ char dirs[DIR_STRSZ]; TSK_STACK *stack_seen; /* Set to one to collect inode info that can be used for orphan listing */ uint8_t save_inum_named; } DENT_DINFO; /* dir_walk local function that is used for recursive calls. Callers * should initially call the non-local version. */ static TSK_WALK_RET_ENUM tsk_fs_dir_walk_lcl(TSK_FS_INFO * a_fs, DENT_DINFO * a_dinfo, TSK_INUM_T a_addr, TSK_FS_DIR_WALK_FLAG_ENUM a_flags, TSK_FS_DIR_WALK_CB a_action, void *a_ptr) { TSK_FS_DIR *fs_dir; TSK_FS_FILE *fs_file; size_t i; // get the list of entries in the directory if ((fs_dir = tsk_fs_dir_open_meta(a_fs, a_addr)) == NULL) { return TSK_WALK_ERROR; } /* Allocate a file structure for the callbacks. We * will allocate fs_meta structures as needed and * point into the fs_dir structure for the names. */ if ((fs_file = tsk_fs_file_alloc(a_fs)) == NULL) { tsk_fs_dir_close(fs_dir); return TSK_WALK_ERROR; } for (i = 0; i < fs_dir->names_used; i++) { int retval; /* Point name to the buffer of names. We need to be * careful about resetting this before we free fs_file */ fs_file->name = (TSK_FS_NAME *) & fs_dir->names[i]; /* load the fs_meta structure if possible. * Must have non-zero inode addr or have allocated name (if inode is 0) */ if (((fs_file->name->meta_addr) || (fs_file->name->flags & TSK_FS_NAME_FLAG_ALLOC))) { if (a_fs->file_add_meta(a_fs, fs_file, fs_file->name->meta_addr)) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); } } // call the action if we have the right flags. if ((fs_file->name->flags & a_flags) == fs_file->name->flags) { retval = a_action(fs_file, a_dinfo->dirs, a_ptr); if (retval == TSK_WALK_STOP) { tsk_fs_dir_close(fs_dir); fs_file->name = NULL; tsk_fs_file_close(fs_file); /* free the list -- fs_dir_walk has no way * of knowing that we stopped early w/out error. */ if (a_dinfo->save_inum_named) { tsk_list_free(a_fs->list_inum_named); a_fs->list_inum_named = NULL; a_dinfo->save_inum_named = 0; } return TSK_WALK_STOP; } else if (retval == TSK_WALK_ERROR) { tsk_fs_dir_close(fs_dir); fs_file->name = NULL; tsk_fs_file_close(fs_file); return TSK_WALK_ERROR; } } // save the inode info for orphan finding - if requested if ((a_dinfo->save_inum_named) && (fs_file->meta) && (fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC)) { if (tsk_list_add(&a_fs->list_inum_named, fs_file->meta->addr)) { // if there is an error, then clear the list tsk_list_free(a_fs->list_inum_named); a_fs->list_inum_named = NULL; a_dinfo->save_inum_named = 0; } } /* Recurse into a directory if: * - Both dir entry and inode have DIR type (or name is undefined) * - Recurse flag is set * - dir entry is allocated OR both are unallocated * - not one of the '.' or '..' entries * - A Non-Orphan Dir or the Orphan Dir with the NOORPHAN flag not set. */ if (((fs_file->name->type == TSK_FS_NAME_TYPE_DIR) || (fs_file->name->type == TSK_FS_NAME_TYPE_UNDEF)) && (fs_file->meta) && (fs_file->meta->type == TSK_FS_META_TYPE_DIR) && (a_flags & TSK_FS_DIR_WALK_FLAG_RECURSE) && ((fs_file->name->flags & TSK_FS_NAME_FLAG_ALLOC) || ((fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC) && (fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC)) ) && (!TSK_FS_ISDOT(fs_file->name->name)) && ((fs_file->name->meta_addr != TSK_FS_ORPHANDIR_INUM(a_fs)) || ((a_flags & TSK_FS_DIR_WALK_FLAG_NOORPHAN) == 0)) ) { /* Make sure we do not get into an infinite loop */ if (0 == tsk_stack_find(a_dinfo->stack_seen, fs_file->name->meta_addr)) { int depth_added = 0; uint8_t save_bak = 0; if (tsk_stack_push(a_dinfo->stack_seen, fs_file->name->meta_addr)) { tsk_fs_dir_close(fs_dir); fs_file->name = NULL; tsk_fs_file_close(fs_file); return TSK_WALK_ERROR; } if ((a_dinfo->depth < MAX_DEPTH) && (DIR_STRSZ > strlen(a_dinfo->dirs) + strlen(fs_file->name->name))) { a_dinfo->didx[a_dinfo->depth] = &a_dinfo->dirs[strlen(a_dinfo->dirs)]; strncpy(a_dinfo->didx[a_dinfo->depth], fs_file->name->name, DIR_STRSZ - strlen(a_dinfo->dirs)); strncat(a_dinfo->dirs, "/", DIR_STRSZ); depth_added = 1; } a_dinfo->depth++; /* We do not want to save info about named unalloc files * when we go into the Orphan directory (because then we have * no orphans). So, disable it for this recursion. */ if (fs_file->name->meta_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { save_bak = a_dinfo->save_inum_named; a_dinfo->save_inum_named = 0; } retval = tsk_fs_dir_walk_lcl(a_fs, a_dinfo, fs_file->name->meta_addr, a_flags, a_action, a_ptr); if (retval == TSK_WALK_ERROR) { /* If this fails because the directory could not be * loaded, then we still continue */ if (tsk_verbose) { tsk_fprintf(stderr, "tsk_fs_dir_walk_lcl: error reading directory: %" PRIuINUM "\n", fs_file->name->meta_addr); tsk_error_print(stderr); } tsk_error_reset(); } else if (retval == TSK_WALK_STOP) { tsk_fs_dir_close(fs_dir); fs_file->name = NULL; tsk_fs_file_close(fs_file); return TSK_WALK_STOP; } // reset the save status if (fs_file->name->meta_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { a_dinfo->save_inum_named = save_bak; } tsk_stack_pop(a_dinfo->stack_seen); a_dinfo->depth--; if (depth_added) *a_dinfo->didx[a_dinfo->depth] = '\0'; } } // remove the pointer to name buffer fs_file->name = NULL; // free the metadata if we allocated it if (fs_file->meta) { tsk_fs_meta_close(fs_file->meta); fs_file->meta = NULL; } } tsk_fs_dir_close(fs_dir); fs_file->name = NULL; tsk_fs_file_close(fs_file); return TSK_WALK_CONT; } /** \ingroup fslib * Walk the file names in a directory and obtain the details of the files via a callback. * * @param a_fs File system to analyze * @param a_addr Metadata address of the directory to analyze * @param a_flags Flags used during analysis * @param a_action Callback function that is called for each file name * @param a_ptr Pointer to data that is passed to the callback function each time * @returns 1 on error and 0 on success */ uint8_t tsk_fs_dir_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr, TSK_FS_DIR_WALK_FLAG_ENUM a_flags, TSK_FS_DIR_WALK_CB a_action, void *a_ptr) { DENT_DINFO dinfo; TSK_RETVAL_ENUM retval; if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_dir_walk: called with NULL or unallocated structures"); return 1; } memset(&dinfo, 0, sizeof(DENT_DINFO)); if ((dinfo.stack_seen = tsk_stack_create()) == NULL) return 1; /* Sanity check on flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_DIR_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_DIR_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_UNALLOC); } /* if the flags are right, we can collect info that may be needed * for an orphan walk. If the walk fails or stops, the code that * calls the action will clear this stuff. */ if ((a_fs->list_inum_named == NULL) && (a_addr == a_fs->root_inum) && (a_flags & TSK_FS_DIR_WALK_FLAG_RECURSE)) { dinfo.save_inum_named = 1; } retval = tsk_fs_dir_walk_lcl(a_fs, &dinfo, a_addr, a_flags, a_action, a_ptr); /* If there was an error, then we stopped early and we should get * rid of the partial list we were making. */ if ((retval != TSK_WALK_CONT) && (dinfo.save_inum_named == 1)) { tsk_list_free(a_fs->list_inum_named); a_fs->list_inum_named = NULL; } tsk_stack_free(dinfo.stack_seen); if (retval == TSK_WALK_ERROR) return 1; else return 0; } /** \internal * Create a dummy NAME entry for the Orphan file virtual directory. * @param a_fs File system directory is for * @param a_fs_name NAME structure to populate with data * @returns 1 on error */ uint8_t tsk_fs_dir_make_orphan_dir_name(TSK_FS_INFO * a_fs, TSK_FS_NAME * a_fs_name) { snprintf(a_fs_name->name, a_fs_name->name_size, "$OrphanFiles"); if (a_fs_name->shrt_name_size > 0) a_fs_name->shrt_name[0] = '\0'; a_fs_name->meta_addr = TSK_FS_ORPHANDIR_INUM(a_fs); a_fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; a_fs_name->type = TSK_FS_NAME_TYPE_DIR; return 0; } /** \internal * Create a dummy META entry for the Orphan file virtual directory. * @param a_fs File system directory is for * @param a_fs_meta META structure to populate with data * @returns 1 on error */ uint8_t tsk_fs_dir_make_orphan_dir_meta(TSK_FS_INFO * a_fs, TSK_FS_META * a_fs_meta) { a_fs_meta->type = TSK_FS_META_TYPE_DIR; a_fs_meta->mode = 0; a_fs_meta->nlink = 1; a_fs_meta->flags = (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_ALLOC); a_fs_meta->uid = a_fs_meta->gid = 0; a_fs_meta->mtime = a_fs_meta->atime = a_fs_meta->ctime = a_fs_meta->crtime = 0; a_fs_meta->mtime_nano = a_fs_meta->atime_nano = a_fs_meta->ctime_nano = a_fs_meta->crtime_nano = 0; if (a_fs_meta->name2 == NULL) { if ((a_fs_meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return 1; a_fs_meta->name2->next = NULL; } a_fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (a_fs_meta->attr) { tsk_fs_attrlist_markunused(a_fs_meta->attr); } a_fs_meta->addr = TSK_FS_ORPHANDIR_INUM(a_fs); strncpy(a_fs_meta->name2->name, "$OrphanFiles", TSK_FS_META_NAME_LIST_NSIZE); if (a_fs_meta->content_len) { TSK_DADDR_T *addr_ptr = (TSK_DADDR_T *) a_fs_meta->content_ptr; addr_ptr[0] = 0; } a_fs_meta->size = 0; return 0; } /* callback that is used by tsk_fs_dir_load_inum_named. It does nothing * because each file system has the code needed to make caller happy. */ static TSK_WALK_RET_ENUM load_named_dir_walk_cb(TSK_FS_FILE * a_fs_file, const char *a_path, void *a_ptr) { return TSK_WALK_CONT; } /** \internal * Proces a file system and populate a list of the metadata structures * that are reachable by file names. This is used to find orphan files. * Each file system has code that does the populating. */ TSK_RETVAL_ENUM tsk_fs_dir_load_inum_named(TSK_FS_INFO * a_fs) { if (a_fs->list_inum_named != NULL) return TSK_OK; /* Do a dir_walk. There is internal caching code that will populate * the structure. The callback is really a dummy call. This could * be made more effecient in the future (not do callbacks...). We * specify UNALLOC only as a flag on the assumption that there will * be fewer callbacks for UNALLOC than ALLOC. */ if (tsk_fs_dir_walk(a_fs, a_fs->root_inum, TSK_FS_NAME_FLAG_UNALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE | TSK_FS_DIR_WALK_FLAG_NOORPHAN, load_named_dir_walk_cb, NULL)) { strncat(tsk_errstr2, " - tsk_fs_dir_load_inum_named: identifying inodes allocated by file names", TSK_ERRSTR_L); return TSK_ERR; } return TSK_OK; } /* Used to keep state while populating the orphan directory */ typedef struct { TSK_FS_NAME *fs_name; // temp name structure used when adding entries to fs_dir TSK_FS_DIR *fs_dir; // unique names are added to this. represents contents of OrphanFiles directory TSK_LIST *orphan_subdir_list; // keep track of files that can already be accessed via orphan directory } FIND_ORPHAN_DATA; /* Used to process orphan directories and make sure that their contents * are now marked as reachable */ static TSK_WALK_RET_ENUM load_orphan_dir_walk_cb(TSK_FS_FILE * a_fs_file, const char *a_path, void *a_ptr) { FIND_ORPHAN_DATA *data = (FIND_ORPHAN_DATA *) a_ptr; /* we don't want to add the dot entries to the seen list, * otherwise we'll lose directories in the later cleanup */ if ((a_fs_file->name) && (a_fs_file->name->name) && (TSK_FS_ISDOT(a_fs_file->name->name))) return TSK_WALK_CONT; // add this entry to the orphan list if (a_fs_file->meta) { tsk_list_add(&data->orphan_subdir_list, a_fs_file->meta->addr); /* FAT file systems spend a lot of time hunting for parent * directory addresses, so we put this code in here to save * the info when we have it. */ if ((a_fs_file->meta->type == TSK_FS_META_TYPE_DIR) && (TSK_FS_TYPE_ISFAT(a_fs_file->fs_info->ftype))) { if (fatfs_dir_buf_add((FATFS_INFO *) a_fs_file->fs_info, a_fs_file->name->par_addr, a_fs_file->meta->addr)) return TSK_WALK_ERROR; } } return TSK_WALK_CONT; } /* used to identify the unnamed metadata structures */ static TSK_WALK_RET_ENUM find_orphan_meta_walk_cb(TSK_FS_FILE * a_fs_file, void *a_ptr) { FIND_ORPHAN_DATA *data = (FIND_ORPHAN_DATA *) a_ptr; TSK_FS_INFO *fs = a_fs_file->fs_info; /* We want only orphans, then check if this * inode is in the seen list */ if ((fs->list_inum_named) && (tsk_list_find(fs->list_inum_named, a_fs_file->meta->addr))) { return TSK_WALK_CONT; } // check if we have already added it as an orphan (in a subdirectory) if (tsk_list_find(data->orphan_subdir_list, a_fs_file->meta->addr)) { return TSK_WALK_CONT; } // use their name if they have one if (a_fs_file->meta->name2) { strncpy(data->fs_name->name, a_fs_file->meta->name2->name, data->fs_name->name_size); } else { snprintf(data->fs_name->name, data->fs_name->name_size, "OrphanFile-%" PRIuINUM, a_fs_file->meta->addr); } data->fs_name->meta_addr = a_fs_file->meta->addr; data->fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; data->fs_name->type = TSK_FS_NAME_TYPE_UNDEF; if (tsk_fs_dir_add(data->fs_dir, data->fs_name)) return TSK_WALK_ERROR; /* FAT file systems spend a lot of time hunting for parent * directory addresses, so we put this code in here to save * the info when we have it. */ if (TSK_FS_TYPE_ISFAT(fs->ftype)) { if (fatfs_dir_buf_add((FATFS_INFO *) fs, TSK_FS_ORPHANDIR_INUM(fs), a_fs_file->meta->addr)) return TSK_WALK_ERROR; } /* Go into directories to mark their contents as "seen" */ if (a_fs_file->meta->type == TSK_FS_META_TYPE_DIR) { if (tsk_fs_dir_walk(fs, a_fs_file->meta->addr, TSK_FS_DIR_WALK_FLAG_UNALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE | TSK_FS_DIR_WALK_FLAG_NOORPHAN, load_orphan_dir_walk_cb, data)) { strncat(tsk_errstr2, " - tsk_fs_dir_load_inum_named: identifying inodes allocated by file names", TSK_ERRSTR_L); return TSK_ERR; } } return TSK_WALK_CONT; } /** \internal * Search the file system for orphan files and create the orphan file directory. * @param a_fs File system to search * @param a_fs_dir Structure to store the orphan file directory info in. */ TSK_RETVAL_ENUM tsk_fs_dir_find_orphans(TSK_FS_INFO * a_fs, TSK_FS_DIR * a_fs_dir) { FIND_ORPHAN_DATA data; size_t i; if (a_fs->orphan_dir != NULL) { if (tsk_fs_dir_copy(a_fs->orphan_dir, a_fs_dir)) return TSK_ERR; return TSK_OK; } if (a_fs->isOrphanHunting) { return TSK_OK; } a_fs->isOrphanHunting = 1; memset(&data, 0, sizeof(FIND_ORPHAN_DATA)); /* We first need to determine which of the unallocated meta structures * have a name pointing to them. We cache this data, so see if it is * already known. */ if (a_fs->list_inum_named == NULL) { a_fs->isOrphanHunting = 0; if (tsk_fs_dir_load_inum_named(a_fs) != TSK_OK) { return TSK_ERR; } a_fs->isOrphanHunting = 1; // note that list_inum_named could still be NULL if there are no deleted names. } /* Now we walk the unallocated metadata structures and find ones that are * not named. The callback will add the names to the FS_DIR structure. */ data.fs_dir = a_fs_dir; // allocate a name once so that we will reuse for each name we add to FS_DIR if ((data.fs_name = tsk_fs_name_alloc(256, 0)) == NULL) { a_fs->isOrphanHunting = 0; return TSK_ERR; } if (tsk_fs_meta_walk(a_fs, a_fs->first_inum, a_fs->last_inum, TSK_FS_META_FLAG_UNALLOC | TSK_FS_META_FLAG_USED, find_orphan_meta_walk_cb, &data)) { a_fs->isOrphanHunting = 0; tsk_fs_name_free(data.fs_name); return TSK_ERR; } tsk_fs_name_free(data.fs_name); /* do some cleanup on the final list. This cleanup will compare the * entries in the root orphan directory with files that can be accessed * from subdirectories of the orphan directory. These entries will exist if * they were added before their parent directory was added to the orphan directory. */ for (i = 0; i < a_fs_dir->names_used; i++) { if (tsk_list_find(data.orphan_subdir_list, a_fs_dir->names[i].meta_addr)) { if (a_fs_dir->names_used > 1) { tsk_fs_name_copy(&a_fs_dir->names[i], &a_fs_dir->names[a_fs_dir->names_used - 1]); } a_fs_dir->names_used--; } } // make copy of this so that we don't need to do it again. if ((a_fs->orphan_dir = tsk_fs_dir_alloc(a_fs, a_fs_dir->addr, a_fs_dir->names_used)) == NULL) { a_fs->isOrphanHunting = 0; return TSK_ERR; } if (tsk_fs_dir_copy(a_fs_dir, a_fs->orphan_dir)) { tsk_fs_dir_close(a_fs->orphan_dir); a_fs->orphan_dir = NULL; a_fs->isOrphanHunting = 0; return TSK_ERR; } // populate the fake FS_FILE structure for the "Orphan Directory" /* Get the inode and verify it has attributes */ if ((a_fs_dir->fs_file = tsk_fs_file_alloc(a_fs)) == NULL) { a_fs->isOrphanHunting = 0; return TSK_ERR; } if ((a_fs_dir->fs_file->meta = tsk_fs_meta_alloc(sizeof(TSK_DADDR_T))) == NULL) { a_fs->isOrphanHunting = 0; return TSK_ERR; } if (tsk_fs_dir_make_orphan_dir_meta(a_fs, a_fs_dir->fs_file->meta)) { a_fs->isOrphanHunting = 0; return TSK_ERR; } if (data.orphan_subdir_list) tsk_list_free(data.orphan_subdir_list); a_fs->isOrphanHunting = 0; return TSK_OK; } sleuthkit-3.2.3/tsk3/fs/fs_file.c000644 000765 000024 00000041122 11643647440 017405 0ustar00carrierstaff000000 000000 /* * fs_file * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 * */ /** * \file fs_file.c * Create, manage, etc. the TSK_FS_FILE structures. */ #include "tsk_fs_i.h" /** * \internal * Allocate a new FS_FILE structure * @param a_fs File system fiel will be in. * @returns NULL on error */ TSK_FS_FILE * tsk_fs_file_alloc(TSK_FS_INFO * a_fs) { TSK_FS_FILE *fs_file; fs_file = (TSK_FS_FILE *) tsk_malloc(sizeof(TSK_FS_FILE)); if (fs_file == NULL) return NULL; fs_file->fs_info = a_fs; fs_file->tag = TSK_FS_FILE_TAG; return fs_file; } /** \internal * * Reset the meta and name structures. * @param a_fs_file File to reset */ void tsk_fs_file_reset(TSK_FS_FILE * a_fs_file) { if (a_fs_file->meta) tsk_fs_meta_reset(a_fs_file->meta); if (a_fs_file->name) tsk_fs_name_reset(a_fs_file->name); } /** * \ingroup fslib * Close an open file. * @param a_fs_file Pointer to open file */ void tsk_fs_file_close(TSK_FS_FILE * a_fs_file) { if ((a_fs_file == NULL) || (a_fs_file->tag != TSK_FS_FILE_TAG)) return; a_fs_file->tag = 0; if (a_fs_file->meta) { tsk_fs_meta_close(a_fs_file->meta); a_fs_file->meta = NULL; } if (a_fs_file->name) { tsk_fs_name_free(a_fs_file->name); a_fs_file->name = NULL; } free(a_fs_file); } /** * \ingroup fslib * * Open a file given its metadata address. This function loads the metadata * and returns a handle that can be used to read and process the file. Note * that the returned TSK_FS_FILE structure will not have the file name set because * it was not used to load the file and this function does not search the * directory structure to find the name that points to the address. In general, * if you know the metadata address of a file, this function is more effecient * then tsk_fs_file_open, which first maps a file name to the metadata address * and then opens the file using this function. * * @param a_fs File system to analyze * @param a_fs_file Structure to store file data in or NULL to have one allocated. * @param a_addr Metadata address of file to lookup * @returns NULL on error */ TSK_FS_FILE * tsk_fs_file_open_meta(TSK_FS_INFO * a_fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T a_addr) { TSK_FS_FILE *fs_file; if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_open_meta: called with NULL or unallocated structures"); return NULL; } fs_file = a_fs_file; if (fs_file == NULL) { if ((fs_file = tsk_fs_file_alloc(a_fs)) == NULL) return NULL; } else { /* if the structure passed has a name structure, free it * because we won't use it. */ if (fs_file->name) { tsk_fs_name_free(fs_file->name); fs_file->name = NULL; } // reset the rest of it tsk_fs_file_reset(fs_file); } if (a_fs->file_add_meta(a_fs, fs_file, a_addr)) { if (a_fs_file == NULL) free(fs_file); return NULL; } return fs_file; } /** * \ingroup fslib * Return the handle structure for a specific file, given its full path. Note that * if you have the metadata address fo the file, then tsk_fs_file_open_meta() is a * more effecient approach. * * @param a_fs File system to analyze * @param a_fs_file Structure to store file data in or NULL to have one allocated. * @param a_path Path of file to open * @returns NULL on error */ TSK_FS_FILE * tsk_fs_file_open(TSK_FS_INFO * a_fs, TSK_FS_FILE * a_fs_file, const char *a_path) { TSK_INUM_T inum; int8_t retval; TSK_FS_FILE *fs_file = NULL; TSK_FS_NAME *fs_name = NULL; if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_open: called with NULL or unallocated structures"); return NULL; } // allocate a structure to store the name in if ((fs_name = tsk_fs_name_alloc(128, 32)) == NULL) { return NULL; } retval = tsk_fs_path2inum(a_fs, a_path, &inum, fs_name); if (retval == -1) { tsk_fs_name_free(fs_name); return NULL; } else if (retval == 1) { tsk_fs_name_free(fs_name); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_open: path not found: %s", a_path); return NULL; } fs_file = tsk_fs_file_open_meta(a_fs, a_fs_file, inum); if (fs_file) { // Add the name to the structure fs_file->name = fs_name; } else { tsk_fs_name_free(fs_name); } return fs_file; } /** \internal * Check the arguments for the tsk_fs_file_attr_XXX functions * and load the attributes if needed. * @param a_fs_file File argument to check. * @param a_func Name of function that this is checking for (for error messages) * @returns 1 on error */ static int tsk_fs_file_attr_check(TSK_FS_FILE * a_fs_file, char *a_func) { TSK_FS_INFO *fs; // check the FS_INFO, FS_FILE structures if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: called with NULL pointers", a_func); return 1; } else if (a_fs_file->meta->tag != TSK_FS_META_TAG) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: called with unallocated structures", a_func); return 1; } fs = a_fs_file->fs_info; // If the attributes haven't been loaded, then load them. if (a_fs_file->meta->attr_state == TSK_FS_META_ATTR_ERROR) { tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: called for file with corrupt data", a_func); return 1; } else if ((a_fs_file->meta->attr_state != TSK_FS_META_ATTR_STUDIED) || (a_fs_file->meta->attr == NULL)) { if (fs->load_attrs(a_fs_file)) { return 1; } } return 0; } /** \ingroup fslib * Return the number of attributes in the file. * * @param a_fs_file File to return attribute count for * @returns number of attributes in file */ int tsk_fs_file_attr_getsize(TSK_FS_FILE * a_fs_file) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_getsize")) return 0; return tsk_fs_attrlist_get_len(a_fs_file->meta->attr); } /** \ingroup fslib * Get a file's attribute based on the 0-based index in the list (and not type, id pair). * @param a_fs_file File to get attributes from. * @param a_idx 0-based index of attribute to return. * @returns Pointer to attribute or NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get_idx(TSK_FS_FILE * a_fs_file, int a_idx) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get_idx")) return NULL; return tsk_fs_attrlist_get_idx(a_fs_file->meta->attr, a_idx); } /** \ingroup fslib * Return the default attribute for the file * @param a_fs_file File to get data from * @returns NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get(TSK_FS_FILE * a_fs_file) { TSK_FS_ATTR_TYPE_ENUM type; TSK_FS_INFO *fs; if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get")) return NULL; // since they did not give us a type, get the default for the file fs = a_fs_file->fs_info; type = fs->get_default_attr_type(a_fs_file); return tsk_fs_attrlist_get(a_fs_file->meta->attr, type); } /** \ingroup fslib * Return a specific type and id attribute for the file. * @param a_fs_file File to get data from * @param a_type Type of attribute to load * @param a_id Id of attribute to load * @param a_id_used Set to 1 if ID is actually set or 0 to use default * @returns NULL on error */ const TSK_FS_ATTR * tsk_fs_file_attr_get_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id, uint8_t a_id_used) { if (tsk_fs_file_attr_check(a_fs_file, "tsk_fs_file_attr_get_type")) return NULL; if (a_id_used) return tsk_fs_attrlist_get_id(a_fs_file->meta->attr, a_type, a_id); else return tsk_fs_attrlist_get(a_fs_file->meta->attr, a_type); } /** * \ingroup fslib * Process a specific attribute in a file and call a callback function with the file contents. The callback will be * called with chunks of data that are fs->block_size or less. The address given in the callback * will be correct only for raw files (when the raw file contents were stored in the block). For * compressed and sparse files, the address may be zero. If the file system you are analyzing does * not have multiple attributes per file, then you can use tsk_fs_file_walk(). For incomplete or * corrupt files, some missing runs will be identified as SPARSE and zeros will be returned in the content. * * @param a_fs_file File to process * @param a_type Attribute type to process * @param a_id Id if attribute to process * @param a_flags Flags to use while processing file * @param a_action Callback action to call with content * @param a_ptr Pointer that will passed to callback * @returns 1 on error and 0 on success. */ uint8_t tsk_fs_file_walk_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr) { const TSK_FS_ATTR *fs_attr; TSK_FS_INFO *fs; // clean up any error messages that are lying around tsk_error_reset(); // check the FS_INFO, FS_FILE structures if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk: called with NULL pointers"); return 1; } else if ((a_fs_file->fs_info->tag != TSK_FS_INFO_TAG) || (a_fs_file->meta->tag != TSK_FS_META_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk: called with unallocated structures"); return 1; } fs = a_fs_file->fs_info; if (tsk_verbose) tsk_fprintf(stderr, "tsk_fs_file_walk: Processing file %" PRIuINUM "\n", a_fs_file->meta->addr); if ((fs_attr = tsk_fs_file_attr_get_type(a_fs_file, a_type, a_id, (a_flags & TSK_FS_FILE_WALK_FLAG_NOID) ? 0 : 1)) == NULL) return 1; return tsk_fs_attr_walk(fs_attr, a_flags, a_action, a_ptr); } /** * \ingroup fslib * Process a file and call a callback function with the file contents. The callback will be * called with chunks of data that are fs->block_size or less. The address given in the callback * will be correct only for raw files (when the raw file contents were stored in the block). For * compressed and sparse files, the address may be zero. If a file has multiple attributes, * such as NTFS files, this function uses the default one ($DATA for files, $IDX_ROOT for directories). * Use tsk_fs_file_walk_type to specify an attribute. * * @param a_fs_file File to process * @param a_flags Flags to use while processing file * @param a_action Callback action to call with content * @param a_ptr Pointer that will passed to callback * @returns 1 on error and 0 on success. */ uint8_t tsk_fs_file_walk(TSK_FS_FILE * a_fs_file, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr) { const TSK_FS_ATTR *fs_attr; TSK_FS_INFO *fs; // clean up any error messages that are lying around tsk_error_reset(); // check the FS_INFO, FS_FILE structures if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk: called with NULL pointers"); return 1; } else if ((a_fs_file->fs_info->tag != TSK_FS_INFO_TAG) || (a_fs_file->meta->tag != TSK_FS_META_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_walk: called with unallocated structures"); return 1; } fs = a_fs_file->fs_info; if (tsk_verbose) tsk_fprintf(stderr, "tsk_fs_file_walk: Processing file %" PRIuINUM "\n", a_fs_file->meta->addr); if ((fs_attr = tsk_fs_file_attr_get(a_fs_file)) == NULL) return 1; return tsk_fs_attr_walk(fs_attr, a_flags, a_action, a_ptr); } /** * \ingroup fslib * Read the contents of a specific attribute of a file using a typical read() type interface and be * able specify a specific attribute to read (applies only to file systems with multiple attributes * per file, such as NTFS). 0s are returned for missing runs of files. * * @param a_fs_file The file to read from * @param a_type The type of attribute to load * @param a_id The id of attribute to load (use 0 and set a_flags if you do not care) * @param a_offset The byte offset to start reading from. * @param a_buf The buffer to read the data into. * @param a_len The number of bytes to read from the file. * @param a_flags Flags to use while reading * @returns The number of bytes read or -1 on error (incl if offset is past EOF). */ ssize_t tsk_fs_file_read_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id, TSK_OFF_T a_offset, char *a_buf, size_t a_len, TSK_FS_FILE_READ_FLAG_ENUM a_flags) { TSK_FS_INFO *fs; const TSK_FS_ATTR *fs_attr; // clean up any error messages that are lying around tsk_error_reset(); // check the FS_INFO, FS_FILE structures if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_read: called with NULL pointers"); return -1; } else if ((a_fs_file->fs_info->tag != TSK_FS_INFO_TAG) || (a_fs_file->meta->tag != TSK_FS_META_TAG)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_read: called with unallocated structures"); return -1; } fs = a_fs_file->fs_info; if ((fs_attr = tsk_fs_file_attr_get_type(a_fs_file, a_type, a_id, (a_flags & TSK_FS_FILE_READ_FLAG_NOID) ? 0 : 1)) == NULL) { return -1; } return tsk_fs_attr_read(fs_attr, a_offset, a_buf, a_len, a_flags); } /** * \ingroup fslib * Read the contents of a specific attribute of a file using a typical read() type interface. * 0s are returned for missing runs of files. * * @param a_fs_file The inode structure of the file to read. * @param a_offset The byte offset to start reading from. * @param a_buf The buffer to read the data into. * @param a_len The number of bytes to read from the file. * @param a_flags Flags to use while reading * @returns The number of bytes read or -1 on error (incl if offset is past EOF). */ ssize_t tsk_fs_file_read(TSK_FS_FILE * a_fs_file, TSK_OFF_T a_offset, char *a_buf, size_t a_len, TSK_FS_FILE_READ_FLAG_ENUM a_flags) { const TSK_FS_ATTR *fs_attr; if ((a_fs_file == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_read: fs_info is NULL"); return -1; } if ((fs_attr = tsk_fs_file_attr_get(a_fs_file)) == NULL) { return -1; } return tsk_fs_attr_read(fs_attr, a_offset, a_buf, a_len, a_flags); } /** * Returns a string representation of the security attributes of a file. * * @param a_fs_file The file to get security info about. * @param sid_str A pointer to a pointer that will contain the SID string. This function will allocate the string and the caller must free it. * @returns 0 on success or 1 on error. */ uint8_t tsk_fs_file_get_owner_sid(TSK_FS_FILE * a_fs_file, char **sid_str) { if ((a_fs_file == NULL) || (a_fs_file->fs_info == NULL) || (a_fs_file->meta == NULL) || (sid_str == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_file_get_owner_sid: fs_info is NULL"); return 1; } // Make sure the function pointer is not NULL. // This function will only work on NTFS filesystems. if (!a_fs_file->fs_info->fread_owner_sid) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Unsupported function"); return 1; } return a_fs_file->fs_info->fread_owner_sid(a_fs_file, sid_str); } sleuthkit-3.2.3/tsk3/fs/fs_inode.c000644 000765 000024 00000012022 11643647440 017561 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved * * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** * \file fs_inode.c * Contains functions to allocate, free, and process the generic inode * structures */ #include "tsk_fs_i.h" /** * Contains the short (1 character) name of the file type */ char tsk_fs_meta_type_str[TSK_FS_META_TYPE_STR_MAX][2] = { "-", "r", "d", "p", "c", "b", "l", "s", "h", "w", "v" }; /** * \internal * Allocates a generic inode / metadata structure. * * @param a_buf_len Number of bytes needed to store fs-specific data regarding where content is stored. * @returns NULL on error */ TSK_FS_META * tsk_fs_meta_alloc(size_t a_buf_len) { TSK_FS_META *fs_meta; if ((fs_meta = (TSK_FS_META *) tsk_malloc(sizeof(TSK_FS_META))) == NULL) return NULL; fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (a_buf_len > 0) { if ((fs_meta->content_ptr = tsk_malloc(a_buf_len)) == NULL) { free(fs_meta); return NULL; } fs_meta->content_len = a_buf_len; } // assign the id so we know the structure is still alloc fs_meta->tag = TSK_FS_META_TAG; return (fs_meta); } /** * \internal * Resize an existing TSK_FS_META structure -- changes the number of * block pointers. * * @param fs_meta Structure to resize * @param direct_count Number of direct block address pointers to include in structure * @param indir_count Number of indirect block address pointers to include in structure * @return NULL on error */ TSK_FS_META * tsk_fs_meta_realloc(TSK_FS_META * a_fs_meta, size_t a_buf_len) { if (a_fs_meta->content_len != a_buf_len) { a_fs_meta->content_len = a_buf_len; a_fs_meta->content_ptr = tsk_realloc((char *) a_fs_meta->content_ptr, a_buf_len); if (a_fs_meta->content_ptr == NULL) { return NULL; } } return (a_fs_meta); } /** * \internal * Free the memory allocated to the TSK_FS_META structure. * * @param fs_meta Structure to free */ void tsk_fs_meta_close(TSK_FS_META * fs_meta) { TSK_FS_META_NAME_LIST *fs_name, *fs_name2; if ((!fs_meta) || (fs_meta->tag != TSK_FS_META_TAG)) return; // clear the tag so we know the structure isn't alloc fs_meta->tag = 0; if (fs_meta->content_ptr) free((char *) fs_meta->content_ptr); fs_meta->content_ptr = NULL; fs_meta->content_len = 0; if (fs_meta->attr) tsk_fs_attrlist_free(fs_meta->attr); fs_meta->attr = NULL; if (fs_meta->link) free(fs_meta->link); fs_meta->link = NULL; fs_name = fs_meta->name2; while (fs_name) { fs_name2 = fs_name->next; fs_name->next = NULL; free(fs_name); fs_name = fs_name2; } free((char *) fs_meta); } /** \internal * Reset the contents of a TSK_FS_META structure. * @param a_fs_meta Structure to reset */ void tsk_fs_meta_reset(TSK_FS_META * a_fs_meta) { void *content_ptr_tmp; size_t content_len_tmp; TSK_FS_ATTRLIST *attr_tmp; TSK_FS_META_NAME_LIST *name2_tmp; char *link_tmp; // backup pointers content_ptr_tmp = a_fs_meta->content_ptr; content_len_tmp = a_fs_meta->content_len; attr_tmp = a_fs_meta->attr; name2_tmp = a_fs_meta->name2; link_tmp = a_fs_meta->link; // clear all data memset(a_fs_meta, 0, sizeof(TSK_FS_META)); a_fs_meta->tag = TSK_FS_META_TAG; // restore and clear the pointers a_fs_meta->content_ptr = content_ptr_tmp; a_fs_meta->content_len = content_len_tmp; a_fs_meta->attr = attr_tmp; a_fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; a_fs_meta->name2 = name2_tmp; a_fs_meta->link = link_tmp; if (a_fs_meta->link) a_fs_meta->link[0] = '\0'; if (a_fs_meta->name2) { name2_tmp = a_fs_meta->name2; while (name2_tmp) { name2_tmp->name[0] = '\0'; name2_tmp->par_inode = 0; name2_tmp->par_seq = 0; name2_tmp = name2_tmp->next; } } } /** * \ingroup fslib * Walk a range of metadata structures and call a callback for each * structure that matches the flags supplied. For example, it can * call the callback on only allocated or unallocated entries. * * @param a_fs File system to process * @param a_start Metadata address to start walking from * @param a_end Metadata address to walk to * @param a_flags Flags that specify the desired metadata features * @param a_cb Callback function to call * @param a_ptr Pointer to pass to the callback * @returns 1 on error and 0 on success */ uint8_t tsk_fs_meta_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_start, TSK_INUM_T a_end, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_cb, void *a_ptr) { if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) return 1; return a_fs->inode_walk(a_fs, a_start, a_end, a_flags, a_cb, a_ptr); } sleuthkit-3.2.3/tsk3/fs/fs_io.c000644 000765 000024 00000012662 11643647440 017104 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved * Copyright (c) 2003-2005 Brian Carrier. All rights reserved * * Copyright (c) 1997,1998,1999, International Business Machines * Corporation and others. All Rights Reserved. * * * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** \file fs_io.c * Contains functions to read data from a disk image and wrapper functions to read file content. */ #include #include "tsk_fs_i.h" /** \internal * Internal method to deal with calculating correct offset when we have pre and post bytes * in teh file system blocks (i.e. RAW Cds) * @param a_fs File system being analyzed * @param a_off Byte offset into file system (i.e. not offset into image) * @param a_buf Buffer to write data into * @param a_len Number of bytes to read * @retuns Number of bytes read or -1 on error */ static ssize_t fs_prepost_read(TSK_FS_INFO *a_fs, TSK_OFF_T a_off, char *a_buf, size_t a_len) { TSK_OFF_T cur_off = a_off; TSK_OFF_T end_off = a_off + a_len; ssize_t cur_idx = 0; // we need to read block by block so that we can skip the needed pre and post bytes while (cur_off < end_off) { TSK_OFF_T read_off; ssize_t retval2 = 0; TSK_DADDR_T blk = cur_off / a_fs->block_size; size_t read_len = a_fs->block_size - cur_off % a_fs->block_size; if (read_len + cur_off > end_off) read_len = end_off - cur_off; read_off = a_fs->offset + cur_off + blk * (a_fs->block_pre_size + a_fs->block_post_size) + a_fs->block_pre_size; if (tsk_verbose) fprintf(stderr, "fs_prepost_read: Mapped %"PRIuOFF" to %"PRIuOFF"\n", cur_off, read_off); retval2 = tsk_img_read(a_fs->img_info, read_off, &a_buf[cur_idx], read_len); if (retval2 == -1) return -1; else if (retval2 == 0) break; cur_idx += retval2; cur_off += retval2; } return cur_idx; } /** * \ingroup fslib * Read arbitrary data from inside of the file system. * @param a_fs The file system handle. * @param a_off The byte offset to start reading from (relative to start of file system) * @param a_buf The buffer to store the block in. * @param a_len The number of bytes to read * @return The number of bytes read or -1 on error. */ ssize_t tsk_fs_read(TSK_FS_INFO * a_fs, TSK_OFF_T a_off, char *a_buf, size_t a_len) { // do a sanity check on the read bounds, but only if the block // value has been set. // note that this could prevent us from viewing the FS slack... if ((a_fs->last_block_act > 0) && ((TSK_DADDR_T) a_off >= ((a_fs->last_block_act + 1) * a_fs->block_size))) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; if ((TSK_DADDR_T) a_off < ((a_fs->last_block + 1) * a_fs->block_size)) snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_read: Offset missing in partial image: %" PRIuDADDR ")", a_off); else snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_read: Offset is too large for image: %" PRIuDADDR ")", a_off); return -1; } if (((a_fs->block_pre_size) || (a_fs->block_post_size)) && (a_fs->block_size)) { return fs_prepost_read(a_fs, a_off, a_buf, a_len); } else { return tsk_img_read(a_fs->img_info, a_off + a_fs->offset, a_buf, a_len); } } /** * \ingroup fslib * Read a file system block into a char* buffer. * This is actually a wrapper around the fs_read_random function, * but it allows the starting location to be specified as a block address. * * @param a_fs The file system structure. * @param a_addr The starting block file system address. * @param a_buf The char * buffer to store the block data in. * @param a_len The number of bytes to read (must be a multiple of the block size) * @return The number of bytes read or -1 on error. */ ssize_t tsk_fs_read_block(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr, char *a_buf, size_t a_len) { if (a_len % a_fs->block_size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_read_block: length %" PRIuSIZE "" " not a multiple of %d", a_len, a_fs->block_size); return -1; } if (a_addr > a_fs->last_block_act) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; if (a_addr <= a_fs->last_block) snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_read_block: Address missing in partial image: %" PRIuDADDR ")", a_addr); else snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_read_block: Address is too large for image: %" PRIuDADDR ")", a_addr); return -1; } if ((a_fs->block_pre_size == 0) && (a_fs->block_post_size == 0)) { TSK_OFF_T off = a_fs->offset + (TSK_OFF_T) (a_addr) * a_fs->block_size; return tsk_img_read(a_fs->img_info, off, a_buf, a_len); } else { TSK_OFF_T off = (TSK_OFF_T) (a_addr) * a_fs->block_size; return fs_prepost_read(a_fs, off, a_buf, a_len); } } sleuthkit-3.2.3/tsk3/fs/fs_load.c000644 000765 000024 00000001771 11643647440 017413 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 * */ /** \file fs_load.c * Contains a general file walk callback that can be * used to load file content into a buffer. */ #include "tsk_fs_i.h" /* File Walk Action to load the journal * TSK_FS_LOAD_FILE is defined in fs_tools.h */ TSK_WALK_RET_ENUM tsk_fs_load_file_action(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { TSK_FS_LOAD_FILE *buf1 = (TSK_FS_LOAD_FILE *) ptr; size_t cp_size; if (size > buf1->left) cp_size = buf1->left; else cp_size = size; memcpy(buf1->cur, buf, cp_size); buf1->left -= cp_size; buf1->cur = (char *) ((uintptr_t) buf1->cur + cp_size); if (buf1->left > 0) return TSK_WALK_CONT; else return TSK_WALK_STOP; } sleuthkit-3.2.3/tsk3/fs/fs_name.c000644 000765 000024 00000044674 11643647440 017425 0ustar00carrierstaff000000 000000 /* ** fs_name ** The Sleuth Kit ** ** Display and manipulate directory entries ** This file contains generic functions that call the appropriate function ** depending on the file system type. ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /** * \file fs_name.c * Code to allocate and free the TSK_FS_NAME structures. */ #include "tsk_fs_i.h" char tsk_fs_name_type_str[TSK_FS_NAME_TYPE_STR_MAX][2] = { "-", "p", "c", "d", "b", "r", "l", "s", "h", "w", "v" }; /** * \internal * Allocate a fs_name structure */ TSK_FS_NAME * tsk_fs_name_alloc(size_t norm_namelen, size_t shrt_namelen) { TSK_FS_NAME *fs_name; fs_name = (TSK_FS_NAME *) tsk_malloc(sizeof(*fs_name)); if (fs_name == NULL) return NULL; fs_name->name = (char *) tsk_malloc(norm_namelen + 1); if (fs_name->name == NULL) { free(fs_name); return NULL; } fs_name->name_size = norm_namelen; fs_name->flags = 0; fs_name->shrt_name_size = shrt_namelen; if (shrt_namelen == 0) { fs_name->shrt_name = NULL; } else { fs_name->shrt_name = (char *) tsk_malloc(shrt_namelen + 1); if (fs_name->shrt_name == NULL) { free(fs_name->name); free(fs_name); return NULL; } } fs_name->type = TSK_FS_NAME_TYPE_UNDEF; fs_name->tag = TSK_FS_NAME_TAG; return fs_name; } /** * \internal * returns 1 on error */ uint8_t tsk_fs_name_realloc(TSK_FS_NAME * fs_name, size_t namelen) { if ((fs_name == NULL) || (fs_name->tag != TSK_FS_NAME_TAG)) return 1; if (fs_name->name_size >= namelen) return 0; fs_name->name = (char *) tsk_realloc(fs_name->name, namelen + 1); if (fs_name->name == NULL) { fs_name->name_size = 0; return 1; } fs_name->type = TSK_FS_NAME_TYPE_UNDEF; fs_name->name_size = namelen; return 0; } /** * \internal * reset the values in the TSK_FS_NAME structure * @param a_fs_name Name structure to reset */ void tsk_fs_name_reset(TSK_FS_NAME * a_fs_name) { if (a_fs_name->name) a_fs_name->name[0] = '\0'; if (a_fs_name->shrt_name) a_fs_name->shrt_name[0] = '\0'; a_fs_name->meta_addr = 0; a_fs_name->meta_seq = 0; a_fs_name->par_addr = 0; a_fs_name->type = 0; a_fs_name->flags = 0; } /** * \internal */ void tsk_fs_name_free(TSK_FS_NAME * fs_name) { if ((!fs_name) || (fs_name->tag != TSK_FS_NAME_TAG)) return; if (fs_name->name) { free(fs_name->name); fs_name->name = NULL; } if (fs_name->shrt_name) { free(fs_name->shrt_name); fs_name->shrt_name = NULL; } free(fs_name); } /** \internal * Copy the contents of a TSK_FS_NAME structure to another * structure. * @param a_fs_name_to Destination structure to copy to * @param a_fs_name_from Source structure to copy from * @returns 1 on error */ uint8_t tsk_fs_name_copy(TSK_FS_NAME * a_fs_name_to, const TSK_FS_NAME * a_fs_name_from) { if ((a_fs_name_to == NULL) || (a_fs_name_from == NULL)) return 1; /* If the source has a full name, copy it */ if (a_fs_name_from->name) { // make sure there is enough space if (strlen(a_fs_name_from->name) >= a_fs_name_to->name_size) { a_fs_name_to->name_size = strlen(a_fs_name_from->name) + 16; a_fs_name_to->name = (char *) tsk_realloc(a_fs_name_to->name, a_fs_name_to->name_size); if (a_fs_name_to->name == NULL) return 1; } strncpy(a_fs_name_to->name, a_fs_name_from->name, a_fs_name_to->name_size); } else { if (a_fs_name_to->name_size > 0) a_fs_name_to->name[0] = '\0'; else a_fs_name_to->name = NULL; } // copy the short name, if one exists if (a_fs_name_from->shrt_name) { if (strlen(a_fs_name_from->shrt_name) >= a_fs_name_to->shrt_name_size) { a_fs_name_to->shrt_name_size = strlen(a_fs_name_from->shrt_name) + 16; a_fs_name_to->shrt_name = (char *) tsk_realloc(a_fs_name_to->shrt_name, a_fs_name_to->shrt_name_size); if (a_fs_name_to->shrt_name == NULL) return 1; } strncpy(a_fs_name_to->shrt_name, a_fs_name_from->shrt_name, a_fs_name_to->shrt_name_size); } else { if (a_fs_name_to->shrt_name_size > 0) a_fs_name_to->shrt_name[0] = '\0'; else a_fs_name_to->shrt_name = NULL; } a_fs_name_to->meta_addr = a_fs_name_from->meta_addr; a_fs_name_to->meta_seq = a_fs_name_from->meta_seq; a_fs_name_to->par_addr = a_fs_name_from->par_addr; a_fs_name_to->type = a_fs_name_from->type; a_fs_name_to->flags = a_fs_name_from->flags; return 0; } /*********************************************************************** * Printing functions ***********************************************************************/ /** * \ingroup fslib * Makes the "ls -l" permissions string for a file. * * @param a_fs_meta File to be processed * @param a_buf [out] Buffer to write results to (must be 12 bytes or longer) * @param a_len Length of buffer */ uint8_t tsk_fs_meta_make_ls(TSK_FS_META * a_fs_meta, char *a_buf, size_t a_len) { if (a_len < 12) { return 1; } /* put the default values in */ strcpy(a_buf, "----------"); if (a_fs_meta->type < TSK_FS_META_TYPE_STR_MAX) a_buf[0] = tsk_fs_meta_type_str[a_fs_meta->type][0]; /* user perms */ if (a_fs_meta->mode & TSK_FS_META_MODE_IRUSR) a_buf[1] = 'r'; if (a_fs_meta->mode & TSK_FS_META_MODE_IWUSR) a_buf[2] = 'w'; /* set uid */ if (a_fs_meta->mode & TSK_FS_META_MODE_ISUID) { if (a_fs_meta->mode & TSK_FS_META_MODE_IXUSR) a_buf[3] = 's'; else a_buf[3] = 'S'; } else if (a_fs_meta->mode & TSK_FS_META_MODE_IXUSR) a_buf[3] = 'x'; /* group perms */ if (a_fs_meta->mode & TSK_FS_META_MODE_IRGRP) a_buf[4] = 'r'; if (a_fs_meta->mode & TSK_FS_META_MODE_IWGRP) a_buf[5] = 'w'; /* set gid */ if (a_fs_meta->mode & TSK_FS_META_MODE_ISGID) { if (a_fs_meta->mode & TSK_FS_META_MODE_IXGRP) a_buf[6] = 's'; else a_buf[6] = 'S'; } else if (a_fs_meta->mode & TSK_FS_META_MODE_IXGRP) a_buf[6] = 'x'; /* other perms */ if (a_fs_meta->mode & TSK_FS_META_MODE_IROTH) a_buf[7] = 'r'; if (a_fs_meta->mode & TSK_FS_META_MODE_IWOTH) a_buf[8] = 'w'; /* sticky bit */ if (a_fs_meta->mode & TSK_FS_META_MODE_ISVTX) { if (a_fs_meta->mode & TSK_FS_META_MODE_IXOTH) a_buf[9] = 't'; else a_buf[9] = 'T'; } else if (a_fs_meta->mode & TSK_FS_META_MODE_IXOTH) a_buf[9] = 'x'; return 0; } static void tsk_fs_print_time(FILE * hFile, time_t time) { if (time <= 0) { tsk_fprintf(hFile, "0000-00-00 00:00:00 (UTC)"); } else { struct tm *tmTime = localtime(&time); tsk_fprintf(hFile, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, tmTime->tm_hour, (int) tmTime->tm_min, (int) tmTime->tm_sec, tzname[(tmTime->tm_isdst == 0) ? 0 : 1]); } } /** * The only difference with this one is that the time is always * 00:00:00, which is applicable for the A-Time in FAT, which does * not have a time and if we do it normally it gets messed up because * of the timezone conversion */ static void tsk_fs_print_day(FILE * hFile, time_t time) { if (time <= 0) { tsk_fprintf(hFile, "0000-00-00 00:00:00 (UTC)"); } else { struct tm *tmTime = localtime(&time); tsk_fprintf(hFile, "%.4d-%.2d-%.2d 00:00:00 (%s)", (int) tmTime->tm_year + 1900, (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday, tzname[(tmTime->tm_isdst == 0) ? 0 : 1]); } } /** * \internal * Simple print of dentry type / inode type, deleted, inode, and * name * * fs_attr is used for alternate data streams in NTFS, set to NULL * for all other file systems * * A newline is not printed at the end * * If path is NULL, then skip else use. it has the full directory name * It needs to end with "/" */ void tsk_fs_name_print(FILE * hFile, const TSK_FS_FILE * fs_file, const char *a_path, TSK_FS_INFO * fs, const TSK_FS_ATTR * fs_attr, uint8_t print_path) { size_t i; /* type of file - based on dentry type */ if (fs_file->name->type < TSK_FS_NAME_TYPE_STR_MAX) tsk_fprintf(hFile, "%s/", tsk_fs_name_type_str[fs_file->name->type]); else tsk_fprintf(hFile, "-/"); /* type of file - based on inode type: we want letters though for * regular files so we use the dent_str though */ if (fs_file->meta) { /* * An NTFS directory can have a Data stream, in which * case it would be printed with modes of a * directory, although it is really a file * So, to avoid confusion we will set the modes * to a file so it is printed that way. The * entry for the directory itself will still be * printed as a directory */ if ((fs_attr) && (fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) && (fs_file->meta->type == TSK_FS_META_TYPE_DIR)) { tsk_fprintf(hFile, "r "); } else { if (fs_file->meta->type < TSK_FS_META_TYPE_STR_MAX) tsk_fprintf(hFile, "%s ", tsk_fs_meta_type_str[fs_file->meta->type]); else tsk_fprintf(hFile, "- "); } } else { tsk_fprintf(hFile, "- "); } /* print a * if it is deleted */ if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC) tsk_fprintf(hFile, "* "); tsk_fprintf(hFile, "%" PRIuINUM "", fs_file->name->meta_addr); /* print the id and type if we have fs_attr (NTFS) */ if (fs_attr) tsk_fprintf(hFile, "-%" PRIu32 "-%" PRIu16 "", fs_attr->type, fs_attr->id); tsk_fprintf(hFile, "%s:\t", ((fs_file->meta) && (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) && (fs_file-> name->flags & TSK_FS_NAME_FLAG_UNALLOC)) ? "(realloc)" : ""); if ((print_path) && (a_path != NULL)) { for (i = 0; i < strlen(a_path); i++) { if (TSK_IS_CNTRL(a_path[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", a_path[i]); } } for (i = 0; i < strlen(fs_file->name->name); i++) { if (TSK_IS_CNTRL(fs_file->name->name[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", fs_file->name->name[i]); } /* This will add the short name in parentheses if (fs_file->name->shrt_name != NULL && fs_file->name->shrt_name[0] != '\0') tsk_fprintf(hFile, " (%s)", fs_file->name->shrt_name); */ /* print the data stream name if we the non-data NTFS stream */ if ((fs_attr) && (fs_attr->name)) { if ((fs_attr->type != TSK_FS_ATTR_TYPE_NTFS_IDXROOT) || (strcmp(fs_attr->name, "$I30") != 0)) { tsk_fprintf(hFile, ":"); for (i = 0; i < strlen(fs_attr->name); i++) { if (TSK_IS_CNTRL(fs_attr->name[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", fs_attr->name[i]); } } } return; } /** * \internal * Print contents of fs_name entry format like ls -l ** ** All elements are tab delimited ** ** If path is NULL, then skip else use. it has the full directory name ** It needs to end with "/" */ void tsk_fs_name_print_long(FILE * hFile, const TSK_FS_FILE * fs_file, const char *a_path, TSK_FS_INFO * fs, const TSK_FS_ATTR * fs_attr, uint8_t print_path, int32_t sec_skew) { tsk_fs_name_print(hFile, fs_file, a_path, fs, fs_attr, print_path); if ((fs == NULL) || (fs_file->meta == NULL)) { tsk_fprintf(hFile, "\t"); tsk_fs_print_time(hFile, 0); // mtime tsk_fprintf(hFile, "\t"); tsk_fs_print_time(hFile, 0); // atime tsk_fprintf(hFile, "\t"); tsk_fs_print_time(hFile, 0); // ctime tsk_fprintf(hFile, "\t"); tsk_fs_print_time(hFile, 0); // crtime // size, uid, gid tsk_fprintf(hFile, "\t0\t0\t0\n"); } else { /* MAC times */ tsk_fprintf(hFile, "\t"); if (fs_file->meta->mtime) tsk_fs_print_time(hFile, fs_file->meta->mtime - sec_skew); else tsk_fs_print_time(hFile, fs_file->meta->mtime); tsk_fprintf(hFile, "\t"); /* FAT only gives the day of last access */ if ((TSK_FS_TYPE_ISFAT(fs->ftype)) || (fs_file->meta->atime == 0)) tsk_fs_print_day(hFile, fs_file->meta->atime); else tsk_fs_print_time(hFile, fs_file->meta->atime - sec_skew); tsk_fprintf(hFile, "\t"); if (fs_file->meta->ctime) tsk_fs_print_time(hFile, fs_file->meta->ctime - sec_skew); else tsk_fs_print_time(hFile, fs_file->meta->ctime); tsk_fprintf(hFile, "\t"); if (fs_file->meta->crtime) tsk_fs_print_time(hFile, fs_file->meta->crtime - sec_skew); else tsk_fs_print_time(hFile, fs_file->meta->crtime); /* use the stream size if one was given */ if (fs_attr) tsk_fprintf(hFile, "\t%" PRIuOFF, fs_attr->size); else tsk_fprintf(hFile, "\t%" PRIuOFF, fs_file->meta->size); tsk_fprintf(hFile, "\t%" PRIuGID "\t%" PRIuUID "\n", fs_file->meta->gid, fs_file->meta->uid); } return; } /** * \internal * ** Print output in the format that mactime reads. ** ** If the flags in the fs_file->meta structure are set to FS_FLAG_ALLOC ** then it is assumed that the inode has been reallocated and the ** contents are not displayed ** ** fs is not required (only used for block size). * @param hFile handle to print results to * @param fs_file File to print details about * @param a_path Parent directory of file (needs to end with "/") * @param fs_attr Attribute in file that is being called for (NULL for non-NTFS) * @param prefix Path of mounting point for image * @param time_skew number of seconds skew to adjust time */ void tsk_fs_name_print_mac(FILE * hFile, const TSK_FS_FILE * fs_file, const char *a_path, const TSK_FS_ATTR * fs_attr, const char *prefix, int32_t time_skew) { char ls[12]; size_t i; if ((!hFile) || (!fs_file)) return; /* md5 */ tsk_fprintf(hFile, "0|"); /* file name */ tsk_fprintf(hFile, "%s", prefix); // remove any control chars as we print the names if (a_path != NULL) { for (i = 0; i < strlen(a_path); i++) { if (TSK_IS_CNTRL(a_path[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", a_path[i]); } } for (i = 0; i < strlen(fs_file->name->name); i++) { if (TSK_IS_CNTRL(fs_file->name->name[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", fs_file->name->name[i]); } /* print the data stream name if it exists and is not the default NTFS */ if ((fs_attr) && (fs_attr->name) && ((fs_attr->type != TSK_FS_ATTR_TYPE_NTFS_IDXROOT) || (strcmp(fs_attr->name, "$I30") != 0))) { tsk_fprintf(hFile, ":"); for (i = 0; i < strlen(fs_attr->name); i++) { if (TSK_IS_CNTRL(fs_attr->name[i])) tsk_fprintf(hFile, "^"); else tsk_fprintf(hFile, "%c", fs_attr->name[i]); } } if ((fs_file->meta) && (fs_file->meta->type == TSK_FS_META_TYPE_LNK) && (fs_file->meta->link)) { tsk_fprintf(hFile, " -> %s", fs_file->meta->link); } /* if filename is deleted add a comment and if the inode is now * allocated, then add realloc comment */ if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC) tsk_fprintf(hFile, " (deleted%s)", ((fs_file->meta) && (fs_file-> meta->flags & TSK_FS_META_FLAG_ALLOC)) ? "-realloc" : ""); /* inode */ tsk_fprintf(hFile, "|%" PRIuINUM, fs_file->name->meta_addr); if (fs_attr) tsk_fprintf(hFile, "-%" PRIu32 "-%" PRIu16 "", fs_attr->type, fs_attr->id); tsk_fprintf(hFile, "|"); /* TYPE as specified in the directory entry */ if (fs_file->name->type < TSK_FS_NAME_TYPE_STR_MAX) tsk_fprintf(hFile, "%s/", tsk_fs_name_type_str[fs_file->name->type]); else tsk_fprintf(hFile, "-/"); if (!fs_file->meta) { tsk_fprintf(hFile, "----------|0|0|0|0|0|0|0\n"); } else { /* mode as string */ tsk_fs_meta_make_ls(fs_file->meta, ls, sizeof(ls)); tsk_fprintf(hFile, "%s|", ls); /* uid, gid */ tsk_fprintf(hFile, "%" PRIuUID "|%" PRIuGID "|", fs_file->meta->uid, fs_file->meta->gid); /* size - use data stream if we have it */ if (fs_attr) tsk_fprintf(hFile, "%" PRIuOFF "|", fs_attr->size); else tsk_fprintf(hFile, "%" PRIuOFF "|", fs_file->meta->size); /* atime, mtime, ctime, crtime */ if (fs_file->meta->atime) tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->atime - time_skew); else tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->atime); if (fs_file->meta->mtime) tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->mtime - time_skew); else tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->mtime); if (fs_file->meta->ctime) tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->ctime - time_skew); else tsk_fprintf(hFile, "%" PRIu32 "|", fs_file->meta->ctime); if (fs_file->meta->crtime) tsk_fprintf(hFile, "%" PRIu32 "\n", fs_file->meta->crtime - time_skew); else tsk_fprintf(hFile, "%" PRIu32 "\n", fs_file->meta->crtime); } } sleuthkit-3.2.3/tsk3/fs/fs_open.c000644 000765 000024 00000017017 11643647440 017435 0ustar00carrierstaff000000 000000 /* ** tsk_fs_open_img ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT */ /*++ * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ #include "tsk_fs_i.h" /** * \file fs_open.c * Contains the general code to open a file system -- this calls * the file system -specific opening routines. */ /** * \ingroup fslib * Tries to process data in a volume as a file system. * Returns a structure that can be used for analysis and reporting. * * @param a_part_info Open volume to read from and analyze * @param a_ftype Type of file system (or autodetect) * * @return NULL on error */ TSK_FS_INFO * tsk_fs_open_vol(const TSK_VS_PART_INFO * a_part_info, TSK_FS_TYPE_ENUM a_ftype) { TSK_OFF_T offset; if (a_part_info == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_open_vol: Null vpart handle"); return NULL; } else if (a_part_info->vs == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_open_vol: Null vs handle"); return NULL; } offset = a_part_info->start * a_part_info->vs->block_size + a_part_info->vs->offset; return tsk_fs_open_img(a_part_info->vs->img_info, offset, a_ftype); } /** * \ingroup fslib * Tries to process data in a disk image at a given offset as a file system. * Returns a structure that can be used for analysis and reporting. * * @param a_img_info Disk image to analyze * @param a_offset Byte offset to start analyzing from * @param a_ftype Type of file system (or autodetect) * * @return NULL on error */ TSK_FS_INFO * tsk_fs_open_img(TSK_IMG_INFO * a_img_info, TSK_OFF_T a_offset, TSK_FS_TYPE_ENUM a_ftype) { if (a_img_info == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_open_img: Null image handle"); return NULL; } /* We will try different file systems ... * We need to try all of them in case more than one matches */ if (a_ftype == TSK_FS_TYPE_DETECT) { TSK_FS_INFO *fs_info, *fs_set = NULL; char *set = NULL; if (tsk_verbose) tsk_fprintf(stderr, "fsopen: Auto detection mode at offset %" PRIuOFF "\n", a_offset); if ((fs_info = ntfs_open(a_img_info, a_offset, TSK_FS_TYPE_NTFS_DETECT, 1)) != NULL) { set = "NTFS"; fs_set = fs_info; } else { tsk_error_reset(); } if ((fs_info = fatfs_open(a_img_info, a_offset, TSK_FS_TYPE_FAT_DETECT, 1)) != NULL) { if (set == NULL) { set = "FAT"; fs_set = fs_info; } else { fs_set->close(fs_set); fs_info->close(fs_info); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "FAT or %s", set); return NULL; } } else { tsk_error_reset(); } if ((fs_info = ext2fs_open(a_img_info, a_offset, TSK_FS_TYPE_EXT_DETECT, 1)) != NULL) { if (set == NULL) { set = "EXT2/3"; fs_set = fs_info; } else { fs_set->close(fs_set); fs_info->close(fs_info); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "EXT2/3 or %s", set); return NULL; } } else { tsk_error_reset(); } if ((fs_info = ffs_open(a_img_info, a_offset, TSK_FS_TYPE_FFS_DETECT)) != NULL) { if (set == NULL) { set = "UFS"; fs_set = fs_info; } else { fs_set->close(fs_set); fs_info->close(fs_info); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "UFS or %s", set); return NULL; } } else { tsk_error_reset(); } #if TSK_USE_HFS if ((fs_info = hfs_open(a_img_info, a_offset, TSK_FS_TYPE_HFS_DETECT, 1)) != NULL) { if (set == NULL) { set = "HFS"; fs_set = fs_info; } else { fs_set->close(fs_set); fs_info->close(fs_info); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "HFS or %s", set); return NULL; } } else { tsk_error_reset(); } #endif if ((fs_info = iso9660_open(a_img_info, a_offset, TSK_FS_TYPE_ISO9660_DETECT, 1)) != NULL) { if (set != NULL) { fs_set->close(fs_set); fs_info->close(fs_info); tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "ISO9660 or %s", set); return NULL; } fs_set = fs_info; } else { tsk_error_reset(); } if (fs_set == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNKTYPE; tsk_errstr[0] = '\0'; tsk_errstr2[0] = '\0'; return NULL; } return fs_set; } else { if (TSK_FS_TYPE_ISNTFS(a_ftype)) return ntfs_open(a_img_info, a_offset, a_ftype, 0); else if (TSK_FS_TYPE_ISFAT(a_ftype)) return fatfs_open(a_img_info, a_offset, a_ftype, 0); else if (TSK_FS_TYPE_ISFFS(a_ftype)) return ffs_open(a_img_info, a_offset, a_ftype); else if (TSK_FS_TYPE_ISEXT(a_ftype)) return ext2fs_open(a_img_info, a_offset, a_ftype, 0); else if (TSK_FS_TYPE_ISHFS(a_ftype)) return hfs_open(a_img_info, a_offset, a_ftype, 0); else if (TSK_FS_TYPE_ISISO9660(a_ftype)) return iso9660_open(a_img_info, a_offset, a_ftype, 0); else if (TSK_FS_TYPE_ISRAW(a_ftype)) return rawfs_open(a_img_info, a_offset); else if (TSK_FS_TYPE_ISSWAP(a_ftype)) return swapfs_open(a_img_info, a_offset); else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPTYPE; snprintf(tsk_errstr, TSK_ERRSTR_L, "%X", (int) a_ftype); return NULL; } } } /** * \ingroup fslib * Close an open file system. * @param a_fs File system to close. */ void tsk_fs_close(TSK_FS_INFO * a_fs) { if ((a_fs == NULL) || (a_fs->tag != TSK_FS_INFO_TAG)) return; a_fs->close(a_fs); } sleuthkit-3.2.3/tsk3/fs/fs_parse.c000644 000765 000024 00000005774 11643647440 017615 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ #include "tsk_fs_i.h" /** * \file fs_parse.c * Contains code to parse specific types of data from * the command line */ /** * \ingroup fslib * Parse a TSK_TCHAR string of an inode, type, and id pair (not all parts * need to be there). This assumes the string is either: * INUM, INUM-TYPE, or INUM-TYPE-ID. Return the values in integer form. * * @param [in] str Input string to parse * @param [out] inum Pointer to location where inode can be stored. * @param [out] type Pointer to location where type can be stored (or NULL) * @param [out] type_used Pointer to location where the value can be set * to 1 if the type was set (to differentiate between meanings of 0) (or NULL). * @param [out] id Pointer to location where id can be stored (or NULL) * @param [out] id_used Pointer to location where the value can be set * to 1 if the id was set (to differentiate between meanings of 0) (or NULL). * * @return 1 on error or if not an inode and 0 on success */ int tsk_fs_parse_inum(const TSK_TCHAR * str, TSK_INUM_T * inum, TSK_FS_ATTR_TYPE_ENUM * type, uint8_t * type_used, uint16_t * id, uint8_t * id_used) { TSK_TCHAR *cp; TSK_TCHAR *tdash = NULL; TSK_TCHAR *tmpstr; if (*str == 0) return 1; if (type) *type = TSK_FS_ATTR_TYPE_DEFAULT; if (type_used) *type_used = 0; if (id) *id = TSK_FS_ATTR_ID_DEFAULT; if (id_used) *id_used = 0; /* Make a copy of the input string */ tmpstr = (TSK_TCHAR *) tsk_malloc((TSTRLEN(str) + 1) * sizeof(TSK_TCHAR)); if (tmpstr == NULL) return 1; TSTRNCPY(tmpstr, str, TSTRLEN(str) + 1); if ((tdash = TSTRCHR(tmpstr, _TSK_T('-'))) != NULL) { *tdash = '\0'; tdash++; } *inum = TSTRTOULL(tmpstr, &cp, 10); if (*cp || *cp == *tmpstr) { free(tmpstr); return 1; } // if there was a dash, verify what follows is numbers if (tdash) { TSK_TCHAR *idash = NULL; uint32_t ttmp; if ((idash = TSTRCHR(tdash, _TSK_T('-'))) != NULL) { *idash = '\0'; idash++; } ttmp = (uint32_t) TSTRTOUL(tdash, &cp, 10); if (*cp || *cp == *tdash) { free(tmpstr); return 1; } if (type != NULL) { *type = ttmp; if (type_used) *type_used = 1; } // if there was a dash after type, verify it is a number after it if (idash) { uint16_t itmp; itmp = (uint16_t) TSTRTOUL(idash, &cp, 0); if (*cp || *cp == *idash) { free(tmpstr); return 1; } if (id) *id = itmp; if (id_used) *id_used = 1; } } free(tmpstr); return 0; } sleuthkit-3.2.3/tsk3/fs/fs_types.c000644 000765 000024 00000007615 11643647440 017643 0ustar00carrierstaff000000 000000 /* ** fs_types ** The Sleuth Kit ** ** Identify the type of file system being used ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file fs_types.c * Contains TSK functions that deal with parsing and printing file system type strings. */ #include "tsk_fs_i.h" /** * \internal */ typedef struct { char *name; TSK_FS_TYPE_ENUM code; char *comment; } FS_TYPES; /** \internal * The table used to parse input strings - supports * legacy strings - in order of expected usage */ static FS_TYPES fs_type_table[] = { {"ntfs", TSK_FS_TYPE_NTFS_DETECT, "NTFS"}, {"fat", TSK_FS_TYPE_FAT_DETECT, "FAT (Auto Detection)"}, {"ext", TSK_FS_TYPE_EXT_DETECT, "ExtX (Auto Detection)"}, {"iso9660", TSK_FS_TYPE_ISO9660_DETECT, "ISO9660 CD"}, #if TSK_USE_HFS {"hfs", TSK_FS_TYPE_HFS_DETECT, "HFS+"}, #endif {"ufs", TSK_FS_TYPE_FFS_DETECT, "UFS (Auto Detection)"}, {"raw", TSK_FS_TYPE_RAW_DETECT, "Raw Data"}, {"swap", TSK_FS_TYPE_SWAP_DETECT, "Swap Space"}, {"fat12", TSK_FS_TYPE_FAT12, "FAT12"}, {"fat16", TSK_FS_TYPE_FAT16, "FAT16"}, {"fat32", TSK_FS_TYPE_FAT32, "FAT32"}, {"ext2", TSK_FS_TYPE_EXT2, "Ext2"}, {"ext3", TSK_FS_TYPE_EXT3, "Ext3"}, {"ufs1", TSK_FS_TYPE_FFS1, "UFS1"}, {"ufs2", TSK_FS_TYPE_FFS2, "UFS2"}, {0}, }; static FS_TYPES fs_legacy_type_table[] = { // legacy CLI arg names {"linux-ext", TSK_FS_TYPE_EXT_DETECT, "auto-detect Linux EXTxFS"}, {"linux-ext2", TSK_FS_TYPE_EXT2, "Linux TSK_FS_TYPE_EXT_2"}, {"linux-ext3", TSK_FS_TYPE_EXT3, "Linux TSK_FS_TYPE_EXT_3"}, {"bsdi", TSK_FS_TYPE_FFS1, "BSDi FFS"}, {"freebsd", TSK_FS_TYPE_FFS1, "FreeBSD FFS"}, {"netbsd", TSK_FS_TYPE_FFS1, "NetBSD FFS"}, {"openbsd", TSK_FS_TYPE_FFS1, "OpenBSD FFS"}, {"solaris", TSK_FS_TYPE_FFS1B, "Solaris FFS"}, {0}, }; /** * \ingroup fslib * Parse a string with the file system type and return its internal ID. * * @param str String to parse. * @returns ID of string (or unsupported if the name is unknown) */ TSK_FS_TYPE_ENUM tsk_fs_type_toid(const TSK_TCHAR * str) { FS_TYPES *sp; char tmp[16]; int i; // convert to char for (i = 0; i < 15 && str[i] != '\0'; i++) { tmp[i] = (char) str[i]; } tmp[i] = '\0'; for (sp = fs_type_table; sp->name; sp++) { if (strcmp(tmp, sp->name) == 0) { return sp->code; } } // look at the legacy names for (sp = fs_legacy_type_table; sp->name; sp++) { if (strcmp(tmp, sp->name) == 0) { return sp->code; } } return TSK_FS_TYPE_UNSUPP; } /** * \ingroup fslib * Print the supported file system types to a file handle * @param hFile File handle to print to */ void tsk_fs_type_print(FILE * hFile) { FS_TYPES *sp; tsk_fprintf(hFile, "Supported file system types:\n"); for (sp = fs_type_table; sp->name; sp++) tsk_fprintf(hFile, "\t%s (%s)\n", sp->name, sp->comment); } /** * \ingroup fslib * Return the string name of a file system type id. * @param ftype File system type id * @returns Name or NULL on error */ const char * tsk_fs_type_toname(TSK_FS_TYPE_ENUM ftype) { FS_TYPES *sp; for (sp = fs_type_table; sp->name; sp++) if (sp->code == ftype) return sp->name; return NULL; } /** * \ingroup fslib * Return the supported file system types. * @returns The bit in the return value is 1 if the type is supported. */ TSK_FS_TYPE_ENUM tsk_fs_type_supported() { TSK_FS_TYPE_ENUM sup_types = 0; FS_TYPES *types; for (types = fs_type_table; types->name; types++) { sup_types |= types->code; } return sup_types; } sleuthkit-3.2.3/tsk3/fs/hfs.c000644 000765 000024 00000316222 11643647440 016564 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Copyright (c) 2009 Brian Carrier. All rights reserved. ** ** Judson Powers [jpowers@atc-nycorp.com] ** Copyright (c) 2008 ATC-NY. All rights reserved. ** This file contains data developed with support from the National ** Institute of Justice, Office of Justice Programs, U.S. Department of Justice. ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier@sleuthkit.org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /** \file hfs.c * Contains the general internal TSK HFS metadata and data unit code -- Not included in code by default. */ #include "tsk_fs_i.h" #include "tsk_hfs.h" #define XSWAP(a,b) { a ^= b; b ^= a; a ^= b; } /* may set error up to string 1 * returns 0 on success, 1 on failure */ uint8_t hfs_checked_read_random(TSK_FS_INFO * fs, char *buf, size_t len, TSK_OFF_T offs) { ssize_t r; r = tsk_fs_read(fs, offs, buf, len); if (r != len) { if (r >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } return 1; } return 0; } /********************************************************************** * * MISC FUNCS * **********************************************************************/ /* convert the HFS Time (seconds from 1/1/1904) * to UNIX (UTC seconds from 1/1/1970) * The number is borrowed from linux HFS driver source */ uint32_t hfs2unixtime(uint32_t hfsdate) { if (hfsdate < NSEC_BTWN_1904_1970) return 0; return (uint32_t) (hfsdate - NSEC_BTWN_1904_1970); } /** * Convert a cnid (metadata address) to big endian array. * This is used to create the key for tree lookups. * @param cnid Metadata address to convert * @param array [out] Array to write data into. */ static void cnid_to_array(uint32_t cnid, uint8_t array[4]) { array[3] = (cnid >> 0) & 0xff; array[2] = (cnid >> 8) & 0xff; array[1] = (cnid >> 16) & 0xff; array[0] = (cnid >> 24) & 0xff; } /********************************************************************** * * Lookup Functions * **********************************************************************/ /* Compares the given HFS+ Extents B-tree key to key constructed * for finding the beginning of the data fork extents for the given * CNID. (That is, the search key uses the given CNID and has * fork = 0 and start_block = 0.) */ static int hfs_ext_compare_keys(HFS_INFO * hfs, uint32_t cnid, const hfs_btree_key_ext * key) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); uint32_t key_cnid; key_cnid = tsk_getu32(fs->endian, key->file_id); if (key_cnid < cnid) return -1; if (key_cnid > cnid) return 1; /* referring to the same cnids */ /* we are always looking for the data fork */ if (key->fork_type != HFS_EXT_KEY_TYPE_DATA) return 1; /* we are always looking for a start_block of zero (interested in the beginning of the extents, regardless of what the start_block is); all files except the bad blocks file should have a start_block greater than zero */ if (tsk_getu32(fs->endian, key->start_block) == 0) return 0; return 1; } /** \internal * Returns the length of an HFS+ B-tree INDEX key based on the tree header * structure and the length claimed in the record. With some trees, * the length given in the record is not used. * Note that this neither detects nor correctly handles 8-bit keys * (which should not be present in HFS+). * @param hfs File System * @param keylen Length of key as given in record * @param header Tree header * @returns Length of key */ uint16_t hfs_get_idxkeylen(HFS_INFO * hfs, uint16_t keylen, const hfs_btree_header_record * header) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); // if the flag is set, use the length given in the record if (tsk_getu32(fs->endian, header->attr) & HFS_BT_HEAD_ATTR_VARIDXKEYS) return keylen; else return tsk_getu16(fs->endian, header->maxKeyLen); } /** * Convert the extents runs to TSK_FS_ATTR_RUN runs. * * @param a_fs File system to analyze * @param a_extents Raw extents to process (in an array of 8) * @param a_start_off Starting block offset of these runs * @returns NULL on error or if no runs are in extents (test tsk_errno) */ static TSK_FS_ATTR_RUN * hfs_extents_to_attr(TSK_FS_INFO * a_fs, const hfs_ext_desc * a_extents, TSK_OFF_T a_start_off) { TSK_FS_ATTR_RUN *head_run = NULL; TSK_FS_ATTR_RUN *prev_run = NULL; int i; TSK_OFF_T cur_off = a_start_off; // since tsk_errno is checked as a return value, make sure it is clean. tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "hfs_extents_to_attr: Converting extents from offset %" PRIuOFF " to runlist\n", a_start_off); for (i = 0; i < 8; i++) { TSK_FS_ATTR_RUN *cur_run; uint32_t addr = tsk_getu32(a_fs->endian, a_extents[i].start_blk); uint32_t len = tsk_getu32(a_fs->endian, a_extents[i].blk_cnt); if (tsk_verbose) tsk_fprintf(stderr, "hfs_extents_to_attr: run %i at addr %" PRIu32 " with len %" PRIu32 "\n", i, addr, len); if ((addr == 0) && (len == 0)) break; // make a non-resident run if ((cur_run = tsk_fs_attr_run_alloc()) == NULL) return NULL; cur_run->addr = addr; cur_run->len = len; cur_run->offset = cur_off; if (head_run == NULL) head_run = cur_run; if (prev_run != NULL) prev_run->next = cur_run; cur_off += cur_run->len; prev_run = cur_run; } return head_run; } /** * Look in the extents catalog for entries for a given file. Add the runs * to the passed attribute structure. * * @param hfs File system being analyzed * @param cnid file id of file to search for * @param a_attr Attribute to add extents runs to * @returns 1 on error and 0 on success */ static uint8_t hfs_ext_find_extent_record_attr(HFS_INFO * hfs, uint32_t cnid, TSK_FS_ATTR * a_attr) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); uint16_t nodesize; /* size of nodes (all, regardless of the name) */ uint32_t cur_node; /* node id of the current node */ char *node = NULL; uint8_t is_done; tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record_attr: Looking for extents for file %" PRIu32 "\n", cnid); // Load the extents attribute, if it has not been done so yet. if (hfs->extents_file == NULL) { ssize_t cnt; if ((hfs->extents_file = tsk_fs_file_open_meta(fs, NULL, HFS_EXTENTS_FILE_ID)) == NULL) { return 1; } /* cache the data attribute */ hfs->extents_attr = tsk_fs_attrlist_get(hfs->extents_file->meta->attr, TSK_FS_ATTR_TYPE_DEFAULT); if (!hfs->extents_attr) { strncat(tsk_errstr2, " - Default Attribute not found in Extents File", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } // cache the extents file header cnt = tsk_fs_attr_read(hfs->extents_attr, 14, (char *) &(hfs->extents_header), sizeof(hfs_btree_header_record), 0); if (cnt != sizeof(hfs_btree_header_record)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: Error reading header"); return 1; } } // allocate a node buffer nodesize = tsk_getu16(fs->endian, hfs->extents_header.nodesize); if ((node = (char *) tsk_malloc(nodesize)) == NULL) { return 1; } /* start at root node */ cur_node = tsk_getu32(fs->endian, hfs->extents_header.rootNode); /* if the root node is zero, then the extents btree is empty */ /* if no files have overflow extents, the Extents B-tree still exists on disk, but is an empty B-tree containing only the header node */ if (cur_node == 0) { if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: " "empty extents btree\n"); free(node); return 0; } if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: starting at " "root node %" PRIu32 "; nodesize = %" PRIu16 "\n", cur_node, nodesize); /* Recurse down to the needed leaf nodes and then go forward */ is_done = 0; while (is_done == 0) { TSK_OFF_T cur_off; /* start address of cur_node */ uint16_t num_rec; /* number of records in this node */ ssize_t cnt; hfs_btree_node *node_desc; // sanity check if (cur_node > tsk_getu32(fs->endian, hfs->extents_header.totalNodes)) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: Node %d too large for file", cur_node); free(node); return 1; } // read the current node cur_off = cur_node * nodesize; if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: reading node %" PRIu32 " at offset %" PRIuOFF "\n", cur_node, cur_off); cnt = tsk_fs_attr_read(hfs->extents_attr, cur_off, node, nodesize, 0); if (cnt != nodesize) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: Error reading node %d at offset %" PRIuOFF, cur_node, cur_off); free(node); return 1; } // process the header / descriptor node_desc = (hfs_btree_node *) node; num_rec = tsk_getu16(fs->endian, node_desc->num_rec); if (num_rec == 0) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record: zero records in node %" PRIu32, cur_node); free(node); return 1; } /* With an index node, find the record with the largest key that is smaller * to or equal to cnid */ if (node_desc->type == HFS_BT_NODE_TYPE_IDX) { uint32_t next_node = 0; int rec; if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: Index node %" PRIu32 " @ %" PRIu64 " has %" PRIu16 " records\n", cur_node, cur_off, num_rec); for (rec = 0; rec < num_rec; rec++) { int cmp; size_t rec_off; hfs_btree_key_ext *key; // get the record offset in the node rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: offset of record %d in index node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_ext *) & node[rec_off]; cmp = hfs_ext_compare_keys(hfs, cnid, key); if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: record %" PRIu16 " ; keylen %" PRIu16 " (FileId: %" PRIu32 ", ForkType: %" PRIu8 ", StartBlk: %" PRIu32 "); compare: %d\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->file_id), key->fork_type, tsk_getu32(fs->endian, key->start_block), cmp); /* save the info from this record unless it is bigger than cnid */ if ((cmp <= 0) || (next_node == 0)) { hfs_btree_index_record *idx_rec; int keylen = 2 + hfs_get_idxkeylen(hfs, tsk_getu16(fs->endian, key->key_len), &(hfs->extents_header)); if (rec_off + keylen > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: offset and keylenth of record %d in index node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off + keylen, nodesize); free(node); return 1; } idx_rec = (hfs_btree_index_record *) & node[rec_off + keylen]; next_node = tsk_getu32(fs->endian, idx_rec->childNode); } // we are bigger than cnid, so move on to the next node if (cmp > 0) { break; } } // check if we found a relevant node, if not stop. if (next_node == 0) { if (tsk_verbose) fprintf(stderr, "hfs_ext_find_extent_record_attr: did not find any keys for %d in index node %d", cnid, cur_node); is_done = 1; break; } cur_node = next_node; } /* with a leaf, we process until we are past cnid. We move right too if we can */ else if (node_desc->type == HFS_BT_NODE_TYPE_LEAF) { int rec; if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: Leaf node %" PRIu32 " @ %" PRIu64 " has %" PRIu16 " records\n", cur_node, cur_off, num_rec); for (rec = 0; rec < num_rec; rec++) { size_t rec_off; hfs_btree_key_ext *key; uint32_t rec_cnid; hfs_extents *extents; TSK_OFF_T ext_off = 0; int keylen; TSK_FS_ATTR_RUN *attr_run; // get the record offset in the node rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: offset of record %d in leaf node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_ext *) & node[rec_off]; if (tsk_verbose) tsk_fprintf(stderr, "hfs_ext_find_extent_record: record %" PRIu16 "; keylen %" PRIu16 " (%" PRIu32 ", %" PRIu8 ", %" PRIu32 ")\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->file_id), key->fork_type, tsk_getu32(fs->endian, key->start_block)); rec_cnid = tsk_getu32(fs->endian, key->file_id); // see if this record is for our file if (rec_cnid < cnid) { continue; } else if ((rec_cnid > cnid) || (key->fork_type != HFS_EXT_KEY_TYPE_DATA)) { is_done = 1; break; } keylen = 2 + tsk_getu16(fs->endian, key->key_len); if (rec_off + keylen > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record_attr: offset and keylenth of record %d in leaf node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off + keylen, nodesize); free(node); return 1; } // get the starting offset of this extent ext_off = tsk_getu32(fs->endian, key->start_block); // convert the extents to the TSK format extents = (hfs_extents *) & node[rec_off + keylen]; attr_run = hfs_extents_to_attr(fs, extents->extents, ext_off); if ((attr_run == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_ext_find_extent_record_attr", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(node); return 1; } if (tsk_fs_attr_add_run(fs, a_attr, attr_run)) { strncat(tsk_errstr2, " - hfs_ext_find_extent_record_attr", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(node); return 1; } } cur_node = tsk_getu32(fs->endian, node_desc->flink); if (cur_node == 0) { is_done = 1; break; } } else { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_ext_find_extent_record: btree node %" PRIu32 " (%" PRIuOFF ") is neither index nor leaf (%" PRIu8 ")", cur_node, cur_off, node_desc->type); free(node); return 1; } } free(node); return 0; } /** \internal * Compares two Catalog B-tree keys. * @param hfs File System being analyzed * @param key1 Key 1 to compare * @param key2 Key 2 to compare * @returns -1 if key1 is smaller, 0 if equal, and 1 if key1 is larger */ int hfs_cat_compare_keys(HFS_INFO * hfs, const hfs_btree_key_cat * key1, const hfs_btree_key_cat * key2) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); uint32_t cnid1, cnid2; cnid1 = tsk_getu32(fs->endian, key1->parent_cnid); cnid2 = tsk_getu32(fs->endian, key2->parent_cnid); if (cnid1 < cnid2) return -1; if (cnid1 > cnid2) return 1; return hfs_unicode_compare(hfs, &key1->name, &key2->name); } /** \internal * @param hfs File system * @param targ_data can be null * @param a_cb callback * @param ptr Pointer to pass to callback * @returns 1 on error */ uint8_t hfs_cat_traverse(HFS_INFO * hfs, const void *targ_data, TSK_HFS_BTREE_CB a_cb, void *ptr) { TSK_FS_INFO *fs = &(hfs->fs_info); uint32_t cur_node; /* node id of the current node */ char *node; uint16_t nodesize; uint8_t is_done = 0; tsk_error_reset(); nodesize = tsk_getu16(fs->endian, hfs->catalog_header.nodesize); if ((node = (char *) tsk_malloc(nodesize)) == NULL) return 1; /* start at root node */ cur_node = tsk_getu32(fs->endian, hfs->catalog_header.rootNode); /* if the root node is zero, then the extents btree is empty */ /* if no files have overflow extents, the Extents B-tree still exists on disk, but is an empty B-tree containing only the header node */ if (cur_node == 0) { if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: " "empty extents btree\n"); free(node); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: starting at " "root node %" PRIu32 "; nodesize = %" PRIu16 "\n", cur_node, nodesize); /* Recurse down to the needed leaf nodes and then go forward */ is_done = 0; while (is_done == 0) { TSK_OFF_T cur_off; /* start address of cur_node */ uint16_t num_rec; /* number of records in this node */ ssize_t cnt; hfs_btree_node *node_desc; // sanity check if (cur_node > tsk_getu32(fs->endian, hfs->catalog_header.totalNodes)) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: Node %d too large for file", cur_node); free(node); return 1; } // read the current node cur_off = cur_node * nodesize; cnt = tsk_fs_attr_read(hfs->catalog_attr, cur_off, node, nodesize, 0); if (cnt != nodesize) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_traverse: Error reading node %d at offset %" PRIuOFF, cur_node, cur_off); free(node); return 1; } // process the header / descriptor node_desc = (hfs_btree_node *) node; num_rec = tsk_getu16(fs->endian, node_desc->num_rec); if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: node %" PRIu32 " @ %" PRIu64 " has %" PRIu16 " records\n", cur_node, cur_off, num_rec); if (num_rec == 0) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: zero records in node %" PRIu32, cur_node); free(node); return 1; } /* With an index node, find the record with the largest key that is smaller * to or equal to cnid */ if (node_desc->type == HFS_BT_NODE_TYPE_IDX) { uint32_t next_node = 0; int rec; for (rec = 0; rec < num_rec; rec++) { size_t rec_off; hfs_btree_key_cat *key; uint8_t retval; // get the record offset in the node rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: offset of record %d in index node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_cat *) & node[rec_off]; /* if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: record %" PRIu16 " ; keylen %" PRIu16 " (%" PRIu32 ")\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->parent_cnid)); */ /* save the info from this record unless it is too big */ retval = a_cb(hfs, HFS_BT_NODE_TYPE_IDX, targ_data, key, cur_off + rec_off, ptr); if (retval == HFS_BTREE_CB_ERR) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_traverse: Callback returned error"); free(node); return 1; } // record the closest entry else if ((retval == HFS_BTREE_CB_IDX_LT) || (next_node == 0)) { hfs_btree_index_record *idx_rec; int keylen = 2 + hfs_get_idxkeylen(hfs, tsk_getu16(fs->endian, key->key_len), &(hfs->catalog_header)); if (rec_off + keylen > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: offset of record and keylength %d in index node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off + keylen, nodesize); free(node); return 1; } idx_rec = (hfs_btree_index_record *) & node[rec_off + keylen]; next_node = tsk_getu32(fs->endian, idx_rec->childNode); } if (retval == HFS_BTREE_CB_IDX_EQGT) { // move down to the next node break; } } // check if we found a relevant node if (next_node == 0) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: did not find any keys in index node %d", cur_node); is_done = 1; break; } cur_node = next_node; } /* With a leaf, we look for the specific record. */ else if (node_desc->type == HFS_BT_NODE_TYPE_LEAF) { int rec; for (rec = 0; rec < num_rec; rec++) { size_t rec_off; hfs_btree_key_cat *key; uint8_t retval; // get the record offset in the node rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: offset of record %d in leaf node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_cat *) & node[rec_off]; /* if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: record %" PRIu16 "; keylen %" PRIu16 " (%" PRIu32 ")\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->parent_cnid)); */ // rec_cnid = tsk_getu32(fs->endian, key->file_id); retval = a_cb(hfs, HFS_BT_NODE_TYPE_LEAF, targ_data, key, cur_off + rec_off, ptr); if (retval == HFS_BTREE_CB_LEAF_STOP) { is_done = 1; break; } else if (retval == HFS_BTREE_CB_ERR) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_traverse: Callback returned error"); free(node); return 1; } } // move right to the next node if we got this far if (is_done == 0) { cur_node = tsk_getu32(fs->endian, node_desc->flink); if (cur_node == 0) { is_done = 1; } if (tsk_verbose) fprintf(stderr, "hfs_cat_traverse: moving forward to next leaf"); } } else { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_traverse: btree node %" PRIu32 " (%" PRIu64 ") is neither index nor leaf (%" PRIu8 ")", cur_node, cur_off, node_desc->type); free(node); return 1; } } free(node); return 0; } static uint8_t hfs_cat_get_record_offset_cb(HFS_INFO * hfs, int8_t level_type, const void *targ_data, const hfs_btree_key_cat * cur_key, TSK_OFF_T key_off, void *ptr) { const hfs_btree_key_cat *targ_key = (hfs_btree_key_cat *) targ_data; if (tsk_verbose) fprintf(stderr, "hfs_cat_get_record_offset_cb: %s node want: %" PRIu32 " vs have: %" PRIu32 "\n", (level_type == HFS_BT_NODE_TYPE_IDX) ? "Index" : "Leaf", tsk_getu32(hfs->fs_info.endian, targ_key->parent_cnid), tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid)); if (level_type == HFS_BT_NODE_TYPE_IDX) { int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key); if (diff < 0) return HFS_BTREE_CB_IDX_LT; else return HFS_BTREE_CB_IDX_EQGT; } else { int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key); // see if this record is for our file or if we passed the interesting entries if (diff < 0) { return HFS_BTREE_CB_LEAF_GO; } else if (diff == 0) { TSK_OFF_T *off = (TSK_OFF_T *) ptr; *off = key_off + 2 + tsk_getu16(hfs->fs_info.endian, cur_key->key_len); } return HFS_BTREE_CB_LEAF_STOP; } } /** \internal * Find the byte offset (from the start of the catalog file) to a record * in the catalog file. * @param hfs File System being analyzed * @param needle Key to search for * @returns Byte offset or 0 on error. 0 is also returned if catalog * record was not found. Check tsk_errno to determine if error occured. */ static TSK_OFF_T hfs_cat_get_record_offset(HFS_INFO * hfs, const hfs_btree_key_cat * needle) { TSK_OFF_T off = 0; if (hfs_cat_traverse(hfs, needle, hfs_cat_get_record_offset_cb, &off)) { return 0; } return off; } /** \internal * Given a byte offset to a leaf record in teh catalog file, read the data as * a thread record. This will zero the buffer and read in the size of the thread * data. * @param hfs File System * @param off Byte offset of record in catalog file (not including key) * @param thread [out] Buffer to write thread data into. * @returns 0 on success, 1 on failure; sets up to error string 1 */ uint8_t hfs_cat_read_thread_record(HFS_INFO * hfs, TSK_OFF_T off, hfs_thread * thread) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); uint16_t uni_len; size_t cnt; memset(thread, 0, sizeof(hfs_thread)); cnt = tsk_fs_attr_read(hfs->catalog_attr, off, (char *) thread, 10, 0); if (cnt != 10) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_read_thread_record: Error reading catalog offset %" PRIuOFF " (header)", off); return 1; } if ((tsk_getu16(fs->endian, thread->rec_type) != HFS_FOLDER_THREAD) && (tsk_getu16(fs->endian, thread->rec_type) != HFS_FILE_THREAD)) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_read_thread_record: unexpected record type %" PRIu16, tsk_getu16(fs->endian, thread->rec_type)); return 1; } uni_len = tsk_getu16(fs->endian, thread->name.length); if (uni_len > 255) { tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_read_thread_record: invalid string length (%" PRIu16 ")", uni_len); return 1; } cnt = tsk_fs_attr_read(hfs->catalog_attr, off + 10, (char *) thread->name.unicode, uni_len * 2, 0); if (cnt != uni_len * 2) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_read_thread_record: Error reading catalog offset %" PRIuOFF " (name)", off + 10); return 1; } return 0; } /** \internal * Read a catalog record into a local data structure. This reads the * correct amount, depending on if it is a file or folder. * @param hfs File system being analyzed * @param off Byte offset (in catalog file) of record (not including key) * @param record [out] Structure to read data into * @returns 1 on error */ uint8_t hfs_cat_read_file_folder_record(HFS_INFO * hfs, TSK_OFF_T off, hfs_file_folder * record) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); size_t cnt; char rec_type[2]; memset(record, 0, sizeof(hfs_file_folder)); cnt = tsk_fs_attr_read(hfs->catalog_attr, off, rec_type, 2, 0); if (cnt != 2) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_read_file_folder_record: Error reading record type from catalog offset %" PRIuOFF " (header)", off); return 1; } if (tsk_getu16(fs->endian, rec_type) == HFS_FOLDER_RECORD) { cnt = tsk_fs_attr_read(hfs->catalog_attr, off, (char *) record, sizeof(hfs_folder), 0); if (cnt != sizeof(hfs_folder)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_read_file_folder_record: Error reading catalog offset %" PRIuOFF " (folder)", off); return 1; } } else if (tsk_getu16(fs->endian, rec_type) == HFS_FILE_RECORD) { cnt = tsk_fs_attr_read(hfs->catalog_attr, off, (char *) record, sizeof(hfs_file), 0); if (cnt != sizeof(hfs_file)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_cat_read_file_folder_record: Error reading catalog offset %" PRIuOFF " (file)", off); return 1; } } else { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_read_file_folder_record: unexpected record type %" PRIu16, tsk_getu16(fs->endian, rec_type)); return 1; } return 0; } /** \internal * Lookup an entry in the catalog file and save it into the entry. Do not * call this for the special files that do not have an entry in the catalog. * data structure. * @param hfs File system being analyzed * @param inum Address (cnid) of file to open * @param entry [out] Structure to read data into * @returns 1 on error or not found, 0 on success. Check tsk_errno * to differentiate between error and not found. */ static uint8_t hfs_cat_file_lookup(HFS_INFO * hfs, TSK_INUM_T inum, HFS_ENTRY * entry) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); hfs_btree_key_cat key; /* current catalog key */ hfs_thread thread; /* thread record */ hfs_file_folder record; /* file/folder record */ TSK_OFF_T off; tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_file_lookup: called for inum %" PRIuINUM "\n", inum); // Test if this is a special file that is not located in the catalog if ((inum == HFS_EXTENTS_FILE_ID) || (inum == HFS_CATALOG_FILE_ID) || (inum == HFS_ALLOCATION_FILE_ID) || (inum == HFS_STARTUP_FILE_ID) || (inum == HFS_ATTRIBUTES_FILE_ID)) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_file_lookup: Called on special file: %" PRIuINUM, inum); return 1; } /* first look up the thread record for the item we're searching for */ /* set up the thread record key */ memset((char *) &key, 0, sizeof(hfs_btree_key_cat)); cnid_to_array((uint32_t) inum, key.parent_cnid); if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_file_lookup: Looking up thread record (%" PRIuINUM ")\n", inum); /* look up the thread record */ off = hfs_cat_get_record_offset(hfs, &key); if (off == 0) { // no parsing error, just not found if (tsk_errno == 0) { tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_file_lookup: Error finding thread node for file (%" PRIuINUM ")", inum); } else { snprintf(tsk_errstr2, TSK_ERRSTR_L, " hfs_cat_file_lookup: thread for file (%" PRIuINUM ")", inum); } return 1; } /* read the thread record */ if (hfs_cat_read_thread_record(hfs, off, &thread)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, " hfs_cat_file_lookup: file (%" PRIuINUM ")", inum); return 1; } /* now look up the actual file/folder record */ /* build key */ memset((char *) &key, 0, sizeof(hfs_btree_key_cat)); memcpy((char *) key.parent_cnid, (char *) thread.parent_cnid, sizeof(key.parent_cnid)); memcpy((char *) &key.name, (char *) &thread.name, sizeof(key.name)); if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_file_lookup: Looking up file record (parent: %" PRIuINUM ")\n", tsk_getu32(fs->endian, key.parent_cnid)); /* look up the record */ off = hfs_cat_get_record_offset(hfs, &key); if (off == 0) { // no parsing error, just not found if (tsk_errno == 0) { tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_cat_file_lookup: Error finding record node %" PRIuINUM, inum); } else { snprintf(tsk_errstr2, TSK_ERRSTR_L, " hfs_cat_file_lookup: file (%" PRIuINUM ")", inum); } return 1; } /* read the record */ if (hfs_cat_read_file_folder_record(hfs, off, &record)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, " hfs_cat_file_lookup: file (%" PRIuINUM ")", inum); return 1; } /* these memcpy can be gotten rid of, really */ if (tsk_getu16(fs->endian, record.file.std.rec_type) == HFS_FOLDER_RECORD) { if (tsk_verbose) fprintf(stderr, "hfs_cat_file_lookup: found folder record valence %" PRIu32 ", cnid %" PRIu32 "\n", tsk_getu32(fs->endian, record.folder.std.valence), tsk_getu32(fs->endian, record.folder.std.cnid)); memcpy((char *) &entry->cat, (char *) &record, sizeof(hfs_folder)); } else if (tsk_getu16(fs->endian, record.file.std.rec_type) == HFS_FILE_RECORD) { if (tsk_verbose) fprintf(stderr, "hfs_cat_file_lookup: found file record cnid %" PRIu32 "\n", tsk_getu32(fs->endian, record.file.std.cnid)); memcpy((char *) &entry->cat, (char *) &record, sizeof(hfs_file)); } /* other cases already caught by hfs_cat_read_file_folder_record */ memcpy((char *) &entry->thread, (char *) &thread, sizeof(hfs_thread)); entry->flags = TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_USED; entry->inum = inum; if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_file_lookup exited\n"); return 0; } /** \internal * Returns the largest inode number in file system * @param hfs File system being analyzed * @returns largest metadata address */ static TSK_INUM_T hfs_find_highest_inum(HFS_INFO * hfs) { // @@@ get actual number from Catalog file (go to far right) (we can't always trust the vol header) /* I haven't gotten looking at the end of the Catalog B-Tree to work properly. A fast method: if HFS_VH_ATTR_CNIDS_REUSED is set, then the maximum CNID is 2^32-1; if it's not set, then nextCatalogId is supposed to be larger than all CNIDs on disk. */ TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); if (tsk_getu32(fs->endian, hfs->fs->attr) & HFS_VH_ATTR_CNIDS_REUSED) return (TSK_INUM_T) 0xffffffff; else return (TSK_INUM_T) tsk_getu32(fs->endian, hfs->fs->next_cat_id) - 1; } static TSK_FS_META_MODE_ENUM hfsmode2tskmode(uint16_t a_mode) { TSK_FS_META_MODE_ENUM mode = 0; if (a_mode & HFS_IN_ISUID) mode |= TSK_FS_META_MODE_ISUID; if (a_mode & HFS_IN_ISGID) mode |= TSK_FS_META_MODE_ISGID; if (a_mode & HFS_IN_ISVTX) mode |= TSK_FS_META_MODE_ISVTX; if (a_mode & HFS_IN_IRUSR) mode |= TSK_FS_META_MODE_IRUSR; if (a_mode & HFS_IN_IWUSR) mode |= TSK_FS_META_MODE_IWUSR; if (a_mode & HFS_IN_IXUSR) mode |= TSK_FS_META_MODE_IXUSR; if (a_mode & HFS_IN_IRGRP) mode |= TSK_FS_META_MODE_IRGRP; if (a_mode & HFS_IN_IWGRP) mode |= TSK_FS_META_MODE_IWGRP; if (a_mode & HFS_IN_IXGRP) mode |= TSK_FS_META_MODE_IXGRP; if (a_mode & HFS_IN_IROTH) mode |= TSK_FS_META_MODE_IROTH; if (a_mode & HFS_IN_IWOTH) mode |= TSK_FS_META_MODE_IWOTH; if (a_mode & HFS_IN_IXOTH) mode |= TSK_FS_META_MODE_IXOTH; return mode; } static TSK_FS_META_TYPE_ENUM hfsmode2tskmetatype(uint16_t a_mode) { switch (a_mode & HFS_IN_IFMT) { case HFS_IN_IFIFO: return TSK_FS_META_TYPE_FIFO; case HFS_IN_IFCHR: return TSK_FS_META_TYPE_CHR; case HFS_IN_IFDIR: return TSK_FS_META_TYPE_DIR; case HFS_IN_IFBLK: return TSK_FS_META_TYPE_BLK; case HFS_IN_IFREG: return TSK_FS_META_TYPE_REG; case HFS_IN_IFLNK: return TSK_FS_META_TYPE_LNK; case HFS_IN_IFSOCK: return TSK_FS_META_TYPE_SOCK; case HFS_IFWHT: return TSK_FS_META_TYPE_WHT; case HFS_IFXATTR: return TSK_FS_META_TYPE_UNDEF; default: /* error */ return TSK_FS_META_TYPE_UNDEF; } } static uint8_t hfs_make_specialbase(TSK_FS_FILE * fs_file) { fs_file->meta->type = TSK_FS_META_TYPE_REG; fs_file->meta->mode = 0; fs_file->meta->nlink = 1; fs_file->meta->flags = (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_ALLOC); fs_file->meta->uid = fs_file->meta->gid = 0; fs_file->meta->mtime = fs_file->meta->atime = fs_file->meta->ctime = fs_file->meta->crtime = 0; fs_file->meta->mtime_nano = fs_file->meta->atime_nano = fs_file->meta->ctime_nano = fs_file->meta->crtime_nano = 0; if (fs_file->meta->name2 == NULL) { if ((fs_file->meta->name2 = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST))) == NULL) return 1; fs_file->meta->name2->next = NULL; } if (fs_file->meta->attr != NULL) { tsk_fs_attrlist_markunused(fs_file->meta->attr); } else { fs_file->meta->attr = tsk_fs_attrlist_alloc(); } return 0; } /** * \internal * Create an FS_INODE structure for the catalog file. * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_catalog(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs = (TSK_FS_INFO *) hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_catalog: Making virtual catalog file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_CATALOG_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_CATALOGNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = tsk_getu64(fs->endian, hfs->fs->cat_file.logic_sz); // convert the runs in the volume header to attribute runs if (((attr_run = hfs_extents_to_attr(fs, hfs->fs->cat_file.extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_make_catalog", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_catalog", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, hfs->fs->cat_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->cat_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->cat_file.logic_sz), 0, 0)) { strncat(tsk_errstr2, " - hfs_make_catalog", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); tsk_fs_attr_run_free(attr_run); return 1; } // see if catalog file has additional runs if (hfs_ext_find_extent_record_attr(hfs, HFS_CATALOG_FILE_ID, fs_attr)) { strncat(tsk_errstr2, " - hfs_make_catalog", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** * \internal * Create an FS_FILE for the extents file * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_extents(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs = (TSK_FS_INFO *) hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_extents: Making virtual extents file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_EXTENTS_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_EXTENTSNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = tsk_getu64(fs->endian, hfs->fs->ext_file.logic_sz); if (((attr_run = hfs_extents_to_attr(fs, hfs->fs->ext_file.extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_make_extents", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_extents", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, hfs->fs->ext_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->ext_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->ext_file.logic_sz), 0, 0)) { strncat(tsk_errstr2, " - hfs_make_extents", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); tsk_fs_attr_run_free(attr_run); return 1; } // Extents doesn't have an entry in itself fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** * \internal * Create an FS_INODE structure for the blockmap / allocation file. * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_blockmap(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs = (TSK_FS_INFO *) hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_blockmap: Making virtual blockmap file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_ALLOCATION_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_ALLOCATIONNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = tsk_getu64(fs->endian, hfs->fs->alloc_file.logic_sz); if (((attr_run = hfs_extents_to_attr(fs, hfs->fs->alloc_file.extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_make_blockmap", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_blockmap", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, hfs->fs->alloc_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->alloc_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->alloc_file.logic_sz), 0, 0)) { strncat(tsk_errstr2, " - hfs_make_blockmap", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); tsk_fs_attr_run_free(attr_run); return 1; } // see if catalog file has additional runs if (hfs_ext_find_extent_record_attr(hfs, HFS_ALLOCATION_FILE_ID, fs_attr)) { strncat(tsk_errstr2, " - hfs_make_blockmap", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** * \internal * Create an FS_INODE structure for the startup / boot file. * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_startfile(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs = (TSK_FS_INFO *) hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_startfile: Making virtual startup file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_STARTUP_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_STARTUPNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = tsk_getu64(fs->endian, hfs->fs->start_file.logic_sz); if (((attr_run = hfs_extents_to_attr(fs, hfs->fs->start_file.extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_make_startfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_startfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, hfs->fs->start_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->start_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->start_file.logic_sz), 0, 0)) { strncat(tsk_errstr2, " - hfs_make_startfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); tsk_fs_attr_run_free(attr_run); return 1; } // see if catalog file has additional runs if (hfs_ext_find_extent_record_attr(hfs, HFS_STARTUP_FILE_ID, fs_attr)) { strncat(tsk_errstr2, " - hfs_make_startfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** * \internal * Create an FS_INODE structure for the attributes file. * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_attrfile(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs = (TSK_FS_INFO *) hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_attrfile: Making virtual attributes file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_ATTRIBUTES_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_ATTRIBUTESNAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = tsk_getu64(fs->endian, hfs->fs->attr_file.logic_sz); if (((attr_run = hfs_extents_to_attr(fs, hfs->fs->attr_file.extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, hfs->fs->attr_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->attr_file.logic_sz), tsk_getu64(fs->endian, hfs->fs->attr_file.logic_sz), 0, 0)) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); tsk_fs_attr_run_free(attr_run); return 1; } // see if catalog file has additional runs if (hfs_ext_find_extent_record_attr(hfs, HFS_ATTRIBUTES_FILE_ID, fs_attr)) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** * \internal * Create an FS_FILE structure for the BadBlocks file. * * @param hfs File system to analyze * @param fs_file Structure to copy file information into. * @return 1 on error and 0 on success */ static uint8_t hfs_make_badblockfile(HFS_INFO * hfs, TSK_FS_FILE * fs_file) { TSK_FS_ATTR *fs_attr; if (tsk_verbose) tsk_fprintf(stderr, "hfs_make_badblockfile: Making virtual badblock file\n"); if (hfs_make_specialbase(fs_file)) return 1; fs_file->meta->addr = HFS_BAD_BLOCK_FILE_ID; strncpy(fs_file->meta->name2->name, HFS_BAD_BLOCK_FILE_NAME, TSK_FS_META_NAME_LIST_NSIZE); fs_file->meta->size = 0; if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } // dd the run to the file. if (tsk_fs_attr_set_run(fs_file, fs_attr, NULL, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, fs_file->meta->size, fs_file->meta->size, fs_file->meta->size, 0, 0)) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_free(fs_attr); return 1; } // see if catalog file has additional runs if (hfs_ext_find_extent_record_attr(hfs, HFS_BAD_BLOCK_FILE_ID, fs_attr)) { strncat(tsk_errstr2, " - hfs_make_attrfile", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } /* @@@ We have a chicken and egg problem here... The current design of * fs_attr_set() requires the size to be set, but we dont' know the size * until we look into the extents file (which adds to an attribute...). * This does not seem to be the best design... neeed a way to test this. */ fs_file->meta->size = fs_attr->nrd.initsize; fs_attr->size = fs_file->meta->size; fs_attr->nrd.allocsize = fs_file->meta->size; fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** \internal * Copy the catalog file or folder record entry into a TSK data structure. * @param a_hfs File system being analyzed * @param a_entry Catalog record entry * @param a_fs_meta Structure to copy data into * Returns 1 on error. */ static uint8_t hfs_dinode_copy(HFS_INFO * a_hfs, const hfs_file_folder * a_entry, TSK_FS_META * a_fs_meta) { const hfs_file_fold_std *std; TSK_FS_INFO *fs = (TSK_FS_INFO *) & a_hfs->fs_info; uint16_t hfsmode; if (a_fs_meta == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dinode_copy: a_fs_meta is NULL"); return 1; } // both files and folders start of the same std = &(a_entry->file.std); if (tsk_verbose) tsk_fprintf(stderr, "hfs_dinode_copy: called for file/folder %" PRIu32 "\n", tsk_getu32(fs->endian, std->cnid)); if (a_fs_meta->content_len < HFS_FILE_CONTENT_LEN) { if ((a_fs_meta = tsk_fs_meta_realloc(a_fs_meta, HFS_FILE_CONTENT_LEN)) == NULL) { return 1; } } a_fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (a_fs_meta->attr) { tsk_fs_attrlist_markunused(a_fs_meta->attr); } /* * Copy the file type specific stuff first */ hfsmode = tsk_getu16(fs->endian, std->perm.mode); if (tsk_getu16(fs->endian, std->rec_type) == HFS_FOLDER_RECORD) { // set the type of mode is not set if ((hfsmode & HFS_IN_IFMT) == 0) a_fs_meta->type = TSK_FS_META_TYPE_DIR; a_fs_meta->size = 0; memset(a_fs_meta->content_ptr, 0, HFS_FILE_CONTENT_LEN); } else if (tsk_getu16(fs->endian, std->rec_type) == HFS_FILE_RECORD) { hfs_fork *fork; // set the type of mode is not set if ((hfsmode & HFS_IN_IFMT) == 0) a_fs_meta->type = TSK_FS_META_TYPE_REG; a_fs_meta->size = tsk_getu64(fs->endian, a_entry->file.data.logic_sz); // copy the data and resource forks fork = (hfs_fork *) a_fs_meta->content_ptr; memcpy(fork, &(a_entry->file.data), sizeof(hfs_fork)); memcpy(&fork[1], &(a_entry->file.resource), sizeof(hfs_fork)); } else { tsk_fprintf(stderr, "hfs_dinode_copy error: catalog entry is neither file nor folder\n"); return 1; } /* * Copy the standard stuff. * Use default values (as defined in spec) if mode is not defined. */ if ((hfsmode & HFS_IN_IFMT) == 0) { a_fs_meta->mode = 0; a_fs_meta->uid = 99; a_fs_meta->gid = 99; } else { a_fs_meta->mode = hfsmode2tskmode(hfsmode); a_fs_meta->type = hfsmode2tskmetatype(hfsmode); a_fs_meta->uid = tsk_getu32(fs->endian, std->perm.owner); a_fs_meta->gid = tsk_getu32(fs->endian, std->perm.group); } // this field is set only for "indirect" entries if (tsk_getu32(fs->endian, std->perm.special.nlink)) a_fs_meta->nlink = tsk_getu32(fs->endian, std->perm.special.nlink); else a_fs_meta->nlink = 1; a_fs_meta->mtime = hfs2unixtime(tsk_getu32(fs->endian, std->cmtime)); a_fs_meta->atime = hfs2unixtime(tsk_getu32(fs->endian, std->atime)); a_fs_meta->crtime = hfs2unixtime(tsk_getu32(fs->endian, std->crtime)); a_fs_meta->ctime = hfs2unixtime(tsk_getu32(fs->endian, std->amtime)); a_fs_meta->time2.hfs.bkup_time = hfs2unixtime(tsk_getu32(fs->endian, std->bkup_date)); a_fs_meta->mtime_nano = a_fs_meta->atime_nano = a_fs_meta->ctime_nano = a_fs_meta->crtime_nano = 0; a_fs_meta->time2.hfs.bkup_time_nano = 0; a_fs_meta->addr = tsk_getu32(fs->endian, std->cnid); // All entries here are used. a_fs_meta->flags = TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_USED; /* TODO @@@ could fill in name2 with this entry's name and parent inode from Catalog entry */ /* If a sym link, copy the destination to a_fs_meta->link */ /* if (fs_file->meta->type == TSK_FS_META_TYPE_LNK) { @@@ Need to do this. We need to read the file content, but we don't really have enough context (i.e. FS_FILE) to simply use the existing load and read functions. Probably need to make a dummy TSK_FS_FILE. } */ return 0; } /** \internal * Load a catalog file entry and save it in the TSK_FS_FILE structure. * * @param fs File system to read from. * @param a_fs_file Structure to read into. * @param inum File address to load * @returns 1 on error */ static uint8_t hfs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { HFS_INFO *hfs = (HFS_INFO *) fs; HFS_ENTRY entry; if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_inode_lookup: fs_file is NULL"); return 1; } if (a_fs_file->meta == NULL) { a_fs_file->meta = tsk_fs_meta_alloc(HFS_FILE_CONTENT_LEN); if (a_fs_file->meta == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } if (tsk_verbose) tsk_fprintf(stderr, "hfs_inode_lookup: looking up %" PRIuINUM "\n", inum); // @@@ Will need to add orphan stuff here too /* First see if this is a special entry * the special ones have their metadata stored in the volume header */ if (inum == HFS_EXTENTS_FILE_ID) { if (hfs_make_extents(hfs, a_fs_file)) return 1; else return 0; } else if (inum == HFS_CATALOG_FILE_ID) { if (hfs_make_catalog(hfs, a_fs_file)) return 1; else return 0; } else if (inum == HFS_BAD_BLOCK_FILE_ID) { if (hfs_make_badblockfile(hfs, a_fs_file)) return 1; else return 0; } else if (inum == HFS_ALLOCATION_FILE_ID) { if (hfs_make_blockmap(hfs, a_fs_file)) return 1; else return 0; } else if (inum == HFS_STARTUP_FILE_ID) { if (hfs_make_startfile(hfs, a_fs_file)) return 1; else return 0; } else if (inum == HFS_ATTRIBUTES_FILE_ID) { if (hfs_make_attrfile(hfs, a_fs_file)) return 1; else return 0; } /* Lookup inode and store it in the HFS structure */ if (hfs_cat_file_lookup(hfs, inum, &entry)) return 1; /* Copy the structure in hfs to generic fs_inode */ if (hfs_dinode_copy(hfs, (const hfs_file_folder *) &entry.cat, a_fs_file->meta)) { return 1; } return 0; } /** \internal * Populate the attributes in fs_file using the internal fork data. This uses * the data cached in the content_ptr structure. * @param fs_file File to load attributes for * * @returns 1 on error and 0 on success */ static uint8_t hfs_load_attrs(TSK_FS_FILE * fs_file) { TSK_FS_INFO *fs; HFS_INFO *hfs; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR_RUN *attr_run; hfs_fork *fork; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file == NULL) || (fs_file->meta == NULL) || (fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_load_attrs: fs_file or meta is NULL"); return 1; } if (fs_file->meta->content_ptr == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_load_attrs: content_ptr is NULL"); return 1; } fs = (TSK_FS_INFO *) fs_file->fs_info; hfs = (HFS_INFO *) fs; if (tsk_verbose) tsk_fprintf(stderr, "hfs_load_attrs: Processing file %" PRIuINUM "\n", fs_file->meta->addr); // see if we have already loaded the runs if (fs_file->meta->attr_state == TSK_FS_META_ATTR_STUDIED) { return 0; } else if (fs_file->meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } // not sure why this would ever happen, but... else if (fs_file->meta->attr != NULL) { tsk_fs_attrlist_markunused(fs_file->meta->attr); } else if (fs_file->meta->attr == NULL) { fs_file->meta->attr = tsk_fs_attrlist_alloc(); } // get an attribute structure to store the data in if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { strncat(tsk_errstr2, " - hfs_load_attrs", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } /* NOTE that fs_attr is now tied to fs_file->meta->attr. * that means that we do not need to free it if we abort in the * following code (and doing so will cause double free errors). */ // if not a file or symbolic link, then make an empty entry if ((fs_file->meta->type != TSK_FS_META_TYPE_REG) && (fs_file->meta->type != TSK_FS_META_TYPE_LNK)) { if (tsk_fs_attr_set_run(fs_file, fs_attr, NULL, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, 0, 0, 0, 0, 0)) { strncat(tsk_errstr2, " - hfs_load_attrs (non-file)", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /* @@@ We need to detect hard links and load up the indirect node info instead of the current node info. //Detect Hard links else if ((tsk_getu32(fs->endian, entry.cat.std.u_info.file_type) == HFS_HARDLINK_FILE_TYPE) && (tsk_getu32(fs->endian, entry.cat.std.u_info.file_cr) == HFS_HARDLINK_FILE_CREATOR)) { // Get the indirect node value tsk_getu32(fs->endian, entry.cat.std.perm.special.inum) // Find the indirect node "/____HFS+ Private Data/iNodeXXXX" // Load its runs and look in extents for others (based on its CNID) */ // Get the data fork and convert it to the TSK format fork = (hfs_fork *) fs_file->meta->content_ptr; if (((attr_run = hfs_extents_to_attr(fs, fork->extents, 0)) == NULL) && (tsk_errno)) { strncat(tsk_errstr2, " - hfs_load_attrs", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } // add the runs to the attribute and the attribute to the file. if (tsk_fs_attr_set_run(fs_file, fs_attr, attr_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, tsk_getu64(fs->endian, fork->logic_sz), tsk_getu64(fs->endian, fork->logic_sz), (TSK_OFF_T) tsk_getu32(fs->endian, fork->total_blk) * fs->block_size, 0, 0)) { strncat(tsk_errstr2, " - hfs_load_attrs", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_attr_run_free(attr_run); return 1; } // see if extents file has additional runs if (hfs_ext_find_extent_record_attr(hfs, (uint32_t) fs_file->meta->addr, fs_attr)) { strncat(tsk_errstr2, " - hfs_load_attrs", TSK_ERRSTR_L - strlen(tsk_errstr2)); fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } // @@@ Load resource fork too fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } /** \internal * Get allocation status of file system block. * adapted from IsAllocationBlockUsed from: * http://developer.apple.com/technotes/tn/tn1150.html * * @param hfs File system being analyzed * @param b Block address * @returns 1 if allocated, 0 if not, -1 on error */ static int8_t hfs_block_is_alloc(HFS_INFO * hfs, TSK_DADDR_T a_addr) { TSK_FS_INFO *fs = &(hfs->fs_info); TSK_OFF_T b; size_t b2; // lazy loading if (hfs->blockmap_file == NULL) { if ((hfs->blockmap_file = tsk_fs_file_open_meta(fs, NULL, HFS_ALLOCATION_FILE_ID)) == NULL) { strncat(tsk_errstr2, " - Loading blockmap file", TSK_ERRSTR_L - strlen(tsk_errstr2)); return -1; } /* cache the data attribute */ hfs->blockmap_attr = tsk_fs_attrlist_get(hfs->blockmap_file->meta->attr, TSK_FS_ATTR_TYPE_DEFAULT); if (!hfs->blockmap_attr) { strncat(tsk_errstr2, " - Data Attribute not found in Blockmap File", TSK_ERRSTR_L - strlen(tsk_errstr2)); return -1; } hfs->blockmap_cache_start = -1; hfs->blockmap_cache_len = 0; } // get the byte offset b = (TSK_OFF_T) a_addr / 8; if (b > hfs->blockmap_file->meta->size) { tsk_errno = TSK_ERR_FS_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_block_is_alloc: block %" PRIuDADDR " is too large for bitmap (%" PRIuOFF ")", a_addr, hfs->blockmap_file->meta->size); return -1; } // see if it is in the cache if ((hfs->blockmap_cache_start == -1) || (hfs->blockmap_cache_start > b) || (hfs->blockmap_cache_start + hfs->blockmap_cache_len <= b)) { size_t cnt = tsk_fs_attr_read(hfs->blockmap_attr, b, hfs->blockmap_cache, sizeof(hfs->blockmap_cache), 0); if (cnt < 1) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_block_is_alloc: Error reading block bitmap at offset %" PRIuOFF, b); return -1; } hfs->blockmap_cache_start = b; hfs->blockmap_cache_len = cnt; } b2 = (size_t) (b - hfs->blockmap_cache_start); return (hfs->blockmap_cache[b2] & (1 << (7 - (a_addr % 8)))) != 0; } TSK_FS_BLOCK_FLAG_ENUM hfs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { return (hfs_block_is_alloc((HFS_INFO *) a_fs, a_addr) == 1) ? TSK_FS_BLOCK_FLAG_ALLOC : TSK_FS_BLOCK_FLAG_UNALLOC; } static uint8_t hfs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T start_blk, TSK_DADDR_T end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM flags, TSK_FS_BLOCK_WALK_CB action, void *ptr) { char *myname = "hfs_block_walk"; HFS_INFO *hfs = (HFS_INFO *) fs; TSK_FS_BLOCK *fs_block; TSK_DADDR_T addr; if (tsk_verbose) tsk_fprintf(stderr, "%s: start_blk: %" PRIuDADDR " end_blk: %" PRIuDADDR " flags: %" PRIu32 "\n", myname, start_blk, end_blk, flags); // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (start_blk < fs->first_block || start_blk > fs->last_block) { tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: invalid start block number: %" PRIuDADDR "", myname, start_blk); return 1; } if (end_blk < fs->first_block || end_blk > fs->last_block) { tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: invalid last block number: %" PRIuDADDR "", myname, end_blk); return 1; } if (start_blk > end_blk) XSWAP(start_blk, end_blk); /* Sanity check on flags -- make sure at least one ALLOC is set */ if (((flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } /* * Iterate */ for (addr = start_blk; addr <= end_blk; addr++) { int retval; int myflags; /* identify if the block is allocated or not */ myflags = hfs_block_is_alloc(hfs, addr) ? TSK_FS_BLOCK_FLAG_ALLOC : TSK_FS_BLOCK_FLAG_UNALLOC; // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; if (tsk_fs_block_get(fs, fs_block, addr) == NULL) { tsk_fs_block_free(fs_block); return 1; } retval = action(fs_block, ptr); if (TSK_WALK_STOP == retval) { break; } else if (TSK_WALK_ERROR == retval) { tsk_fs_block_free(fs_block); return 1; } } tsk_fs_block_free(fs_block); return 0; } uint8_t hfs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB action, void *ptr) { TSK_INUM_T inum; TSK_FS_FILE *fs_file; if (tsk_verbose) tsk_fprintf(stderr, "hfs_inode_walk: start_inum: %" PRIuINUM " end_inum: %" PRIuINUM " flags: %" PRIu32 "\n", start_inum, end_inum, flags); /* * Sanity checks. */ if (start_inum < fs->first_inum) { tsk_fprintf(stderr, "Starting inode number is too small (%" PRIuINUM ")", start_inum); return 1; } if (start_inum > fs->last_inum) { tsk_fprintf(stderr, "Starting inode number is too large (%" PRIuINUM ")", start_inum); return 1; } if (end_inum < fs->first_inum) { tsk_fprintf(stderr, "Ending inode number is too small (%" PRIuINUM ")", end_inum); return 1; } if (end_inum > fs->last_inum) { tsk_fprintf(stderr, "Ending inode number is too large (%" PRIuINUM ")", end_inum); return 1; } /* If ORPHAN is wanted, then make sure that the flags are correct */ if (flags & TSK_FS_META_FLAG_ORPHAN) { flags |= TSK_FS_META_FLAG_UNALLOC; flags &= ~TSK_FS_META_FLAG_ALLOC; flags |= TSK_FS_META_FLAG_USED; flags &= ~TSK_FS_META_FLAG_UNUSED; } else { if (((flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED flags are set, then set them * both */ if (((flags & TSK_FS_META_FLAG_USED) == 0) && ((flags & TSK_FS_META_FLAG_UNUSED) == 0)) { flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(HFS_FILE_CONTENT_LEN)) == NULL) return 1; if (start_inum > end_inum) XSWAP(start_inum, end_inum); for (inum = start_inum; inum <= end_inum; inum++) { int retval; if (hfs_inode_lookup(fs, fs_file, inum)) { // deleted files may not exist in the catalog if (tsk_errno == TSK_ERR_FS_INODE_NUM) { tsk_error_reset(); continue; } else { return 1; } } if ((fs_file->meta->flags & flags) != fs_file->meta->flags) continue; /* call action */ retval = action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } tsk_fs_file_close(fs_file); return 0; } /* print the name of a file at a given inode * returns 0 on success, 1 on error */ static uint8_t print_inode_name(FILE * hFile, TSK_FS_INFO * fs, TSK_INUM_T inum) { HFS_INFO *hfs = (HFS_INFO *) fs; char fn[HFS_MAXNAMLEN + 1]; HFS_ENTRY entry; if (hfs_cat_file_lookup(hfs, inum, &entry)) return 1; if (hfs_uni2ascii(fs, entry.thread.name.unicode, tsk_getu16(fs->endian, entry.thread.name.length), fn, HFS_MAXNAMLEN + 1)) return 1; tsk_fprintf(hFile, "%s", fn); return 0; } /* tail recursive function to print a path... prints the parent path, then * appends / and the name of the given inode. prints nothing for root * returns 0 on success, 1 on failure */ static uint8_t print_parent_path(FILE * hFile, TSK_FS_INFO * fs, TSK_INUM_T inum) { HFS_INFO *hfs = (HFS_INFO *) fs; char fn[HFS_MAXNAMLEN + 1]; HFS_ENTRY entry; if (inum == HFS_ROOT_INUM) return 0; if (inum <= HFS_ROOT_INUM) { tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "print_parent_path: out-of-range inode %" PRIuINUM, inum); return 1; } if (hfs_cat_file_lookup(hfs, inum, &entry)) return 1; if (hfs_uni2ascii(fs, entry.thread.name.unicode, tsk_getu16(fs->endian, entry.thread.name.length), fn, HFS_MAXNAMLEN + 1)) return 1; if (print_parent_path(hFile, fs, (TSK_INUM_T) tsk_getu32(fs->endian, entry.thread.parent_cnid))) return 1; tsk_fprintf(hFile, "/%s", fn); return 0; } /* print the file name corresponding to an inode, in brackets after a space. * uses Unix path conventions, and does not include the volume name. * returns 0 on success, 1 on failure */ static uint8_t print_inode_file(FILE * hFile, TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_fprintf(hFile, " ["); if (inum == HFS_ROOT_INUM) tsk_fprintf(hFile, "/"); else { if (print_parent_path(hFile, fs, inum)) { tsk_fprintf(hFile, "unknown]"); return 1; } } tsk_fprintf(hFile, "]"); return 0; } static uint8_t hfs_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for HFS yet"); return 1; } static uint8_t hfs_fsstat(TSK_FS_INFO * fs, FILE * hFile) { // char *myname = "hfs_fsstat"; HFS_INFO *hfs = (HFS_INFO *) fs; hfs_plus_vh *sb = hfs->fs; time_t mac_time; TSK_INUM_T inode; if (tsk_verbose) tsk_fprintf(stderr, "hfs_fstat: called\n"); tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: "); if (tsk_getu16(fs->endian, hfs->fs->signature) == HFS_VH_SIG_HFSPLUS) tsk_fprintf(hFile, "HFS+\n"); else if (tsk_getu16(fs->endian, hfs->fs->signature) == HFS_VH_SIG_HFSX) tsk_fprintf(hFile, "HFSX\n"); else tsk_fprintf(hFile, "Unknown\n"); // print name and number of version tsk_fprintf(hFile, "File System Version: "); switch (tsk_getu16(fs->endian, hfs->fs->version)) { case 4: tsk_fprintf(hFile, "HFS+\n"); break; case 5: tsk_fprintf(hFile, "HFSX\n"); break; default: tsk_fprintf(hFile, "Unknown (%" PRIu16 ")\n", tsk_getu16(fs->endian, hfs->fs->version)); break; } if (tsk_getu16(fs->endian, hfs->fs->signature) == HFS_VH_SIG_HFSX) { tsk_fprintf(hFile, "Case Sensitive: %s\n", hfs->is_case_sensitive ? "yes" : "no"); } if (hfs->hfs_wrapper_offset > 0) { tsk_fprintf(hFile, "File system is embedded in an HFS wrapper at offset %" PRIuOFF "\n", hfs->hfs_wrapper_offset); } tsk_fprintf(hFile, "\nVolume Name: "); if (print_inode_name(hFile, fs, HFS_ROOT_INUM)) return 1; tsk_fprintf(hFile, "\n"); tsk_fprintf(hFile, "Volume Identifier: %08" PRIx32 "%08" PRIx32 "\n", tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_ID1]), tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_ID2])); // print last mounted info tsk_fprintf(hFile, "\nLast Mounted By: "); if (tsk_getu32(fs->endian, sb->last_mnt_ver) == HFS_VH_MVER_HFSPLUS) tsk_fprintf(hFile, "Mac OS X\n"); else if (tsk_getu32(fs->endian, sb->last_mnt_ver) == HFS_VH_MVER_HFSJ) tsk_fprintf(hFile, "Mac OS X, Journaled\n"); else if (tsk_getu32(fs->endian, sb->last_mnt_ver) == HFS_VH_MVER_FSK) tsk_fprintf(hFile, "failed journal replay\n"); else if (tsk_getu32(fs->endian, sb->last_mnt_ver) == HFS_VH_MVER_FSCK) tsk_fprintf(hFile, "fsck_hfs\n"); else if (tsk_getu32(fs->endian, sb->last_mnt_ver) == HFS_VH_MVER_OS89) tsk_fprintf(hFile, "Mac OS 8.1 - 9.2.2\n"); else tsk_fprintf(hFile, "Unknown (%" PRIx32 "\n", tsk_getu32(fs->endian, sb->last_mnt_ver)); /* State of the file system */ if ((tsk_getu32(fs->endian, hfs->fs->attr) & HFS_VH_ATTR_UNMOUNTED) && (!(tsk_getu32(fs->endian, hfs->fs->attr) & HFS_VH_ATTR_INCONSISTENT))) tsk_fprintf(hFile, "Volume Unmounted Properly\n"); else tsk_fprintf(hFile, "Volume Unmounted Improperly\n"); tsk_fprintf(hFile, "Mount Count: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->write_cnt)); // Dates // (creation date is in local time zone, not UTC, according to TN 1150) mac_time = hfs2unixtime(tsk_getu32(fs->endian, hfs->fs->cr_date)); tsk_fprintf(hFile, "\nCreation Date: \t%s", asctime(gmtime(&mac_time))); mac_time = hfs2unixtime(tsk_getu32(fs->endian, hfs->fs->m_date)); tsk_fprintf(hFile, "Last Written Date: \t%s", ctime(&mac_time)); mac_time = hfs2unixtime(tsk_getu32(fs->endian, hfs->fs->bkup_date)); tsk_fprintf(hFile, "Last Backup Date: \t%s", ctime(&mac_time)); mac_time = hfs2unixtime(tsk_getu32(fs->endian, hfs->fs->chk_date)); tsk_fprintf(hFile, "Last Checked Date: \t%s", ctime(&mac_time)); if (tsk_getu32(fs->endian, hfs->fs->attr) & HFS_VH_ATTR_SOFTWARE_LOCK) tsk_fprintf(hFile, "Software write protect enabled\n"); /* Print journal information */ if (tsk_getu32(fs->endian, sb->attr) & HFS_VH_ATTR_JOURNALED) { tsk_fprintf(hFile, "\nJournal Info Block: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->jinfo_blk)); } tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); inode = tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_BOOT]); tsk_fprintf(hFile, "Bootable Folder ID: %" PRIuINUM, inode); if (inode > 0) print_inode_file(hFile, fs, inode); tsk_fprintf(hFile, "\n"); inode = tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_START]); tsk_fprintf(hFile, "Startup App ID: %" PRIuINUM, inode); if (inode > 0) print_inode_file(hFile, fs, inode); tsk_fprintf(hFile, "\n"); inode = tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_OPEN]); tsk_fprintf(hFile, "Startup Open Folder ID: %" PRIuINUM, inode); if (inode > 0) print_inode_file(hFile, fs, inode); tsk_fprintf(hFile, "\n"); inode = tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_BOOT9]); tsk_fprintf(hFile, "Mac OS 8/9 Blessed System Folder ID: %" PRIuINUM, inode); if (inode > 0) print_inode_file(hFile, fs, inode); tsk_fprintf(hFile, "\n"); inode = tsk_getu32(fs->endian, sb->finder_info[HFS_VH_FI_BOOTX]); tsk_fprintf(hFile, "Mac OS X Blessed System Folder ID: %" PRIuINUM, inode); if (inode > 0) print_inode_file(hFile, fs, inode); tsk_fprintf(hFile, "\n"); tsk_fprintf(hFile, "Number of files: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->file_cnt)); tsk_fprintf(hFile, "Number of folders: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->fldr_cnt)); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Block Range: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block); if (fs->last_block != fs->last_block_act) tsk_fprintf(hFile, "Total Range in Image: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block_act); tsk_fprintf(hFile, "Allocation Block Size: %u\n", fs->block_size); tsk_fprintf(hFile, "Number of Free Blocks: %" PRIu32 "\n", tsk_getu32(fs->endian, sb->free_blks)); if (tsk_getu32(fs->endian, hfs->fs->attr) & HFS_VH_ATTR_BADBLOCKS) tsk_fprintf(hFile, "Volume has bad blocks\n"); return 0; } /************************* istat *******************************/ #define HFS_PRINT_WIDTH 8 typedef struct { FILE *hFile; int idx; } HFS_PRINT_ADDR; static TSK_WALK_RET_ENUM print_addr_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { HFS_PRINT_ADDR *print = (HFS_PRINT_ADDR *) ptr; tsk_fprintf(print->hFile, "%" PRIuDADDR " ", addr); if (++(print->idx) == HFS_PRINT_WIDTH) { tsk_fprintf(print->hFile, "\n"); print->idx = 0; } return TSK_WALK_CONT; } /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File name to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t hfs_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { HFS_INFO *hfs = (HFS_INFO *) fs; TSK_FS_FILE *fs_file; char hfs_mode[12]; HFS_PRINT_ADDR print; HFS_ENTRY entry; if (tsk_verbose) tsk_fprintf(stderr, "hfs_istat: inum: %" PRIuINUM " numblock: %" PRIu32 "\n", inum, numblock); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) { strncat(tsk_errstr2, " - istat", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } tsk_fprintf(hFile, "Catalog Record: %" PRIuINUM "\n", inum); tsk_fprintf(hFile, "%sAllocated\n", (fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) ? "Not " : ""); tsk_fprintf(hFile, "Type:\t"); if (fs_file->meta->type == TSK_FS_META_TYPE_REG) tsk_fprintf(hFile, "File\n"); else if (fs_file->meta->type == TSK_FS_META_TYPE_DIR) tsk_fprintf(hFile, "Folder\n"); else tsk_fprintf(hFile, "\n"); tsk_fs_meta_make_ls(fs_file->meta, hfs_mode, sizeof(hfs_mode)); tsk_fprintf(hFile, "Mode:\t%s\n", hfs_mode); tsk_fprintf(hFile, "Size:\t%" PRIuOFF "\n", fs_file->meta->size); tsk_fprintf(hFile, "uid / gid: %" PRIuUID " / %" PRIuGID "\n", fs_file->meta->uid, fs_file->meta->gid); tsk_fprintf(hFile, "Link count:\t%d\n", fs_file->meta->nlink); if (hfs_cat_file_lookup(hfs, inum, &entry) == 0) { tsk_fprintf(hFile, "\n"); /* The cat.perm union contains file-type specific values. * Print them if they are relevant. */ if ((fs_file->meta->type == TSK_FS_META_TYPE_CHR) || (fs_file->meta->type == TSK_FS_META_TYPE_BLK)) { tsk_fprintf(hFile, "Device ID:\t%" PRIu32 "\n", tsk_getu32(fs->endian, entry.cat.std.perm.special.raw)); } else if ((tsk_getu32(fs->endian, entry.cat.std.u_info.file_type) == HFS_HARDLINK_FILE_TYPE) && (tsk_getu32(fs->endian, entry.cat.std.u_info.file_cr) == HFS_HARDLINK_FILE_CREATOR)) { // technically, the creation date of this item should be the same as either the // creation date of the "HFS+ Private Data" folder or the creation date of the root folder tsk_fprintf(hFile, "Hard link inode number\t %" PRIu32 "\n", tsk_getu32(fs->endian, entry.cat.std.perm.special.inum)); } tsk_fprintf(hFile, "Admin flags: %" PRIu8, entry.cat.std.perm.a_flags); if (entry.cat.std.perm.a_flags != 0) { tsk_fprintf(hFile, " - "); if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_ARCHIVED) tsk_fprintf(hFile, "archived "); if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_IMMUTABLE) tsk_fprintf(hFile, "immutable "); if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_APPEND) tsk_fprintf(hFile, "append-only "); } tsk_fprintf(hFile, "\n"); tsk_fprintf(hFile, "Owner flags: %" PRIu8, entry.cat.std.perm.o_flags); if (entry.cat.std.perm.o_flags != 0) { tsk_fprintf(hFile, " - "); if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_NODUMP) tsk_fprintf(hFile, "no-dump "); if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_IMMUTABLE) tsk_fprintf(hFile, "immutable "); if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_APPEND) tsk_fprintf(hFile, "append-only "); if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_OPAQUE) tsk_fprintf(hFile, "opaque "); if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_COMPRESSED) tsk_fprintf(hFile, "compressed "); } tsk_fprintf(hFile, "\n"); if (tsk_getu16(fs->endian, entry.cat.std.flags) & HFS_FILE_FLAG_LOCKED) tsk_fprintf(hFile, "Locked\n"); if (tsk_getu16(fs->endian, entry.cat.std.flags) & HFS_FILE_FLAG_ATTR) tsk_fprintf(hFile, "Has extended attributes\n"); if (tsk_getu16(fs->endian, entry.cat.std.flags) & HFS_FILE_FLAG_ACL) tsk_fprintf(hFile, "Has security data (ACLs)\n"); tsk_fprintf(hFile, "File type:\t%04" PRIx32 "\nFile creator:\t%04" PRIx32 "\n", tsk_getu32(fs->endian, entry.cat.std.u_info.file_type), tsk_getu32(fs->endian, entry.cat.std.u_info.file_type)); if (tsk_getu16(fs->endian, entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_NAME_LOCKED) tsk_fprintf(hFile, "Name locked\n"); if (tsk_getu16(fs->endian, entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_HAS_BUNDLE) tsk_fprintf(hFile, "Has bundle\n"); if (tsk_getu16(fs->endian, entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_IS_INVISIBLE) tsk_fprintf(hFile, "Is invisible\n"); if (tsk_getu16(fs->endian, entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_IS_ALIAS) tsk_fprintf(hFile, "Is alias\n"); // @@@ The tech note has a table that converts nums to encoding names. tsk_fprintf(hFile, "Text encoding:\t%" PRIx32 "\n", tsk_getu32(fs->endian, entry.cat.std.text_enc)); if (tsk_getu16(fs->endian, entry.cat.std.rec_type) == HFS_FILE_RECORD) { tsk_fprintf(hFile, "Resource fork size:\t%" PRIu64 "\n", tsk_getu64(fs->endian, entry.cat.resource.logic_sz)); } } if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted times:\n"); fs_file->meta->mtime -= sec_skew; fs_file->meta->atime -= sec_skew; fs_file->meta->ctime -= sec_skew; fs_file->meta->crtime -= sec_skew; fs_file->meta->time2.hfs.bkup_time -= sec_skew; tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); tsk_fprintf(hFile, "Content Modified:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "Attributes Modified:\t%s", ctime(&fs_file->meta->ctime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); tsk_fprintf(hFile, "Backed Up:\t%s", ctime(&fs_file->meta->time2.hfs.bkup_time)); fs_file->meta->mtime += sec_skew; fs_file->meta->atime += sec_skew; fs_file->meta->ctime += sec_skew; fs_file->meta->crtime += sec_skew; fs_file->meta->time2.hfs.bkup_time += sec_skew; tsk_fprintf(hFile, "\nOriginal times:\n"); } else { tsk_fprintf(hFile, "\nTimes:\n"); } tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); tsk_fprintf(hFile, "Content Modified:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "Attributes Modified:\t%s", ctime(&fs_file->meta->ctime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); tsk_fprintf(hFile, "Backed Up:\t%s", ctime(&fs_file->meta->time2.hfs.bkup_time)); // @@@ Will need to add resource fork to here when support is added. tsk_fprintf(hFile, "\nData Fork Blocks:\n"); print.idx = 0; print.hFile = hFile; if (tsk_fs_file_walk(fs_file, (TSK_FS_FILE_WALK_FLAG_AONLY | TSK_FS_FILE_WALK_FLAG_SLACK), print_addr_act, (void *) &print)) { tsk_fprintf(hFile, "\nError reading file\n"); tsk_error_print(hFile); tsk_error_reset(); } else if (print.idx != 0) { tsk_fprintf(hFile, "\n"); } tsk_fs_file_close(fs_file); return 0; } static TSK_FS_ATTR_TYPE_ENUM hfs_get_default_attr_type(const TSK_FS_FILE * a_file) { return TSK_FS_ATTR_TYPE_DEFAULT; } static void hfs_close(TSK_FS_INFO * fs) { HFS_INFO *hfs = (HFS_INFO *) fs; fs->tag = 0; free(hfs->fs); tsk_fs_file_close(hfs->catalog_file); hfs->catalog_attr = NULL; if (hfs->blockmap_file) { tsk_fs_file_close(hfs->blockmap_file); hfs->blockmap_attr = NULL; } free(hfs); } /* hfs_open - open an hfs file system * * Return NULL on error (or not an HFS or HFS+ file system) * */ TSK_FS_INFO * hfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype, uint8_t test) { HFS_INFO *hfs; unsigned int len; TSK_FS_INFO *fs; ssize_t cnt; tsk_error_reset(); if (TSK_FS_TYPE_ISHFS(ftype) == 0) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS Type in hfs_open"); return NULL; } if ((hfs = (HFS_INFO *) tsk_malloc(sizeof(HFS_INFO))) == NULL) return NULL; fs = &(hfs->fs_info); fs->ftype = TSK_FS_TYPE_HFS; fs->duname = "Allocation Block"; fs->tag = TSK_FS_INFO_TAG; fs->flags = 0; fs->img_info = img_info; fs->offset = offset; /* * Read the superblock. */ len = sizeof(hfs_plus_vh); if ((hfs->fs = (hfs_plus_vh *) tsk_malloc(len)) == NULL) { fs->tag = 0; free(hfs); return NULL; } if (hfs_checked_read_random(fs, (char *) hfs->fs, len, (TSK_OFF_T) HFS_VH_OFF)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_open: superblock"); fs->tag = 0; free(hfs->fs); free(hfs); return NULL; } /* * Verify we are looking at an HFS+ image */ if (tsk_fs_guessu16(fs, hfs->fs->signature, HFS_VH_SIG_HFSPLUS) && tsk_fs_guessu16(fs, hfs->fs->signature, HFS_VH_SIG_HFSX) && tsk_fs_guessu16(fs, hfs->fs->signature, HFS_VH_SIG_HFS)) { fs->tag = 0; free(hfs->fs); free(hfs); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "not an HFS+ file system (magic)"); return NULL; } /* * Handle an HFS-wrapped HFS+ image, which is a HFS volume that contains * the HFS+ volume inside of it. */ if (tsk_getu16(fs->endian, hfs->fs->signature) == HFS_VH_SIG_HFS) { hfs_mdb *wrapper_sb = (hfs_mdb *) hfs->fs; // Verify that we are setting a wrapper and not a normal HFS volume if ((tsk_getu16(fs->endian, wrapper_sb->drEmbedSigWord) == HFS_VH_SIG_HFSPLUS) || (tsk_getu16(fs->endian, wrapper_sb->drEmbedSigWord) == HFS_VH_SIG_HFSX)) { TSK_FS_INFO *fs_info2; // offset in sectors to start of first HFS block uint16_t drAlBlSt = tsk_getu16(fs->endian, wrapper_sb->drAlBlSt); // size of each HFS block uint32_t drAlBlkSiz = tsk_getu32(fs->endian, wrapper_sb->drAlBlkSiz); // start of embedded FS uint16_t startBlock = tsk_getu16(fs->endian, wrapper_sb->drEmbedExtent_startBlock); // @@@ VERIFY THE USE OF 512 here instead of something else.... TSK_OFF_T hfsplus_offset = (drAlBlSt * (TSK_OFF_T) 512) + (drAlBlkSiz * (TSK_OFF_T) startBlock); if (tsk_verbose) tsk_fprintf(stderr, "hfs_open: HFS+/HFSX within HFS wrapper at byte offset %" PRIuOFF "\n", hfsplus_offset); fs->tag = 0; free(hfs->fs); free(hfs); /* just re-open with the new offset, then record the offset */ fs_info2 = hfs_open(img_info, offset + hfsplus_offset, ftype, test); if (fs_info2) ((HFS_INFO *) fs_info2)->hfs_wrapper_offset = hfsplus_offset; return fs_info2; } else { fs->tag = 0; free(hfs->fs); free(hfs); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "HFS file systems (other than wrappers HFS+/HFSX file systems) are not supported"); return NULL; } } fs->block_count = tsk_getu32(fs->endian, hfs->fs->blk_cnt); fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; /* this isn't really accurate; fs->block_size reports only the size of the allocation block; the size of the device block has to be found from the device (allocation block size should always be larger than device block size and an even multiple of the device block size) */ fs->dev_bsize = fs->block_size = tsk_getu32(fs->endian, hfs->fs->blk_sz); // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; /* * Set function pointers */ fs->inode_walk = hfs_inode_walk; fs->block_walk = hfs_block_walk; fs->block_getflags = hfs_block_getflags; fs->load_attrs = hfs_load_attrs; fs->get_default_attr_type = hfs_get_default_attr_type; fs->file_add_meta = hfs_inode_lookup; fs->dir_open_meta = hfs_dir_open_meta; fs->fsstat = hfs_fsstat; fs->fscheck = hfs_fscheck; fs->istat = hfs_istat; fs->close = hfs_close; // lazy loading of block map hfs->blockmap_file = NULL; hfs->blockmap_attr = NULL; hfs->blockmap_cache_start = -1; hfs->blockmap_cache_len = 0; fs->first_inum = HFS_ROOT_INUM; fs->root_inum = HFS_ROOT_INUM; fs->last_inum = HFS_FIRST_USER_CNID - 1; // we will later increase this fs->inum_count = fs->last_inum - fs->first_inum + 1; /* We will load the extents file data when we need it */ hfs->extents_file = NULL; hfs->extents_attr = NULL; /* Load the catalog file though */ if ((hfs->catalog_file = tsk_fs_file_open_meta(fs, NULL, HFS_CATALOG_FILE_ID)) == NULL) { fs->tag = 0; free(hfs->fs); free(hfs); return NULL; } /* cache the data attribute */ hfs->catalog_attr = tsk_fs_attrlist_get(hfs->catalog_file->meta->attr, TSK_FS_ATTR_TYPE_DEFAULT); if (!hfs->catalog_attr) { fs->tag = 0; tsk_fs_file_close(hfs->catalog_file); free(hfs->fs); free(hfs); strncat(tsk_errstr2, " - Data Attribute not found in Catalog File", TSK_ERRSTR_L - strlen(tsk_errstr2)); return NULL; } // cache the catalog file header cnt = tsk_fs_attr_read(hfs->catalog_attr, 14, (char *) &(hfs->catalog_header), sizeof(hfs_btree_header_record), 0); if (cnt != sizeof(hfs_btree_header_record)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "hfs_open: Error reading catalog header"); fs->tag = 0; free(hfs->fs); free(hfs); return NULL; } if (tsk_getu16(fs->endian, hfs->fs->version) == HFS_VH_VER_HFSPLUS) hfs->is_case_sensitive = 0; else if (tsk_getu16(fs->endian, hfs->fs->version) == HFS_VH_VER_HFSX) { if (hfs->catalog_header.compType == HFS_BT_HEAD_COMP_SENS) hfs->is_case_sensitive = 1; else if (hfs->catalog_header.compType == HFS_BT_HEAD_COMP_INSENS) hfs->is_case_sensitive = 0; else { tsk_fprintf(stderr, "hfs_open: invalid value (0x%02" PRIx8 ") for key compare type\n", hfs->catalog_header.compType); hfs->is_case_sensitive = 0; } } else { tsk_fprintf(stderr, "hfs_open: unknown HFS+/HFSX version (%" PRIu16 "\n", tsk_getu16(fs->endian, hfs->fs->version)); hfs->is_case_sensitive = 0; } // update the numbers. fs->last_inum = hfs_find_highest_inum(hfs); fs->inum_count = fs->last_inum + 1; snprintf((char *) fs->fs_id, 17, "%08" PRIx32 "%08" PRIx32, tsk_getu32(fs->endian, hfs->fs->finder_info[HFS_VH_FI_ID1]), tsk_getu32(fs->endian, hfs->fs->finder_info[HFS_VH_FI_ID2])); fs->fs_id_used = 16; /* journal */ fs->jblk_walk = hfs_jblk_walk; fs->jentry_walk = hfs_jentry_walk; fs->jopen = hfs_jopen; fs->name_cmp = hfs_name_cmp; fs->journ_inum = 0; return fs; } sleuthkit-3.2.3/tsk3/fs/hfs_dent.c000644 000765 000024 00000035533 11643647440 017601 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Copyright (c) 2009 Brian Carrier. All rights reserved. ** ** Judson Powers [jpowers@atc-nycorp.com] ** Copyright (c) 2008 ATC-NY. All rights reserved. ** This file contains data developed with support from the National ** Institute of Justice, Office of Justice Programs, U.S. Department of Justice. ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier@sleuthkit.org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /** \file hfs_dent.c * Contains the file name layer code for HFS+ file systems -- not included in * code by default. */ #include "tsk_fs_i.h" #include "tsk_hfs.h" #define UTF16_NULL 0x0000 #define UTF16_NULL_REPLACE 0x005e #define UTF16_SLASH 0x002f #define UTF16_COLON 0x003a /* convert HFS+'s UTF16 to UTF8 * replaces null characters with another character (0xfffd) * replaces slashes (permitted by HFS+ but causes problems with TSK) * with colons (generally not allowed by Mac OS X) * note that at least one directory on HFS+ volumes begins with * four nulls, so we do need to handle nulls; also, Apple chooses * to encode nulls as UTF8 \xC0\x80, which is not a valid UTF8 sequence * returns 0 on success, 1 on failure; sets up to error string 1 */ uint8_t hfs_uni2ascii(TSK_FS_INFO * fs, uint8_t * uni, int ulen, char *asc, int alen) { UTF8 *ptr8; uint8_t *uniclean; UTF16 *ptr16; int i; TSKConversionResult r; // remove nulls from the Unicode string // convert / to : uniclean = (uint8_t *) tsk_malloc(ulen * 2); if (!uniclean) return 1; memcpy(uniclean, uni, ulen * 2); for (i = 0; i < ulen; ++i) { uint16_t uc = tsk_getu16(fs->endian, uniclean + i * 2); int changed = 0; if (uc == UTF16_NULL) { uc = UTF16_NULL_REPLACE; changed = 1; } else if (uc == UTF16_SLASH) { uc = UTF16_COLON; changed = 1; } if (changed) *((uint16_t *) (uniclean + i * 2)) = tsk_getu16(fs->endian, (uint8_t *) & uc); } // convert to UTF-8 memset(asc, 0, alen); ptr8 = (UTF8 *) asc; ptr16 = (UTF16 *) uniclean; r = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &ptr16, (const UTF16 *) (&uniclean[ulen * 2]), &ptr8, (UTF8 *) & asc[alen], TSKstrictConversion); free(uniclean); if (r != TSKconversionOK) { tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_uni2ascii: unicode conversion failed (%d)", (int) r); return 1; } return 0; } static TSK_FS_NAME_TYPE_ENUM hfsmode2tsknametype(uint16_t a_mode) { switch (a_mode & HFS_IN_IFMT) { case HFS_IN_IFIFO: return TSK_FS_NAME_TYPE_FIFO; case HFS_IN_IFCHR: return TSK_FS_NAME_TYPE_CHR; case HFS_IN_IFDIR: return TSK_FS_NAME_TYPE_DIR; case HFS_IN_IFBLK: return TSK_FS_NAME_TYPE_BLK; case HFS_IN_IFREG: return TSK_FS_NAME_TYPE_REG; case HFS_IN_IFLNK: return TSK_FS_NAME_TYPE_LNK; case HFS_IN_IFSOCK: return TSK_FS_NAME_TYPE_SOCK; case HFS_IFWHT: return TSK_FS_NAME_TYPE_WHT; case HFS_IFXATTR: return TSK_FS_NAME_TYPE_UNDEF; default: /* error */ return TSK_FS_NAME_TYPE_UNDEF; } } // used to pass data to the callback typedef struct { TSK_FS_DIR *fs_dir; TSK_FS_NAME *fs_name; } HFS_DIR_OPEN_META_INFO; static uint8_t hfs_dir_open_meta_cb(HFS_INFO * hfs, int8_t level_type, const void *targ_data, const hfs_btree_key_cat * cur_key, TSK_OFF_T key_off, void *ptr) { uint32_t *cnid_p = (uint32_t *) targ_data; HFS_DIR_OPEN_META_INFO *info = (HFS_DIR_OPEN_META_INFO *) ptr; TSK_FS_INFO *fs = &hfs->fs_info; if (tsk_verbose) fprintf(stderr, "hfs_dir_open_meta_cb: want %" PRIu32 " vs got %" PRIu32 " (%s node)\n", *cnid_p, tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid), (level_type == HFS_BT_NODE_TYPE_IDX) ? "Index" : "Leaf"); if (level_type == HFS_BT_NODE_TYPE_IDX) { if (tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid) < *cnid_p) return HFS_BTREE_CB_IDX_LT; else return HFS_BTREE_CB_IDX_EQGT; } else { uint8_t *rec_buf = (uint8_t *) cur_key; uint16_t rec_type; size_t rec_off2; if (tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid) < *cnid_p) return HFS_BTREE_CB_LEAF_GO; else if (tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid) > *cnid_p) return HFS_BTREE_CB_LEAF_STOP; rec_off2 = 2 + tsk_getu16(hfs->fs_info.endian, cur_key->key_len); // @@@ NEED TO REPLACE THIS SOMEHOW, but need to figure out the max length /* if (rec_off2 > nodesize) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dir_open_meta: offset of record+keylen %d in leaf node %d too large (%zu vs %" PRIu16 ")", rec, cur_node, rec_off2, nodesize); tsk_fs_name_free(fs_name); free(node); return TSK_COR; } */ rec_type = tsk_getu16(hfs->fs_info.endian, &rec_buf[rec_off2]); // Catalog entry is for a file if (rec_type == HFS_FILE_THREAD) { tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dir_open_meta: Entry" " is a file, not a folder"); return HFS_BTREE_CB_ERR; } /* This will link the folder to its parent, which is the ".." entry */ else if (rec_type == HFS_FOLDER_THREAD) { hfs_thread *thread = (hfs_thread *) & rec_buf[rec_off2]; strcpy(info->fs_name->name, ".."); info->fs_name->meta_addr = tsk_getu32(hfs->fs_info.endian, thread->parent_cnid); info->fs_name->type = TSK_FS_NAME_TYPE_DIR; info->fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; } /* This is a folder in the folder */ else if (rec_type == HFS_FOLDER_RECORD) { hfs_folder *folder = (hfs_folder *) & rec_buf[rec_off2]; info->fs_name->meta_addr = tsk_getu32(hfs->fs_info.endian, folder->std.cnid); info->fs_name->type = TSK_FS_NAME_TYPE_DIR; info->fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (hfs_uni2ascii(fs, (uint8_t *) cur_key->name.unicode, tsk_getu16(hfs->fs_info.endian, cur_key->name.length), info->fs_name->name, HFS_MAXNAMLEN + 1)) { return HFS_BTREE_CB_ERR; } } /* This is a normal file in the folder */ else if (rec_type == HFS_FILE_RECORD) { hfs_file *file = (hfs_file *) & rec_buf[rec_off2]; info->fs_name->meta_addr = tsk_getu32(hfs->fs_info.endian, file->std.cnid); info->fs_name->type = hfsmode2tsknametype(tsk_getu16(hfs->fs_info.endian, file->std.perm.mode)); info->fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (hfs_uni2ascii(fs, (uint8_t *) cur_key->name.unicode, tsk_getu16(hfs->fs_info.endian, cur_key->name.length), info->fs_name->name, HFS_MAXNAMLEN + 1)) { return HFS_BTREE_CB_ERR; } } else { tsk_errno = TSK_ERR_FS_GENFS; // @@@ MAY NEED TO IMPROVE BELOW MESSAGE snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dir_open_meta: Unknown record type %d in leaf node", rec_type); return HFS_BTREE_CB_ERR; } if (tsk_fs_dir_add(info->fs_dir, info->fs_name)) { return HFS_BTREE_CB_ERR; } return HFS_BTREE_CB_LEAF_GO; } } /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM hfs_dir_open_meta(TSK_FS_INFO * fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { HFS_INFO *hfs = (HFS_INFO *) fs; uint32_t cnid; /* catalog node ID of the entry (= inum) */ TSK_FS_DIR *fs_dir; TSK_FS_NAME *fs_name; HFS_DIR_OPEN_META_INFO info; tsk_error_reset(); cnid = (uint32_t) a_addr; if (tsk_verbose) fprintf(stderr, "hfs_dir_open_meta: called for directory %" PRIu32 "\n", cnid); if (a_addr < fs->first_inum || a_addr > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dir_open_meta: Invalid inode value: %" PRIuINUM, a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "hfs_dir_open_meta: NULL fs_dir argument given"); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "hfs_dir_open_meta: Processing directory %" PRIuINUM "\n", a_addr); fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(fs, a_addr, 128)) == NULL) { return TSK_ERR; } if ((fs_name = tsk_fs_name_alloc(HFS_MAXNAMLEN, 0)) == NULL) { return TSK_ERR; } info.fs_dir = fs_dir; info.fs_name = fs_name; if ((fs_dir->fs_file = tsk_fs_file_open_meta(fs, NULL, a_addr)) == NULL) { strncat(tsk_errstr2, " - hfs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_name_free(fs_name); return TSK_ERR; } // if we are listing the root directory, add the Orphan directory and special HFS file entries if (a_addr == fs->root_inum) { int i; for (i = 0; i < 6; i++) { switch (i) { case 0: strncpy(fs_name->name, HFS_EXTENTS_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_EXTENTS_FILE_ID; break; case 1: strncpy(fs_name->name, HFS_CATALOG_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_CATALOG_FILE_ID; break; case 2: strncpy(fs_name->name, HFS_BAD_BLOCK_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_BAD_BLOCK_FILE_ID; break; case 3: strncpy(fs_name->name, HFS_ALLOCATION_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_ALLOCATION_FILE_ID; break; case 4: strncpy(fs_name->name, HFS_STARTUP_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_STARTUP_FILE_ID; break; case 5: strncpy(fs_name->name, HFS_ATTRIBUTES_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_ATTRIBUTES_FILE_ID; break; /* case 6: strncpy(fs_name->name, HFS_REPAIR_CATALOG_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_REPAIR_CATALOG_FILE_ID; break; case 7: strncpy(fs_name->name, HFS_BOGUS_EXTENT_FILE_NAME, fs_name->name_size); fs_name->meta_addr = HFS_BOGUS_EXTENT_FILE_ID; break; */ } fs_name->type = TSK_FS_NAME_TYPE_REG; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } } } if (hfs_cat_traverse(hfs, &cnid, hfs_dir_open_meta_cb, &info)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); return TSK_OK; } int hfs_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { HFS_INFO *hfs = (HFS_INFO *) a_fs_info; if (hfs->is_case_sensitive) return strcmp(s1, s2); else return strcasecmp(s1, s2); } sleuthkit-3.2.3/tsk3/fs/hfs_journal.c000644 000765 000024 00000001432 11643647440 020310 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * This software is distributed under the Common Public License 1.0 */ /** * \file hfs_journal.c * Contains the internal TSK HFS+ journal code -- not included in code by default. */ #include "tsk_fs_i.h" #include "tsk_hfs.h" uint8_t hfs_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_fprintf(stderr, "jopen not implemented for HFS yet"); return 0; } uint8_t hfs_jentry_walk(TSK_FS_INFO * fs, int flags, TSK_FS_JENTRY_WALK_CB action, void *ptr) { tsk_fprintf(stderr, "jentry_walk not implemented for HFS yet"); return 0; } uint8_t hfs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int flags, TSK_FS_JBLK_WALK_CB action, void *ptr) { tsk_fprintf(stderr, "jblk_walk not implemented for HFS yet"); return 0; } sleuthkit-3.2.3/tsk3/fs/hfs_unicompare.c000644 000765 000024 00000101357 11643647440 021007 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Judson Powers [jpowers@atc-nycorp.com] ** Copyright (c) 2008 ATC-NY. All rights reserved. ** This file contains data developed with support from the National ** Institute of Justice, Office of Justice Programs, U.S. Department of Justice. */ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ // Adapted from Apple's Tech Note 1150 // // FastUnicodeCompare - Compare two Unicode strings; produce a relative ordering // // IF RESULT // -------------------------- // str1 < str2 => -1 // str1 = str2 => 0 // str1 > str2 => +1 // // The lower case table starts with 256 entries (one for each of the upper bytes // of the original Unicode char). If that entry is zero, then all characters with // that upper byte are already case folded. If the entry is non-zero, then it is // the _index_ (not byte offset) of the start of the sub-table for the characters // with that upper byte. All ignorable characters are folded to the value zero. // // In pseudocode: // // Let c = source Unicode character // Let table[] = lower case table // // lower = table[highbyte(c)] // if (lower == 0) // lower = c // else // lower = table[lower+lowbyte(c)] // // if (lower == 0) // ignore this character // // To handle ignorable characters, we now need a loop to find the next valid // character. Also, we can't pre-compute the number of characters to compare; // the string length might be larger than the number of non-ignorable characters. // Further, we must be able to handle ignorable characters at any point in the // string, including as the first or last characters. We use a zero value as a // sentinel to detect both end-of-string and ignorable characters. Since the File // Manager doesn't prevent the NUL character (value zero) as part of a filename, // the case mapping table is assumed to map u+0000 to some non-zero value (like // 0xFFFF, which is an invalid Unicode character). // // Pseudocode: // // while (1) { // c1 = GetNextValidChar(str1) // returns zero if at end of string // c2 = GetNextValidChar(str2) // // if (c1 != c2) break // found a difference // // if (c1 == 0) // reached end of string on both // // strings at once? // return 0; // yes, so strings are equal // } // // // When we get here, c1 != c2. So, we just need to determine which one is // // less. // if (c1 < c2) // return -1; // else // return 1; // #include "tsk_fs_i.h" #include "tsk_hfs.h" static int hfs_unicode_compare_int(uint16_t endian, const hfs_uni_str * uni1, const hfs_uni_str * uni2); int hfs_unicode_compare(HFS_INFO * hfs, const hfs_uni_str * uni1, const hfs_uni_str * uni2) { if (hfs->is_case_sensitive) { uint16_t l1, l2; const uint8_t *s1, *s2; uint16_t c1, c2; l1 = tsk_getu16(hfs->fs_info.endian, uni1->length); l2 = tsk_getu16(hfs->fs_info.endian, uni2->length); s1 = uni1->unicode; s2 = uni2->unicode; while (1) { if ((l1 == 0) && (l2 == 0)) return 0; if (l1 == 0) return -1; if (l2 == 0) return 1; c1 = tsk_getu16(hfs->fs_info.endian, s1); c2 = tsk_getu16(hfs->fs_info.endian, s2); if (c1 < c2) return -1; if (c1 > c2) return 1; s1 += 2; s2 += 2; --l1; --l2; } } else return hfs_unicode_compare_int(hfs->fs_info.endian, uni1, uni2); } extern uint16_t gLowerCaseTable[]; static int hfs_unicode_compare_int(uint16_t endian, const hfs_uni_str * uni1, const hfs_uni_str * uni2) { uint16_t c1, c2; uint16_t temp; uint16_t *lowerCaseTable; const uint8_t *str1 = uni1->unicode; const uint8_t *str2 = uni2->unicode; uint16_t length1 = tsk_getu16(endian, uni1->length); uint16_t length2 = tsk_getu16(endian, uni2->length); lowerCaseTable = gLowerCaseTable; while (1) { // Set default values for c1, c2 in case there are no more valid chars c1 = 0; c2 = 0; // Find next non-ignorable char from str1, or zero if no more while (length1 && c1 == 0) { c1 = tsk_getu16(endian, str1); str1 += 2; --length1; if ((temp = lowerCaseTable[c1 >> 8]) != 0) // is there a subtable // for this upper byte? c1 = lowerCaseTable[temp + (c1 & 0x00FF)]; // yes, so fold the char } // Find next non-ignorable char from str2, or zero if no more while (length2 && c2 == 0) { c2 = tsk_getu16(endian, str2); str2 += 2; --length2; if ((temp = lowerCaseTable[c2 >> 8]) != 0) // is there a subtable // for this upper byte? c2 = lowerCaseTable[temp + (c2 & 0x00FF)]; // yes, so fold the char } if (c1 != c2) // found a difference, so stop looping break; if (c1 == 0) // did we reach the end of both strings at the same time? return 0; // yes, so strings are equal } if (c1 < c2) return -1; else return 1; } /* The lower case table consists of a 256-entry high-byte table followed by some number of 256-entry subtables. The high-byte table contains either an offset to the subtable for characters with that high byte or zero, which means that there are no case mappings or ignored characters in that block. Ignored characters are mapped to zero. */ uint16_t gLowerCaseTable[] = { // High-byte indices ( == 0 iff no case mapping and no ignorables ) /* 0 */ 0x0100, 0x0200, 0x0000, 0x0300, 0x0400, 0x0500, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 1 */ 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 2 */ 0x0700, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 3 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 4 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 5 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 6 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 7 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 9 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* A */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* B */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* C */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* D */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* E */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* F */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0900, 0x0A00, // Table 1 (for high byte 0x00) /* 0 */ 0xFFFF, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, /* 1 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, /* 2 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, /* 3 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, /* 4 */ 0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, /* 5 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, /* 6 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, /* 7 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, /* 8 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, /* 9 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, /* A */ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, /* B */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, /* C */ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00E6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, /* D */ 0x00F0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00F8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00FE, 0x00DF, /* E */ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, /* F */ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, // Table 2 (for high byte 0x01) /* 0 */ 0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F, /* 1 */ 0x0111, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F, /* 2 */ 0x0120, 0x0121, 0x0122, 0x0123, 0x0124, 0x0125, 0x0127, 0x0127, 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F, /* 3 */ 0x0130, 0x0131, 0x0133, 0x0133, 0x0134, 0x0135, 0x0136, 0x0137, 0x0138, 0x0139, 0x013A, 0x013B, 0x013C, 0x013D, 0x013E, 0x0140, /* 4 */ 0x0140, 0x0142, 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0147, 0x0148, 0x0149, 0x014B, 0x014B, 0x014C, 0x014D, 0x014E, 0x014F, /* 5 */ 0x0150, 0x0151, 0x0153, 0x0153, 0x0154, 0x0155, 0x0156, 0x0157, 0x0158, 0x0159, 0x015A, 0x015B, 0x015C, 0x015D, 0x015E, 0x015F, /* 6 */ 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0167, 0x0167, 0x0168, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F, /* 7 */ 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E, 0x017F, /* 8 */ 0x0180, 0x0253, 0x0183, 0x0183, 0x0185, 0x0185, 0x0254, 0x0188, 0x0188, 0x0256, 0x0257, 0x018C, 0x018C, 0x018D, 0x01DD, 0x0259, /* 9 */ 0x025B, 0x0192, 0x0192, 0x0260, 0x0263, 0x0195, 0x0269, 0x0268, 0x0199, 0x0199, 0x019A, 0x019B, 0x026F, 0x0272, 0x019E, 0x0275, /* A */ 0x01A0, 0x01A1, 0x01A3, 0x01A3, 0x01A5, 0x01A5, 0x01A6, 0x01A8, 0x01A8, 0x0283, 0x01AA, 0x01AB, 0x01AD, 0x01AD, 0x0288, 0x01AF, /* B */ 0x01B0, 0x028A, 0x028B, 0x01B4, 0x01B4, 0x01B6, 0x01B6, 0x0292, 0x01B9, 0x01B9, 0x01BA, 0x01BB, 0x01BD, 0x01BD, 0x01BE, 0x01BF, /* C */ 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C6, 0x01C6, 0x01C6, 0x01C9, 0x01C9, 0x01C9, 0x01CC, 0x01CC, 0x01CC, 0x01CD, 0x01CE, 0x01CF, /* D */ 0x01D0, 0x01D1, 0x01D2, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7, 0x01D8, 0x01D9, 0x01DA, 0x01DB, 0x01DC, 0x01DD, 0x01DE, 0x01DF, /* E */ 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E5, 0x01E5, 0x01E6, 0x01E7, 0x01E8, 0x01E9, 0x01EA, 0x01EB, 0x01EC, 0x01ED, 0x01EE, 0x01EF, /* F */ 0x01F0, 0x01F3, 0x01F3, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF, // Table 3 (for high byte 0x03) /* 0 */ 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x030F, /* 1 */ 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, 0x0317, 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F, /* 2 */ 0x0320, 0x0321, 0x0322, 0x0323, 0x0324, 0x0325, 0x0326, 0x0327, 0x0328, 0x0329, 0x032A, 0x032B, 0x032C, 0x032D, 0x032E, 0x032F, /* 3 */ 0x0330, 0x0331, 0x0332, 0x0333, 0x0334, 0x0335, 0x0336, 0x0337, 0x0338, 0x0339, 0x033A, 0x033B, 0x033C, 0x033D, 0x033E, 0x033F, /* 4 */ 0x0340, 0x0341, 0x0342, 0x0343, 0x0344, 0x0345, 0x0346, 0x0347, 0x0348, 0x0349, 0x034A, 0x034B, 0x034C, 0x034D, 0x034E, 0x034F, /* 5 */ 0x0350, 0x0351, 0x0352, 0x0353, 0x0354, 0x0355, 0x0356, 0x0357, 0x0358, 0x0359, 0x035A, 0x035B, 0x035C, 0x035D, 0x035E, 0x035F, /* 6 */ 0x0360, 0x0361, 0x0362, 0x0363, 0x0364, 0x0365, 0x0366, 0x0367, 0x0368, 0x0369, 0x036A, 0x036B, 0x036C, 0x036D, 0x036E, 0x036F, /* 7 */ 0x0370, 0x0371, 0x0372, 0x0373, 0x0374, 0x0375, 0x0376, 0x0377, 0x0378, 0x0379, 0x037A, 0x037B, 0x037C, 0x037D, 0x037E, 0x037F, /* 8 */ 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0386, 0x0387, 0x0388, 0x0389, 0x038A, 0x038B, 0x038C, 0x038D, 0x038E, 0x038F, /* 9 */ 0x0390, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, /* A */ 0x03C0, 0x03C1, 0x03A2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, /* B */ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, /* C */ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x03CF, /* D */ 0x03D0, 0x03D1, 0x03D2, 0x03D3, 0x03D4, 0x03D5, 0x03D6, 0x03D7, 0x03D8, 0x03D9, 0x03DA, 0x03DB, 0x03DC, 0x03DD, 0x03DE, 0x03DF, /* E */ 0x03E0, 0x03E1, 0x03E3, 0x03E3, 0x03E5, 0x03E5, 0x03E7, 0x03E7, 0x03E9, 0x03E9, 0x03EB, 0x03EB, 0x03ED, 0x03ED, 0x03EF, 0x03EF, /* F */ 0x03F0, 0x03F1, 0x03F2, 0x03F3, 0x03F4, 0x03F5, 0x03F6, 0x03F7, 0x03F8, 0x03F9, 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF, // Table 4 (for high byte 0x04) /* 0 */ 0x0400, 0x0401, 0x0452, 0x0403, 0x0454, 0x0455, 0x0456, 0x0407, 0x0458, 0x0459, 0x045A, 0x045B, 0x040C, 0x040D, 0x040E, 0x045F, /* 1 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0419, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, /* 2 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, /* 3 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, /* 4 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, /* 5 */ 0x0450, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x045D, 0x045E, 0x045F, /* 6 */ 0x0461, 0x0461, 0x0463, 0x0463, 0x0465, 0x0465, 0x0467, 0x0467, 0x0469, 0x0469, 0x046B, 0x046B, 0x046D, 0x046D, 0x046F, 0x046F, /* 7 */ 0x0471, 0x0471, 0x0473, 0x0473, 0x0475, 0x0475, 0x0476, 0x0477, 0x0479, 0x0479, 0x047B, 0x047B, 0x047D, 0x047D, 0x047F, 0x047F, /* 8 */ 0x0481, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487, 0x0488, 0x0489, 0x048A, 0x048B, 0x048C, 0x048D, 0x048E, 0x048F, /* 9 */ 0x0491, 0x0491, 0x0493, 0x0493, 0x0495, 0x0495, 0x0497, 0x0497, 0x0499, 0x0499, 0x049B, 0x049B, 0x049D, 0x049D, 0x049F, 0x049F, /* A */ 0x04A1, 0x04A1, 0x04A3, 0x04A3, 0x04A5, 0x04A5, 0x04A7, 0x04A7, 0x04A9, 0x04A9, 0x04AB, 0x04AB, 0x04AD, 0x04AD, 0x04AF, 0x04AF, /* B */ 0x04B1, 0x04B1, 0x04B3, 0x04B3, 0x04B5, 0x04B5, 0x04B7, 0x04B7, 0x04B9, 0x04B9, 0x04BB, 0x04BB, 0x04BD, 0x04BD, 0x04BF, 0x04BF, /* C */ 0x04C0, 0x04C1, 0x04C2, 0x04C4, 0x04C4, 0x04C5, 0x04C6, 0x04C8, 0x04C8, 0x04C9, 0x04CA, 0x04CC, 0x04CC, 0x04CD, 0x04CE, 0x04CF, /* D */ 0x04D0, 0x04D1, 0x04D2, 0x04D3, 0x04D4, 0x04D5, 0x04D6, 0x04D7, 0x04D8, 0x04D9, 0x04DA, 0x04DB, 0x04DC, 0x04DD, 0x04DE, 0x04DF, /* E */ 0x04E0, 0x04E1, 0x04E2, 0x04E3, 0x04E4, 0x04E5, 0x04E6, 0x04E7, 0x04E8, 0x04E9, 0x04EA, 0x04EB, 0x04EC, 0x04ED, 0x04EE, 0x04EF, /* F */ 0x04F0, 0x04F1, 0x04F2, 0x04F3, 0x04F4, 0x04F5, 0x04F6, 0x04F7, 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC, 0x04FD, 0x04FE, 0x04FF, // Table 5 (for high byte 0x05) /* 0 */ 0x0500, 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x0508, 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x050E, 0x050F, /* 1 */ 0x0510, 0x0511, 0x0512, 0x0513, 0x0514, 0x0515, 0x0516, 0x0517, 0x0518, 0x0519, 0x051A, 0x051B, 0x051C, 0x051D, 0x051E, 0x051F, /* 2 */ 0x0520, 0x0521, 0x0522, 0x0523, 0x0524, 0x0525, 0x0526, 0x0527, 0x0528, 0x0529, 0x052A, 0x052B, 0x052C, 0x052D, 0x052E, 0x052F, /* 3 */ 0x0530, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567, 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F, /* 4 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577, 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F, /* 5 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0557, 0x0558, 0x0559, 0x055A, 0x055B, 0x055C, 0x055D, 0x055E, 0x055F, /* 6 */ 0x0560, 0x0561, 0x0562, 0x0563, 0x0564, 0x0565, 0x0566, 0x0567, 0x0568, 0x0569, 0x056A, 0x056B, 0x056C, 0x056D, 0x056E, 0x056F, /* 7 */ 0x0570, 0x0571, 0x0572, 0x0573, 0x0574, 0x0575, 0x0576, 0x0577, 0x0578, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F, /* 8 */ 0x0580, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0587, 0x0588, 0x0589, 0x058A, 0x058B, 0x058C, 0x058D, 0x058E, 0x058F, /* 9 */ 0x0590, 0x0591, 0x0592, 0x0593, 0x0594, 0x0595, 0x0596, 0x0597, 0x0598, 0x0599, 0x059A, 0x059B, 0x059C, 0x059D, 0x059E, 0x059F, /* A */ 0x05A0, 0x05A1, 0x05A2, 0x05A3, 0x05A4, 0x05A5, 0x05A6, 0x05A7, 0x05A8, 0x05A9, 0x05AA, 0x05AB, 0x05AC, 0x05AD, 0x05AE, 0x05AF, /* B */ 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, 0x05B8, 0x05B9, 0x05BA, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, /* C */ 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05C4, 0x05C5, 0x05C6, 0x05C7, 0x05C8, 0x05C9, 0x05CA, 0x05CB, 0x05CC, 0x05CD, 0x05CE, 0x05CF, /* D */ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, /* E */ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05EB, 0x05EC, 0x05ED, 0x05EE, 0x05EF, /* F */ 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x05F9, 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF, // Table 6 (for high byte 0x10) /* 0 */ 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F, /* 1 */ 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017, 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F, /* 2 */ 0x1020, 0x1021, 0x1022, 0x1023, 0x1024, 0x1025, 0x1026, 0x1027, 0x1028, 0x1029, 0x102A, 0x102B, 0x102C, 0x102D, 0x102E, 0x102F, /* 3 */ 0x1030, 0x1031, 0x1032, 0x1033, 0x1034, 0x1035, 0x1036, 0x1037, 0x1038, 0x1039, 0x103A, 0x103B, 0x103C, 0x103D, 0x103E, 0x103F, /* 4 */ 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047, 0x1048, 0x1049, 0x104A, 0x104B, 0x104C, 0x104D, 0x104E, 0x104F, /* 5 */ 0x1050, 0x1051, 0x1052, 0x1053, 0x1054, 0x1055, 0x1056, 0x1057, 0x1058, 0x1059, 0x105A, 0x105B, 0x105C, 0x105D, 0x105E, 0x105F, /* 6 */ 0x1060, 0x1061, 0x1062, 0x1063, 0x1064, 0x1065, 0x1066, 0x1067, 0x1068, 0x1069, 0x106A, 0x106B, 0x106C, 0x106D, 0x106E, 0x106F, /* 7 */ 0x1070, 0x1071, 0x1072, 0x1073, 0x1074, 0x1075, 0x1076, 0x1077, 0x1078, 0x1079, 0x107A, 0x107B, 0x107C, 0x107D, 0x107E, 0x107F, /* 8 */ 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086, 0x1087, 0x1088, 0x1089, 0x108A, 0x108B, 0x108C, 0x108D, 0x108E, 0x108F, /* 9 */ 0x1090, 0x1091, 0x1092, 0x1093, 0x1094, 0x1095, 0x1096, 0x1097, 0x1098, 0x1099, 0x109A, 0x109B, 0x109C, 0x109D, 0x109E, 0x109F, /* A */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7, 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF, /* B */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7, 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF, /* C */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10C6, 0x10C7, 0x10C8, 0x10C9, 0x10CA, 0x10CB, 0x10CC, 0x10CD, 0x10CE, 0x10CF, /* D */ 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10D7, 0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10DD, 0x10DE, 0x10DF, /* E */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7, 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF, /* F */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10F6, 0x10F7, 0x10F8, 0x10F9, 0x10FA, 0x10FB, 0x10FC, 0x10FD, 0x10FE, 0x10FF, // Table 7 (for high byte 0x20) /* 0 */ 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x0000, 0x0000, 0x0000, 0x0000, /* 1 */ 0x2010, 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017, 0x2018, 0x2019, 0x201A, 0x201B, 0x201C, 0x201D, 0x201E, 0x201F, /* 2 */ 0x2020, 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027, 0x2028, 0x2029, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x202F, /* 3 */ 0x2030, 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037, 0x2038, 0x2039, 0x203A, 0x203B, 0x203C, 0x203D, 0x203E, 0x203F, /* 4 */ 0x2040, 0x2041, 0x2042, 0x2043, 0x2044, 0x2045, 0x2046, 0x2047, 0x2048, 0x2049, 0x204A, 0x204B, 0x204C, 0x204D, 0x204E, 0x204F, /* 5 */ 0x2050, 0x2051, 0x2052, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057, 0x2058, 0x2059, 0x205A, 0x205B, 0x205C, 0x205D, 0x205E, 0x205F, /* 6 */ 0x2060, 0x2061, 0x2062, 0x2063, 0x2064, 0x2065, 0x2066, 0x2067, 0x2068, 0x2069, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 7 */ 0x2070, 0x2071, 0x2072, 0x2073, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079, 0x207A, 0x207B, 0x207C, 0x207D, 0x207E, 0x207F, /* 8 */ 0x2080, 0x2081, 0x2082, 0x2083, 0x2084, 0x2085, 0x2086, 0x2087, 0x2088, 0x2089, 0x208A, 0x208B, 0x208C, 0x208D, 0x208E, 0x208F, /* 9 */ 0x2090, 0x2091, 0x2092, 0x2093, 0x2094, 0x2095, 0x2096, 0x2097, 0x2098, 0x2099, 0x209A, 0x209B, 0x209C, 0x209D, 0x209E, 0x209F, /* A */ 0x20A0, 0x20A1, 0x20A2, 0x20A3, 0x20A4, 0x20A5, 0x20A6, 0x20A7, 0x20A8, 0x20A9, 0x20AA, 0x20AB, 0x20AC, 0x20AD, 0x20AE, 0x20AF, /* B */ 0x20B0, 0x20B1, 0x20B2, 0x20B3, 0x20B4, 0x20B5, 0x20B6, 0x20B7, 0x20B8, 0x20B9, 0x20BA, 0x20BB, 0x20BC, 0x20BD, 0x20BE, 0x20BF, /* C */ 0x20C0, 0x20C1, 0x20C2, 0x20C3, 0x20C4, 0x20C5, 0x20C6, 0x20C7, 0x20C8, 0x20C9, 0x20CA, 0x20CB, 0x20CC, 0x20CD, 0x20CE, 0x20CF, /* D */ 0x20D0, 0x20D1, 0x20D2, 0x20D3, 0x20D4, 0x20D5, 0x20D6, 0x20D7, 0x20D8, 0x20D9, 0x20DA, 0x20DB, 0x20DC, 0x20DD, 0x20DE, 0x20DF, /* E */ 0x20E0, 0x20E1, 0x20E2, 0x20E3, 0x20E4, 0x20E5, 0x20E6, 0x20E7, 0x20E8, 0x20E9, 0x20EA, 0x20EB, 0x20EC, 0x20ED, 0x20EE, 0x20EF, /* F */ 0x20F0, 0x20F1, 0x20F2, 0x20F3, 0x20F4, 0x20F5, 0x20F6, 0x20F7, 0x20F8, 0x20F9, 0x20FA, 0x20FB, 0x20FC, 0x20FD, 0x20FE, 0x20FF, // Table 8 (for high byte 0x21) /* 0 */ 0x2100, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2109, 0x210A, 0x210B, 0x210C, 0x210D, 0x210E, 0x210F, /* 1 */ 0x2110, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, 0x2119, 0x211A, 0x211B, 0x211C, 0x211D, 0x211E, 0x211F, /* 2 */ 0x2120, 0x2121, 0x2122, 0x2123, 0x2124, 0x2125, 0x2126, 0x2127, 0x2128, 0x2129, 0x212A, 0x212B, 0x212C, 0x212D, 0x212E, 0x212F, /* 3 */ 0x2130, 0x2131, 0x2132, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137, 0x2138, 0x2139, 0x213A, 0x213B, 0x213C, 0x213D, 0x213E, 0x213F, /* 4 */ 0x2140, 0x2141, 0x2142, 0x2143, 0x2144, 0x2145, 0x2146, 0x2147, 0x2148, 0x2149, 0x214A, 0x214B, 0x214C, 0x214D, 0x214E, 0x214F, /* 5 */ 0x2150, 0x2151, 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215A, 0x215B, 0x215C, 0x215D, 0x215E, 0x215F, /* 6 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, /* 7 */ 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, /* 8 */ 0x2180, 0x2181, 0x2182, 0x2183, 0x2184, 0x2185, 0x2186, 0x2187, 0x2188, 0x2189, 0x218A, 0x218B, 0x218C, 0x218D, 0x218E, 0x218F, /* 9 */ 0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199, 0x219A, 0x219B, 0x219C, 0x219D, 0x219E, 0x219F, /* A */ 0x21A0, 0x21A1, 0x21A2, 0x21A3, 0x21A4, 0x21A5, 0x21A6, 0x21A7, 0x21A8, 0x21A9, 0x21AA, 0x21AB, 0x21AC, 0x21AD, 0x21AE, 0x21AF, /* B */ 0x21B0, 0x21B1, 0x21B2, 0x21B3, 0x21B4, 0x21B5, 0x21B6, 0x21B7, 0x21B8, 0x21B9, 0x21BA, 0x21BB, 0x21BC, 0x21BD, 0x21BE, 0x21BF, /* C */ 0x21C0, 0x21C1, 0x21C2, 0x21C3, 0x21C4, 0x21C5, 0x21C6, 0x21C7, 0x21C8, 0x21C9, 0x21CA, 0x21CB, 0x21CC, 0x21CD, 0x21CE, 0x21CF, /* D */ 0x21D0, 0x21D1, 0x21D2, 0x21D3, 0x21D4, 0x21D5, 0x21D6, 0x21D7, 0x21D8, 0x21D9, 0x21DA, 0x21DB, 0x21DC, 0x21DD, 0x21DE, 0x21DF, /* E */ 0x21E0, 0x21E1, 0x21E2, 0x21E3, 0x21E4, 0x21E5, 0x21E6, 0x21E7, 0x21E8, 0x21E9, 0x21EA, 0x21EB, 0x21EC, 0x21ED, 0x21EE, 0x21EF, /* F */ 0x21F0, 0x21F1, 0x21F2, 0x21F3, 0x21F4, 0x21F5, 0x21F6, 0x21F7, 0x21F8, 0x21F9, 0x21FA, 0x21FB, 0x21FC, 0x21FD, 0x21FE, 0x21FF, // Table 9 (for high byte 0xFE) /* 0 */ 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, /* 1 */ 0xFE10, 0xFE11, 0xFE12, 0xFE13, 0xFE14, 0xFE15, 0xFE16, 0xFE17, 0xFE18, 0xFE19, 0xFE1A, 0xFE1B, 0xFE1C, 0xFE1D, 0xFE1E, 0xFE1F, /* 2 */ 0xFE20, 0xFE21, 0xFE22, 0xFE23, 0xFE24, 0xFE25, 0xFE26, 0xFE27, 0xFE28, 0xFE29, 0xFE2A, 0xFE2B, 0xFE2C, 0xFE2D, 0xFE2E, 0xFE2F, /* 3 */ 0xFE30, 0xFE31, 0xFE32, 0xFE33, 0xFE34, 0xFE35, 0xFE36, 0xFE37, 0xFE38, 0xFE39, 0xFE3A, 0xFE3B, 0xFE3C, 0xFE3D, 0xFE3E, 0xFE3F, /* 4 */ 0xFE40, 0xFE41, 0xFE42, 0xFE43, 0xFE44, 0xFE45, 0xFE46, 0xFE47, 0xFE48, 0xFE49, 0xFE4A, 0xFE4B, 0xFE4C, 0xFE4D, 0xFE4E, 0xFE4F, /* 5 */ 0xFE50, 0xFE51, 0xFE52, 0xFE53, 0xFE54, 0xFE55, 0xFE56, 0xFE57, 0xFE58, 0xFE59, 0xFE5A, 0xFE5B, 0xFE5C, 0xFE5D, 0xFE5E, 0xFE5F, /* 6 */ 0xFE60, 0xFE61, 0xFE62, 0xFE63, 0xFE64, 0xFE65, 0xFE66, 0xFE67, 0xFE68, 0xFE69, 0xFE6A, 0xFE6B, 0xFE6C, 0xFE6D, 0xFE6E, 0xFE6F, /* 7 */ 0xFE70, 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE75, 0xFE76, 0xFE77, 0xFE78, 0xFE79, 0xFE7A, 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F, /* 8 */ 0xFE80, 0xFE81, 0xFE82, 0xFE83, 0xFE84, 0xFE85, 0xFE86, 0xFE87, 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C, 0xFE8D, 0xFE8E, 0xFE8F, /* 9 */ 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95, 0xFE96, 0xFE97, 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E, 0xFE9F, /* A */ 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF, /* B */ 0xFEB0, 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8, 0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF, /* C */ 0xFEC0, 0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8, 0xFEC9, 0xFECA, 0xFECB, 0xFECC, 0xFECD, 0xFECE, 0xFECF, /* D */ 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4, 0xFED5, 0xFED6, 0xFED7, 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD, 0xFEDE, 0xFEDF, /* E */ 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF, /* F */ 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0x0000, // Table 10 (for high byte 0xFF) /* 0 */ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05, 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B, 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F, /* 1 */ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17, 0xFF18, 0xFF19, 0xFF1A, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0xFF1F, /* 2 */ 0xFF20, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, /* 3 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0xFF3B, 0xFF3C, 0xFF3D, 0xFF3E, 0xFF3F, /* 4 */ 0xFF40, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, /* 5 */ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0xFF5B, 0xFF5C, 0xFF5D, 0xFF5E, 0xFF5F, /* 6 */ 0xFF60, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67, 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F, /* 7 */ 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77, 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F, /* 8 */ 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87, 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F, /* 9 */ 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97, 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F, /* A */ 0xFFA0, 0xFFA1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0xFFA6, 0xFFA7, 0xFFA8, 0xFFA9, 0xFFAA, 0xFFAB, 0xFFAC, 0xFFAD, 0xFFAE, 0xFFAF, /* B */ 0xFFB0, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0xFFB6, 0xFFB7, 0xFFB8, 0xFFB9, 0xFFBA, 0xFFBB, 0xFFBC, 0xFFBD, 0xFFBE, 0xFFBF, /* C */ 0xFFC0, 0xFFC1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0xFFC7, 0xFFC8, 0xFFC9, 0xFFCA, 0xFFCB, 0xFFCC, 0xFFCD, 0xFFCE, 0xFFCF, /* D */ 0xFFD0, 0xFFD1, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7, 0xFFD8, 0xFFD9, 0xFFDA, 0xFFDB, 0xFFDC, 0xFFDD, 0xFFDE, 0xFFDF, /* E */ 0xFFE0, 0xFFE1, 0xFFE2, 0xFFE3, 0xFFE4, 0xFFE5, 0xFFE6, 0xFFE7, 0xFFE8, 0xFFE9, 0xFFEA, 0xFFEB, 0xFFEC, 0xFFED, 0xFFEE, 0xFFEF, /* F */ 0xFFF0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6, 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF, }; sleuthkit-3.2.3/tsk3/fs/icat_lib.c000644 000765 000024 00000004622 11643647440 017550 0ustar00carrierstaff000000 000000 /* ** icat_lib ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** * \file icat_lib.c * Contains the library API functions used by the TSK icat command * line tool. */ #include "tsk_fs_i.h" /* Call back action for file_walk */ static TSK_WALK_RET_ENUM icat_action(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { if (size == 0) return TSK_WALK_CONT; if (fwrite(buf, size, 1, stdout) != 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "icat_action: error writing to stdout: %s", strerror(errno)); return TSK_WALK_ERROR; } return TSK_WALK_CONT; } /* Return 1 on error and 0 on success */ uint8_t tsk_fs_icat(TSK_FS_INFO * fs, TSK_INUM_T inum, TSK_FS_ATTR_TYPE_ENUM type, uint8_t type_used, uint16_t id, uint8_t id_used, TSK_FS_FILE_WALK_FLAG_ENUM flags) { TSK_FS_FILE *fs_file; #ifdef TSK_WIN32 if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WRITE; snprintf(tsk_errstr, TSK_ERRSTR_L, "icat_lib: error setting stdout to binary: %s", strerror(errno)); return 1; } #endif fs_file = tsk_fs_file_open_meta(fs, NULL, inum); if (!fs_file) { return 1; } if (type_used) { if (id_used == 0) { flags |= TSK_FS_FILE_WALK_FLAG_NOID; } if (tsk_fs_file_walk_type(fs_file, type, id, flags, icat_action, NULL)) { tsk_fs_file_close(fs_file); return 1; } } else { if (tsk_fs_file_walk(fs_file, flags, icat_action, NULL)) { tsk_fs_file_close(fs_file); return 1; } } tsk_fs_file_close(fs_file); return 0; } sleuthkit-3.2.3/tsk3/fs/ifind_lib.c000644 000765 000024 00000044041 11643647440 017720 0ustar00carrierstaff000000 000000 /* ** ifind (inode find) ** The Sleuth Kit ** ** Given an image and block number, identify which inode it is used by ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2010 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** TCTUTILs ** Copyright (c) 2001 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file ifind_lib.c * Contains the library API functions used by the TSK ifind command * line tool. */ #include "tsk_fs_i.h" #include "tsk_hfs.h" /******************************************************************************* * Find an unallocated NTFS MFT entry based on its parent directory */ typedef struct { TSK_INUM_T parinode; TSK_FS_IFIND_FLAG_ENUM flags; uint8_t found; } IFIND_PAR_DATA; /* inode walk call back for tsk_fs_ifind_par to find unallocated files * based on parent directory */ static TSK_WALK_RET_ENUM ifind_par_act(TSK_FS_FILE * fs_file, void *ptr) { IFIND_PAR_DATA *data = (IFIND_PAR_DATA *) ptr; TSK_FS_META_NAME_LIST *fs_name_list; /* go through each file name attribute for this file */ fs_name_list = fs_file->meta->name2; while (fs_name_list) { /* we found a file that has the target parent directory. * Make a FS_NAME structure and print it. */ if (fs_name_list->par_inode == data->parinode) { int i, cnt; uint8_t printed; TSK_FS_NAME *fs_name; if ((fs_name = tsk_fs_name_alloc(256, 0)) == NULL) return TSK_WALK_ERROR; /* Fill in the basics of the fs_name entry * so we can print in the fls formats */ fs_name->meta_addr = fs_file->meta->addr; fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; strncpy(fs_name->name, fs_name_list->name, fs_name->name_size); // now look for the $Data and $IDXROOT attributes fs_file->name = fs_name; printed = 0; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if ((fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) || (fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_IDXROOT)) { if (data->flags & TSK_FS_IFIND_PAR_LONG) { tsk_fs_name_print_long(stdout, fs_file, NULL, fs_file->fs_info, fs_attr, 0, 0); } else { tsk_fs_name_print(stdout, fs_file, NULL, fs_file->fs_info, fs_attr, 0); tsk_printf("\n"); } printed = 1; } } // if there were no attributes, print what we got if (printed == 0) { if (data->flags & TSK_FS_IFIND_PAR_LONG) { tsk_fs_name_print_long(stdout, fs_file, NULL, fs_file->fs_info, NULL, 0, 0); } else { tsk_fs_name_print(stdout, fs_file, NULL, fs_file->fs_info, NULL, 0); tsk_printf("\n"); } } tsk_fs_name_free(fs_name); data->found = 1; } fs_name_list = fs_name_list->next; } return TSK_WALK_CONT; } /** * Searches for unallocated MFT entries that have a given * MFT entry as their parent directory (as reported in FILE_NAME). * @param fs File system to search * @param lclflags Flags * @param par Parent directory MFT entry address * @returns 1 on error and 0 on success */ uint8_t tsk_fs_ifind_par(TSK_FS_INFO * fs, TSK_FS_IFIND_FLAG_ENUM lclflags, TSK_INUM_T par) { IFIND_PAR_DATA data; data.found = 0; data.flags = lclflags; data.parinode = par; /* Walk unallocated MFT entries */ if (fs->inode_walk(fs, fs->first_inum, fs->last_inum, TSK_FS_META_FLAG_UNALLOC, ifind_par_act, &data)) { return 1; } return 0; } /** * \ingroup fslib * * Find the meta data address for a given file name (UTF-8). * The basic idea of the function is to break the given name into its * subdirectories and start looking for each (starting in the root * directory). * * @param a_fs FS to analyze * @param a_path UTF-8 path of file to search for * @param [out] a_result Meta data address of file * @param [out] a_fs_name Copy of name details (or NULL if details not wanted) * @returns -1 on (system) error, 0 if found, and 1 if not found */ int8_t tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path, TSK_INUM_T * a_result, TSK_FS_NAME * a_fs_name) { char *cpath; size_t clen; char *cur_dir; // The "current" directory or file we are looking for char *cur_attr; // The "current" attribute of the dir we are looking for char *strtok_last; TSK_INUM_T next_meta; uint8_t is_done; *a_result = 0; // copy path to a buffer that we can modify clen = strlen(a_path) + 1; if ((cpath = (char *) tsk_malloc(clen)) == NULL) { return -1; } strncpy(cpath, a_path, clen); // Get the first part of the directory path. cur_dir = (char *) strtok_r(cpath, "/", &strtok_last); cur_attr = NULL; /* If there is no token, then only a '/' was given */ if (cur_dir == NULL) { free(cpath); *a_result = a_fs->root_inum; // create the dummy entry if needed if (a_fs_name) { a_fs_name->meta_addr = a_fs->root_inum; a_fs_name->type = TSK_FS_NAME_TYPE_DIR; a_fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (a_fs_name->name) a_fs_name->name[0] = '\0'; if (a_fs_name->shrt_name) a_fs_name->shrt_name[0] = '\0'; } return 0; } /* If this is NTFS, seperate out the attribute of the current directory */ if (TSK_FS_TYPE_ISNTFS(a_fs->ftype) && ((cur_attr = strchr(cur_dir, ':')) != NULL)) { *(cur_attr) = '\0'; cur_attr++; } if (tsk_verbose) tsk_fprintf(stderr, "Looking for %s\n", cur_dir); // initialize the first place to look, the root dir next_meta = a_fs->root_inum; // we loop until we know the outcome and then exit. // everything should return from inside the loop. is_done = 0; while (is_done == 0) { size_t i; TSK_FS_FILE *fs_file_alloc = NULL; // set to the allocated file that is our target TSK_FS_FILE *fs_file_del = NULL; // set to an unallocated file that matches our criteria TSK_FS_DIR *fs_dir = NULL; // open the next directory in the recursion if ((fs_dir = tsk_fs_dir_open_meta(a_fs, next_meta)) == NULL) { free(cpath); return -1; } /* Verify this is indeed a directory. We had one reported * problem where a file was a disk image and opening it as * a directory found the directory entries inside of the file * and this caused problems... */ if (fs_dir->fs_file->meta->type != TSK_FS_META_TYPE_DIR) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "Address %"PRIuINUM" is not for a directory\n", next_meta); free(cpath); return -1; } // cycle through each entry for (i = 0; i < tsk_fs_dir_getsize(fs_dir); i++) { TSK_FS_FILE *fs_file; uint8_t found_name = 0; if ((fs_file = tsk_fs_dir_get(fs_dir, i)) == NULL) { tsk_fs_dir_close(fs_dir); free(cpath); return -1; } /* * Check if this is the name that we are currently looking for, * as identified in 'cur_dir' */ /* FAT is a special case because we check the short name */ if (TSK_FS_TYPE_ISFAT(a_fs->ftype)) { if ((fs_file->name->name) && (a_fs->name_cmp(a_fs, fs_file->name->name, cur_dir) == 0)) { found_name = 1; } else if ((fs_file->name->shrt_name) && (a_fs->name_cmp(a_fs, fs_file->name->shrt_name, cur_dir) == 0)) { found_name = 1; } } /* NTFS gets a case insensitive comparison */ else if (TSK_FS_TYPE_ISNTFS(a_fs->ftype)) { if ((fs_file->name->name) && (a_fs->name_cmp(a_fs, fs_file->name->name, cur_dir) == 0)) { /* ensure we have the right attribute name */ if (cur_attr == NULL) { found_name = 1; } else { if (fs_file->meta) { int cnt, i; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if ((fs_attr->name) && (a_fs->name_cmp(a_fs, fs_attr->name, cur_attr) == 0)) { found_name = 1; } } } } } } else { if ((fs_file->name->name) && (a_fs->name_cmp(a_fs, fs_file->name->name, cur_dir) == 0)) { found_name = 1; } } if (found_name) { /* If we found our file and it is allocated, then stop. If * it is unallocated, keep on going to see if we can get * an allocated hit */ if (fs_file->name->flags & TSK_FS_NAME_FLAG_ALLOC) { fs_file_alloc = fs_file; break; } else { // if we already have an unalloc and its addr is 0, then use the new one if ((fs_file_del) && (fs_file_del->name->meta_addr == 0)) { tsk_fs_file_close(fs_file_del); } fs_file_del = fs_file; } } // close the file if we did not save it for future analysis. else { tsk_fs_file_close(fs_file); fs_file = NULL; } } // we found a directory, go into it if ((fs_file_alloc) || (fs_file_del)) { const char *pname; TSK_FS_FILE *fs_file_tmp; // choose the alloc one first (if they both exist) if (fs_file_alloc) fs_file_tmp = fs_file_alloc; else fs_file_tmp = fs_file_del; pname = cur_dir; // save a copy of the current name pointer // advance to the next name cur_dir = (char *) strtok_r(NULL, "/", &(strtok_last)); cur_attr = NULL; if (tsk_verbose) tsk_fprintf(stderr, "Found it (%s), now looking for %s\n", pname, cur_dir); /* That was the last name in the path -- we found the file! */ if (cur_dir == NULL) { *a_result = fs_file_tmp->name->meta_addr; // make a copy if one was requested if (a_fs_name) { tsk_fs_name_copy(a_fs_name, fs_file_tmp->name); } tsk_fs_dir_close(fs_dir); free(cpath); return 0; } // update the attribute field, if needed if (TSK_FS_TYPE_ISNTFS(a_fs->ftype) && ((cur_attr = strchr(cur_dir, ':')) != NULL)) { *(cur_attr) = '\0'; cur_attr++; } // update the value for the next directory to open next_meta = fs_file_tmp->name->meta_addr; if (fs_file_alloc) { tsk_fs_file_close(fs_file_alloc); fs_file_alloc = NULL; } if (fs_file_del) { tsk_fs_file_close(fs_file_del); fs_file_del = NULL; } } // no hit in directory else { is_done = 1; } tsk_fs_dir_close(fs_dir); fs_dir = NULL; } free(cpath); return 1; } /** * Find the meta data address for a given file TCHAR name * * @param fs FS to analyze * @param tpath Path of file to search for * @param [out] result Meta data address of file * @returns -1 on error, 0 if found, and 1 if not found */ int8_t tsk_fs_ifind_path(TSK_FS_INFO * fs, TSK_TCHAR * tpath, TSK_INUM_T * result) { #ifdef TSK_WIN32 // Convert the UTF-16 path to UTF-8 { size_t clen; UTF8 *ptr8; UTF16 *ptr16; int retval; char *cpath; clen = TSTRLEN(tpath) * 4; if ((cpath = (char *) tsk_malloc(clen)) == NULL) { return -1; } ptr8 = (UTF8 *) cpath; ptr16 = (UTF16 *) tpath; retval = tsk_UTF16toUTF8_lclorder((const UTF16 **) &ptr16, (UTF16 *) & ptr16[TSTRLEN(tpath) + 1], &ptr8, (UTF8 *) ((uintptr_t) ptr8 + clen), TSKlenientConversion); if (retval != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_fs_ifind_path: Error converting path to UTF-8: %d", retval); free(cpath); return -1; } return tsk_fs_path2inum(fs, cpath, result, NULL); } #else return tsk_fs_path2inum(fs, (const char *) tpath, result, NULL); #endif } /******************************************************************************* * Find an inode given a data unit */ typedef struct { TSK_DADDR_T block; /* the block to find */ TSK_FS_IFIND_FLAG_ENUM flags; uint8_t found; TSK_INUM_T curinode; /* the inode being analyzed */ uint32_t curtype; /* the type currently being analyzed: NTFS */ uint16_t curid; } IFIND_DATA_DATA; /* * file_walk action for non-ntfs */ static TSK_WALK_RET_ENUM ifind_data_file_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { TSK_FS_INFO *fs = fs_file->fs_info; IFIND_DATA_DATA *data = (IFIND_DATA_DATA *) ptr; /* Ignore sparse blocks because they do not reside on disk */ if (flags & TSK_FS_BLOCK_FLAG_SPARSE) return TSK_WALK_CONT; if (addr == data->block) { if (TSK_FS_TYPE_ISNTFS(fs->ftype)) tsk_printf("%" PRIuINUM "-%" PRIu32 "-%" PRIu16 "\n", data->curinode, data->curtype, data->curid); else tsk_printf("%" PRIuINUM "\n", data->curinode); data->found = 1; return TSK_WALK_STOP; } return TSK_WALK_CONT; } /* ** find_inode ** ** Callback action for inode_walk */ static TSK_WALK_RET_ENUM ifind_data_act(TSK_FS_FILE * fs_file, void *ptr) { IFIND_DATA_DATA *data = (IFIND_DATA_DATA *) ptr; int file_flags = (TSK_FS_FILE_WALK_FLAG_AONLY | TSK_FS_FILE_WALK_FLAG_SLACK); int i, cnt; data->curinode = fs_file->meta->addr; /* Search all attrributes */ cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; data->curtype = fs_attr->type; data->curid = fs_attr->id; if (fs_attr->flags & TSK_FS_ATTR_NONRES) { if (tsk_fs_attr_walk(fs_attr, file_flags, ifind_data_file_act, ptr)) { if (tsk_verbose) tsk_fprintf(stderr, "Error walking file %" PRIuINUM " Attribute: %i", fs_file->meta->addr, i); /* Ignore these errors */ tsk_error_reset(); } // stop if we only want one hit if ((data->found) && (!(data->flags & TSK_FS_IFIND_ALL))) break; } } if ((data->found) && (!(data->flags & TSK_FS_IFIND_ALL))) return TSK_WALK_STOP; else return TSK_WALK_CONT; } /* * Find the inode that has allocated block blk * Return 1 on error, 0 if no error */ uint8_t tsk_fs_ifind_data(TSK_FS_INFO * fs, TSK_FS_IFIND_FLAG_ENUM lclflags, TSK_DADDR_T blk) { IFIND_DATA_DATA data; memset(&data, 0, sizeof(IFIND_DATA_DATA)); data.flags = lclflags; data.block = blk; if (fs->inode_walk(fs, fs->first_inum, fs->last_inum, TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC, ifind_data_act, &data)) { return 1; } /* If we did not find an inode yet, get the block's * flags so we can identify it as a meta data block */ if (!data.found) { TSK_FS_BLOCK *fs_block; if ((fs_block = tsk_fs_block_get(fs, NULL, blk)) != NULL) { if (fs_block->flags & TSK_FS_BLOCK_FLAG_META) { tsk_printf("Meta Data\n"); data.found = 1; } tsk_fs_block_free(fs_block); } } if (!data.found) { tsk_printf("Inode not found\n"); } return 0; } sleuthkit-3.2.3/tsk3/fs/ils_lib.c000644 000765 000024 00000017311 11643647440 017416 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /** * \file ils_lib.c * Library functionality of the TSK ils tool. */ /* TCT */ /*++ * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ #include "tsk_fs_i.h" #ifdef TSK_WIN32 #include #endif typedef struct { const TSK_TCHAR *image; /* number of seconds time skew of system * if the system was 100 seconds fast, the value should be +100 */ int32_t sec_skew; TSK_FS_ILS_FLAG_ENUM flags; } ILS_DATA; /* print_header - print time machine header */ static void print_header(TSK_FS_INFO * fs) { char hostnamebuf[BUFSIZ]; time_t now; #ifndef TSK_WIN32 if (gethostname(hostnamebuf, sizeof(hostnamebuf) - 1) < 0) { if (tsk_verbose) tsk_fprintf(stderr, "error getting host by name\n"); strcpy(hostnamebuf, "unknown"); } hostnamebuf[sizeof(hostnamebuf) - 1] = 0; #else strcpy(hostnamebuf, "unknown"); #endif now = time((time_t *) 0); /* * Identify table type and table origin. */ tsk_printf("class|host|device|start_time\n"); tsk_printf("ils|%s||%" PRIu64 "\n", hostnamebuf, (uint64_t) now); /* * Identify the fields in the data that follow. */ tsk_printf ("st_ino|st_alloc|st_uid|st_gid|st_mtime|st_atime|st_ctime|st_crtime"); tsk_printf("|st_mode|st_nlink|st_size\n"); } static void print_header_mac() { char hostnamebuf[BUFSIZ]; time_t now; #ifndef TSK_WIN32 if (gethostname(hostnamebuf, sizeof(hostnamebuf) - 1) < 0) { if (tsk_verbose) tsk_fprintf(stderr, "Error getting host by name\n"); strcpy(hostnamebuf, "unknown"); } hostnamebuf[sizeof(hostnamebuf) - 1] = 0; #else strcpy(hostnamebuf, "unknown"); #endif now = time((time_t *) 0); /* * Identify the fields in the data that follow. */ tsk_printf ("md5|file|st_ino|st_ls|st_uid|st_gid|st_size|st_atime|st_mtime|st_ctime|st_crtime\n"); return; } /* print_inode - list generic inode */ static TSK_WALK_RET_ENUM ils_act(TSK_FS_FILE * fs_file, void *ptr) { ILS_DATA *data = (ILS_DATA *) ptr; // if we have no link count and want open files -- exit if ((fs_file->meta->nlink == 0) && ((data->flags & TSK_FS_ILS_OPEN) != 0)) { return TSK_WALK_CONT; } // verify link flags if ((fs_file->meta->nlink == 0) && ((data->flags & TSK_FS_ILS_UNLINK) == 0)) { return TSK_WALK_CONT; } else if ((fs_file->meta->nlink > 0) && ((data->flags & TSK_FS_ILS_LINK) == 0)) { return TSK_WALK_CONT; } if (data->sec_skew != 0) { fs_file->meta->mtime -= data->sec_skew; fs_file->meta->atime -= data->sec_skew; fs_file->meta->ctime -= data->sec_skew; fs_file->meta->crtime -= data->sec_skew; } tsk_printf("%" PRIuINUM "|%c|%" PRIuUID "|%" PRIuGID "|%" PRIu32 "|%" PRIu32 "|%" PRIu32 "|%" PRIu32, fs_file->meta->addr, (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) ? 'a' : 'f', fs_file->meta->uid, fs_file->meta->gid, (uint32_t) fs_file->meta->mtime, (uint32_t) fs_file->meta->atime, (uint32_t) fs_file->meta->ctime, (uint32_t) fs_file->meta->crtime); if (data->sec_skew != 0) { fs_file->meta->mtime += data->sec_skew; fs_file->meta->atime += data->sec_skew; fs_file->meta->ctime += data->sec_skew; fs_file->meta->crtime += data->sec_skew; } tsk_printf("|%lo|%d|%" PRIuOFF "\n", (unsigned long) fs_file->meta->mode, fs_file->meta->nlink, fs_file->meta->size); return TSK_WALK_CONT; } /* * Print the inode information in the format that the mactimes program expects */ static TSK_WALK_RET_ENUM ils_mac_act(TSK_FS_FILE * fs_file, void *ptr) { char ls[12]; ILS_DATA *data = (ILS_DATA *) ptr; if ((fs_file->meta->nlink == 0) && ((data->flags & TSK_FS_ILS_UNLINK) == 0)) { return TSK_WALK_CONT; } else if ((fs_file->meta->nlink > 0) && ((data->flags & TSK_FS_ILS_LINK) == 0)) { return TSK_WALK_CONT; } /* ADD image and file name (if we have one) */ TFPRINTF(stdout, _TSK_T("0|<%s-"), data->image); tsk_printf("%s%s%s-%" PRIuINUM ">|%" PRIuINUM "|", (fs_file->meta->name2) ? fs_file->meta->name2->name : "", (fs_file->meta->name2) ? "-" : "", (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) ? "alive" : "dead", fs_file->meta->addr, fs_file->meta->addr); /* Print the "ls" mode in ascii format */ tsk_fs_meta_make_ls(fs_file->meta, ls, sizeof(ls)); if (data->sec_skew != 0) { fs_file->meta->mtime -= data->sec_skew; fs_file->meta->atime -= data->sec_skew; fs_file->meta->ctime -= data->sec_skew; fs_file->meta->crtime -= data->sec_skew; } tsk_printf("-/%s|%" PRIuUID "|%" PRIuGID "|%" PRIuOFF "|%" PRIu32 "|%" PRIu32 "|%" PRIu32 "|%" PRIu32 "\n", ls, fs_file->meta->uid, fs_file->meta->gid, fs_file->meta->size, (uint32_t) fs_file->meta->atime, (uint32_t) fs_file->meta->mtime, (uint32_t) fs_file->meta->ctime, (uint32_t) fs_file->meta->crtime); if (data->sec_skew != 0) { fs_file->meta->mtime -= data->sec_skew; fs_file->meta->atime -= data->sec_skew; fs_file->meta->ctime -= data->sec_skew; fs_file->meta->crtime -= data->sec_skew; } return TSK_WALK_CONT; } /** * Library API for inode walking. * * @param fs File system to analyze * @param lclflags TSK_FS_ILS_XXX flag settings * @param istart Starting inode address * @param ilast Ending inode address * @param flags Inode walk flags * @param skew clock skew in seconds * @param img Path to disk image name for header * * @returns 1 on error and 0 on success */ uint8_t tsk_fs_ils(TSK_FS_INFO * fs, TSK_FS_ILS_FLAG_ENUM lclflags, TSK_INUM_T istart, TSK_INUM_T ilast, TSK_FS_META_FLAG_ENUM flags, int32_t skew, const TSK_TCHAR * img) { ILS_DATA data; /* If orphan is desired, then make sure LINK flags are set */ if (flags & TSK_FS_META_FLAG_ORPHAN) { lclflags |= (TSK_FS_ILS_LINK | TSK_FS_ILS_UNLINK); } /* if OPEN lcl flag is given, then make sure ALLOC is not and UNALLOC is */ if (lclflags & TSK_FS_ILS_OPEN) { flags |= TSK_FS_META_FLAG_UNALLOC; flags &= ~TSK_FS_META_FLAG_ALLOC; lclflags |= TSK_FS_ILS_LINK; lclflags &= ~TSK_FS_ILS_UNLINK; } else { /* If LINK is not set at all, then set them */ if (((lclflags & TSK_FS_ILS_LINK) == 0) && ((lclflags & TSK_FS_ILS_UNLINK) == 0)) lclflags |= (TSK_FS_ILS_LINK | TSK_FS_ILS_UNLINK); } data.flags = lclflags; data.sec_skew = skew; /* Print the data */ if (lclflags & TSK_FS_ILS_MAC) { TSK_TCHAR *tmpptr; data.image = img; #ifdef TSK_WIN32 tmpptr = TSTRCHR(data.image, '\\'); #else tmpptr = strrchr(data.image, '/'); #endif if (tmpptr) data.image = ++tmpptr; print_header_mac(); if (fs->inode_walk(fs, istart, ilast, flags, ils_mac_act, &data)) return 1; } else { print_header(fs); if (fs->inode_walk(fs, istart, ilast, flags, ils_act, &data)) return 1; } return 0; } sleuthkit-3.2.3/tsk3/fs/iso9660.c000644 000765 000024 00000234664 11643647440 017134 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** Copyright (c) 2007-2008 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /** * \file iso9660.c * Contains the internal TSK ISO9660 file system code to handle basic file * system processing for opening file system, processing sectors, and directory entries. */ #include "tsk_fs_i.h" #include "tsk_iso9660.h" #include /* free all memory used by inode linked list */ static void iso9660_inode_list_free(TSK_FS_INFO * fs) { ISO_INFO *iso = (ISO_INFO *) fs; iso9660_inode_node *tmp; while (iso->in_list) { tmp = iso->in_list; iso->in_list = iso->in_list->next; free(tmp); } iso->in_list = NULL; } /** * Process the System Use Sharing Protocol (SUSP) data. Typically, * rockridge data are stored in this. * * @param fs File system to process * @param buf Buffer of data to process * @param count Length of buffer in bytes. * @param hFile File handle to print details to (or NULL for no printing) * @returns NULL on error */ static rockridge_ext * parse_susp(TSK_FS_INFO * fs, char *buf, int count, FILE * hFile) { rockridge_ext *rr; ISO_INFO *iso = (ISO_INFO *) fs; char *end = buf + count - 1; if (tsk_verbose) tsk_fprintf(stderr, "parse_susp: count is: %d\n", count); // allocate the output data structure rr = (rockridge_ext *) tsk_malloc(sizeof(rockridge_ext)); if (rr == NULL) { return NULL; } while (buf < end) { iso9660_susp_head *head = (iso9660_susp_head *) buf; if (((uintptr_t) & (head->len) >= (uintptr_t) end) || (buf + head->len - 1 > end)) break; /* Identify the entry type -- listed in the order * that they are listed in the specs */ // SUSP Continuation Entry -- NOT SUPPORTED if ((head->sig[0] == 'C') && (head->sig[1] == 'E')) { iso9660_susp_ce *ce = (iso9660_susp_ce *) buf; if (hFile) { fprintf(hFile, "CE Entry\n"); fprintf(hFile, "* Block: %" PRIu32 "\n", tsk_getu32(fs->endian, ce->blk_m)); fprintf(hFile, "* Offset: %" PRIu32 "\n", tsk_getu32(fs->endian, ce->offset_m)); fprintf(hFile, "* Len: %" PRIu32 "\n", tsk_getu32(fs->endian, ce->celen_m)); } if ((tsk_getu32(fs->endian, ce->blk_m) < fs->last_block) && (tsk_getu32(fs->endian, ce->offset_m) < fs->block_size)) { ssize_t cnt; TSK_OFF_T off; char *buf2; off = tsk_getu32(fs->endian, ce->blk_m) * fs->block_size + tsk_getu32(fs->endian, ce->offset_m); buf2 = (char *) tsk_malloc(tsk_getu32(fs->endian, ce->celen_m)); if (buf2 != NULL) { cnt = tsk_fs_read(fs, off, buf2, tsk_getu32(fs->endian, ce->celen_m)); if (cnt == tsk_getu32(fs->endian, ce->celen_m)) { parse_susp(fs, buf2, (int) cnt, hFile); } else if (tsk_verbose) { fprintf(stderr, "parse_susp: error reading CE entry\n"); tsk_error_print(stderr); tsk_error_reset(); } free(buf2); } else { if (tsk_verbose) fprintf(stderr, "parse_susp: error allocating memory to process CE entry\n"); tsk_error_reset(); } } else { if (tsk_verbose) fprintf(stderr, "parse_susp: CE offset or block too large to process\n"); } buf += head->len; } // SUSP Padding Entry else if ((head->sig[0] == 'P') && (head->sig[1] == 'D')) { if (hFile) { fprintf(hFile, "PD Entry\n"); } buf += head->len; } // SUSP Sharing Protocol Entry -- we ignore else if ((head->sig[0] == 'S') && (head->sig[1] == 'P')) { iso9660_susp_sp *sp = (iso9660_susp_sp *) buf; if (hFile) { fprintf(hFile, "SP Entry\n"); fprintf(hFile, "* SKip Len: %d\n", sp->skip); } buf += head->len; } // SUSP System Terminator else if ((head->sig[0] == 'S') && (head->sig[1] == 'T')) { if (hFile) { fprintf(hFile, "ST Entry\n"); } buf += head->len; } // SUSP Extention Registration -- not used else if ((head->sig[0] == 'E') && (head->sig[1] == 'R')) { iso9660_susp_er *er = (iso9660_susp_er *) buf; if (hFile) { char buf[258]; fprintf(hFile, "ER Entry\n"); memcpy(buf, er->ext_id, er->len_id); buf[er->len_id] = '\0'; fprintf(hFile, "* Extension ID: %s\n", buf); memcpy(buf, er->ext_id + er->len_id, er->len_des); buf[er->len_des] = '\0'; fprintf(hFile, "* Extension Descriptor: %s\n", buf); memcpy(buf, er->ext_id + er->len_id + er->len_des, er->len_src); buf[er->len_src] = '\0'; fprintf(hFile, "* Extension Spec Source: %s\n", buf); } buf += head->len; } // SUSP Extention Sigs -- not used else if ((head->sig[0] == 'E') && (head->sig[1] == 'S')) { if (hFile) { fprintf(hFile, "ES Entry\n"); } buf += head->len; } /* * Rock Ridge Extensions */ /* POSIX file attributes */ else if ((head->sig[0] == 'P') && (head->sig[1] == 'X')) { iso9660_rr_px_entry *rr_px; rr_px = (iso9660_rr_px_entry *) buf; rr->uid = tsk_getu32(fs->endian, rr_px->uid_m); rr->gid = tsk_getu32(fs->endian, rr_px->gid_m); rr->mode = tsk_getu16(fs->endian, rr_px->mode_m); rr->nlink = tsk_getu32(fs->endian, rr_px->links_m); if (hFile) { fprintf(hFile, "PX Entry\n"); fprintf(hFile, "* UID: %" PRIuUID "\n", rr->uid); fprintf(hFile, "* GID: %" PRIuGID "\n", rr->gid); fprintf(hFile, "* Mode: %d\n", rr->mode); fprintf(hFile, "* Links: %" PRIu32 "\n", rr->nlink); } buf += head->len; } // RR - device information else if ((head->sig[0] == 'P') && (head->sig[1] == 'N')) { iso9660_rr_pn_entry *rr_pn = (iso9660_rr_pn_entry *) buf; if (hFile) { fprintf(hFile, "PN Entry\n"); fprintf(hFile, "* Device ID High: %" PRIu32 "\n", tsk_getu32(fs->endian, rr_pn->dev_h_m)); fprintf(hFile, "* Device ID Low: %" PRIu32 "\n", tsk_getu32(fs->endian, rr_pn->dev_l_m)); } buf += head->len; } // RR - symbolic link else if ((head->sig[0] == 'S') && (head->sig[1] == 'L')) { //iso9660_rr_sl_entry *rr_sl = (iso9660_rr_sl_entry *) buf; if (hFile) { fprintf(hFile, "SL Entry\n"); } buf += head->len; } // RR -- alternative name else if ((head->sig[0] == 'N') && (head->sig[1] == 'M')) { iso9660_rr_nm_entry *rr_nm; rr_nm = (iso9660_rr_nm_entry *) buf; strncpy(rr->fn, &rr_nm->name[0], (int) rr_nm->len - 5); rr->fn[(int) rr_nm->len - 5] = '\0'; if (hFile) { fprintf(hFile, "NM Entry\n"); fprintf(hFile, "* %s\n", rr->fn); } buf += head->len; } // RR - relocated directory else if ((head->sig[0] == 'C') && (head->sig[1] == 'L')) { if (hFile) { fprintf(hFile, "CL Entry\n"); } buf += head->len; } // RR - parent of relocated directory else if ((head->sig[0] == 'P') && (head->sig[1] == 'L')) { if (hFile) { fprintf(hFile, "PL Entry\n"); } buf += head->len; } // RR - relocation signal else if ((head->sig[0] == 'R') && (head->sig[1] == 'E')) { if (hFile) { fprintf(hFile, "RE Entry\n"); } buf += head->len; } // RR - time stamps else if ((head->sig[0] == 'T') && (head->sig[1] == 'F')) { if (hFile) { fprintf(hFile, "TF Entry\n"); } buf += head->len; } // RR - sparse file else if ((head->sig[0] == 'S') && (head->sig[1] == 'F')) { if (hFile) { fprintf(hFile, "SF Entry\n"); } buf += head->len; } /* RR is a system use field indicating RockRidge, but not part of RockRidge */ else if ((head->sig[0] == 'R') && (head->sig[1] == 'R')) { iso->rr_found = 1; if (hFile) { fprintf(hFile, "RR Entry\n"); } buf += head->len; } else { buf += 2; if ((uintptr_t) buf % 2) buf--; } } return rr; } /////////////////////////////////////////////////////////////////////////// // The following functions are responsible for loading all of the file metadata into memory. // The process is that the Path table is processed first. It contains an entry for each // directory. That info is then used to locate the directory contents and those contents // are then processed. // // Files do not have a corresponding metadata entry, so we assign them based // on the order that they are loaded. /////////////////////////////////////////////////////////////////////////// /* XXX Instead of loading all of the file metadata, we could instead save a mapping * between inode number and the byte offset of the metadata (and any other data * needed for fast lookups). */ /** \internal * Process the contents of a directory and load the * information about files in that directory into ISO_INFO. This is called * by the methods that process the path table (which contains pointers to the * various directories). The results in ISO_INFO are used to identify the * inode address of files found from dent_walk and for file lookups. * * Type: ISO9660_TYPE_PVD for primary volume descriptor, ISO9660_TYPE_SVD for * supplementary volume descriptor (do Joliet utf-8 conversion). * * @param fs File system to analyze * @param a_offs Byte offset of directory start * @param count previous file count * @param ctype Character set used for the names * @param a_fn Name of the directory to use for the "." entry (in UTF-8) * * @returns total number of files or -1 on error */ static int iso9660_load_inodes_dir(TSK_FS_INFO * fs, TSK_OFF_T a_offs, int count, int ctype, const char *a_fn, uint8_t is_first) { ISO_INFO *iso = (ISO_INFO *) fs; int s_cnt = 1; // count of sectors needed for dir TSK_OFF_T s_offs = a_offs; // offset for sector reads int i; if (tsk_verbose) tsk_fprintf(stderr, "iso9660_load_inodes_dir: fs: %lu offs: %" PRIuOFF " count: %d ctype: %d fn: %s\n", (uintptr_t) fs, a_offs, count, ctype, a_fn); // cycle through each sector -- entries will not cross them for (i = 0; i < s_cnt; i++) { ssize_t cnt1; int b_offs; // offset in buffer char buf[ISO9660_SSIZE_B]; cnt1 = tsk_fs_read(fs, s_offs, buf, ISO9660_SSIZE_B); if (cnt1 != ISO9660_SSIZE_B) { if (cnt1 >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_get_dentries"); return -1; } // @@@@ We need to add more checks when reading from buf to make sure b_off is still in the buffer /* process the directory entries */ for (b_offs = 0; b_offs < ISO9660_SSIZE_B;) { iso9660_inode_node *in_node; iso9660_dentry *dentry; dentry = (iso9660_dentry *) & buf[b_offs]; if (dentry->entry_len == 0) { b_offs += 2; continue; } /* when processing the other volume descriptor directories, we ignore the * directories because we have no way of detecting if it is a duplicate of * a directory from the other volume descriptor (they use different blocks). * We will see the contents of this directory from the path table anyway. */ if ((dentry->flags & ISO9660_FLAG_DIR) && (is_first == 0)) { b_offs += dentry->entry_len; continue; } // allocate a node for this entry in_node = (iso9660_inode_node *) tsk_malloc(sizeof(iso9660_inode_node)); if (in_node == NULL) { return -1; } // the first entry should have no name and is for the current directory if ((i == 0) && (b_offs == 0)) { if (dentry->fi_len != 0) { // XXX } /* find how many more sectors are in the directory */ s_cnt = tsk_getu32(fs->endian, dentry->data_len_m) / ISO9660_SSIZE_B; /* use the specified name instead of "." */ if (strlen(a_fn) > ISO9660_MAXNAMLEN_STD) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_load_inodes_dir: Name argument specified is too long"); return -1; } strncpy(in_node->inode.fn, a_fn, ISO9660_MAXNAMLEN_STD + 1); /* for all directories except the root, we skip processing the "." and ".." entries because * they duplicate the other entires and the dent_walk code will rely on the offset * for the entry in the parent directory. */ if (count != 0) { free(in_node); in_node = NULL; b_offs += dentry->entry_len; dentry = (iso9660_dentry *) & buf[b_offs]; b_offs += dentry->entry_len; continue; } } else { char *file_ver; // the entry has a UTF-16 name if (ctype == ISO9660_CTYPE_UTF16) { UTF16 *name16; UTF8 *name8; int retVal; name16 = (UTF16 *) & buf[b_offs + sizeof(iso9660_dentry)]; // the name is in UTF-16 BE -- convert to LE if needed if (fs->endian & TSK_LIT_ENDIAN) { int a; for (a = 0; a < dentry->fi_len / 2; a++) { name16[i] = ((name16[i] & 0xff) << 8) + ((name16[i] & 0xff00) >> 8); } } name8 = (UTF8 *) in_node->inode.fn; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & buf[b_offs + sizeof(iso9660_dentry) + dentry->fi_len], &name8, (UTF8 *) ((uintptr_t) & in_node-> inode.fn[ISO9660_MAXNAMLEN_STD]), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "iso9660_load_inodes_dir: Error converting Joliet name to UTF8: %d", retVal); in_node->inode.fn[0] = '\0'; } *name8 = '\0'; } else if (ctype == ISO9660_CTYPE_ASCII) { int readlen; readlen = dentry->fi_len; if (readlen > ISO9660_MAXNAMLEN_STD) readlen = ISO9660_MAXNAMLEN_STD; memcpy(in_node->inode.fn, &buf[b_offs + sizeof(iso9660_dentry)], readlen); in_node->inode.fn[readlen] = '\0'; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid ctype in iso9660_load_inodes_dir"); return -1; } // the version is embedded in the name file_ver = strchr(in_node->inode.fn, ';'); if (file_ver) { in_node->inode.version = atoi(file_ver + 1); *file_ver = '\0'; file_ver = NULL; } // if no extension, remove the final '.' if (in_node->inode.fn[strlen(in_node->inode.fn) - 1] == '.') in_node->inode.fn[strlen(in_node->inode.fn) - 1] = '\0'; } // copy the raw dentry data into the node memcpy(&(in_node->inode.dr), dentry, sizeof(iso9660_dentry)); in_node->inode.ea = NULL; in_node->offset = tsk_getu32(fs->endian, dentry->ext_loc_m) * fs->block_size; in_node->ea_size = dentry->ext_len; in_node->dentry_offset = s_offs + b_offs; if (is_first) in_node->inode.is_orphan = 0; else in_node->inode.is_orphan = 1; /* record size to make sure fifos show up as unique files */ in_node->size = tsk_getu32(fs->endian, in_node->inode.dr.data_len_m); in_node->inum = count++; /* RockRidge data is located after the name. See if it is there. */ if ((int) (dentry->entry_len - sizeof(iso9660_dentry) - dentry->fi_len) > 1) { int extra_bytes = dentry->entry_len - sizeof(iso9660_dentry) - dentry->fi_len; in_node->inode.rr = parse_susp(fs, &buf[b_offs + sizeof(iso9660_dentry) + dentry->fi_len], extra_bytes, NULL); in_node->inode.susp_off = b_offs + sizeof(iso9660_dentry) + dentry->fi_len + s_offs; in_node->inode.susp_len = extra_bytes; if (in_node->inode.rr == NULL) { // return -1; // @@@ Verbose error } } else { in_node->inode.susp_off = 0; in_node->inode.susp_len = 0; } /* add inode to the list */ if (iso->in_list) { iso9660_inode_node *tmp, *prev_tmp; for (tmp = iso->in_list; tmp; tmp = tmp->next) { /* When processing the "first" volume descriptor, all entries get added to the list. * for the later ones, we skip duplicate ones that overlap with entries from a * previous volume descriptor. */ if ((in_node->offset == tmp->offset) && (in_node->size == tmp->size) && (in_node->size) && (is_first == 0)) { if (in_node->inode.rr) { if (tmp->inode.rr == NULL) { tmp->inode.rr = in_node->inode.rr; tmp->inode.susp_off = in_node->inode.susp_off; tmp->inode.susp_len = in_node->inode.susp_len; in_node->inode.rr = NULL; } else { free(in_node->inode.rr); } } if (tsk_verbose) tsk_fprintf(stderr, "iso9660_load_inodes_dir: Removing duplicate entry for: %s\n", in_node->inode.fn); free(in_node); in_node = NULL; count--; break; } prev_tmp = tmp; } // add it to the end (if we didn't get rid of it above) if (in_node) { prev_tmp->next = in_node; in_node->next = NULL; } } else { iso->in_list = in_node; in_node->next = NULL; } // skip two entries if this was the root directory (the . and ..). if ((i == 0) && (b_offs == 0) && (count == 1)) { b_offs += dentry->entry_len; dentry = (iso9660_dentry *) & buf[b_offs]; } b_offs += dentry->entry_len; } s_offs += cnt1; } return count; } /** * Process the path table for a joliet secondary volume descriptor * and load all of the files pointed to it. * The path table contains an entry for each directory. This code * then locates each of the diretories and proceses the contents. * * @param fs File system to process * @param svd Pointer to the secondary volume descriptor * @param count Current count of inodes * @returns updated count of inodes or -1 on error */ static int iso9660_load_inodes_pt_joliet(TSK_FS_INFO * fs, iso9660_svd * svd, int count, uint8_t is_first) { TSK_OFF_T pt_offs; /* offset of where we are in path table */ size_t pt_len; /* bytes left in path table */ // get the location of the path table pt_offs = (TSK_OFF_T) (tsk_getu32(fs->endian, svd->pt_loc_m) * fs->block_size); pt_len = tsk_getu32(fs->endian, svd->pt_size_m); while (pt_len > 0) { char utf16_buf[ISO9660_MAXNAMLEN_JOL + 1]; // UTF-16 name from img char utf8buf[2 * ISO9660_MAXNAMLEN_JOL + 1]; // UTF-8 version of name int readlen; TSK_OFF_T extent; /* offset of extent for current directory */ path_table_rec dir; int retVal; ssize_t cnt; UTF16 *name16; UTF8 *name8; // Read the path table entry cnt = tsk_fs_read(fs, pt_offs, (char *) &dir, (int) sizeof(dir)); if (cnt != sizeof(dir)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso9660_load_inodes_pt"); return -1; } pt_len -= cnt; pt_offs += (TSK_OFF_T) cnt; readlen = dir.len_di; if (dir.len_di > ISO9660_MAXNAMLEN_JOL) readlen = ISO9660_MAXNAMLEN_JOL; memset(utf16_buf, 0, ISO9660_MAXNAMLEN_JOL); /* get UCS-2 filename for the entry */ cnt = tsk_fs_read(fs, pt_offs, (char *) utf16_buf, readlen); if (cnt != dir.len_di) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_find_inodes"); return -1; } pt_len -= cnt; pt_offs += (TSK_OFF_T) cnt; // ISO stores UTF-16 in BE -- convert to local if we need to if (fs->endian & TSK_LIT_ENDIAN) { int i; for (i = 0; i < cnt; i += 2) { char t = utf16_buf[i]; utf16_buf[i] = utf16_buf[i + 1]; utf16_buf[i] = t; } } name16 = (UTF16 *) utf16_buf; name8 = (UTF8 *) utf8buf; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) & utf16_buf[cnt + 1]), &name8, (UTF8 *) ((uintptr_t) & utf8buf[2 * ISO9660_MAXNAMLEN_JOL]), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "fsstat: Error converting Joliet name to UTF8: %d", retVal); utf8buf[0] = '\0'; } *name8 = '\0'; /* padding byte is there if strlen(file name) is odd */ if (dir.len_di % 2) { pt_len--; pt_offs++; } extent = (TSK_OFF_T) (tsk_getu32(fs->endian, dir.ext_loc) * fs->block_size); // process the directory contents count = iso9660_load_inodes_dir(fs, extent, count, ISO9660_CTYPE_UTF16, utf8buf, is_first); if (count == -1) { return -1; } } return count; } /** * Proces the path table and the directories that are listed in it. * The files in each directory will be stored in ISO_INFO. * * @param iso File system to analyze and store results in * @returns -1 on error or count of inodes found. */ static int iso9660_load_inodes_pt(ISO_INFO * iso) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & iso->fs_info; int count = 0; iso9660_svd_node *s; iso9660_pvd_node *p; char fn[ISO9660_MAXNAMLEN_STD + 1]; /* store current directory name */ path_table_rec dir; TSK_OFF_T pt_offs; /* offset of where we are in path table */ size_t pt_len; /* bytes left in path table */ TSK_OFF_T extent; /* offset of extent for current directory */ ssize_t cnt; uint8_t is_first = 1; if (tsk_verbose) tsk_fprintf(stderr, "iso9660_load_inodes_pt: iso: %lu\n", (uintptr_t) iso); /* initialize in case repeatedly called */ iso9660_inode_list_free(fs); iso->in_list = NULL; /* The secondary volume descriptor table will contain the * longer / unicode files, so we process it first to give them * a higher priority */ for (s = iso->svd; s != NULL; s = s->next) { /* Check if this is Joliet -- there are three possible signatures */ if ((s->svd.esc_seq[0] == 0x25) && (s->svd.esc_seq[1] == 0x2F) && ((s->svd.esc_seq[2] == 0x40) || (s->svd.esc_seq[2] == 0x43) || (s->svd.esc_seq[2] == 0x45))) { count = iso9660_load_inodes_pt_joliet(fs, &(s->svd), count, is_first); if (count == -1) { return -1; } is_first = 0; } } /* Now look for unique files in the primary descriptors */ for (p = iso->pvd; p != NULL; p = p->next) { pt_offs = (TSK_OFF_T) (tsk_getu32(fs->endian, p->pvd.pt_loc_m) * fs->block_size); pt_len = tsk_getu32(fs->endian, p->pvd.pt_size_m); while (pt_len > 0) { int readlen; /* get next path table entry... */ cnt = tsk_fs_read(fs, pt_offs, (char *) &dir, sizeof(dir)); if (cnt != sizeof(dir)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_find_inodes"); return -1; } pt_len -= cnt; pt_offs += (TSK_OFF_T) cnt; readlen = dir.len_di; if (readlen > ISO9660_MAXNAMLEN_STD) readlen = ISO9660_MAXNAMLEN_STD; /* get directory name, this is the only chance */ cnt = tsk_fs_read(fs, pt_offs, fn, readlen); if (cnt != readlen) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_find_inodes"); return -1; } fn[cnt] = '\0'; pt_len -= cnt; pt_offs += (TSK_OFF_T) cnt; /* padding byte is there if strlen(file name) is odd */ if (dir.len_di % 2) { pt_len--; pt_offs++; } extent = (TSK_OFF_T) (tsk_getu32(fs->endian, dir.ext_loc) * fs->block_size); // process the directory contents count = iso9660_load_inodes_dir(fs, extent, count, ISO9660_CTYPE_ASCII, fn, is_first); if (count == -1) { return -1; } } } return count; } /** * Load the raw "inode" into the cached buffer (iso->dinode) * * dinode_load (for now) does not check for extended attribute records... * my issue is I dont have an iso9660 image with extended attr recs, so I * can't test/debug, etc * * @returns 1 if not found and 0 on succuss */ uint8_t iso9660_dinode_load(ISO_INFO * iso, TSK_INUM_T inum) { iso9660_inode_node *n; n = iso->in_list; while (n && (n->inum != inum)) n = n->next; if (n) { memcpy(iso->dinode, &n->inode, sizeof(iso9660_inode)); iso->dinum = inum; return 0; } else { return 1; } } static uint16_t isomode2tskmode(uint16_t a_mode) { uint16_t mode = 0; if (a_mode & ISO_EA_IRUSR) mode |= TSK_FS_META_MODE_IRUSR; if (a_mode & ISO_EA_IWUSR) mode |= TSK_FS_META_MODE_IWUSR; if (a_mode & ISO_EA_IXUSR) mode |= TSK_FS_META_MODE_IXUSR; if (a_mode & ISO_EA_IRGRP) mode |= TSK_FS_META_MODE_IRGRP; if (a_mode & ISO_EA_IWGRP) mode |= TSK_FS_META_MODE_IWGRP; if (a_mode & ISO_EA_IXGRP) mode |= TSK_FS_META_MODE_IXGRP; if (a_mode & ISO_EA_IROTH) mode |= TSK_FS_META_MODE_IROTH; if (a_mode & ISO_EA_IWOTH) mode |= TSK_FS_META_MODE_IWOTH; if (a_mode & ISO_EA_IXOTH) mode |= TSK_FS_META_MODE_IXOTH; return mode; } /** * Copies cached disk inode into generic structure. * * @returns 1 on error and 0 on success */ static uint8_t iso9660_dinode_copy(ISO_INFO * iso, TSK_FS_META * fs_meta) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & iso->fs_info; struct tm t; if (fs_meta == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_dinode_copy: fs_file or meta is NULL"); return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_EMPTY; if (fs_meta->attr) { tsk_fs_attrlist_markunused(fs_meta->attr); } if (fs_meta->content_len < ISO9660_FILE_CONTENT_LEN) { if ((fs_meta = tsk_fs_meta_realloc(fs_meta, ISO9660_FILE_CONTENT_LEN)) == NULL) { return 1; } } fs_meta->addr = iso->dinum; fs_meta->size = tsk_getu32(fs->endian, iso->dinode->dr.data_len_m); memset(&t, 0, sizeof(struct tm)); t.tm_sec = iso->dinode->dr.rec_time.sec; t.tm_min = iso->dinode->dr.rec_time.min; t.tm_hour = iso->dinode->dr.rec_time.hour; t.tm_mday = iso->dinode->dr.rec_time.day; t.tm_mon = iso->dinode->dr.rec_time.month - 1; t.tm_year = iso->dinode->dr.rec_time.year; //gmt_hrdiff = iso->dinode->dr.rec_time.gmt_off * 15 / 60; fs_meta->crtime = mktime(&t); fs_meta->mtime = fs_meta->atime = fs_meta->ctime = 0; fs_meta->crtime_nano = fs_meta->mtime_nano = fs_meta->atime_nano = fs_meta->ctime_nano = 0; if (iso->dinode->dr.flags & ISO9660_FLAG_DIR) fs_meta->type = TSK_FS_META_TYPE_DIR; else fs_meta->type = TSK_FS_META_TYPE_REG; if (iso->dinode->ea) { fs_meta->uid = tsk_getu32(fs->endian, iso->dinode->ea->uid); fs_meta->gid = tsk_getu32(fs->endian, iso->dinode->ea->gid); fs_meta->mode = isomode2tskmode(tsk_getu16(fs->endian, iso->dinode->ea->mode)); fs_meta->nlink = 1; } else { fs_meta->uid = 0; fs_meta->gid = 0; fs_meta->mode = 0; fs_meta->nlink = 1; } ((TSK_DADDR_T *) fs_meta->content_ptr)[0] = (TSK_DADDR_T) tsk_getu32(fs->endian, iso->dinode->dr.ext_loc_m); // mark files that were found from other volume descriptors as unalloc so that they // come up as orphan files. if (iso->dinode->is_orphan) fs_meta->flags = TSK_FS_META_FLAG_UNALLOC | TSK_FS_META_FLAG_USED; else fs_meta->flags = TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_USED; return 0; } static uint8_t iso9660_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { ISO_INFO *iso = (ISO_INFO *) fs; if (tsk_verbose) tsk_fprintf(stderr, "iso9660_inode_lookup: iso: %lu" " inum: %" PRIuINUM "\n", (uintptr_t) iso, inum); if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_inode_lookup: fs_file is NULL"); return 1; } if (a_fs_file->meta == NULL) { if ((a_fs_file->meta = tsk_fs_meta_alloc(ISO9660_FILE_CONTENT_LEN)) == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } // see if they are looking for the special "orphans" directory if (inum == TSK_FS_ORPHANDIR_INUM(fs)) { if (tsk_fs_dir_make_orphan_dir_meta(fs, a_fs_file->meta)) return 1; else return 0; } else { // load the inode into the ISO buffer if (iso9660_dinode_load(iso, inum)) { return 1; } // copy into the FS_META structure if (iso9660_dinode_copy(iso, a_fs_file->meta)) { return 1; } } return 0; } uint8_t iso9660_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start, TSK_INUM_T last, TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB action, void *ptr) { char *myname = "iso9660_inode_walk"; ISO_INFO *iso = (ISO_INFO *) fs; TSK_INUM_T inum, end_inum_tmp; TSK_FS_FILE *fs_file; int myflags; // clean up any error messages that are lying around tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "iso9660_inode_walk: iso: %lu" " start: %" PRIuINUM " last: %" PRIuINUM " flags: %d" " action: %lu ptr: %lu\n", (uintptr_t) fs, start, last, flags, (uintptr_t) action, (uintptr_t) ptr); myflags = TSK_FS_META_FLAG_ALLOC; /* * Sanity checks. */ if (start < fs->first_inum || start > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start inode: %" PRIuINUM "", myname, start); return 1; } if (last < fs->first_inum || last > fs->last_inum || last < start) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End inode: %" PRIuINUM "", myname, last); return 1; } /* If ORPHAN is wanted, then make sure that the flags are correct */ if (flags & TSK_FS_META_FLAG_ORPHAN) { flags |= TSK_FS_META_FLAG_UNALLOC; flags &= ~TSK_FS_META_FLAG_ALLOC; flags |= TSK_FS_META_FLAG_USED; flags &= ~TSK_FS_META_FLAG_UNUSED; } else if (((flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED flags are set, then set them * both */ if (((flags & TSK_FS_META_FLAG_USED) == 0) && ((flags & TSK_FS_META_FLAG_UNUSED) == 0)) { flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } /* If we are looking for orphan files and have not yet filled * in the list of unalloc inodes that are pointed to, then fill * in the list * */ if ((flags & TSK_FS_META_FLAG_ORPHAN) && (fs->list_inum_named == NULL)) { if (tsk_fs_dir_load_inum_named(fs) != TSK_OK) { strncat(tsk_errstr2, " - iso9660_inode_walk: identifying inodes allocated by file names", TSK_ERRSTR_L); return 1; } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(ISO9660_FILE_CONTENT_LEN)) == NULL) return 1; // we need to handle fs->last_inum specially because it is for the // virtual ORPHANS directory. Handle it outside of the loop. if (last == TSK_FS_ORPHANDIR_INUM(fs)) end_inum_tmp = last - 1; else end_inum_tmp = last; /* * Iterate. */ for (inum = start; inum <= end_inum_tmp; inum++) { int retval; if (iso9660_dinode_load(iso, inum)) { tsk_fs_file_close(fs_file); return 1; } if (iso9660_dinode_copy(iso, fs_file->meta)) return 1; myflags = fs_file->meta->flags; if ((flags & myflags) != myflags) continue; /* If we want only orphans, then check if this * inode is in the seen list * */ if ((myflags & TSK_FS_META_FLAG_UNALLOC) && (flags & TSK_FS_META_FLAG_ORPHAN) && (tsk_list_find(fs->list_inum_named, inum))) { continue; } retval = action(fs_file, ptr); if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } else if (retval == TSK_WALK_STOP) { break; } } // handle the virtual orphans folder if they asked for it if ((last == TSK_FS_ORPHANDIR_INUM(fs)) && (flags & TSK_FS_META_FLAG_ALLOC) && (flags & TSK_FS_META_FLAG_USED)) { int retval; if (tsk_fs_dir_make_orphan_dir_meta(fs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } /* call action */ retval = action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } /* * Cleanup. */ tsk_fs_file_close(fs_file); return 0; } // @@@ Doesn' thit seem to ignore interleave? /* return 1 if block is allocated in a file's extent, return 0 otherwise */ static int iso9660_is_block_alloc(TSK_FS_INFO * fs, TSK_DADDR_T blk_num) { ISO_INFO *iso = (ISO_INFO *) fs; iso9660_inode_node *in_node; if (tsk_verbose) tsk_fprintf(stderr, "iso9660_is_block_alloc: fs: %lu" " blk_num: %" PRIuDADDR "\n", (uintptr_t) fs, blk_num); for (in_node = iso->in_list; in_node; in_node = in_node->next) { TSK_DADDR_T first_block = in_node->offset / fs->block_size; TSK_DADDR_T file_size = tsk_getu32(fs->endian, in_node->inode.dr.data_len_m); TSK_DADDR_T last_block = first_block + (file_size / fs->block_size); if (file_size % fs->block_size) last_block++; if ((blk_num >= first_block) && (blk_num <= last_block)) return 1; } return 0; } TSK_FS_BLOCK_FLAG_ENUM iso9660_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { return (iso9660_is_block_alloc(a_fs, a_addr)) ? TSK_FS_BLOCK_FLAG_ALLOC : TSK_FS_BLOCK_FLAG_UNALLOC; } /* flags: TSK_FS_BLOCK_FLAG_ALLOC and FS_FLAG_UNALLOC * ISO9660 has a LOT of very sparse meta, so in this function a block is only * checked to see if it is part of an inode's extent */ uint8_t iso9660_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T last, TSK_FS_BLOCK_WALK_FLAG_ENUM flags, TSK_FS_BLOCK_WALK_CB action, void *ptr) { char *myname = "iso9660_block_walk"; TSK_DADDR_T addr; TSK_FS_BLOCK *fs_block; // clean up any error messages that are lying around tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "iso9660_block_walk: fs: %lu" " start: %" PRIuDADDR " last: %" PRIuDADDR " flags: %d" " action: %lu ptr: %lu\n", (uintptr_t) fs, start, last, flags, (uintptr_t) action, (uintptr_t) ptr); /* * Sanity checks. */ if (start < fs->first_block || start > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: Start block: %" PRIuDADDR "", myname, start); return 1; } if (last < fs->first_block || last > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: End block: %" PRIuDADDR "", myname, last); return 1; } /* Sanity check on flags -- make sure at least one ALLOC is set */ if (((flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } if (tsk_verbose) tsk_fprintf(stderr, "isofs_block_walk: Block Walking %" PRIuDADDR " to %" PRIuDADDR "\n", start, last); /* cycle through block addresses */ for (addr = start; addr <= last; addr++) { int retval; int myflags = iso9660_block_getflags(fs, addr); // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; if (tsk_fs_block_get(fs, fs_block, addr) == NULL) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_block_walk"); tsk_fs_block_free(fs_block); return 1; } retval = action(fs_block, ptr); if (retval == TSK_WALK_ERROR) { tsk_fs_block_free(fs_block); return 1; } else if (retval == TSK_WALK_STOP) { break; } } tsk_fs_block_free(fs_block); return 0; } static uint8_t iso9660_make_data_run(TSK_FS_FILE * a_fs_file) { ISO_INFO *iso; iso9660_dentry dd; TSK_FS_INFO *fs = NULL; TSK_FS_ATTR *fs_attr = NULL; TSK_FS_ATTR_RUN *data_run = NULL; // clean up any error messages that are lying around tsk_error_reset(); if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_make_data_run: fs_file or meta is NULL"); return 1; } fs = a_fs_file->fs_info; iso = (ISO_INFO *) fs; // see if we have already loaded the runs if ((a_fs_file->meta->attr != NULL) && (a_fs_file->meta->attr_state == TSK_FS_META_ATTR_STUDIED)) { return 0; } else if (a_fs_file->meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } // not sure why this would ever happen, but... else if (a_fs_file->meta->attr != NULL) { tsk_fs_attrlist_markunused(a_fs_file->meta->attr); } else if (a_fs_file->meta->attr == NULL) { a_fs_file->meta->attr = tsk_fs_attrlist_alloc(); } // copy the raw data if (iso9660_dinode_load(iso, a_fs_file->meta->addr)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso9660_make_data_run"); a_fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } memcpy(&dd, &iso->dinode->dr, sizeof(iso9660_dentry)); if (dd.gap_sz) { a_fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "file %" PRIuINUM " has an interleave gap -- not supported", a_fs_file->meta->addr); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(a_fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { return 1; } // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) return -1; data_run->addr = ((TSK_DADDR_T *) a_fs_file->meta->content_ptr)[0]; data_run->len = (a_fs_file->meta->size + fs->block_size - 1) / fs->block_size; data_run->offset = 0; // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, a_fs_file->meta->size, a_fs_file->meta->size, roundup(a_fs_file->meta->size + dd.ext_len, fs->block_size) - dd.ext_len, 0, 0)) { return 1; } // the first bytes in the run could be allocated for the extended attribute. fs_attr->nrd.skiplen = dd.ext_len; a_fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } static uint8_t iso9660_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for iso9660 yet"); return 1; } /** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ static uint8_t iso9660_fsstat(TSK_FS_INFO * fs, FILE * hFile) { char str[129]; /* store name of publisher/preparer/etc */ ISO_INFO *iso = (ISO_INFO *) fs; char *cp; int i; iso9660_pvd_node *p = iso->pvd; iso9660_svd_node *s; // clean up any error messages that are lying around tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "iso9660_fsstat: fs: %lu \ hFile: %lu\n", (uintptr_t) fs, (uintptr_t) hFile); i = 0; for (p = iso->pvd; p != NULL; p = p->next) { i++; tsk_fprintf(hFile, "\n=== PRIMARY VOLUME DESCRIPTOR %d ===\n", i); tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: ISO9660\n"); tsk_fprintf(hFile, "Volume Name: %s\n", p->pvd.vol_id); tsk_fprintf(hFile, "Volume Set Size: %d\n", tsk_getu16(fs->endian, p->pvd.vol_set_m)); tsk_fprintf(hFile, "Volume Set Sequence: %d\n", tsk_getu16(fs->endian, p->pvd.vol_seq_m)); /* print publisher */ if (p->pvd.pub_id[0] == 0x5f) /* publisher is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.pub_id); cp = &str[127]; /* find last printable non space character */ while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Publisher: %s\n", str); memset(str, ' ', 128); /* print data preparer */ if (p->pvd.prep_id[0] == 0x5f) /* preparer is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.prep_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Data Preparer: %s\n", str); memset(str, ' ', 128); /* print recording application */ if (p->pvd.app_id[0] == 0x5f) /* application is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.app_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Recording Application: %s\n", str); memset(str, ' ', 128); /* print copyright */ if (p->pvd.copy_id[0] == 0x5f) /* copyright is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 37, "%s", p->pvd.copy_id); cp = &str[36]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Copyright: %s\n", str); memset(str, ' ', 37); tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Path Table Location: %" PRIu32 "-%" PRIu32 "\n", tsk_getu32(fs->endian, p->pvd.pt_loc_m), tsk_getu32(fs->endian, p->pvd.pt_loc_m) + tsk_getu32(fs->endian, p->pvd.pt_size_m) / fs->block_size); tsk_fprintf(hFile, "Inode Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "Root Directory Block: %" PRIuDADDR "\n", tsk_getu32(fs->endian, p->pvd.dir_rec.ext_loc_m)); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %d\n", ISO9660_SSIZE_B); tsk_fprintf(hFile, "Block Size: %d\n", tsk_getu16(fs->endian, p->pvd.blk_sz_m)); tsk_fprintf(hFile, "Total Sector Range: 0 - %d\n", (int) ((fs->block_size / ISO9660_SSIZE_B) * (fs->block_count - 1))); /* get image slack, ignore how big the image claims itself to be */ tsk_fprintf(hFile, "Total Block Range: 0 - %d\n", (int) fs->block_count - 1); } i = 0; for (s = iso->svd; s != NULL; s = s->next) { i++; tsk_fprintf(hFile, "\n=== SUPPLEMENTARY VOLUME DESCRIPTOR %d ===\n", i); tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: ISO9660\n"); tsk_fprintf(hFile, "Volume Name: %s\n", s->svd.vol_id); tsk_fprintf(hFile, "Volume Set Size: %d\n", tsk_getu16(fs->endian, s->svd.vol_set_m)); tsk_fprintf(hFile, "Volume Set Sequence: %d\n", tsk_getu16(fs->endian, s->svd.vol_seq_m)); /* print publisher */ if (s->svd.pub_id[0] == 0x5f) /* publisher is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.pub_id); cp = &str[127]; /* find last printable non space character */ while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Publisher: %s\n", str); memset(str, ' ', 128); /* print data preparer */ if (s->svd.prep_id[0] == 0x5f) /* preparer is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.prep_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Data Preparer: %s\n", str); memset(str, ' ', 128); /* print recording application */ if (s->svd.app_id[0] == 0x5f) /* application is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.app_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Recording Application: %s\n", str); memset(str, ' ', 128); /* print copyright */ if (s->svd.copy_id[0] == 0x5f) /* copyright is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 37, "%s\n", s->svd.copy_id); cp = &str[36]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Copyright: %s\n", str); memset(str, ' ', 37); tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Path Table Location: %" PRIu32 "-%" PRIu32 "\n", tsk_getu32(fs->endian, s->svd.pt_loc_m), tsk_getu32(fs->endian, s->svd.pt_loc_m) + tsk_getu32(fs->endian, s->svd.pt_size_m) / fs->block_size); tsk_fprintf(hFile, "Root Directory Block: %" PRIuDADDR "\n", tsk_getu32(fs->endian, s->svd.dir_rec.ext_loc_m)); /* learn joliet level (1-3) */ if (!strncmp((char *) s->svd.esc_seq, "%/E", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 3\n"); if (!strncmp((char *) s->svd.esc_seq, "%/C", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 2\n"); if (!strncmp((char *) s->svd.esc_seq, "%/@", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 1\n"); if (iso->rr_found) tsk_fprintf(hFile, "RockRidge Extensions present\n"); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %d\n", ISO9660_SSIZE_B); tsk_fprintf(hFile, "Block Size: %d\n", fs->block_size); tsk_fprintf(hFile, "Total Sector Range: 0 - %d\n", (int) ((fs->block_size / ISO9660_SSIZE_B) * (fs->block_count - 1))); /* get image slack, ignore how big the image claims itself to be */ tsk_fprintf(hFile, "Total Block Range: 0 - %d\n", (int) fs->block_count - 1); } return 0; } /** * Make a unix-style permissions string based the flags in dentry * and the cached inode in fs */ char * make_unix_perm(TSK_FS_INFO * fs, iso9660_dentry * dd) { // @@@ we should change this design static char perm[11]; ISO_INFO *iso = (ISO_INFO *) fs; if (tsk_verbose) tsk_fprintf(stderr, "make_unix_perm: fs: %lu" " dd: %lu\n", (uintptr_t) fs, (uintptr_t) dd); perm[10] = '\0'; memset(perm, '-', 11); if (dd->flags & ISO9660_FLAG_DIR) perm[0] = 'd'; if (iso->dinode->ea) { if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_UR) perm[1] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_UX) perm[3] = 'x'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_GR) perm[4] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_GX) perm[6] = 'x'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_AR) perm[7] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_AX) perm[9] = 'x'; } else { strcpy(&perm[1], "r-xr-xr-x"); } return perm; } # if 0 static void iso9660_print_rockridge(FILE * hFile, rockridge_ext * rr) { char mode_buf[11]; tsk_fprintf(hFile, "\nROCKRIDGE EXTENSIONS\n"); tsk_fprintf(hFile, "Owner-ID: "); tsk_fprintf(hFile, "%d\t", (int) rr->uid); tsk_fprintf(hFile, "Group-ID: "); tsk_fprintf(hFile, "%d\n", (int) rr->gid); tsk_fprintf(hFile, "Mode: "); memset(mode_buf, '-', 11); mode_buf[10] = '\0'; /* file type */ /* note: socket and symbolic link are multi bit fields */ if ((rr->mode & MODE_IFSOCK) == MODE_IFSOCK) mode_buf[0] = 's'; else if ((rr->mode & MODE_IFLNK) == MODE_IFLNK) mode_buf[0] = 'l'; else if (rr->mode & MODE_IFDIR) mode_buf[0] = 'd'; else if (rr->mode & MODE_IFIFO) mode_buf[0] = 'p'; else if (rr->mode & MODE_IFBLK) mode_buf[0] = 'b'; else if (rr->mode & MODE_IFCHR) mode_buf[0] = 'c'; /* owner permissions */ if (rr->mode & TSK_FS_META_MODE_IRUSR) mode_buf[1] = 'r'; if (rr->mode & TSK_FS_META_MODE_IWUSR) mode_buf[2] = 'w'; if ((rr->mode & TSK_FS_META_MODE_IXUSR) && (rr->mode & TSK_FS_META_MODE_ISUID)) mode_buf[3] = 's'; else if (rr->mode & TSK_FS_META_MODE_IXUSR) mode_buf[3] = 'x'; else if (rr->mode & TSK_FS_META_MODE_ISUID) mode_buf[3] = 'S'; /* group permissions */ if (rr->mode & TSK_FS_META_MODE_IRGRP) mode_buf[4] = 'r'; if (rr->mode & TSK_FS_META_MODE_IWGRP) mode_buf[5] = 'w'; if ((rr->mode & TSK_FS_META_MODE_IXGRP) && (rr->mode & TSK_FS_META_MODE_ISGID)) mode_buf[6] = 's'; else if (rr->mode & TSK_FS_META_MODE_IXGRP) mode_buf[6] = 'x'; else if (rr->mode & TSK_FS_META_MODE_ISGID) mode_buf[6] = 'S'; /* other permissions */ if (rr->mode & TSK_FS_META_MODE_IROTH) mode_buf[7] = 'r'; if (rr->mode & TSK_FS_META_MODE_IWOTH) mode_buf[8] = 'w'; if ((rr->mode & TSK_FS_META_MODE_IXOTH) && (rr->mode & TSK_FS_META_MODE_ISVTX)) mode_buf[9] = 't'; else if (rr->mode & TSK_FS_META_MODE_IXOTH) mode_buf[9] = 'x'; else if (rr->mode & TSK_FS_META_MODE_ISVTX) mode_buf[9] = 'T'; tsk_fprintf(hFile, "%s\n", mode_buf); tsk_fprintf(hFile, "Number links: %" PRIu32 "\n", rr->nlink); tsk_fprintf(hFile, "Alternate name: %s\n", rr->fn); tsk_fprintf(hFile, "\n"); } #endif /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File handle to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t iso9660_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { ISO_INFO *iso = (ISO_INFO *) fs; TSK_FS_FILE *fs_file; iso9660_dentry dd; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) return 1; tsk_fprintf(hFile, "Entry: %" PRIuINUM "\n", inum); if (iso9660_dinode_load(iso, inum)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso9660_istat"); tsk_fs_file_close(fs_file); return 1; } memcpy(&dd, &iso->dinode->dr, sizeof(iso9660_dentry)); tsk_fprintf(hFile, "Type: "); if (dd.flags & ISO9660_FLAG_DIR) tsk_fprintf(hFile, "Directory\n"); else tsk_fprintf(hFile, "File\n"); tsk_fprintf(hFile, "Links: %d\n", fs_file->meta->nlink); if (dd.gap_sz > 0) { tsk_fprintf(hFile, "Interleave Gap Size: %d\n", dd.gap_sz); tsk_fprintf(hFile, "Interleave File Unit Size: %d\n", dd.unit_sz); } tsk_fprintf(hFile, "Flags: "); if (dd.flags & ISO9660_FLAG_HIDE) tsk_fprintf(hFile, "Hidden, "); if (dd.flags & ISO9660_FLAG_ASSOC) tsk_fprintf(hFile, "Associated, "); if (dd.flags & ISO9660_FLAG_RECORD) tsk_fprintf(hFile, "Record Format, "); if (dd.flags & ISO9660_FLAG_PROT) tsk_fprintf(hFile, "Protected, "); /* check if reserved bits are set, be suspicious */ if (dd.flags & ISO9660_FLAG_RES1) tsk_fprintf(hFile, "Reserved1, "); if (dd.flags & ISO9660_FLAG_RES2) tsk_fprintf(hFile, "Reserved2, "); if (dd.flags & ISO9660_FLAG_MULT) tsk_fprintf(hFile, "Non-final multi-extent entry"); putchar('\n'); tsk_fprintf(hFile, "Name: %s\n", iso->dinode->fn); tsk_fprintf(hFile, "Size: %" PRIu32 "\n", tsk_getu32(fs->endian, iso->dinode->dr.data_len_m)); if (iso->dinode->ea) { tsk_fprintf(hFile, "\nEXTENDED ATTRIBUTE INFO\n"); tsk_fprintf(hFile, "Owner-ID: %" PRIu32 "\n", tsk_getu32(fs->endian, iso->dinode->ea->uid)); tsk_fprintf(hFile, "Group-ID: %" PRIu32 "\n", tsk_getu32(fs->endian, iso->dinode->ea->gid)); tsk_fprintf(hFile, "Mode: %s\n", make_unix_perm(fs, &dd)); } else if (iso->dinode->susp_off) { char *buf2 = (char *) tsk_malloc((size_t) iso->dinode->susp_len); if (buf2 != NULL) { ssize_t cnt; fprintf(hFile, "\nRock Ridge Extension Data\n"); cnt = tsk_fs_read(fs, iso->dinode->susp_off, buf2, (size_t) iso->dinode->susp_len); if (cnt == iso->dinode->susp_len) { parse_susp(fs, buf2, (int) cnt, hFile); } else { fprintf(hFile, "Error reading Rock Ridge Location\n"); if (tsk_verbose) { fprintf(stderr, "istat: error reading rock ridge entry\n"); tsk_error_print(stderr); } tsk_error_reset(); } free(buf2); } else { if (tsk_verbose) fprintf(stderr, "istat: error allocating memory to process rock ridge entry\n"); tsk_error_reset(); } } //else if (iso->dinode->rr) { // iso9660_print_rockridge(hFile, iso->dinode->rr); //} else { tsk_fprintf(hFile, "Owner-ID: 0\n"); tsk_fprintf(hFile, "Group-ID: 0\n"); tsk_fprintf(hFile, "Mode: %s\n", make_unix_perm(fs, &dd)); } if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted File Times:\n"); fs_file->meta->mtime -= sec_skew; fs_file->meta->atime -= sec_skew; fs_file->meta->crtime -= sec_skew; tsk_fprintf(hFile, "Written:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); fs_file->meta->mtime += sec_skew; fs_file->meta->atime += sec_skew; fs_file->meta->crtime += sec_skew; tsk_fprintf(hFile, "\nOriginal File Times:\n"); } else { tsk_fprintf(hFile, "\nFile Times:\n"); } tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); tsk_fprintf(hFile, "\nSectors:\n"); /* since blocks are all contiguous, print them here to simplify file_walk */ { int block = tsk_getu32(fs->endian, iso->dinode->dr.ext_loc_m); TSK_OFF_T size = fs_file->meta->size; int rowcount = 0; while ((int64_t) size > 0) { tsk_fprintf(hFile, "%d ", block++); size -= fs->block_size; rowcount++; if (rowcount == 8) { rowcount = 0; tsk_fprintf(hFile, "\n"); } } tsk_fprintf(hFile, "\n"); } tsk_fs_file_close(fs_file); return 0; } uint8_t iso9660_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "ISO9660 does not have a journal"); return 1; } uint8_t iso9660_jentry_walk(TSK_FS_INFO * fs, int flags, TSK_FS_JENTRY_WALK_CB action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "ISO9660 does not have a journal"); return 1; } uint8_t iso9660_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int flags, TSK_FS_JBLK_WALK_CB action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "ISO9660 does not have a journal"); return 1; } static TSK_FS_ATTR_TYPE_ENUM iso9660_get_default_attr_type(const TSK_FS_FILE * a_file) { return TSK_FS_ATTR_TYPE_DEFAULT; } static void iso9660_close(TSK_FS_INFO * fs) { ISO_INFO *iso = (ISO_INFO *) fs; iso9660_pvd_node *p; iso9660_svd_node *s; fs->tag = 0; while (iso->pvd != NULL) { p = iso->pvd; iso->pvd = iso->pvd->next; free(p); } while (iso->svd != NULL) { s = iso->svd; iso->svd = iso->svd->next; free(s); } free((char *) iso->dinode); if (fs->list_inum_named) { tsk_list_free(fs->list_inum_named); fs->list_inum_named = NULL; } free(fs); } /** Load the volume descriptors into save the raw data structures in * the file system state structure (fs). Also determines the block size. * * This is useful for discs which may have 2 volumes on them (no, not * multisession CD-R/CD-RW). * Design note: If path table address is the same, then you have the same image. * Only store unique image info. * Uses a linked list even though Ecma-119 says there is only 1 primary vol * desc, consider possibility of more. * * Returns -1 on error and 0 on success */ static int load_vol_desc(TSK_FS_INFO * fs) { int count = 0; ISO_INFO *iso = (ISO_INFO *) fs; TSK_OFF_T offs; char *myname = "iso_load_vol_desc"; ssize_t cnt; iso9660_pvd_node *p; iso9660_svd_node *s; uint8_t magic_seen = 0; iso->pvd = NULL; iso->svd = NULL; //fs->block_size = 0; fs->dev_bsize = fs->img_info->sector_size; #if 0 b = (iso_bootrec *) tsk_malloc(sizeof(iso_bootrec)); if (b == NULL) { return -1; } #endif // @@@ Technically, we should seek ahea 16 * sector size for (offs = ISO9660_SBOFF;; offs += sizeof(iso9660_gvd)) { iso9660_gvd *vd; // allocate a buffer the size of the nodes in the linked list // this will be stored in ISO_INFO, so it is not always freed here if ((vd = (iso9660_gvd *) tsk_malloc(sizeof(iso9660_pvd_node))) == NULL) { return -1; } ISO_RETRY_MAGIC: // read the full descriptor cnt = tsk_fs_read(fs, offs, (char *) vd, sizeof(iso9660_gvd)); if (cnt != sizeof(iso9660_gvd)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_load_vol_desc: Error reading"); free(vd); return -1; } // verify the magic value if (strncmp(vd->magic, ISO9660_MAGIC, 5)) { if (tsk_verbose) tsk_fprintf(stderr, "%s: Bad volume descriptor: Magic number is not CD001\n", myname); // see if we have a RAW image if (magic_seen == 0) { if (fs->block_pre_size == 0) { if (tsk_verbose) tsk_fprintf(stderr, "Trying RAW ISO9660 with 16-byte pre-block size\n"); fs->block_pre_size = 16; // 304 = 2352 - 2048 fs->block_post_size = 304 - fs->block_pre_size; goto ISO_RETRY_MAGIC; } else if (fs->block_pre_size == 16) { if (tsk_verbose) tsk_fprintf(stderr, "Trying RAW ISO9660 with 24-byte pre-block size\n"); fs->block_pre_size = 24; fs->block_post_size = 304 - fs->block_pre_size; goto ISO_RETRY_MAGIC; } else { fs->block_pre_size = 0; fs->block_post_size = 0; } } free(vd); return -1; } magic_seen = 1; // see if we are done if (vd->type == ISO9660_VOL_DESC_SET_TERM) break; switch (vd->type) { case ISO9660_PRIM_VOL_DESC: p = (iso9660_pvd_node *) vd; /* list not empty */ if (iso->pvd) { iso9660_pvd_node *ptmp = iso->pvd; /* append to list if path table address not found in list */ while ((p->pvd.pt_loc_l != ptmp->pvd.pt_loc_l) && (ptmp->next)) ptmp = ptmp->next; // we already have it if (p->pvd.pt_loc_l == ptmp->pvd.pt_loc_l) { free(vd); p = NULL; vd = NULL; } else { ptmp->next = p; p->next = NULL; count++; } } /* list empty, insert */ else { iso->pvd = p; p->next = NULL; count++; } break; case ISO9660_SUPP_VOL_DESC: s = (iso9660_svd_node *) vd; /* list not empty */ if (iso->svd) { iso9660_svd_node *stmp = iso->svd; /* append to list if path table address not found in list */ while ((s->svd.pt_loc_l != stmp->svd.pt_loc_l) && (stmp->next)) stmp = stmp->next; // we already have it if (s->svd.pt_loc_l == stmp->svd.pt_loc_l) { free(vd); s = NULL; vd = NULL; } else { stmp->next = s; s->next = NULL; count++; } } /* list empty, insert */ else { iso->svd = s; s->next = NULL; count++; } break; /* boot records are just read and discarded for now... */ case ISO9660_BOOT_RECORD: #if 0 cnt = tsk_fs_read(fs, offs, (char *) b, sizeof(iso_bootrec)); if (cnt != sizeof(iso_bootrec)) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso_load_vol_desc: Error reading"); return -1; } offs += sizeof(iso_bootrec); #endif break; } } /* now that we have all primary and supplementary volume descs, we should cull the list of */ /* primary that match up with supplems, since supplem has all info primary has plus more. */ /* this will make jobs such as searching all volumes easier later */ for (s = iso->svd; s != NULL; s = s->next) { for (p = iso->pvd; p != NULL; p = p->next) { // see if they have the same starting address if (tsk_getu32(fs->endian, p->pvd.pt_loc_m) == tsk_getu32(fs->endian, s->svd.pt_loc_m)) { // see if it is the head of the list if (p == iso->pvd) { iso->pvd = p->next; } else { iso9660_pvd_node *ptmp = iso->pvd; while (ptmp->next != p) ptmp = ptmp->next; ptmp->next = p->next; } p->next = NULL; free(p); p = NULL; count--; break; } } } if ((iso->pvd == NULL) && (iso->svd == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "load_vol_desc: primary and secondary volume descriptors null"); return -1; } return 0; } /* iso9660_open - * opens an iso9660 filesystem. * Design note: This function doesn't read a superblock, since iso9660 doesnt * really have one. Volume info is read in with a call to load_vol_descs(). */ TSK_FS_INFO * iso9660_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype, uint8_t test) { ISO_INFO *iso; TSK_FS_INFO *fs; uint8_t tmpguess[4]; if (TSK_FS_TYPE_ISISO9660(ftype) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS type in iso9660_open"); return NULL; } if (tsk_verbose) { tsk_fprintf(stderr, "iso9660_open img_info: %lu" " ftype: %" PRIu8 " test: %" PRIu8 "\n", (uintptr_t) img_info, ftype, test); } if ((iso = (ISO_INFO *) tsk_malloc(sizeof(ISO_INFO))) == NULL) { return NULL; } fs = &(iso->fs_info); iso->rr_found = 0; iso->in_list = NULL; fs->ftype = TSK_FS_TYPE_ISO9660; fs->duname = "Block"; fs->flags = 0; fs->tag = TSK_FS_INFO_TAG; fs->img_info = img_info; fs->offset = offset; /* ISO has no magic to calibrate the endian ordering on and it * stores all numbers in big and small endian. We will use the big * endian order so load up a 4-byte array and flags. We could hardwire * the definition, but I would rather use guessu32 in case I later add * other initialization data to that function (since all other FSs use * it) */ tmpguess[0] = 0; tmpguess[1] = 0; tmpguess[2] = 0; tmpguess[3] = 1; tsk_fs_guessu32(fs, tmpguess, 1); // we need a value here to test for RAW images. So, start with 2048 fs->block_size = 2048; /* load_vol_descs checks magic value */ if (load_vol_desc(fs) == -1) { fs->tag = 0; iso9660_close(fs); if (test) return NULL; else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS type in iso9660_open"); return NULL; } } if (iso->pvd) { fs->block_size = tsk_getu16(fs->endian, iso->pvd->pvd.blk_sz_m); fs->block_count = tsk_getu32(fs->endian, iso->pvd->pvd.vs_sz_m); /* Volume ID */ for (fs->fs_id_used = 0; fs->fs_id_used < 32; fs->fs_id_used++) { fs->fs_id[fs->fs_id_used] = iso->pvd->pvd.vol_id[fs->fs_id_used]; } } else { fs->block_size = tsk_getu16(fs->endian, iso->svd->svd.blk_sz_m); fs->block_count = tsk_getu32(fs->endian, iso->svd->svd.vs_sz_m); /* Volume ID */ for (fs->fs_id_used = 0; fs->fs_id_used < 32; fs->fs_id_used++) { fs->fs_id[fs->fs_id_used] = iso->svd->svd.vol_id[fs->fs_id_used]; } } fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; fs->inum_count = iso9660_load_inodes_pt(iso); if ((int) fs->inum_count == -1) { fs->tag = 0; iso9660_close(fs); return NULL; } fs->inum_count++; // account for the orphan directory fs->last_inum = fs->inum_count - 1; fs->first_inum = ISO9660_FIRSTINO; fs->root_inum = ISO9660_ROOTINO; fs->inode_walk = iso9660_inode_walk; fs->block_walk = iso9660_block_walk; fs->block_getflags = iso9660_block_getflags; fs->get_default_attr_type = iso9660_get_default_attr_type; fs->load_attrs = iso9660_make_data_run; fs->file_add_meta = iso9660_inode_lookup; fs->dir_open_meta = iso9660_dir_open_meta; fs->fsstat = iso9660_fsstat; fs->fscheck = iso9660_fscheck; fs->istat = iso9660_istat; fs->close = iso9660_close; fs->name_cmp = iso9660_name_cmp; fs->jblk_walk = iso9660_jblk_walk; fs->jentry_walk = iso9660_jentry_walk; fs->jopen = iso9660_jopen; /* allocate cache buffers */ /* dinode */ iso->dinode = (iso9660_inode *) tsk_malloc(sizeof(iso9660_inode)); if (iso->dinode == NULL) { fs->tag = 0; iso9660_close(fs); return NULL; } iso->dinum = -1; fs->list_inum_named = NULL; return fs; } sleuthkit-3.2.3/tsk3/fs/iso9660_dent.c000644 000765 000024 00000024705 11643647440 020137 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c)2007 Brian Carrier. All righs reserved. ** ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Copyright (c) 2007-2008 Brian Carrier. All rights reserved ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /** * \file iso9660_dent.c * Contains the internal TSK ISO9660 file system code to handle the parsing of * file names and directory structures. */ #include "tsk_fs_i.h" #include "tsk_iso9660.h" /** \internal * process the data from inside of a directory and load the corresponding * file data into a TSK_FS_DIR structure. * * @param a_fs File system * @param a_fs_dir Structore to store file names into * @param buf Buffer that contains the directory content * @param a_length Number of bytes in buffer * @param a_addr The metadata address for the directory being processed * @param a_dir_addr The block offset where this directory starts * @returns TSK_ERR on error and TSK_OK otherwise */ static uint8_t iso9660_proc_dir(TSK_FS_INFO * a_fs, TSK_FS_DIR * a_fs_dir, char *buf, size_t a_length, TSK_INUM_T a_addr, TSK_OFF_T a_dir_addr) { ISO_INFO *iso = (ISO_INFO *) a_fs; TSK_FS_NAME *fs_name; size_t buf_idx; iso9660_dentry *dd; /* directory descriptor */ iso9660_inode_node *in; TSK_OFF_T dir_offs = a_dir_addr * a_fs->block_size; if ((fs_name = tsk_fs_name_alloc(ISO9660_MAXNAMLEN + 1, 0)) == NULL) return TSK_ERR; buf_idx = 0; dd = (iso9660_dentry *) & buf[buf_idx]; /* handle "." entry */ fs_name->meta_addr = a_addr; strcpy(fs_name->name, "."); fs_name->type = TSK_FS_NAME_TYPE_DIR; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; tsk_fs_dir_add(a_fs_dir, fs_name); buf_idx += dd->entry_len; if (buf_idx > a_length - sizeof(iso9660_dentry)) { free(buf); tsk_fs_name_free(fs_name); return TSK_OK; } dd = (iso9660_dentry *) & buf[buf_idx]; /* handle ".." entry */ in = iso->in_list; while (in && (tsk_getu32(a_fs->endian, in->inode.dr.ext_loc_m) != tsk_getu32(a_fs->endian, dd->ext_loc_m))) in = in->next; if (in) { fs_name->meta_addr = in->inum; strcpy(fs_name->name, ".."); fs_name->type = TSK_FS_NAME_TYPE_DIR; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; tsk_fs_dir_add(a_fs_dir, fs_name); } buf_idx += dd->entry_len; // process the rest of the entries in the directory while (buf_idx < a_length - sizeof(iso9660_dentry)) { dd = (iso9660_dentry *) & buf[buf_idx]; // process the entry (if it has a defined and valid length) if ((dd->entry_len) && (buf_idx + dd->entry_len < a_length)) { /* We need to find the data in the pre-processed list because that * contains the meta data address that TSK assigned to this file. * We find the entry by looking for one that was stored at the same * byte offset that we now are. We used to use the extent location, but * we found an image * that had a file with 0 bytes with the same starting block as another * file. */ for (in = iso->in_list; in; in = in->next) { if (in->dentry_offset == dir_offs + buf_idx) break; } // we may have not found it because we are reading corrupt data... if (!in) { buf_idx++; continue; } // copy the data in fs_name for loading fs_name->meta_addr = in->inum; strncpy(fs_name->name, in->inode.fn, ISO9660_MAXNAMLEN); if (dd->flags & ISO9660_FLAG_DIR) fs_name->type = TSK_FS_NAME_TYPE_DIR; else fs_name->type = TSK_FS_NAME_TYPE_REG; fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; tsk_fs_dir_add(a_fs_dir, fs_name); buf_idx += dd->entry_len; } /* If the length was not defined, we are probably in a hole in the * directory. The contents are block aligned. So, we * scan ahead until we get either a non-zero entry or the block boundary */ else { buf_idx++; for (; buf_idx < a_length - sizeof(iso9660_dentry); buf_idx++) { if (buf[buf_idx] != 0) { dd = (iso9660_dentry *) & buf[buf_idx]; if ((dd->entry_len) && (buf_idx + dd->entry_len < a_length)) break; } if (buf_idx % a_fs->block_size == 0) break; } } } free(buf); tsk_fs_name_free(fs_name); return TSK_OK; } /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM iso9660_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { TSK_RETVAL_ENUM retval; TSK_FS_DIR *fs_dir; ssize_t cnt; char *buf; size_t length; if (a_addr < a_fs->first_inum || a_addr > a_fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_dir_open_meta: Invalid inode value: %" PRIuINUM, a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_dir_open_meta: NULL fs_attr argument given"); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "iso9660_dir_open_meta: Processing directory %" PRIuINUM "\n", a_addr); fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else { if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(a_fs, a_addr, 128)) == NULL) { return TSK_ERR; } } // handle the orphan directory if its contents were requested if (a_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { return tsk_fs_dir_find_orphans(a_fs, fs_dir); } fs_dir->fs_file = tsk_fs_file_open_meta(a_fs, NULL, a_addr); if (fs_dir->fs_file == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_dir_open_meta: %" PRIuINUM " is not a valid inode", a_addr); return TSK_COR; } /* read directory extent into memory */ length = (size_t) fs_dir->fs_file->meta->size; if ((buf = tsk_malloc(length)) == NULL) return TSK_ERR; cnt = tsk_fs_file_read(fs_dir->fs_file, 0, buf, length, 0); if (cnt != length) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; tsk_errstr[0] = '\0'; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso9660_dir_open_meta"); return TSK_ERR; } // process the contents retval = iso9660_proc_dir(a_fs, fs_dir, buf, length, a_addr, fs_dir->fs_file->meta->attr->head->nrd.run->addr); // if we are listing the root directory, add the Orphan directory entry if (a_addr == a_fs->root_inum) { TSK_FS_NAME *fs_name = tsk_fs_name_alloc(256, 0); if (fs_name == NULL) return TSK_ERR; if (tsk_fs_dir_make_orphan_dir_name(a_fs, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); } return retval; } int iso9660_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { return strcmp(s1, s2); } sleuthkit-3.2.3/tsk3/fs/Makefile.am000644 000765 000024 00000001362 11643647440 017670 0ustar00carrierstaff000000 000000 AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskfs.la # Note that the .h files are in the top-level Makefile libtskfs_la_SOURCES = tsk_fs_i.h fs_inode.c fs_io.c fs_block.c fs_open.c \ fs_name.c fs_dir.c fs_types.c fs_attr.c fs_attrlist.c fs_load.c \ fs_parse.c fs_file.c \ unix_misc.c nofs_misc.c \ ffs.c ffs_dent.c ext2fs.c ext2fs_dent.c ext2fs_journal.c \ fatfs.c fatfs_meta.c fatfs_dent.c ntfs.c ntfs_dent.c swapfs.c rawfs.c \ iso9660.c iso9660_dent.c \ hfs.c hfs_dent.c hfs_journal.c hfs_unicompare.c \ dcalc_lib.c dcat_lib.c dls_lib.c dstat_lib.c ffind_lib.c \ fls_lib.c icat_lib.c ifind_lib.c ils_lib.c indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ sleuthkit-3.2.3/tsk3/fs/Makefile.in000644 000765 000024 00000041667 11643647517 017722 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/fs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskfs_la_LIBADD = am_libtskfs_la_OBJECTS = fs_inode.lo fs_io.lo fs_block.lo fs_open.lo \ fs_name.lo fs_dir.lo fs_types.lo fs_attr.lo fs_attrlist.lo \ fs_load.lo fs_parse.lo fs_file.lo unix_misc.lo nofs_misc.lo \ ffs.lo ffs_dent.lo ext2fs.lo ext2fs_dent.lo ext2fs_journal.lo \ fatfs.lo fatfs_meta.lo fatfs_dent.lo ntfs.lo ntfs_dent.lo \ swapfs.lo rawfs.lo iso9660.lo iso9660_dent.lo hfs.lo \ hfs_dent.lo hfs_journal.lo hfs_unicompare.lo dcalc_lib.lo \ dcat_lib.lo dls_lib.lo dstat_lib.lo ffind_lib.lo fls_lib.lo \ icat_lib.lo ifind_lib.lo ils_lib.lo libtskfs_la_OBJECTS = $(am_libtskfs_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskfs_la_SOURCES) DIST_SOURCES = $(libtskfs_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskfs.la # Note that the .h files are in the top-level Makefile libtskfs_la_SOURCES = tsk_fs_i.h fs_inode.c fs_io.c fs_block.c fs_open.c \ fs_name.c fs_dir.c fs_types.c fs_attr.c fs_attrlist.c fs_load.c \ fs_parse.c fs_file.c \ unix_misc.c nofs_misc.c \ ffs.c ffs_dent.c ext2fs.c ext2fs_dent.c ext2fs_journal.c \ fatfs.c fatfs_meta.c fatfs_dent.c ntfs.c ntfs_dent.c swapfs.c rawfs.c \ iso9660.c iso9660_dent.c \ hfs.c hfs_dent.c hfs_journal.c hfs_unicompare.c \ dcalc_lib.c dcat_lib.c dls_lib.c dstat_lib.c ffind_lib.c \ fls_lib.c icat_lib.c ifind_lib.c ils_lib.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/fs/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/fs/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskfs.la: $(libtskfs_la_OBJECTS) $(libtskfs_la_DEPENDENCIES) $(LINK) $(libtskfs_la_OBJECTS) $(libtskfs_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dcalc_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dcat_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dls_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dstat_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext2fs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext2fs_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext2fs_journal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatfs_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatfs_meta.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffind_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffs_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fls_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_attr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_attrlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_block.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_dir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_inode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_load.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_name.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_parse.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs_types.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfs_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfs_journal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfs_unicompare.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icat_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifind_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ils_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iso9660.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iso9660_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nofs_misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs_dent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rawfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swapfs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix_misc.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ # 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: sleuthkit-3.2.3/tsk3/fs/nofs_misc.c000644 000765 000024 00000015164 11643647440 017765 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2004-2005 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ #include "tsk_fs_i.h" /** *\file nofs_misc.c * Contains internal functions that are common to the "non-file system" file systems, such as * raw and swap. Many of the functions in this file simply give an error that the functionality * is not supported for the given file system type. */ /** \internal * Print details about the file system to a file handle. * * @param a_fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ uint8_t tsk_fs_nofs_fsstat(TSK_FS_INFO * a_fs, FILE * hFile) { tsk_fprintf(hFile, "%s Data\n", tsk_fs_type_toname(a_fs->ftype)); tsk_fprintf(hFile, "Block Size: %d\n", a_fs->block_size); tsk_fprintf(hFile, "Block Range: 0 - %" PRIuDADDR "\n", a_fs->last_block); return 0; } /** \internal */ TSK_FS_ATTR_TYPE_ENUM tsk_fs_nofs_get_default_attr_type(const TSK_FS_FILE * a_fs_file) { return TSK_FS_ATTR_TYPE_DEFAULT; } /** \internal */ uint8_t tsk_fs_nofs_make_data_run(TSK_FS_FILE * a_fs_file) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", (a_fs_file->fs_info) ? tsk_fs_type_toname(a_fs_file->fs_info-> ftype) : ""); return 1; } /** \internal */ void tsk_fs_nofs_close(TSK_FS_INFO * a_fs) { a_fs->tag = 0; free(a_fs); } /************* BLOCKS *************/ /** \internal */ TSK_FS_BLOCK_FLAG_ENUM tsk_fs_nofs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { return TSK_FS_BLOCK_FLAG_ALLOC | TSK_FS_BLOCK_FLAG_CONT; } /** \internal * * return 1 on error and 0 on success */ uint8_t tsk_fs_nofs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr) { TSK_FS_BLOCK *fs_block; TSK_DADDR_T addr; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (a_start_blk < fs->first_block || a_start_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nofs_block_walk: Start block number: %" PRIuDADDR, a_start_blk); return 1; } if (a_end_blk < fs->first_block || a_end_blk > fs->last_block || a_end_blk < a_start_blk) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "nofs_block_walk: Last block number: %" PRIuDADDR, a_end_blk); return 1; } /* Sanity check on a_flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } /* All swap has is allocated blocks... exit if not wanted */ if (!(a_flags & TSK_FS_BLOCK_FLAG_ALLOC)) { return 0; } if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } for (addr = a_start_blk; addr <= a_end_blk; addr++) { int retval; if (tsk_fs_block_get(fs, fs_block, addr) == NULL) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "nofs_block_walk: Block %" PRIuDADDR, addr); tsk_fs_block_free(fs_block); return 1; } retval = a_action(fs_block, a_ptr); if (retval == TSK_WALK_STOP) { break; } else if (retval == TSK_WALK_ERROR) { tsk_fs_block_free(fs_block); return 1; } } /* * Cleanup. */ tsk_fs_block_free(fs_block); return 0; } /************ META / FILES ************/ /** \internal */ uint8_t tsk_fs_nofs_inode_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_start_inum, TSK_INUM_T a_end_inum, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_action, void *a_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } /** \internal */ uint8_t tsk_fs_nofs_file_add_meta(TSK_FS_INFO * a_fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } /** \internal */ uint8_t tsk_fs_nofs_istat(TSK_FS_INFO * a_fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } /************ DIR **************/ /** \internal */ TSK_RETVAL_ENUM tsk_fs_nofs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return TSK_ERR; } /******** JOURNAL **********/ /** \internal */ uint8_t tsk_fs_nofs_jopen(TSK_FS_INFO * a_fs, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } /** \internal */ uint8_t tsk_fs_nofs_jentry_walk(TSK_FS_INFO * a_fs, int a_flags, TSK_FS_JENTRY_WALK_CB a_action, void *a_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } /** \internal */ uint8_t tsk_fs_nofs_jblk_walk(TSK_FS_INFO * a_fs, TSK_INUM_T start, TSK_INUM_T end, int a_flags, TSK_FS_JBLK_WALK_CB a_action, void *a_ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", tsk_fs_type_toname(a_fs->ftype)); return 1; } int tsk_fs_nofs_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { return strcmp(s1, s2); } sleuthkit-3.2.3/tsk3/fs/ntfs.c000644 000765 000024 00000510372 11643647440 016760 0ustar00carrierstaff000000 000000 /* ** ntfs ** The Sleuth Kit ** ** Content and meta data layer support for the NTFS file system ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2010 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 ** ** Unicode added with support from I.D.E.A.L. Technology Corp (Aug '05) ** */ #include "tsk_fs_i.h" #include "tsk_ntfs.h" #include /** * \file ntfs.c * Contains the TSK internal general NTFS processing code */ /* * NOTES TO SELF: * * - multiple ".." entries may exist */ /* * How are we to handle the META flag? Is the MFT $Data Attribute META? */ /* mini-design note: * The MFT has entries for every file and dir in the fs. * The first entry ($MFT) is for the MFT itself and it is used to find * the location of the entire table because it can become fragmented. * Therefore, the $Data attribute of $MFT is saved in the NTFS_INFO * structure for easy access. We also use the size of the MFT as * a way to calculate the maximum MFT entry number (last_inum). * * Ok, that is simple, but getting the full $Data attribute can be tough * because $MFT may not fit into one MFT entry (i.e. an attribute list). * We need to process the attribute list attribute to find out which * other entries to process. But, the attribute list attribute comes * before any $Data attribute (so it could refer to an MFT that has not * yet been 'defined'). Although, the $Data attribute seems to always * exist and define at least the run for the entry in the attribute list. * * So, the way this is solved is that generic mft_lookup is used to get * any MFT entry, even $MFT. If $MFT is not cached then we calculate * the address of where to read based on mutliplication and guessing. * When we are loading the $MFT, we set 'loading_the_MFT' to 1 so * that we can update things as we go along. When we read $MFT we * read all the attributes and save info about the $Data one. If * there is an attribute list, we will have the location of the * additional MFT in the cached $Data location, which will be * updated as we process the attribute list. After each MFT * entry that we process while loading the MFT, the 'final_inum' * value is updated to reflect what we can currently load so * that the sanity checks still work. */ /********************************************************************** * * MISC FUNCS * **********************************************************************/ /* convert the NT Time (UTC hundred nanoseconds from 1/1/1601) * to UNIX (UTC seconds from 1/1/1970) * * The basic calculation is to remove the nanoseconds and then * subtract the number of seconds between 1601 and 1970 * i.e. TIME - DELTA * */ uint32_t nt2unixtime(uint64_t ntdate) { // (369*365 + 89) * 24 * 3600 * 10000000 #define NSEC_BTWN_1601_1970 (uint64_t)(116444736000000000ULL) ntdate -= (uint64_t) NSEC_BTWN_1601_1970; ntdate /= (uint64_t) 10000000; return (uint32_t) ntdate; } /* convert the NT Time (UTC hundred nanoseconds from 1/1/1601) * to only the nanoseconds * */ uint32_t nt2nano(uint64_t ntdate) { return (uint32_t) (ntdate % 10000000); } /********************************************************************** * * Lookup Functions * **********************************************************************/ /** * Read an MFT entry and save it in raw form in the given buffer. * NOTE: This will remove the update sequence integrity checks in the * structure. * * @param a_ntfs File system to read from * @param a_mft Buffer to save raw data to * @param a_mftnum Address of MFT entry to read * * @returns Error value */ static TSK_RETVAL_ENUM ntfs_dinode_lookup(NTFS_INFO * a_ntfs, ntfs_mft * a_mft, TSK_INUM_T a_mftnum) { TSK_OFF_T mftaddr_b, mftaddr2_b, offset; size_t mftaddr_len = 0; int i; TSK_FS_INFO *fs = (TSK_FS_INFO *) & a_ntfs->fs_info; TSK_FS_ATTR_RUN *data_run; ntfs_upd *upd; uint16_t sig_seq; /* sanity checks */ if (!a_mft) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "mft_lookup: null mft buffer"); return TSK_ERR; } if (a_mftnum < fs->first_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "mft_lookup: inode number is too small (%" PRIuINUM ")", a_mftnum); return TSK_ERR; } /* Because this code reads teh actual MFT, we need to make sure we * decrement the last_inum because the last value is a special value * for the ORPHANS directory */ if (a_mftnum > fs->last_inum - 1) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "mft_lookup: inode number is too large (%" PRIuINUM ")", a_mftnum); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dinode_lookup: Processing MFT %" PRIuINUM "\n", a_mftnum); /* If mft_data (the cached $Data attribute of $MFT) is not there yet, * then we have not started to load $MFT yet. In that case, we will * 'cheat' and calculate where it goes. This should only be for * $MFT itself, in which case the calculation is easy */ if (!a_ntfs->mft_data) { /* This is just a random check with the assumption being that * we don't want to just do a guess calculation for a very large * MFT entry */ if (a_mftnum > NTFS_LAST_DEFAULT_INO) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error trying to load a high MFT entry when the MFT itself has not been loaded (%" PRIuINUM ")", a_mftnum); return TSK_ERR; } mftaddr_b = a_ntfs->root_mft_addr + a_mftnum * a_ntfs->mft_rsize_b; mftaddr2_b = 0; } else { /* The MFT may not be in consecutive clusters, so we need to use its * data attribute run list to find out what address to read * * This is why we cached it */ // will be set to the address of the MFT entry mftaddr_b = mftaddr2_b = 0; /* The byte offset within the $Data stream */ offset = a_mftnum * a_ntfs->mft_rsize_b; /* NOTE: data_run values are in clusters * * cycle through the runs in $Data and identify which * has the MFT entry that we want */ for (data_run = a_ntfs->mft_data->nrd.run; data_run != NULL; data_run = data_run->next) { /* The length of this specific run */ TSK_OFF_T run_len = data_run->len * a_ntfs->csize_b; /* Is our MFT entry is in this run somewhere ? */ if (offset < run_len) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dinode_lookup: Found in offset: %" PRIuDADDR " size: %" PRIuDADDR " at offset: %" PRIuOFF "\n", data_run->addr, data_run->len, offset); /* special case where the MFT entry crosses * a run (only happens when cluster size is 512-bytes * and there are an odd number of clusters in the run) */ if (run_len < offset + a_ntfs->mft_rsize_b) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dinode_lookup: Entry crosses run border\n"); if (data_run->next == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "mft_lookup: MFT entry crosses a cluster and there are no more clusters!"); return TSK_COR; } /* Assign address where the remainder of the entry is */ mftaddr2_b = data_run->next->addr * a_ntfs->csize_b; /* this should always be 512, but just in case */ mftaddr_len = (size_t) (run_len - offset); } /* Assign address of where the MFT entry starts */ mftaddr_b = data_run->addr * a_ntfs->csize_b + offset; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dinode_lookup: Entry address at: %" PRIuOFF "\n", mftaddr_b); break; } /* decrement the offset we are looking for */ offset -= run_len; } /* Did we find it? */ if (!mftaddr_b) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "mft_lookup: Error finding MFT entry %" PRIuINUM " in $MFT", a_mftnum); return TSK_ERR; } } /* can we do just one read or do we need multiple? */ if (mftaddr2_b) { ssize_t cnt; /* read the first part into mft */ cnt = tsk_fs_read(&a_ntfs->fs_info, mftaddr_b, (char *) a_mft, mftaddr_len); if (cnt != mftaddr_len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_dinode_lookup: Error reading MFT Entry (part 1) at %" PRIuOFF, mftaddr_b); return TSK_ERR; } /* read the second part into mft */ cnt = tsk_fs_read (&a_ntfs->fs_info, mftaddr2_b, (char *) ((uintptr_t) a_mft + (uintptr_t) mftaddr_len), a_ntfs->mft_rsize_b - mftaddr_len); if (cnt != a_ntfs->mft_rsize_b - mftaddr_len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_dinode_lookup: Error reading MFT Entry (part 2) at %" PRIuOFF, mftaddr2_b); return TSK_ERR; } } else { ssize_t cnt; /* read the raw entry into mft */ cnt = tsk_fs_read(&a_ntfs->fs_info, mftaddr_b, (char *) a_mft, a_ntfs->mft_rsize_b); if (cnt != a_ntfs->mft_rsize_b) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_dinode_lookup: Error reading MFT Entry at %" PRIuOFF, mftaddr_b); return TSK_ERR; } } /* if we are saving into the NTFS_INFO structure, assign mnum too */ if ((uintptr_t) a_mft == (uintptr_t) a_ntfs->mft) a_ntfs->mnum = a_mftnum; /* Sanity Check */ #if 0 /* This is no longer applied because it caused too many problems * with images that had 0 and 1 etc. as values. Testing shows that * even Windows XP doesn't care if entries have an invalid entry, so * this is no longer checked. The update sequence check should find * corrupt entries * */ if ((tsk_getu32(fs->endian, mft->magic) != NTFS_MFT_MAGIC) && (tsk_getu32(fs->endian, mft->magic) != NTFS_MFT_MAGIC_BAAD) && (tsk_getu32(fs->endian, mft->magic) != NTFS_MFT_MAGIC_ZERO)) { tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "entry %d has an invalid MFT magic: %x", mftnum, tsk_getu32(fs->endian, mft->magic)); return 1; } #endif /* The MFT entries have error and integrity checks in them * called update sequences. They must be checked and removed * so that later functions can process the data as normal. * They are located in the last 2 bytes of each 512-byte sector * * We first verify that the the 2-byte value is a give value and * then replace it with what should be there */ /* sanity check so we don't run over in the next loop */ if ((tsk_getu16(fs->endian, a_mft->upd_cnt) > 0) && (((uint32_t) (tsk_getu16(fs->endian, a_mft->upd_cnt) - 1) * a_ntfs->ssize_b) > a_ntfs->mft_rsize_b)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "dinode_lookup: More Update Sequence Entries than MFT size"); return TSK_COR; } if (tsk_getu16(fs->endian, a_mft->upd_off) > a_ntfs->mft_rsize_b) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "dinode_lookup: Update sequence offset larger than MFT size"); return TSK_COR; } /* Apply the update sequence structure template */ upd = (ntfs_upd *) ((uintptr_t) a_mft + tsk_getu16(fs->endian, a_mft->upd_off)); /* Get the sequence value that each 16-bit value should be */ sig_seq = tsk_getu16(fs->endian, upd->upd_val); /* cycle through each sector */ for (i = 1; i < tsk_getu16(fs->endian, a_mft->upd_cnt); i++) { uint8_t *new_val, *old_val; /* The offset into the buffer of the value to analyze */ size_t offset = i * a_ntfs->ssize_b - 2; /* get the current sequence value */ uint16_t cur_seq = tsk_getu16(fs->endian, (uintptr_t) a_mft + offset); if (cur_seq != sig_seq) { /* get the replacement value */ uint16_t cur_repl = tsk_getu16(fs->endian, &upd->upd_seq + (i - 1) * 2); tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "Incorrect update sequence value in MFT entry\nSignature Value: 0x%" PRIx16 " Actual Value: 0x%" PRIx16 " Replacement Value: 0x%" PRIx16 "\nThis is typically because of a corrupted entry", sig_seq, cur_seq, cur_repl); return TSK_COR; } new_val = &upd->upd_seq + (i - 1) * 2; old_val = (uint8_t *) ((uintptr_t) a_mft + offset); /* if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dinode_lookup: upd_seq %i Replacing: %.4" PRIx16 " With: %.4" PRIx16 "\n", i, tsk_getu16(fs->endian, old_val), tsk_getu16(fs->endian, new_val)); */ *old_val++ = *new_val++; *old_val = *new_val; } return TSK_OK; } /* * given a cluster, return the allocation status or * -1 if an error occurs */ static int is_clustalloc(NTFS_INFO * ntfs, TSK_DADDR_T addr) { int bits_p_clust, b; TSK_DADDR_T base; bits_p_clust = 8 * ntfs->fs_info.block_size; /* While we are loading the MFT, assume that everything * is allocated. This should only be needed when we are * dealing with an attribute list ... */ if (ntfs->loading_the_MFT == 1) { return 1; } else if (ntfs->bmap == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "is_clustalloc: Bitmap pointer is null: %" PRIuDADDR "\n", addr); return -1; } /* Is the cluster too big? */ if (addr > ntfs->fs_info.last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "is_clustalloc: cluster too large"); return -1; } /* identify the base cluster in the bitmap file */ base = addr / bits_p_clust; b = (int) (addr % bits_p_clust); /* is this the same as in the cached buffer? */ if (base != ntfs->bmap_buf_off) { TSK_DADDR_T c = base; TSK_FS_ATTR_RUN *run; TSK_DADDR_T fsaddr = 0; ssize_t cnt; /* get the file system address of the bitmap cluster */ for (run = ntfs->bmap; run; run = run->next) { if (run->len <= c) { c -= run->len; } else { fsaddr = run->addr + c; break; } } if (fsaddr == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "is_clustalloc: cluster not found in bitmap: %" PRIuDADDR "", c); return -1; } if (fsaddr > ntfs->fs_info.last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "is_clustalloc: Cluster in bitmap too large for image: %" PRIuDADDR, fsaddr); return -1; } ntfs->bmap_buf_off = base; cnt = tsk_fs_read_block (&ntfs->fs_info, fsaddr, ntfs->bmap_buf, ntfs->fs_info.block_size); if (cnt != ntfs->fs_info.block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "is_clustalloc: Error reading bitmap at %" PRIuDADDR, fsaddr); return -1; } } /* identify if the cluster is allocated or not */ return (isset(ntfs->bmap_buf, b)) ? 1 : 0; } /********************************************************************** * * TSK_FS_ATTR functions * **********************************************************************/ /** * Process a non-resident runlist and convert its contents into the generic fs_attr_run * structure. * @param ntfs File system that attribute is located in. * @param start_vcn The starting VCN for this run. * @param runlist The raw runlist data from the MFT entry. * @param a_data_run_head [out] Pointer to pointer of run that is created. (NULL on error and for $BadClust - special case because it is a sparse file for the entire FS). * @param totlen [out] Pointer to location where total length of run (in bytes) can be returned (or NULL) * * @returns Return status of error, corrupt, or OK (note a_data_run can be NULL even when OK is returned if $BadClust is encountered) */ static TSK_RETVAL_ENUM ntfs_make_data_run(NTFS_INFO * ntfs, TSK_OFF_T start_vcn, ntfs_runlist * runlist_head, TSK_FS_ATTR_RUN ** a_data_run_head, TSK_OFF_T * totlen) { TSK_FS_INFO *fs = (TSK_FS_INFO *) ntfs; ntfs_runlist *run; TSK_FS_ATTR_RUN *data_run, *data_run_prev = NULL; unsigned int i, idx; TSK_DADDR_T prev_addr = 0; TSK_OFF_T file_offset = start_vcn; run = runlist_head; *a_data_run_head = NULL; /* initialize if non-NULL */ if (totlen) *totlen = 0; /* Cycle through each run in the runlist * We go until we find an entry with no length * An entry with offset of 0 is for a sparse run */ while (NTFS_RUNL_LENSZ(run) != 0) { int64_t addr_offset = 0; /* allocate a new tsk_fs_attr_run */ if ((data_run = tsk_fs_attr_run_alloc()) == NULL) { tsk_fs_attr_run_free(*a_data_run_head); *a_data_run_head = NULL; return TSK_ERR; } /* make the list, unless its the first pass & then we set the head */ if (data_run_prev) data_run_prev->next = data_run; else *a_data_run_head = data_run; data_run_prev = data_run; /* These fields are a variable number of bytes long * these for loops are the equivalent of the getuX macros */ idx = 0; /* Get the length of this run */ for (i = 0, data_run->len = 0; i < NTFS_RUNL_LENSZ(run); i++) { data_run->len |= (run->buf[idx++] << (i * 8)); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_make_data_run: Len idx: %i cur: %" PRIu8 " (%" PRIx8 ") tot: %" PRIuDADDR " (%" PRIxDADDR ")\n", i, run->buf[idx - 1], run->buf[idx - 1], data_run->len, data_run->len); } /* Sanity check on length */ if (data_run->len > fs->block_count) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_make_run: Run length is larger than file system"); tsk_fs_attr_run_free(*a_data_run_head); *a_data_run_head = NULL; return TSK_COR; } data_run->offset = file_offset; file_offset += data_run->len; /* Update the length if we were passed a value */ if (totlen) *totlen += (data_run->len * ntfs->csize_b); /* Get the address of this run */ for (i = 0, data_run->addr = 0; i < NTFS_RUNL_OFFSZ(run); i++) { //data_run->addr |= (run->buf[idx++] << (i * 8)); addr_offset |= (run->buf[idx++] << (i * 8)); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_make_data_run: Off idx: %i cur: %" PRIu8 " (%" PRIx8 ") tot: %" PRIuDADDR " (%" PRIxDADDR ")\n", i, run->buf[idx - 1], run->buf[idx - 1], addr_offset, addr_offset); } /* addr_offset value is signed so extend it to 64-bits */ if ((int8_t) run->buf[idx - 1] < 0) { for (; i < sizeof(addr_offset); i++) addr_offset |= (int64_t) ((int64_t) 0xff << (i * 8)); } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_make_data_run: Signed addr_offset: %" PRIdDADDR " Previous address: %" PRIdDADDR "\n", addr_offset, prev_addr); /* The NT 4.0 version of NTFS uses an offset of -1 to represent * a hole, so add the sparse flag and make it look like the 2K * version with a offset of 0 * * A user reported an issue where the $Bad file started with * its offset as -1 and it was not NT (maybe a conversion) * Change the check now to not limit to NT, but make sure * that it is the first run */ if (((addr_offset == -1) && (prev_addr == 0)) || ((addr_offset == -1) && (ntfs->ver == NTFS_VINFO_NT))) { data_run->flags |= TSK_FS_ATTR_RUN_FLAG_SPARSE; data_run->addr = 0; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_make_data_run: Sparse Run\n"); } /* A Sparse file has a run with an offset of 0 * there is a special case though of the BOOT MFT entry which * is the super block and has a legit offset of 0. * * The value given is a delta of the previous offset, so add * them for non-sparse files * * For sparse files the next run will have its offset relative * to the current "prev_addr" so skip that code */ else if ((addr_offset) || (ntfs->mnum == NTFS_MFT_BOOT)) { data_run->addr = prev_addr + addr_offset; prev_addr = data_run->addr; /* Sanity check on length and offset */ if (data_run->addr + data_run->len > fs->block_count) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_make_run: Run offset and length is larger than file system"); tsk_fs_attr_run_free(*a_data_run_head); *a_data_run_head = NULL; return TSK_COR; } } else { data_run->flags |= TSK_FS_ATTR_RUN_FLAG_SPARSE; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_make_data_run: Sparse Run\n"); } /* Advance run */ run = (ntfs_runlist *) ((uintptr_t) run + (1 + NTFS_RUNL_LENSZ(run) + NTFS_RUNL_OFFSZ(run))); } /* special case for $BADCLUST, which is a sparse file whose size is * the entire file system. * * If there is only one run entry and it is sparse, then there are no * bad blocks, so get rid of it. */ if ((*a_data_run_head != NULL) && ((*a_data_run_head)->next == NULL) && ((*a_data_run_head)->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) && ((*a_data_run_head)->len == fs->last_block + 1)) { tsk_fs_attr_run_free(*a_data_run_head); *a_data_run_head = NULL; } return TSK_OK; } /*********** UNCOMPRESSION CODE *************/ /* * NTFS Breaks compressed data into compression units, which are * typically 16 clusters in size. If the data in the comp unit * compresses to something smaller than 16 clusters then the * compresed data is stored and the rest of the compression unit * is filled with sparse clusters. The entire compression unit * can also be sparse. * * When the data is compressed, it is broken up into 4k blocks. Each * of the blocks is compressed and the resulting data is stored with * a 2-byte header that identifies the compressed size. The * compressed data contains token groups, which contain a 1 byte * header followed by 8 variable length tokens. There are two types * of tokens. Symbol tokens are 1 byte in length and the 1byte value * should be directly copied into the uncompressed data. Phrase tokens * identify a run of data in the same compression unit that should be * copied to the current location. Each bit in the 1-byte header identifies * the type of the 8 tokens in the group. * */ /* Variables used for ntfs_uncompress() method */ typedef struct { char *uncomp_buf; // Buffer for uncompressed data char *comp_buf; // buffer for compressed data size_t comp_len; // number of bytes used in compressed data size_t uncomp_idx; // Index into buffer for next byte size_t buf_size_b; // size of buffer in bytes (1 compression unit) } NTFS_COMP_INFO; /** * Reset the values in the NTFS_COMP_INFO structure. We need to * do this in between every compression unit that we process in the file. * * @param comp Structure to reset */ static void ntfs_uncompress_reset(NTFS_COMP_INFO * comp) { memset(comp->uncomp_buf, 0, comp->buf_size_b); comp->uncomp_idx = 0; memset(comp->comp_buf, 0, comp->buf_size_b); comp->comp_len = 0; } /** * Setup the NTFS_COMP_INFO structure with a buffer and * initialize the basic settings. * * @param fs File system state information * @param comp Compression state information to initialize * @param compunit_size_c The size (in clusters) of a compression * unit * @return 1 on error and 0 on success */ static int ntfs_uncompress_setup(TSK_FS_INFO * fs, NTFS_COMP_INFO * comp, uint32_t compunit_size_c) { comp->buf_size_b = fs->block_size * compunit_size_c; if ((comp->uncomp_buf = tsk_malloc(comp->buf_size_b)) == NULL) { comp->buf_size_b = 0; return 1; } if ((comp->comp_buf = tsk_malloc(comp->buf_size_b)) == NULL) { comp->buf_size_b = 0; return 1; } ntfs_uncompress_reset(comp); return 0; } static void ntfs_uncompress_done(NTFS_COMP_INFO * comp) { if (comp->uncomp_buf) free(comp->uncomp_buf); comp->uncomp_buf = NULL; if (comp->comp_buf) free(comp->comp_buf); comp->comp_buf = NULL; comp->buf_size_b = 0; } /** * Uncompress the block of data in comp->comp_buf, * which has a size of comp->comp_len. * Store the result in the comp->uncomp_buf. * * @param comp Compression unit structure * * @returns 1 on error and 0 on success */ static uint8_t ntfs_uncompress_compunit(NTFS_COMP_INFO * comp) { size_t cl_index; tsk_error_reset(); comp->uncomp_idx = 0; /* Cycle through the compressed data * We maintain state using different levels of loops. * We use +1 here because the size value at start of block is 2 bytes. */ for (cl_index = 0; cl_index + 1 < comp->comp_len;) { size_t blk_end; // index into the buffer to where block ends size_t blk_size; // size of the current block uint8_t iscomp; // set to 1 if block is compressed size_t blk_st_uncomp; // index into uncompressed buffer where block started /* The first two bytes of each block contain the size * information.*/ blk_size = ((((unsigned char) comp->comp_buf[cl_index + 1] << 8) | ((unsigned char) comp->comp_buf[cl_index])) & 0x0FFF) + 3; // this seems to indicate end of block if (blk_size == 3) break; blk_end = cl_index + blk_size; if (blk_end > comp->comp_len) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Block length longer than buffer length: %" PRIuSIZE "", blk_end); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_uncompress_compunit: Block size is %" PRIuSIZE "\n", blk_size); /* The MSB identifies if the block is compressed */ if ((comp->comp_buf[cl_index + 1] & 0x8000) == 0) iscomp = 0; else iscomp = 1; // keep track of where this block started in the buffer blk_st_uncomp = comp->uncomp_idx; cl_index += 2; // the 4096 size seems to occur at the same times as no compression if ((iscomp) || (blk_size - 2 != 4096)) { // cycle through the block while (cl_index < blk_end) { int a; // get the header header unsigned char header = comp->comp_buf[cl_index]; cl_index++; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_uncompress_compunit: New Tag: %x\n", header); for (a = 0; a < 8 && cl_index < blk_end; a++) { /* Determine token type and parse appropriately. * * Symbol tokens are the symbol themselves, so copy it * into the umcompressed buffer */ if ((header & NTFS_TOKEN_MASK) == NTFS_SYMBOL_TOKEN) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_uncompress_compunit: Symbol Token: %" PRIuSIZE "\n", cl_index); if (comp->uncomp_idx >= comp->buf_size_b) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Trying to write past end of uncompression buffer: %" PRIuSIZE "", comp->uncomp_idx); return 1; } comp->uncomp_buf[comp->uncomp_idx++] = comp->comp_buf[cl_index]; cl_index++; } /* Otherwise, it is a phrase token, which points back * to a previous sequence of bytes. */ else { size_t i; int shift; size_t start_position_index = 0; size_t end_position_index = 0; unsigned int offset = 0; unsigned int length = 0; uint16_t pheader; if (cl_index + 1 >= blk_end) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Phrase token index is past end of block: %d", a); return 1; } pheader = ((((comp->comp_buf[cl_index + 1]) << 8) & 0xFF00) | (comp->comp_buf[cl_index] & 0xFF)); cl_index += 2; /* The number of bits for the start and length * in the 2-byte header change depending on the * location in the compression unit. This identifies * how many bits each has */ shift = 0; for (i = comp->uncomp_idx - blk_st_uncomp - 1; i >= 0x10; i >>= 1) { shift++; } //tsk_fprintf(stderr, "Start: %X Shift: %d UnComp_IDX %d BlkStart: %lu BlkIdx: %d BlkSize: %d\n", (int)(comp->uncomp_idx - comp->blk_st - 1), shift, comp->uncomp_idx, comp->blk_st, comp->blk_idx, comp->blk_size); offset = (pheader >> (12 - shift)) + 1; length = (pheader & (0xFFF >> shift)) + 2; start_position_index = comp->uncomp_idx - offset; end_position_index = start_position_index + length; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_uncompress_compunit: Phrase Token: %" PRIuSIZE "\t%d\t%d\t%x\n", cl_index, length, offset, pheader); /* Sanity checks on values */ if (offset > comp->uncomp_idx) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Phrase token offset is too large: %d (max: %" PRIuSIZE ")", offset, comp->uncomp_idx); return 1; } else if (length + start_position_index > comp->buf_size_b) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Phrase token length is too large: %d (max: %zu)", length, comp->buf_size_b - start_position_index); return 1; } else if (end_position_index - start_position_index + 1 > comp->buf_size_b - comp->uncomp_idx) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Phrase token length is too large for rest of uncomp buf: %zu (max: %" PRIuSIZE ")", end_position_index - start_position_index + 1, comp->buf_size_b - comp->uncomp_idx); return 1; } for (; start_position_index <= end_position_index && comp->uncomp_idx < comp->buf_size_b; start_position_index++) { // Copy the previous data to the current position comp->uncomp_buf[comp->uncomp_idx++] = comp->uncomp_buf[start_position_index]; } } header >>= 1; } // end of loop inside of token group } // end of loop inside of block } // this block contains uncompressed data uncompressed data else { while (cl_index < blk_end && cl_index < comp->comp_len) { /* This seems to happen only with corrupt data -- such as * when an unallocated file is being processed... */ if (comp->uncomp_idx >= comp->buf_size_b) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_uncompress_compunit: Trying to write past end of uncompression buffer (1) -- corrupt data?)"); return 1; } // Place data in uncompression_buffer comp->uncomp_buf[comp->uncomp_idx++] = comp->comp_buf[cl_index++]; } } } // end of loop inside of compression unit return 0; } /** * Process a compression unit and return the decompressed data in a buffer in comp. * * @param ntfs File system * @param comp Compression state info (output will be stored in here) * @param comp_unit List of addresses that store compressed data * @param comp_unit_size Number of addresses in comp_unit * @returns 1 on error and 0 on success */ static uint8_t ntfs_proc_compunit(NTFS_INFO * ntfs, NTFS_COMP_INFO * comp, TSK_DADDR_T * comp_unit, uint32_t comp_unit_size) { TSK_FS_INFO *fs = (TSK_FS_INFO *) ntfs; int sparse; uint64_t a; /* With compressed attributes, there are three scenarios. * 1: The compression unit is not compressed, * 2: The compression unit is sparse * 3: The compression unit is compressed */ /* Check if the entire compression unit is sparse */ sparse = 1; for (a = 0; a < comp_unit_size && sparse == 1; a++) { if (comp_unit[a]) { sparse = 0; break; } } /* Entire comp unit is sparse... */ if (sparse) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_compunit: Unit is fully sparse\n"); memset(comp->uncomp_buf, 0, comp->buf_size_b); comp->uncomp_idx = comp->buf_size_b; } /* Check if the end of the unit is sparse, which means the * unit is compressed */ else if (comp_unit[comp_unit_size - 1] == 0) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_compunit: Unit is compressed\n"); // load up the compressed buffer so we can decompress it ntfs_uncompress_reset(comp); for (a = 0; a < comp_unit_size; a++) { ssize_t cnt; if (comp_unit[a] == 0) break; /* To get the uncompressed size, we must uncompress the * data -- even if addresses are only needed */ cnt = tsk_fs_read_block(fs, comp_unit[a], &comp->comp_buf[comp->comp_len], fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_proc_compunit: Error reading block at %" PRIuDADDR, comp_unit[a]); return 1; } comp->comp_len += fs->block_size; } if (ntfs_uncompress_compunit(comp)) { return 1; } } /* Uncompressed data */ else { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_compunit: Unit is not compressed\n"); comp->uncomp_idx = 0; for (a = 0; a < comp_unit_size; a++) { ssize_t cnt; cnt = tsk_fs_read_block(fs, comp_unit[a], &comp->uncomp_buf[comp->uncomp_idx], fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_proc_compunit: Error reading block at %" PRIuDADDR, comp_unit[a]); return 1; } comp->uncomp_idx += fs->block_size; } } return 0; } /** * Currently ignores the SPARSE flag */ uint8_t ntfs_attr_walk_special(const TSK_FS_ATTR * fs_attr, int flags, TSK_FS_FILE_WALK_CB a_action, void *ptr) { TSK_FS_INFO *fs; NTFS_INFO *ntfs; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_attr == NULL) || (fs_attr->fs_file == NULL) || (fs_attr->fs_file->meta == NULL) || (fs_attr->fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_attr_walk_special: Null arguments given\n"); return 1; } fs = fs_attr->fs_file->fs_info; ntfs = (NTFS_INFO *) fs; /* Process the compressed buffer * * The compsize value equal to 0 can occur if we are processing an * isolated entry that is part of an attribute list. The first * sequence of the attribute has the compsize and the latter ones * do not. So, if one of the non-base MFT entries is processed by * itself, we have that case. I tried to assume it was 16, but it * caused decompression problems -- likely because this sequence * did not start on a compression unit boundary. So, now we just * dump the compressed data instead of giving an error. */ if (fs_attr->flags & TSK_FS_ATTR_COMP) { TSK_DADDR_T addr; TSK_FS_ATTR_RUN *fs_attr_run; TSK_DADDR_T *comp_unit; uint32_t comp_unit_idx = 0; NTFS_COMP_INFO comp; TSK_OFF_T off = 0; int retval; uint8_t stop_loop = 0; if (fs_attr->nrd.compsize <= 0) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_attrwalk_special: Compressed attribute has compsize of 0"); return 1; } /* Allocate the buffers and state structure */ if (ntfs_uncompress_setup(fs, &comp, fs_attr->nrd.compsize)) { return 1; } comp_unit = (TSK_DADDR_T *) tsk_malloc(fs_attr->nrd.compsize * sizeof(TSK_DADDR_T)); if (comp_unit == NULL) { ntfs_uncompress_done(&comp); return 1; } retval = TSK_WALK_CONT; /* cycle through the number of runs we have */ for (fs_attr_run = fs_attr->nrd.run; fs_attr_run; fs_attr_run = fs_attr_run->next) { size_t len_idx; /* We may get a FILLER entry at the beginning of the run * if we are processing a non-base file record since * this $DATA attribute could not be the first sequence in the * attribute. Therefore, do not error if it starts at 0 */ if (fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) { if (fs_attr_run->addr != 0) { tsk_error_reset(); if (fs_attr->fs_file-> meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "Filler Entry exists in fs_attr_run %" PRIuDADDR "@%" PRIuDADDR " - type: %" PRIu32 " id: %d", fs_attr_run->len, fs_attr_run->addr, fs_attr->type, fs_attr->id); free(comp_unit); ntfs_uncompress_done(&comp); return 1; } else { off += (fs_attr_run->len * fs->block_size); continue; } } addr = fs_attr_run->addr; /* cycle through each cluster in the run */ for (len_idx = 0; len_idx < fs_attr_run->len; len_idx++) { if (addr > fs->last_block) { tsk_error_reset(); if (fs_attr->fs_file-> meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_BLK_NUM; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid address in run (too large): %" PRIuDADDR "", addr); free(comp_unit); ntfs_uncompress_done(&comp); return 1; } // queue up the addresses until we get a full unit comp_unit[comp_unit_idx++] = addr; // time to decompress (if queue is full or this is the last block) if ((comp_unit_idx == fs_attr->nrd.compsize) || ((len_idx == fs_attr_run->len - 1) && (fs_attr_run->next == NULL))) { size_t i; // decompress the unit if (ntfs_proc_compunit(ntfs, &comp, comp_unit, comp_unit_idx)) { free(comp_unit); ntfs_uncompress_done(&comp); return 1; } // now call the callback with the uncompressed data for (i = 0; i < comp_unit_idx; i++) { int myflags; size_t read_len; myflags = TSK_FS_BLOCK_FLAG_CONT | TSK_FS_BLOCK_FLAG_COMP; retval = is_clustalloc(ntfs, comp_unit[i]); if (retval == -1) { if (fs_attr->fs_file-> meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; free(comp_unit); ntfs_uncompress_done(&comp); return 1; } else if (retval == 1) { myflags |= TSK_FS_BLOCK_FLAG_ALLOC; } else if (retval == 0) { myflags |= TSK_FS_BLOCK_FLAG_UNALLOC; } if (fs_attr->size - off > fs->block_size) read_len = fs->block_size; else read_len = (size_t) (fs_attr->size - off); if (i * fs->block_size + read_len > comp.uncomp_idx) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_attrwalk_special: Trying to read past end of uncompressed buffer: %" PRIuSIZE " %" PRIuSIZE "", i * fs->block_size + read_len, comp.uncomp_idx); free(comp_unit); ntfs_uncompress_done(&comp); return 1; } // call the callback retval = a_action(fs_attr->fs_file, off, comp_unit[i], &comp.uncomp_buf[i * fs->block_size], read_len, myflags, ptr); off += read_len; if (off >= fs_attr->size) { stop_loop = 1; break; } if (retval != TSK_WALK_CONT) { stop_loop = 1; break; } } comp_unit_idx = 0; } if (stop_loop) break; /* If it is a sparse run, don't increment the addr so that * it remains 0 */ if (((fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) == 0) && ((fs_attr_run->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) == 0)) addr++; } if (stop_loop) break; } ntfs_uncompress_done(&comp); free(comp_unit); if (retval == TSK_WALK_ERROR) return 1; else return 0; } else { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_attrwalk_special: called with non-special attribute: %x", fs_attr->flags); return 1; } } /** \internal * * @returns number of bytes read or -1 on error (incl if offset is past EOF) */ ssize_t ntfs_file_read_special(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, char *a_buf, size_t a_len) { TSK_FS_INFO *fs = NULL; NTFS_INFO *ntfs = NULL; if ((a_fs_attr == NULL) || (a_fs_attr->fs_file == NULL) || (a_fs_attr->fs_file->meta == NULL) || (a_fs_attr->fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_read_special: NULL parameters passed"); return -1; } fs = a_fs_attr->fs_file->fs_info; ntfs = (NTFS_INFO *) fs; if (a_fs_attr->flags & TSK_FS_ATTR_COMP) { TSK_FS_ATTR_RUN *data_run_cur; TSK_OFF_T cu_blkoffset; // block offset of starting compression unit to start reading from size_t byteoffset; // byte offset in compression unit of where we want to start reading from TSK_DADDR_T *comp_unit; uint32_t comp_unit_idx = 0; NTFS_COMP_INFO comp; size_t buf_idx = 0; if (a_fs_attr->nrd.compsize <= 0) { tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_read_special: Compressed attribute has compsize of 0"); return -1; } if (a_offset >= a_fs_attr->size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ_OFF; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_read_special - %" PRIuOFF, a_offset); return -1; } // we return 0s for reads past the initsize if (a_offset >= a_fs_attr->nrd.initsize) { ssize_t len; if (tsk_verbose) fprintf(stderr, "ntfs_file_read_special: Returning 0s for read past end of initsize (%" PRIuINUM ")\n", a_fs_attr->fs_file->meta->addr); if (a_offset + a_len > a_fs_attr->nrd.allocsize) len = (ssize_t) (a_fs_attr->nrd.allocsize - a_offset); else len = (ssize_t) a_len; memset(a_buf, 0, a_len); return len; } /* Allocate the buffers and state structure */ if (ntfs_uncompress_setup(fs, &comp, a_fs_attr->nrd.compsize)) { return -1; } comp_unit = (TSK_DADDR_T *) tsk_malloc(a_fs_attr->nrd.compsize * sizeof(TSK_DADDR_T)); if (comp_unit == NULL) { ntfs_uncompress_done(&comp); return -1; } // figure out the needed offsets cu_blkoffset = a_offset / fs->block_size; if (cu_blkoffset) { cu_blkoffset /= a_fs_attr->nrd.compsize; cu_blkoffset *= a_fs_attr->nrd.compsize; } byteoffset = (size_t) (a_offset - cu_blkoffset * fs->block_size); // cycle through the run until we find where we can start to process the clusters for (data_run_cur = a_fs_attr->nrd.run; (data_run_cur) && (buf_idx < a_len); data_run_cur = data_run_cur->next) { TSK_DADDR_T addr; size_t a; // See if this run contains the starting offset they requested if (data_run_cur->offset + data_run_cur->len < (TSK_DADDR_T) cu_blkoffset) continue; // seek to the start of where we want to read (we may need to read several runs) if (data_run_cur->offset > (TSK_DADDR_T) cu_blkoffset) a = 0; else a = (size_t) (cu_blkoffset - data_run_cur->offset); addr = data_run_cur->addr; // don't increment addr if it is 0 -- sparse if (addr) addr += a; /* cycle through the relevant in the run */ for (; a < data_run_cur->len && buf_idx < a_len; a++) { // queue up the addresses until we get a full unit comp_unit[comp_unit_idx++] = addr; // time to decompress (if queue is full or this is the last block) if ((comp_unit_idx == a_fs_attr->nrd.compsize) || ((a == data_run_cur->len - 1) && (data_run_cur->next == NULL))) { size_t cpylen; // decompress the unit if (ntfs_proc_compunit(ntfs, &comp, comp_unit, comp_unit_idx)) { free(comp_unit); ntfs_uncompress_done(&comp); return -1; } // copy uncompressed data to the output buffer if (comp.uncomp_idx < byteoffset) { // @@ ERROR free(comp_unit); ntfs_uncompress_done(&comp); return -1; } else if (comp.uncomp_idx - byteoffset < a_len - buf_idx) { cpylen = comp.uncomp_idx - byteoffset; } else { cpylen = a_len - buf_idx; } // Make sure not to return more bytes than are in the file if (cpylen > (a_fs_attr->size - (a_offset + buf_idx))) cpylen = (size_t) (a_fs_attr->size - (a_offset + buf_idx)); memcpy(&a_buf[buf_idx], &comp.uncomp_buf[byteoffset], cpylen); // reset this in case we need to also read from the next run byteoffset = 0; buf_idx += cpylen; comp_unit_idx = 0; } /* If it is a sparse run, don't increment the addr so that * it remains 0 */ if (((data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) == 0) && ((data_run_cur->flags & TSK_FS_ATTR_RUN_FLAG_FILLER) == 0)) addr++; } } free(comp_unit); ntfs_uncompress_done(&comp); return (ssize_t) buf_idx; } else { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_read_special: called with non-special attribute: %x", a_fs_attr->flags); return -1; } } /* needs to be predefined for proc_attrseq */ static uint8_t ntfs_proc_attrlist(NTFS_INFO *, TSK_FS_FILE *, const TSK_FS_ATTR *); /* This structure is used when processing attrlist attributes. * The Id part of the MFTNUM-TYPE-ID triple is unique only to a given * MFTNUM. With the case of attribute lists, a file may use multiple * MFT entires and therefore have multiple attributes with the same * type and id pair (if they are in different MFT entries). This map * is created by proc_attrlist when it assigns unique IDs to the * other entries. proc_attrseq uses this when it adds the attributes. */ typedef struct { int num_used; TSK_INUM_T extMft[256]; uint32_t type[256]; uint32_t extId[256]; uint8_t name[256][512]; uint32_t newId[256]; } NTFS_ATTRLIST_MAP; /* * Process an NTFS attribute sequence and load the data into data * structures. * An attribute sequence is a linked list of the attributes in an MFT entry. * This is called by copy_inode and proc_attrlist. * * @param ntfs File system to analyze * @param fs_file Generic metadata structure to add the attribute info to * @param attrseq Start of the attribute sequence to analyze * @param len Length of the attribute sequence buffer * @param a_attrinum MFT entry address that the attribute sequence came from (diff from fs_file for attribute lists) * @param a_attr_map List that maps to new IDs that were assigned by processing * the attribute list attribute (if it exists) or NULL if there is no attrlist. * @returns Error code */ static TSK_RETVAL_ENUM ntfs_proc_attrseq(NTFS_INFO * ntfs, TSK_FS_FILE * fs_file, const ntfs_attr * a_attrseq, size_t len, TSK_INUM_T a_attrinum, const NTFS_ATTRLIST_MAP *a_attr_map) { const ntfs_attr *attr; const TSK_FS_ATTR *fs_attr_attrl = NULL; char name[NTFS_MAXNAMLEN_UTF8 + 1]; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrseq: Processing extended entry for primary entry %" PRIuINUM "\n", fs_file->meta->addr); if (fs_file->meta->attr == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Null attribute list in ntfs_proc_attrseq"); return TSK_ERR; } /* Cycle through the list of attributes */ for (attr = a_attrseq; ((uintptr_t) attr >= (uintptr_t) a_attrseq) && ((uintptr_t) attr <= ((uintptr_t) a_attrseq + len)) && (tsk_getu32(fs->endian, attr->len) > 0 && (tsk_getu32(fs->endian, attr->type) != 0xffffffff)); attr = (ntfs_attr *) ((uintptr_t) attr + tsk_getu32(fs->endian, attr->len))) { int retVal; int i; /* Get the type of this attribute */ uint32_t type = tsk_getu32(fs->endian, attr->type); uint16_t id = tsk_getu16(fs->endian, attr->id); uint16_t id_new = id; /* If the map was supplied, search through it to see if this * entry is in there. Use that ID instead so that we always have * unique IDs for each attribute -- even if it spans multiple MFT entries. */ if (a_attr_map) { for (i = 0; i < a_attr_map->num_used; i++) { if ((a_attr_map->type[i] == type) && (memcmp(a_attr_map->name[i], (void *)((uintptr_t)attr+tsk_getu16(fs->endian, attr->name_off)), attr->nlen*2) == 0)) { id_new = a_attr_map->newId[i]; break; } } } /* Copy the name and convert it to UTF8 */ if (attr->nlen) { int i; UTF8 *name8; UTF16 *name16; name8 = (UTF8 *) name; name16 = (UTF16 *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->name_off)); retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + attr->nlen * 2), &name8, (UTF8 *) ((uintptr_t) name8 + sizeof(name)), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrseq: Error converting NTFS attribute name to UTF8: %d %" PRIuINUM, retVal, fs_file->meta->addr); *name = '\0'; } /* Make sure it is NULL Terminated */ else if ((uintptr_t) name8 >= (uintptr_t) name + sizeof(name)) name[sizeof(name) - 1] = '\0'; else *name8 = '\0'; /* Clean up name */ i = 0; while (name[i] != '\0') { if (TSK_IS_CNTRL(name[i])) name[i] = '^'; i++; } } else { name[0] = '\0'; } /* For resident attributes, we will copy the buffer into * a TSK_FS_ATTR buffer, which is stored in the TSK_FS_META * structure */ if (attr->res == NTFS_MFT_RES) { TSK_FS_ATTR *fs_attr; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrseq: Resident Attribute in Type: %" PRIu32 " Id: %" PRIu16 " IdNew: %"PRIu16 " Name: %s\n", type, id, id_new, name); /* Validate the offset lengths */ if (((tsk_getu16(fs->endian, attr->c.r.soff) + (uintptr_t) attr) > ((uintptr_t) a_attrseq + len)) || ((tsk_getu16(fs->endian, attr->c.r.soff) + tsk_getu32(fs->endian, attr->c.r.ssize) + (uintptr_t) attr) > ((uintptr_t) a_attrseq + len))) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_CORRUPT; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_attr_walk: Resident attribute %" PRIuINUM "-%" PRIu32 " starting offset and length too large", fs_file->meta->addr, type); return TSK_COR; } // Get a free fs_attr structure if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_RES)) == NULL) { strncat(tsk_errstr2, " - proc_attrseq", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_ERR; } // set the details in the fs_attr structure if (tsk_fs_attr_set_str(fs_file, fs_attr, name, type, id_new, (void *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->c.r.soff)), tsk_getu32(fs->endian, attr->c.r.ssize))) { strncat(tsk_errstr2, " - proc_attrseq", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_ERR; } // set the meta size if we find the relevant attribute if ((fs_file->meta->type == TSK_FS_META_TYPE_DIR) && (type == NTFS_ATYPE_IDXROOT)) { fs_file->meta->size = tsk_getu32(fs->endian, attr->c.r.ssize); } else if ((fs_file->meta->type == TSK_FS_META_TYPE_REG) && (type == NTFS_ATYPE_DATA) && (name[0] == '\0')) { fs_file->meta->size = tsk_getu32(fs->endian, attr->c.r.ssize); } } /* For non-resident attributes, we will copy the runlist * to the generic form and then save it in the TSK_FS_META->attr * list */ else { TSK_FS_ATTR *fs_attr = NULL; TSK_FS_ATTR_RUN *fs_attr_run = NULL; uint8_t data_flag = 0; uint32_t compsize = 0; TSK_RETVAL_ENUM retval; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrseq: Non-Resident Attribute Type: %" PRIu32 " Id: %" PRIu16 " IdNew: %"PRIu16 " Name: %s Start VCN: %" PRIu64 "\n", type, id, id_new, name, tsk_getu64(fs->endian, attr->c.nr.start_vcn)); /* convert the run to generic form */ retval = ntfs_make_data_run(ntfs, tsk_getu64(fs->endian, attr->c.nr.start_vcn), (ntfs_runlist *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->c.nr.run_off)), &fs_attr_run, NULL); if (retval != TSK_OK) { strncat(tsk_errstr2, " - proc_attrseq", TSK_ERRSTR_L - strlen(tsk_errstr2)); return retval; } /* Determine the flags based on compression and stuff */ data_flag = 0; if (tsk_getu16(fs->endian, attr->flags) & NTFS_ATTR_FLAG_COMP) { data_flag |= TSK_FS_ATTR_COMP; fs_file->meta->flags |= TSK_FS_META_FLAG_COMP; } if (tsk_getu16(fs->endian, attr->flags) & NTFS_ATTR_FLAG_ENC) data_flag |= TSK_FS_ATTR_ENC; if (tsk_getu16(fs->endian, attr->flags) & NTFS_ATTR_FLAG_SPAR) data_flag |= TSK_FS_ATTR_SPARSE; /* SPECIAL CASE * We are in non-res section, so we know this * isn't $STD_INFO and $FNAME * * When we are processing a non-base entry, we may * find an attribute with an id of 0 and it is an * extention of a previous run (i.e. non-zero start VCN) * * We will lookup if we already have such an attribute * and get its ID * * We could also check for a start_vcn if this does * not fix the problem. * * NOTE: This should not be needed now that TSK assigns * unique ID values to the extended attributes. */ if (id_new == 0) { int cnt, i; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr2 = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr2) continue; /* We found an attribute with the same name and type */ if (fs_attr2->type == type) { if (((name[0] == '\0') && (fs_attr2->name == NULL)) || ((fs_attr2->name) && (strcmp(fs_attr2->name, name) == 0))) { id_new = fs_attr2->id; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrseq: Updating id from 0 to %" PRIu16 "\n", id_new); break; } } } } /* the compression unit size is stored in the header * it is stored as the power of 2 (if it is not 0) */ if (tsk_getu16(fs->endian, attr->c.nr.compusize) > 0) { compsize = 1 << (tsk_getu16(fs->endian, attr->c.nr.compusize)); } else { compsize = 0; /* if this is 0, be sure to cancel out the COMP flag. * This occurs when we process an extended attribute * that has compressed data -- the attributes in the * latter MFT entries do not have compsize set. */ if (data_flag & TSK_FS_ATTR_COMP) { if (tsk_verbose) fprintf(stderr, "ntfs_proc_attrseq: Clearing compression setting for attribute %" PRIuINUM "-%d because compsize is 0\n", fs_file->meta->addr, type); data_flag &= ~TSK_FS_ATTR_COMP; } } /* Add the run to the list */ // see if this attribute has already been partially defined // @@@ This is bad design, we are casting away the const... fs_attr = (TSK_FS_ATTR *) tsk_fs_attrlist_get_id(fs_file->meta->attr, type, id_new); if (fs_attr == NULL) { uint64_t ssize; // size uint64_t alen; // allocated length if ((fs_attr = tsk_fs_attrlist_getnew(fs_file->meta->attr, TSK_FS_ATTR_RES)) == NULL) { strncat(tsk_errstr2, " - proc_attrseq: getnew", TSK_ERRSTR_L - strlen(tsk_errstr2)); // JRB: Coverity found leak. if (fs_attr_run) tsk_fs_attr_run_free(fs_attr_run); fs_attr_run = NULL; return TSK_ERR; } ssize = tsk_getu64(fs->endian, attr->c.nr.ssize); /* This can happen with extended attributes, so * we set it based on what we currently have. * fs_attr_run can be NULL for $BadClust file. */ if ((ssize == 0) && (fs_attr_run)) { TSK_FS_ATTR_RUN *fs_attr_run_tmp; ssize = fs_attr_run->offset * fs->block_size; fs_attr_run_tmp = fs_attr_run; while (fs_attr_run_tmp) { ssize += (fs_attr_run_tmp->len * fs->block_size); fs_attr_run_tmp = fs_attr_run_tmp->next; } } // update the meta->size value if this is the default $Data attribute if ((fs_file->meta->type == TSK_FS_META_TYPE_REG) && (type == NTFS_ATYPE_DATA) && (name[0] == '\0')) { fs_file->meta->size = ssize; } alen = tsk_getu64(fs->endian, attr->c.nr.alen); /* This can also happen with extended attributes. * set it to what we know about */ if (alen == 0) { alen = ssize; } if (tsk_fs_attr_set_run(fs_file, fs_attr, fs_attr_run, name, type, id_new, ssize, tsk_getu64(fs->endian, attr->c.nr.initsize), alen, data_flag, compsize)) { strncat(tsk_errstr2, " - proc_attrseq: set run", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_ERR; } // set the special functions if (fs_file->meta->flags & TSK_FS_META_FLAG_COMP) { fs_attr->w = ntfs_attr_walk_special; fs_attr->r = ntfs_file_read_special; } } else { if (tsk_fs_attr_add_run(fs, fs_attr, fs_attr_run)) { strncat(tsk_errstr2, " - proc_attrseq: put run", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_ERR; } } } /* * Special Cases, where we grab additional information * regardless if they are resident or not */ /* Standard Information (is always resident) */ if (type == NTFS_ATYPE_SI) { ntfs_attr_si *si; if (attr->res != NTFS_MFT_RES) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "proc_attrseq: Standard Information Attribute is not resident!"); return TSK_COR; } si = (ntfs_attr_si *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->c.r.soff)); fs_file->meta->mtime = nt2unixtime(tsk_getu64(fs->endian, si->mtime)); fs_file->meta->mtime_nano = nt2nano(tsk_getu64(fs->endian, si->mtime)); fs_file->meta->atime = nt2unixtime(tsk_getu64(fs->endian, si->atime)); fs_file->meta->atime_nano = nt2nano(tsk_getu64(fs->endian, si->atime)); fs_file->meta->ctime = nt2unixtime(tsk_getu64(fs->endian, si->ctime)); fs_file->meta->ctime_nano = nt2nano(tsk_getu64(fs->endian, si->ctime)); fs_file->meta->crtime = nt2unixtime(tsk_getu64(fs->endian, si->crtime)); fs_file->meta->crtime_nano = nt2nano(tsk_getu64(fs->endian, si->crtime)); fs_file->meta->uid = tsk_getu32(fs->endian, si->own_id); fs_file->meta->mode |= (TSK_FS_META_MODE_IXUSR | TSK_FS_META_MODE_IXGRP | TSK_FS_META_MODE_IXOTH); if ((tsk_getu32(fs->endian, si->dos) & NTFS_SI_RO) == 0) fs_file->meta->mode |= (TSK_FS_META_MODE_IRUSR | TSK_FS_META_MODE_IRGRP | TSK_FS_META_MODE_IROTH); if ((tsk_getu32(fs->endian, si->dos) & NTFS_SI_HID) == 0) fs_file->meta->mode |= (TSK_FS_META_MODE_IWUSR | TSK_FS_META_MODE_IWGRP | TSK_FS_META_MODE_IWOTH); } /* File Name (always resident) */ else if (type == NTFS_ATYPE_FNAME) { ntfs_attr_fname *fname; TSK_FS_META_NAME_LIST *fs_name; UTF16 *name16; UTF8 *name8; if (attr->res != NTFS_MFT_RES) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "proc_attr_seq: File Name Attribute is not resident!"); return TSK_COR; } fname = (ntfs_attr_fname *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->c.r.soff)); if (fname->nspace == NTFS_FNAME_DOS) { continue; } /* Seek to the end of the fs_name structures in TSK_FS_META */ if (fs_file->meta->name2) { for (fs_name = fs_file->meta->name2; (fs_name) && (fs_name->next != NULL); fs_name = fs_name->next) { } /* add to the end of the existing list */ fs_name->next = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST)); if (fs_name->next == NULL) { return TSK_ERR; } fs_name = fs_name->next; fs_name->next = NULL; } else { /* First name, so we start a list */ fs_file->meta->name2 = fs_name = (TSK_FS_META_NAME_LIST *) tsk_malloc(sizeof(TSK_FS_META_NAME_LIST)); if (fs_name == NULL) { return TSK_ERR; } fs_name->next = NULL; } name16 = (UTF16 *) & fname->name; name8 = (UTF8 *) fs_name->name; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + fname->nlen * 2), &name8, (UTF8 *) ((uintptr_t) name8 + sizeof(fs_name->name)), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "proc_attr_seq: Error converting NTFS name in $FNAME to UTF8: %d", retVal); *name8 = '\0'; } /* Make sure it is NULL Terminated */ else if ((uintptr_t) name8 >= (uintptr_t) fs_name->name + sizeof(fs_name->name)) fs_name->name[sizeof(fs_name->name) - 1] = '\0'; else *name8 = '\0'; fs_name->par_inode = tsk_getu48(fs->endian, fname->par_ref); fs_name->par_seq = tsk_getu16(fs->endian, fname->par_seq); } /* If this is an attribute list than we need to process * it to get the list of other entries to read. But, because * of the wierd scenario of the $MFT having an attribute list * and not knowing where the other MFT entires are yet, we wait * until the end of the attrseq to processes the list and then * we should have the $Data attribute loaded */ else if (type == NTFS_ATYPE_ATTRLIST) { if (fs_attr_attrl) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Multiple instances of attribute lists in the same MFT\n" "I didn't realize that could happen, contact the developers"); return TSK_ERR; } fs_attr_attrl = tsk_fs_attrlist_get_id(fs_file->meta->attr, NTFS_ATYPE_ATTRLIST, id_new); if (fs_attr_attrl == NULL) { strncat(tsk_errstr2, " - proc_attrseq: getting attribute list", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_ERR; } } } /* Are we currently in the process of loading $MFT? */ if (ntfs->loading_the_MFT == 1) { /* If we don't even have a mini cached version, get it now * Even if we are not done because of attribute lists, then we * should at least have the head of the list */ if (!ntfs->mft_data) { int cnt, i; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; // get the default attribute if ((fs_attr->type == NTFS_ATYPE_DATA) && (fs_attr->name == NULL)) { ntfs->mft_data = fs_attr; break; } } // @@@ Is this needed here -- maybe it should be only in _open if (!ntfs->mft_data) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "$Data not found while loading the MFT"); return TSK_ERR; } } /* Update the inode count based on the current size * IF $MFT has an attribute list, this value will increase each * time */ fs->inum_count = ntfs->mft_data->size / ntfs->mft_rsize_b; fs->last_inum = fs->inum_count - 1; } /* If there was an attribute list, process it now, we wait because * the list can contain MFT entries that are described in $Data * of this MFT entry. For example, part of the $DATA attribute * could follow the ATTRLIST entry, so we read it first and then * process the attribute list */ if (fs_attr_attrl) { if (ntfs_proc_attrlist(ntfs, fs_file, fs_attr_attrl)) { return TSK_ERR; } } fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return TSK_OK; } /******** Attribute List Action and Function ***********/ /* * Attribute lists are used when all of the attribute headers can not * fit into one MFT entry. This contains an entry for every attribute * and where they are located. We process this to get the locations * and then call proc_attrseq on each of those, which adds the data * to the fs_file structure. * * @param ntfs File system being analyzed * @param fs_file Main file that will have attributes added to it. * @param fs_attr_attrlist Attrlist attribute that needs to be parsed. * * Return 1 on error and 0 on success */ static uint8_t ntfs_proc_attrlist(NTFS_INFO * ntfs, TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr_attrlist) { ntfs_attrlist *list; char *buf; uintptr_t endaddr; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; ntfs_mft *mft; TSK_FS_LOAD_FILE load_file; TSK_INUM_T mftToDo[256]; uint16_t mftToDoCnt = 0; NTFS_ATTRLIST_MAP *map; uint16_t nextid = 0; int a; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrlist: Processing entry %" PRIuINUM "\n", fs_file->meta->addr); if ((mft = (ntfs_mft *) tsk_malloc(ntfs->mft_rsize_b)) == NULL) { return 1; } if ((map = (NTFS_ATTRLIST_MAP *)tsk_malloc(sizeof(NTFS_ATTRLIST_MAP))) == NULL) { free(mft); return 1; } /* Clear the contents of the todo buffer */ memset(mftToDo, 0, sizeof(mftToDo)); /* Get a copy of the attribute list stream using the above action */ load_file.left = load_file.total = (size_t) fs_attr_attrlist->size; load_file.base = load_file.cur = buf = tsk_malloc((size_t) fs_attr_attrlist->size); if (buf == NULL) { free(mft); free(map); return 1; } endaddr = (uintptr_t) buf + (uintptr_t) fs_attr_attrlist->size; if (tsk_fs_attr_walk(fs_attr_attrlist, 0, tsk_fs_load_file_action, (void *) &load_file)) { strncat(tsk_errstr2, " - processing attrlist", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(mft); free(map); return 1; } /* this value should be zero, if not then we didn't read all of the * buffer */ if (load_file.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr2, TSK_ERRSTR_L, "processing attrlist of entry %" PRIuINUM, ntfs->mnum); free(mft); free(buf); free(map); return 1; } /* The TSK design requres that each attribute have its own ID. * Therefore, we need to identify all of the unique attributes * so that we can assign a unique ID to them. * In this process, we will also identify the unique MFT entries to * process. */ nextid = fs_attr_attrlist->id; // we won't see this entry in the list for (list = (ntfs_attrlist *) buf; (list) && ((uintptr_t) list < endaddr) && (tsk_getu16(fs->endian, list->len) > 0); list = (ntfs_attrlist *) ((uintptr_t) list + tsk_getu16(fs->endian, list->len))) { uint8_t found; int i; TSK_INUM_T mftnum = tsk_getu48(fs->endian, list->file_ref); uint32_t type = tsk_getu32(fs->endian, list->type); uint16_t id = tsk_getu16(fs->endian, list->id); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_attrlist: mft: %" PRIuINUM " type %" PRIu32 " id %" PRIu16 " VCN: %" PRIu64 "\n", mftnum, type, id, tsk_getu64(fs->endian, list->start_vcn)); // keep track of the biggest ID that we saw. if (id > nextid) nextid = id; /* First identify the unique attributes. * we can have duplicate entries at different VCNs. Ignore those. */ found = 0; for (i = 0; i < map->num_used; i++) { if ((map->type[i] == type) && (memcmp(map->name[i], &list->name, list->nlen*2) == 0)) { found=1; break; } } // add it to the list if (found == 0) { map->extMft[map->num_used] = mftnum; map->type[map->num_used] = type; map->extId[map->num_used] = id; memcpy(map->name[map->num_used], &list->name, list->nlen*2); if (map->num_used < 255) map->num_used++; } /* also check the todo list -- skip the base entry * the goal here is to get a unique list of MFT entries * to later process. */ if (mftnum != ntfs->mnum) { found = 0; for (i = 0; i < mftToDoCnt; i++) { if (mftToDo[i] == mftnum) { found = 1; break; } } if ((found == 0) && (mftToDoCnt < 256)) { mftToDo[mftToDoCnt++] = mftnum; } } } // update the map and assign unique IDs for (a = 0; a < map->num_used; a++) { // skip the base entry attributes -- they have unique attribute IDs if (map->extMft[a] == ntfs->mnum) continue; map->newId[a] = ++nextid; } /* Process the ToDo list & and call ntfs_proc_attr */ for (a = 0; a < mftToDoCnt; a++) { TSK_RETVAL_ENUM retval; /* Sanity check. */ if (mftToDo[a] < ntfs->fs_info.first_inum || mftToDo[a] > ntfs->fs_info.last_inum) { if (tsk_verbose) { /* this case can easily occur if the attribute list was non-resident and the cluster has been reallocated */ tsk_fprintf(stderr, "Invalid MFT file reference (%" PRIuINUM ") in the unallocated attribute list of MFT %" PRIuINUM "", mftToDo[a], ntfs->mnum); } continue; } if ((retval = ntfs_dinode_lookup(ntfs, mft, mftToDo[a])) != TSK_OK) { // if the entry is corrupt, then continue if (retval == TSK_COR) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); continue; } free(mft); free(map); free(buf); strncat(tsk_errstr2, " - proc_attrlist", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } /* verify that this entry refers to the original one */ if (tsk_getu48(fs->endian, mft->base_ref) != ntfs->mnum) { /* Before we raise alarms, check if the original was * unallocated. If so, then the list entry could * have been reallocated, so we will just ignore it */ if ((tsk_getu16(fs->endian, ntfs->mft->flags) & NTFS_MFT_INUSE) == 0) { continue; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Extension record %" PRIuINUM " (file ref = %" PRIuINUM ") is not for attribute list of %" PRIuINUM "", mftToDo[a], tsk_getu48(fs->endian, mft->base_ref), ntfs->mnum); free(mft); free(map); free(buf); return 1; } } /* Process the attribute seq for this MFT entry and add them * to the TSK_FS_META structure */ if ((retval = ntfs_proc_attrseq(ntfs, fs_file, (ntfs_attr *) ((uintptr_t) mft + tsk_getu16(fs->endian, mft->attr_off)), ntfs->mft_rsize_b - tsk_getu16(fs->endian, mft->attr_off), mftToDo[a], map)) != TSK_OK) { if (retval == TSK_COR) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); continue; } strncat(tsk_errstr2, "- proc_attrlist", TSK_ERRSTR_L - strlen(tsk_errstr2)); free(mft); free(map); free(buf); return 1; } } free(mft); free(map); free(buf); return 0; } /** * Copy the MFT entry saved in ntfs->mft into the generic structure. * * @param ntfs File system structure that contains entry to copy * @param fs_file Structure to copy processed data to. * * @returns error code */ static TSK_RETVAL_ENUM ntfs_dinode_copy(NTFS_INFO * ntfs, TSK_FS_FILE * a_fs_file) { ntfs_mft *mft = ntfs->mft; ntfs_attr *attr; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; TSK_RETVAL_ENUM retval; if ((a_fs_file == NULL) || (a_fs_file->meta == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_dinode_copy: NULL fs_file given"); return TSK_ERR; } /* if the attributes list has been used previously, then make sure the * flags are cleared */ if (a_fs_file->meta->attr) { tsk_fs_attrlist_markunused(a_fs_file->meta->attr); } else { a_fs_file->meta->attr = tsk_fs_attrlist_alloc(); if (a_fs_file->meta->attr == NULL) return TSK_ERR; } a_fs_file->meta->attr_state = TSK_FS_META_ATTR_EMPTY; /* If there are any name structures allocated, then free 'em */ if (a_fs_file->meta->name2) { TSK_FS_META_NAME_LIST *fs_name1, *fs_name2; fs_name1 = a_fs_file->meta->name2; while (fs_name1) { fs_name2 = fs_name1->next; free(fs_name1); fs_name1 = fs_name2; } a_fs_file->meta->name2 = NULL; } /* Set the a_fs_file->meta values from mft */ a_fs_file->meta->nlink = tsk_getu16(fs->endian, mft->link); a_fs_file->meta->seq = tsk_getu16(fs->endian, mft->seq); a_fs_file->meta->addr = ntfs->mnum; /* Set the mode for file or directory */ if (tsk_getu16(fs->endian, ntfs->mft->flags) & NTFS_MFT_DIR) a_fs_file->meta->type = TSK_FS_META_TYPE_DIR; else a_fs_file->meta->type = TSK_FS_META_TYPE_REG; a_fs_file->meta->mode = 0; // will be set by proc_attrseq /* the following will be changed once we find the correct attribute, * but initialize them now just in case */ a_fs_file->meta->uid = 0; a_fs_file->meta->gid = 0; a_fs_file->meta->size = 0; a_fs_file->meta->mtime = 0; a_fs_file->meta->mtime_nano = 0; a_fs_file->meta->atime = 0; a_fs_file->meta->atime_nano = 0; a_fs_file->meta->ctime = 0; a_fs_file->meta->ctime_nano = 0; a_fs_file->meta->crtime = 0; a_fs_file->meta->crtime_nano = 0; /* add the flags */ a_fs_file->meta->flags = ((tsk_getu16(fs->endian, ntfs->mft->flags) & NTFS_MFT_INUSE) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); /* Process the attribute sequence to fill in the fs_meta->attr * list and the other info such as size and times */ attr = (ntfs_attr *) ((uintptr_t) mft + tsk_getu16(fs->endian, mft->attr_off)); if ((retval = ntfs_proc_attrseq(ntfs, a_fs_file, attr, ntfs->mft_rsize_b - tsk_getu16(fs->endian, mft->attr_off), a_fs_file->meta->addr, NULL)) != TSK_OK) { return retval; } /* The entry has been 'used' if it has attributes */ if ((a_fs_file->meta->attr == NULL) || (a_fs_file->meta->attr->head == NULL) || ((a_fs_file->meta->attr->head->flags & TSK_FS_ATTR_INUSE) == 0)) a_fs_file->meta->flags |= TSK_FS_META_FLAG_UNUSED; else a_fs_file->meta->flags |= TSK_FS_META_FLAG_USED; return 0; } /** * Read the mft entry and put it into the local ntfs->mft structure * Also sets the ntfs->mnum value. * * @param ntfs NTFS file system to get inode from * @param mftnum Address of inode to copy * @returns TSK_OK, TSK_CORR, or TSK_ERR */ static TSK_RETVAL_ENUM ntfs_dinode_load(NTFS_INFO * a_ntfs, TSK_INUM_T a_mftnum) { TSK_RETVAL_ENUM retval; /* mft_lookup does a sanity check, so we can skip it here */ if ((retval = ntfs_dinode_lookup(a_ntfs, a_ntfs->mft, a_mftnum)) != TSK_OK) return retval; a_ntfs->mnum = a_mftnum; return 0; } /** \internal * Load the attributes. In NTFS, the attributes are already loaded * so return error values based on current state. * @param a_fs_file File to load attributes for. * @returns 1 on error */ static uint8_t ntfs_load_attrs(TSK_FS_FILE * a_fs_file) { if ((a_fs_file == NULL) || (a_fs_file->meta == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_load_attrs: called with NULL pointers"); return 1; } /* Verify the file has attributes */ if (a_fs_file->meta->attr == NULL) { if (a_fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_load_attrs: attributes are NULL"); return 1; } return 0; } /** * Read an MFT entry and save it in the generic TSK_FS_META format. * * @param fs File system to read from. * @param mftnum Address of mft entry to read * @returns 1 on error */ static uint8_t ntfs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T mftnum) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; // clean up any error messages that are lying around tsk_error_reset(); if (a_fs_file == NULL) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_inode_lookup: fs_file is NULL"); return 1; } if (a_fs_file->meta == NULL) { a_fs_file->meta = tsk_fs_meta_alloc(NTFS_FILE_CONTENT_LEN); if (a_fs_file->meta == NULL) return 1; } else { tsk_fs_meta_reset(a_fs_file->meta); } // see if they are looking for the special "orphans" directory if (mftnum == TSK_FS_ORPHANDIR_INUM(fs)) { if (tsk_fs_dir_make_orphan_dir_meta(fs, a_fs_file->meta)) return 1; else return 0; } /* Lookup inode and store it in the ntfs structure */ if (ntfs_dinode_load(ntfs, mftnum) != TSK_OK) { return 1; } /* Copy the structure in ntfs to generic a_fs_file->meta */ if (ntfs_dinode_copy(ntfs, a_fs_file) != TSK_OK) { return 1; } return 0; } /********************************************************************** * * Load special MFT structures into the NTFS_INFO structure * **********************************************************************/ /* The attrdef structure defines the types of attributes and gives a * name value to the type number. * * We currently do not use this during the analysis (Because it has not * historically changed, but we do display it in fsstat * * Return 1 on error and 0 on success */ static uint8_t ntfs_load_attrdef(NTFS_INFO * ntfs) { TSK_FS_FILE *fs_file; const TSK_FS_ATTR *fs_attr; TSK_FS_INFO *fs = &ntfs->fs_info; TSK_FS_LOAD_FILE load_file; /* if already loaded, return now */ if (ntfs->attrdef) return 1; if ((fs_file = tsk_fs_file_open_meta(fs, NULL, NTFS_MFT_ATTR)) == NULL) return 1; fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_DATA); if (!fs_attr) { //("Data attribute not found in $Attr"); tsk_fs_file_close(fs_file); return 1; } // @@@ We need to do a sanity check on the size of fs_attr->size /* Get a copy of the attribute list stream using the above action */ load_file.left = load_file.total = (size_t) fs_attr->size; load_file.base = load_file.cur = tsk_malloc((size_t) fs_attr->size); if (load_file.cur == NULL) { tsk_fs_file_close(fs_file); return 1; } ntfs->attrdef = (ntfs_attrdef *) load_file.base; if (tsk_fs_attr_walk(fs_attr, 0, tsk_fs_load_file_action, (void *) &load_file)) { strncat(tsk_errstr2, " - load_attrdef", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_file_close(fs_file); free(ntfs->attrdef); ntfs->attrdef = NULL; return 1; } else if (load_file.left > 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "load_attrdef: space still left after walking $Attr data"); tsk_fs_file_close(fs_file); free(ntfs->attrdef); ntfs->attrdef = NULL; return 1; } ntfs->attrdef_len = (size_t) fs_attr->size; tsk_fs_file_close(fs_file); return 0; } /* * return the name of the attribute type. If the attribute has not * been loaded yet, it will be. * * Return 1 on error and 0 on success */ uint8_t ntfs_attrname_lookup(TSK_FS_INFO * fs, uint16_t type, char *name, int len) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; ntfs_attrdef *attrdef; if (!ntfs->attrdef) { if (ntfs_load_attrdef(ntfs)) return 1; } attrdef = ntfs->attrdef; while ( (((uintptr_t) attrdef - (uintptr_t) ntfs->attrdef + sizeof(ntfs_attrdef)) < ntfs->attrdef_len) && (tsk_getu32(fs->endian, attrdef->type))) { if (tsk_getu32(fs->endian, attrdef->type) == type) { UTF16 *name16 = (UTF16 *) attrdef->label; UTF8 *name8 = (UTF8 *) name; int retVal; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + sizeof(attrdef->label)), &name8, (UTF8 *) ((uintptr_t) name8 + len), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "attrname_lookup: Error converting NTFS attribute def label to UTF8: %d", retVal); break; } /* Make sure it is NULL Terminated */ else if ((uintptr_t) name8 >= (uintptr_t) name + len) name[len - 1] = '\0'; else *name8 = '\0'; return 0; } attrdef++; } /* If we didn't find it, then call it '?' */ snprintf(name, len, "?"); return 0; } /* Load the block bitmap $Data run and allocate a buffer for a cache * * return 1 on error and 0 on success * */ static uint8_t ntfs_load_bmap(NTFS_INFO * ntfs) { ssize_t cnt; ntfs_attr *attr; TSK_FS_INFO *fs = &ntfs->fs_info; /* Get data on the bitmap */ if (ntfs_dinode_load(ntfs, NTFS_MFT_BMAP) != TSK_OK) { return 1; } attr = (ntfs_attr *) ((uintptr_t) ntfs->mft + tsk_getu16(fs->endian, ntfs->mft->attr_off)); /* cycle through them */ while (((uintptr_t) attr >= (uintptr_t) ntfs->mft) && ((uintptr_t) attr <= ((uintptr_t) ntfs->mft + (uintptr_t) ntfs->mft_rsize_b)) && (tsk_getu32(fs->endian, attr->len) > 0 && (tsk_getu32(fs->endian, attr->type) != 0xffffffff) && (tsk_getu32(fs->endian, attr->type) != NTFS_ATYPE_DATA))) { attr = (ntfs_attr *) ((uintptr_t) attr + tsk_getu32(fs->endian, attr->len)); } /* did we get it? */ if (tsk_getu32(fs->endian, attr->type) != NTFS_ATYPE_DATA) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error Finding Bitmap Data Attribute"); return 1; } /* convert to generic form */ if ((ntfs_make_data_run(ntfs, tsk_getu64(fs->endian, attr->c.nr.start_vcn), (ntfs_runlist *) ((uintptr_t) attr + tsk_getu16(fs->endian, attr->c.nr.run_off)), &(ntfs->bmap), NULL)) != TSK_OK) { return 1; } ntfs->bmap_buf = (char *) tsk_malloc(fs->block_size); if (ntfs->bmap_buf == NULL) { return 1; } /* Load the first cluster so that we have something there */ ntfs->bmap_buf_off = 0; if (ntfs->bmap->addr > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_load_bmap: Bitmap too large for image size: %" PRIuDADDR "", ntfs->bmap->addr); return 1; } cnt = tsk_fs_read_block(fs, ntfs->bmap->addr, ntfs->bmap_buf, fs->block_size); if (cnt != fs->block_size) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_load_bmap: Error reading block at %" PRIuDADDR, ntfs->bmap->addr); return 1; } return 0; } /* * Load the VOLUME MFT entry and the VINFO attribute so that we * can identify the volume version of this. * * Return 1 on error and 0 on success */ static uint8_t ntfs_load_ver(NTFS_INFO * ntfs) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; TSK_FS_FILE *fs_file; const TSK_FS_ATTR *fs_attr; if ((fs_file = tsk_fs_file_open_meta(fs, NULL, NTFS_MFT_VOL)) == NULL) { return 1; } /* cache the data attribute */ fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_VINFO); if (!fs_attr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Volume Info attribute not found in $Volume"); tsk_fs_file_close(fs_file); return 1; } if ((fs_attr->flags & TSK_FS_ATTR_RES) && (fs_attr->size)) { ntfs_attr_vinfo *vinfo = (ntfs_attr_vinfo *) fs_attr->rd.buf; if ((vinfo->maj_ver == 1) && (vinfo->min_ver == 2)) { ntfs->ver = NTFS_VINFO_NT; } else if ((vinfo->maj_ver == 3) && (vinfo->min_ver == 0)) { ntfs->ver = NTFS_VINFO_2K; } else if ((vinfo->maj_ver == 3) && (vinfo->min_ver == 1)) { ntfs->ver = NTFS_VINFO_XP; } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "unknown version: %d.%d\n", vinfo->maj_ver, vinfo->min_ver); tsk_fs_file_close(fs_file); return 1; } } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "load_version: VINFO is a non-resident attribute"); return 1; } tsk_fs_file_close(fs_file); return 0; } #if TSK_USE_SID /** \internal * Prints the value of sds into the a_sidstr string in ASCII form. This will allocate a new buffer for the * string, so a_sidstr should not point to a buffer. * * @param a_fs File system * @param a_sds SDS * @param a_sidstr [out] Pointer that will be assigned to the buffer allocated by this function to store the string. * @returns 1 on error, 0 on success */ static uint8_t ntfs_sds_to_str(TSK_FS_INFO * a_fs, const ntfs_attr_sds * a_sds, char **a_sidstr) { char *sid_str = NULL; ntfs_sid *sid = NULL; // "S-" unsigned int sid_str_len = 2; uint32_t owner_offset = 0; if ((a_fs == NULL) || (a_sds == NULL) || (a_sidstr == NULL)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid argument"); return 1; } owner_offset = tsk_getu32(a_fs->endian, a_sds->self_rel_sec_desc.owner); if (((uintptr_t) & a_sds->self_rel_sec_desc + owner_offset) > ((uintptr_t) a_sds + tsk_getu32(a_fs->endian, a_sds->ent_size))) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_sds_to_str: owner offset larger than a_sds length"); return 1; } *a_sidstr = NULL; sid = (ntfs_sid *) ((uint8_t *) & a_sds->self_rel_sec_desc + owner_offset); // "1-" sid_str_len += 2; //tsk_fprintf(stderr, "Revision: %i\n", sid->revision); // This check helps not process invalid data, which was noticed while testing // a failing harddrive if (sid->revision == 1) { int index; int len; uint64_t authority; int i, j; char *sid_str_offset; //tsk_fprintf(stderr, "Sub-Authority Count: %i\n", sid->sub_auth_count); for (authority = i = 0, j = 40; i < 6; i++, j -= 8) authority += (uint64_t) sid->ident_auth[i] << j; //tsk_fprintf(stderr, "NT Authority: %" PRIu64 "\n", authority); // "-XXXXXXXXXX" sid_str_len += (1 + 10) * sid->sub_auth_count; // Allocate the buffer for the string representation of the SID. if ((sid_str = (char *) tsk_malloc(sid_str_len)) == NULL) { return 1; } len = sprintf(sid_str, "S-1-%" PRIu64, authority); sid_str_offset = sid_str + len; for (index = 0; index < sid->sub_auth_count; index++) { len = sprintf(sid_str_offset, "-%" PRIu32, sid->sub_auth[index]); sid_str_offset += len; } *a_sidstr = sid_str; //tsk_fprintf(stderr, "SID: %s\n", sid_str); } else { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_sds_to_str: Invalid SID revision (%d)", sid->revision); return 1; // Invalid revision number in the SID. } return 0; } /** \internal * Maps a security id value from a file to its SDS structure * * @param fs File system * @param secid Security Id to find SDS for. * @returns NULL on error */ const ntfs_attr_sds * ntfs_get_sds(TSK_FS_INFO * fs, uint32_t secid) { uint32_t i = 0; NTFS_INFO *ntfs = (NTFS_INFO *) fs; ntfs_attr_sii *sii = NULL; ntfs_attr_sds *sds = NULL; uint32_t sii_secid = 0; uint32_t sds_secid = 0; uint32_t sii_sechash = 0; uint32_t sds_sechash = 0; uint64_t sds_file_off = 0; uint32_t sds_ent_size = 0; uint64_t sii_sds_file_off = 0; uint32_t sii_sds_ent_size = 0; if ((fs == NULL) || (secid == 0)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid argument"); return NULL; } // Loop through all the SII entries looking for the security id matching that found in the file. // This lookup is obviously O(n^2) for all n files. However, since so many files have the exact // same security identifier, it is not really that bad. In reality, 100,000 files may only map to // 10,000 security identifiers. Since SII entries are 0x28 bytes each and security identifiers // increase incrementally, we could go directly to the entry in question ((secid * 0x28) + 256). // SII entries started at 256 on Vista; however, I did not look at the starting secid for other // versions of NTFS. for (i = 0; i < ntfs->sii_data.used; i++) { if (tsk_getu32(fs->endian, ((ntfs_attr_sii *) (ntfs->sii_data. buffer))[i].key_sec_id) == secid) { sii = &((ntfs_attr_sii *) (ntfs->sii_data.buffer))[i]; break; } } if (sii == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_get_sds: SII entry not found (%" PRIu32 ")", secid); return NULL; } sii_secid = tsk_getu32(fs->endian, sii->key_sec_id); sii_sechash = tsk_getu32(fs->endian, sii->data_hash_sec_desc); sii_sds_file_off = tsk_getu64(fs->endian, sii->sec_desc_off); sii_sds_ent_size = tsk_getu32(fs->endian, sii->sec_desc_size); // Check that we do not go out of bounds. if ((uint32_t) sii_sds_file_off > ntfs->sds_data.size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_get_sds: SII offset too large (%" PRIu64 ")", sii_sds_file_off); return NULL; } else if (!sii_sds_ent_size) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_get_sds: SII entry size is invalid (%" PRIu32 ")", sii_sds_ent_size); return NULL; } sds = (ntfs_attr_sds *) ((uint8_t *) ntfs->sds_data.buffer + sii_sds_file_off); sds_secid = tsk_getu32(fs->endian, sds->sec_id); sds_sechash = tsk_getu32(fs->endian, sds->hash_sec_desc); sds_file_off = tsk_getu64(fs->endian, sds->file_off); sds_ent_size = tsk_getu32(fs->endian, sds->ent_size); // Sanity check to make sure the $SII entry points to // the correct $SDS entry. if ((sds_secid == sii_secid) && (sds_sechash == sii_sechash) && (sds_file_off == sii_sds_file_off) //&& (sds_ent_size == sii_sds_ent_size) ) { return sds; } else { if (sii_secid != 0) { // There is obviously a mismatch between the information in the SII entry and that in the SDS entry. // After looking at these mismatches, it appears there is not a pattern. Perhaps some entries have been reused. //printf("\nsecid %d hash %x offset %I64x size %x\n", sii_secid, sii_sechash, sii_sds_file_off, sii_sds_ent_size); //printf("secid %d hash %x offset %I64x size %x\n", sds_secid, sds_sechash, sds_file_off, sds_ent_size); } } tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_get_sds: Got to end w/out data"); return NULL; } #endif /** \internal * NTFS-specific function (pointed to in FS_INFO) that maps a security ID * to an ASCII printable string. * Read the contents of the STANDARD_INFORMATION attribute of a file * to get the security id. Once we have the security id, we will * search $Secure:$SII to find a matching security id. That $SII entry * will contain the offset within the $SDS stream for the $SDS entry, * which contains the owner SID * * @param a_fs_file File to get security info on * @param sid_str [out] location where string representation of security info will be stored. Caller must free the string. * @returns 1 on error */ static uint8_t ntfs_file_get_sidstr(TSK_FS_FILE * a_fs_file, char **sid_str) { #if TSK_USE_SID const TSK_FS_ATTR *fs_data; ntfs_attr_si *si; const ntfs_attr_sds *sds; *sid_str = NULL; if (!a_fs_file->meta->attr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_get_sidstr: file argument has no meta data"); return 1; } // Read STANDARD_INFORMATION attribute for the security id of the file. fs_data = tsk_fs_attrlist_get(a_fs_file->meta->attr, TSK_FS_ATTR_TYPE_NTFS_SI); if (!fs_data) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "- ntfs_file_get_sidstr:SI attribute"); return 1; } si = (ntfs_attr_si *) fs_data->rd.buf; if (!si) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_GENFS; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_file_get_sidstr: SI buf is NULL"); return 1; } sds = ntfs_get_sds(a_fs_file->fs_info, tsk_getu32(a_fs_file->fs_info->endian, si->sec_id)); if (!sds) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "- ntfs_file_get_sidstr:SI attribute"); return 1; } if (ntfs_sds_to_str(a_fs_file->fs_info, sds, sid_str)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "- ntfs_file_get_sidstr:SI attribute"); return 1; } return 0; #else *sid_str = NULL; tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Unsupported function"); return 1; #endif } #if TSK_USE_SID void ntfs_proc_sii(TSK_FS_INFO * fs, NTFS_SXX_BUFFER * sii_buffer) { unsigned int total_bytes_processed = 0; unsigned int idx_buffer_length = 0; unsigned int sii_buffer_offset = 0; NTFS_INFO *ntfs = (NTFS_INFO *) fs; ntfs_attr_sii *sii; if ((fs == NULL) || (sii_buffer == NULL) || (ntfs->sii_data.buffer == NULL)) return; /* Loop by cluster size */ for (sii_buffer_offset = 0; sii_buffer_offset < sii_buffer->size; sii_buffer_offset += ntfs->idx_rsize_b) { ntfs_idxrec *idxrec = (ntfs_idxrec *) & sii_buffer->buffer[sii_buffer_offset]; idx_buffer_length = tsk_getu32(fs->endian, idxrec->list.bufend_off); sii = (ntfs_attr_sii *) ((uintptr_t) & idxrec->list + tsk_getu32(fs->endian, idxrec->list.begin_off)); total_bytes_processed = (uint8_t) ((uintptr_t) sii - (uintptr_t) idxrec); do { /* if ((tsk_getu16(fs->endian,sii->size) == 0x14) && (tsk_getu16(fs->endian,sii->data_off) == 0x14) && (tsk_getu16(fs->endian,sii->ent_size) == 0x28) ) { */ memcpy(ntfs->sii_data.buffer + (ntfs->sii_data.used * sizeof(ntfs_attr_sii)), sii, sizeof(ntfs_attr_sii)); ntfs->sii_data.size += sizeof(ntfs_attr_sii); ntfs->sii_data.used += 1; /* printf("Security id %d is at offset 0x%I64x for 0x%x bytes\n", tsk_getu32(fs->endian,sii->key_sec_id), tsk_getu64(fs->endian,sii->sec_desc_off), tsk_getu32(fs->endian,sii->sec_desc_size)); } else { printf("\n\tOffset to data %x Size of data %x Size of Index entry %x\n", tsk_getu16(fs->endian,sii->data_off), tsk_getu16(fs->endian,sii->size), tsk_getu16(fs->endian,sii->ent_size)); printf("\tSecurity id %d is at offset 0x%I64x for 0x%x bytes\n\n", tsk_getu32(fs->endian,sii->key_sec_id), tsk_getu64(fs->endian,sii->sec_desc_off), tsk_getu32(fs->endian,sii->sec_desc_size)); } */ sii++; total_bytes_processed += sizeof(ntfs_attr_sii); } while (total_bytes_processed + sizeof(ntfs_attr_sii) <= idx_buffer_length); } } /* * Load the $Secure attributes so that we can identify the user. * @returns 1 on error (which occurs only if malloc or other system error). */ static uint8_t ntfs_load_secure(NTFS_INFO * ntfs) { TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; TSK_FS_META *fs_meta = NULL; const TSK_FS_ATTR *fs_attr = NULL; const TSK_FS_ATTR *fs_attr_sii = NULL; NTFS_SXX_BUFFER sds_buffer; NTFS_SXX_BUFFER sii_buffer; TSK_FS_FILE *secure = NULL; ssize_t cnt; ntfs->sii_data.buffer = NULL; ntfs->sii_data.size = 0; ntfs->sii_data.used = 0; ntfs->sds_data.buffer = NULL; ntfs->sds_data.size = 0; ntfs->sds_data.used = 0; // Open $Secure. The $SDS stream contains all the security descriptors // and is indexed by $SII and $SDH. secure = tsk_fs_file_open_meta(fs, NULL, NTFS_MFT_SECURE); if (!secure) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error opening $Secure file: %s\n", tsk_errstr); tsk_error_reset(); return 0; } // Make sure the TSK_FS_META is not NULL. We need it to get the // $SII and $SDH attributes. fs_meta = secure->meta; if (!fs_meta) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: $Secure file has no attributes\n"); tsk_error_reset(); tsk_fs_file_close(secure); return 0; } // Get the $SII attribute. fs_attr_sii = tsk_fs_attrlist_get_name_type(fs_meta->attr, NTFS_ATYPE_IDXALLOC, "$SII\0"); if (!fs_attr_sii) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error getting $Secure:$SII IDX_ALLOC attribute\n"); tsk_error_reset(); tsk_fs_file_close(secure); return 0; } // Get the $SDS attribute. fs_attr = tsk_fs_attrlist_get(fs_meta->attr, NTFS_ATYPE_DATA); if (!fs_attr) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error getting $Secure:$SDS $Data attribute\n"); tsk_error_reset(); tsk_fs_file_close(secure); return 0; } // Allocate space for the entire $SII stream. sii_buffer.size = (size_t) roundup(fs_attr_sii->size, fs->block_size); sii_buffer.used = 0; if ((sii_buffer.buffer = tsk_malloc(sii_buffer.size)) == NULL) { return 1; } // We will use this structure to store the raw $SII entries since // they are a fixed size (x28 bytes) ntfs->sii_data.size = 0; ntfs->sii_data.used = 0; // use this to count the number of $SII entries if ((ntfs->sii_data.buffer = tsk_malloc(sii_buffer.size)) == NULL) { free(sii_buffer.buffer); tsk_fs_file_close(secure); return 1; } // Allocate space for the entire $SDS stream with all the security // descriptors. We should be able to use the $SII offset to index // into the $SDS stream. sds_buffer.size = (size_t) roundup(fs_attr->size, fs->block_size); sds_buffer.used = 0; if ((sds_buffer.buffer = tsk_malloc(sds_buffer.size)) == NULL) { free(sii_buffer.buffer); if (ntfs->sii_data.buffer) free(ntfs->sii_data.buffer); ntfs->sii_data.buffer = NULL; tsk_fs_file_close(secure); return 1; } // Read in the raw $SII stream. cnt = tsk_fs_attr_read(fs_attr_sii, 0, sii_buffer.buffer, sii_buffer.size, TSK_FS_FILE_READ_FLAG_NONE); if (cnt != sii_buffer.size) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error reading $Secure:$SII attribute: %s\n", tsk_errstr); tsk_error_reset(); free(sii_buffer.buffer); free(sds_buffer.buffer); if (ntfs->sii_data.buffer) free(ntfs->sii_data.buffer); ntfs->sii_data.buffer = NULL; tsk_fs_file_close(secure); return 0; } // Read in the raw $SDS ($DATA) stream. cnt = tsk_fs_attr_read(fs_attr, (TSK_OFF_T) sds_buffer.used, sds_buffer.buffer, sds_buffer.size, TSK_FS_FILE_READ_FLAG_NONE); if (cnt != sds_buffer.size) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_load_secure: error reading $Secure:$SDS attribute: %s\n", tsk_errstr); tsk_error_reset(); free(sii_buffer.buffer); free(sds_buffer.buffer); if (ntfs->sii_data.buffer) free(ntfs->sii_data.buffer); ntfs->sii_data.buffer = NULL; tsk_fs_file_close(secure); return 0; } // Process all the $SII entries into a single array by removing all the Attribute Headers. ntfs_proc_sii(fs, &sii_buffer); // Initialize our global to hold the raw $SDS stream. ntfs->sds_data = sds_buffer; free(sii_buffer.buffer); free(sds_buffer.buffer); tsk_fs_file_close(secure); return 0; } #endif /********************************************************************** * * Exported Walk Functions * **********************************************************************/ TSK_FS_BLOCK_FLAG_ENUM ntfs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr) { NTFS_INFO *ntfs = (NTFS_INFO *) a_fs; int retval; int flags = 0; /* identify if the cluster is allocated or not */ retval = is_clustalloc(ntfs, a_addr); if (retval == 1) flags = TSK_FS_BLOCK_FLAG_ALLOC; else if (retval == 0) flags = TSK_FS_BLOCK_FLAG_UNALLOC; return flags; } /* * flags: TSK_FS_BLOCK_FLAG_ALLOC and FS_FLAG_UNALLOC * * @@@ We should probably consider some data META, but it is tough with * the NTFS design ... */ uint8_t ntfs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr) { char *myname = "ntfs_block_walk"; NTFS_INFO *ntfs = (NTFS_INFO *) fs; TSK_DADDR_T addr; TSK_FS_BLOCK *fs_block; // clean up any error messages that are lying around tsk_error_reset(); /* * Sanity checks. */ if (a_start_blk < fs->first_block || a_start_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: start block: %" PRIuDADDR "", myname, a_start_blk); return 1; } else if (a_end_blk < fs->first_block || a_end_blk > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "%s: last block: %" PRIuDADDR "", myname, a_end_blk); return 1; } /* Sanity check on a_flags -- make sure at least one ALLOC is set */ if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_ALLOC | TSK_FS_BLOCK_WALK_FLAG_UNALLOC); } if (((a_flags & TSK_FS_BLOCK_WALK_FLAG_META) == 0) && ((a_flags & TSK_FS_BLOCK_WALK_FLAG_CONT) == 0)) { a_flags |= (TSK_FS_BLOCK_WALK_FLAG_CONT | TSK_FS_BLOCK_WALK_FLAG_META); } if ((fs_block = tsk_fs_block_alloc(fs)) == NULL) { return 1; } /* Cycle through the blocks */ for (addr = a_start_blk; addr <= a_end_blk; addr++) { int retval; int myflags; /* identify if the cluster is allocated or not */ retval = is_clustalloc(ntfs, addr); if (retval == -1) { tsk_fs_block_free(fs_block); return 1; } else if (retval == 1) { myflags = TSK_FS_BLOCK_FLAG_ALLOC; } else { myflags = TSK_FS_BLOCK_FLAG_UNALLOC; } // test if we should call the callback with this one if ((myflags & TSK_FS_BLOCK_FLAG_ALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_ALLOC))) continue; else if ((myflags & TSK_FS_BLOCK_FLAG_UNALLOC) && (!(a_flags & TSK_FS_BLOCK_WALK_FLAG_UNALLOC))) continue; if (tsk_fs_block_get(fs, fs_block, addr) == NULL) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "ntfs_block_walk: Error reading block at %" PRIuDADDR, addr); tsk_fs_block_free(fs_block); return 1; } retval = a_action(fs_block, a_ptr); if (retval == TSK_WALK_STOP) { break; } else if (retval == TSK_WALK_ERROR) { tsk_fs_block_free(fs_block); return 1; } } tsk_fs_block_free(fs_block); return 0; } /* * inode_walk * * Flags: TSK_FS_META_FLAG_ALLOC, TSK_FS_META_FLAG_UNALLOC, * TSK_FS_META_FLAG_USED, TSK_FS_META_FLAG_UNUSED, TSK_FS_META_FLAG_ORPHAN * * Note that with ORPHAN, entries will be found that can also be * found by searching based on parent directories (if parent directory is * known) */ uint8_t ntfs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB a_action, void *ptr) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; int myflags; TSK_INUM_T mftnum; TSK_FS_FILE *fs_file; TSK_INUM_T end_inum_tmp; /* * Sanity checks. */ if (start_inum < fs->first_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "inode_walk: Starting inode number is too small (%" PRIuINUM ")", start_inum); return 1; } if (start_inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "inode_walk: Starting inode number is too large (%" PRIuINUM ")", start_inum); return 1; } if (end_inum < fs->first_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "inode_walk: Ending inode number is too small (%" PRIuINUM ")", end_inum); return 1; } if (end_inum > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Ending inode number is too large (%" PRIuINUM ")", end_inum); return 1; } /* If ORPHAN is wanted, then make sure that the flags are correct */ if (flags & TSK_FS_META_FLAG_ORPHAN) { flags |= TSK_FS_META_FLAG_UNALLOC; flags &= ~TSK_FS_META_FLAG_ALLOC; flags |= TSK_FS_META_FLAG_USED; flags &= ~TSK_FS_META_FLAG_UNUSED; } else { if (((flags & TSK_FS_META_FLAG_ALLOC) == 0) && ((flags & TSK_FS_META_FLAG_UNALLOC) == 0)) { flags |= (TSK_FS_META_FLAG_ALLOC | TSK_FS_META_FLAG_UNALLOC); } /* If neither of the USED or UNUSED flags are set, then set them * both */ if (((flags & TSK_FS_META_FLAG_USED) == 0) && ((flags & TSK_FS_META_FLAG_UNUSED) == 0)) { flags |= (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED); } } /* If we are looking for orphan files and have not yet filled * in the list of unalloc inodes that are pointed to, then fill * in the list * */ if ((flags & TSK_FS_META_FLAG_ORPHAN) && (fs->list_inum_named == NULL)) { if (tsk_fs_dir_load_inum_named(fs) != TSK_OK) { strncat(tsk_errstr2, " - ntfs_inode_walk: identifying inodes allocated by file names", TSK_ERRSTR_L); return 1; } } if ((fs_file = tsk_fs_file_alloc(fs)) == NULL) return 1; if ((fs_file->meta = tsk_fs_meta_alloc(NTFS_FILE_CONTENT_LEN)) == NULL) { // JRB: Coverity CID: 348 if (fs_file) tsk_fs_file_close(fs_file); return 1; } // we need to handle fs->last_inum specially because it is for the // virtual ORPHANS directory. Handle it outside of the loop. if (end_inum == TSK_FS_ORPHANDIR_INUM(fs)) end_inum_tmp = end_inum - 1; else end_inum_tmp = end_inum; for (mftnum = start_inum; mftnum <= end_inum_tmp; mftnum++) { int retval; TSK_RETVAL_ENUM retval2; /* read MFT entry in to NTFS_INFO */ if ((retval2 = ntfs_dinode_load(ntfs, mftnum)) != TSK_OK) { // if the entry is corrupt, then skip to the next one if (retval2 == TSK_COR) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); continue; } tsk_fs_file_close(fs_file); return 1; } /* we only want to look at base file records * (extended are because the base could not fit into one) */ if (tsk_getu48(fs->endian, ntfs->mft->base_ref) != NTFS_MFT_BASE) continue; /* NOTE: We could add a sanity check here with the MFT bitmap * to validate of the INUSE flag and bitmap are in agreement */ /* check flags */ myflags = ((tsk_getu16(fs->endian, ntfs->mft->flags) & NTFS_MFT_INUSE) ? TSK_FS_META_FLAG_ALLOC : TSK_FS_META_FLAG_UNALLOC); /* If we want only orphans, then check if this * inode is in the seen list * */ if ((myflags & TSK_FS_META_FLAG_UNALLOC) && (flags & TSK_FS_META_FLAG_ORPHAN) && (tsk_list_find(fs->list_inum_named, mftnum))) { continue; } /* copy into generic format */ if ((retval = ntfs_dinode_copy(ntfs, fs_file)) != TSK_OK) { // continue on if there were only corruption problems if (retval == TSK_COR) { if (tsk_verbose) tsk_error_print(stderr); tsk_error_reset(); continue; } tsk_fs_file_close(fs_file); return 1; } myflags |= (fs_file->meta->flags & (TSK_FS_META_FLAG_USED | TSK_FS_META_FLAG_UNUSED)); if ((flags & myflags) != myflags) continue; /* call action */ retval = a_action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } // handle the virtual orphans folder if they asked for it if ((end_inum == TSK_FS_ORPHANDIR_INUM(fs)) && (flags & TSK_FS_META_FLAG_ALLOC) && (flags & TSK_FS_META_FLAG_USED)) { int retval; if (tsk_fs_dir_make_orphan_dir_meta(fs, fs_file->meta)) { tsk_fs_file_close(fs_file); return 1; } /* call action */ retval = a_action(fs_file, ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } tsk_fs_file_close(fs_file); return 0; } static uint8_t ntfs_fscheck(TSK_FS_INFO * fs, FILE * hFile) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for NTFS yet"); return 1; } /** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */ static uint8_t ntfs_fsstat(TSK_FS_INFO * fs, FILE * hFile) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; TSK_FS_FILE *fs_file; const TSK_FS_ATTR *fs_attr; char asc[512]; ntfs_attrdef *attrdeftmp; tsk_fprintf(hFile, "FILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "File System Type: NTFS\n"); tsk_fprintf(hFile, "Volume Serial Number: %.16" PRIX64 "\n", tsk_getu64(fs->endian, ntfs->fs->serial)); tsk_fprintf(hFile, "OEM Name: %c%c%c%c%c%c%c%c\n", ntfs->fs->oemname[0], ntfs->fs->oemname[1], ntfs->fs->oemname[2], ntfs->fs->oemname[3], ntfs->fs->oemname[4], ntfs->fs->oemname[5], ntfs->fs->oemname[6], ntfs->fs->oemname[7]); /* * Volume */ if ((fs_file = tsk_fs_file_open_meta(fs, NULL, NTFS_MFT_VOL)) == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_NUM; strncat(tsk_errstr2, " - fsstat: Error finding Volume MFT Entry", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_VNAME); if (!fs_attr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Volume Name attribute not found in $Volume"); return 1; } if ((fs_attr->flags & TSK_FS_ATTR_RES) && (fs_attr->size)) { UTF16 *name16 = (UTF16 *) fs_attr->rd.buf; UTF8 *name8 = (UTF8 *) asc; int retVal; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + (int) fs_attr->size), &name8, (UTF8 *) ((uintptr_t) name8 + sizeof(asc)), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "fsstat: Error converting NTFS Volume label to UTF8: %d", retVal); *name8 = '\0'; } /* Make sure it is NULL Terminated */ else if ((uintptr_t) name8 >= (uintptr_t) asc + sizeof(asc)) asc[sizeof(asc) - 1] = '\0'; else *name8 = '\0'; tsk_fprintf(hFile, "Volume Name: %s\n", asc); } tsk_fs_file_close(fs_file); fs_file = NULL; fs_attr = NULL; if (ntfs->ver == NTFS_VINFO_NT) tsk_fprintf(hFile, "Version: Windows NT\n"); else if (ntfs->ver == NTFS_VINFO_2K) tsk_fprintf(hFile, "Version: Windows 2000\n"); else if (ntfs->ver == NTFS_VINFO_XP) tsk_fprintf(hFile, "Version: Windows XP\n"); tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "First Cluster of MFT: %" PRIu64 "\n", tsk_getu64(fs->endian, ntfs->fs->mft_clust)); tsk_fprintf(hFile, "First Cluster of MFT Mirror: %" PRIu64 "\n", tsk_getu64(fs->endian, ntfs->fs->mftm_clust)); tsk_fprintf(hFile, "Size of MFT Entries: %" PRIu16 " bytes\n", ntfs->mft_rsize_b); tsk_fprintf(hFile, "Size of Index Records: %" PRIu16 " bytes\n", ntfs->idx_rsize_b); tsk_fprintf(hFile, "Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "Root Directory: %" PRIuINUM "\n", fs->root_inum); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %" PRIu16 "\n", ntfs->ssize_b); tsk_fprintf(hFile, "Cluster Size: %" PRIu16 "\n", ntfs->csize_b); tsk_fprintf(hFile, "Total Cluster Range: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block); if (fs->last_block != fs->last_block_act) tsk_fprintf(hFile, "Total Range in Image: %" PRIuDADDR " - %" PRIuDADDR "\n", fs->first_block, fs->last_block_act); tsk_fprintf(hFile, "Total Sector Range: 0 - %" PRIu64 "\n", tsk_getu64(fs->endian, ntfs->fs->vol_size_s) - 1); /* * Attrdef Info */ tsk_fprintf(hFile, "\n$AttrDef Attribute Values:\n"); if (!ntfs->attrdef) { if (ntfs_load_attrdef(ntfs)) { tsk_fprintf(hFile, "Error loading attribute definitions\n"); goto attrdef_egress; } } attrdeftmp = ntfs->attrdef; while ((((uintptr_t) attrdeftmp - (uintptr_t) ntfs->attrdef + sizeof(ntfs_attrdef)) < ntfs->attrdef_len) && (tsk_getu32(fs->endian, attrdeftmp->type))) { UTF16 *name16 = (UTF16 *) attrdeftmp->label; UTF8 *name8 = (UTF8 *) asc; int retVal; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + sizeof(attrdeftmp->label)), &name8, (UTF8 *) ((uintptr_t) name8 + sizeof(asc)), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) tsk_fprintf(stderr, "fsstat: Error converting NTFS attribute def label to UTF8: %d", retVal); *name8 = '\0'; } /* Make sure it is NULL Terminated */ else if ((uintptr_t) name8 >= (uintptr_t) asc + sizeof(asc)) asc[sizeof(asc) - 1] = '\0'; else *name8 = '\0'; tsk_fprintf(hFile, "%s (%" PRIu32 ") ", asc, tsk_getu32(fs->endian, attrdeftmp->type)); if ((tsk_getu64(fs->endian, attrdeftmp->minsize) == 0) && (tsk_getu64(fs->endian, attrdeftmp->maxsize) == 0xffffffffffffffffULL)) { tsk_fprintf(hFile, "Size: No Limit"); } else { tsk_fprintf(hFile, "Size: %" PRIu64 "-%" PRIu64, tsk_getu64(fs->endian, attrdeftmp->minsize), tsk_getu64(fs->endian, attrdeftmp->maxsize)); } tsk_fprintf(hFile, " Flags: %s%s%s\n", (tsk_getu32(fs->endian, attrdeftmp->flags) & NTFS_ATTRDEF_FLAGS_RES ? "Resident" : ""), (tsk_getu32(fs->endian, attrdeftmp->flags) & NTFS_ATTRDEF_FLAGS_NONRES ? "Non-resident" : ""), (tsk_getu32(fs->endian, attrdeftmp->flags) & NTFS_ATTRDEF_FLAGS_IDX ? ",Index" : "")); attrdeftmp++; } attrdef_egress: return 0; } /************************* istat *******************************/ #define NTFS_PRINT_WIDTH 8 typedef struct { FILE *hFile; int idx; } NTFS_PRINT_ADDR; static TSK_WALK_RET_ENUM print_addr_act(TSK_FS_FILE * fs_file, TSK_OFF_T a_off, TSK_DADDR_T addr, char *buf, size_t size, TSK_FS_BLOCK_FLAG_ENUM flags, void *ptr) { NTFS_PRINT_ADDR *print = (NTFS_PRINT_ADDR *) ptr; tsk_fprintf(print->hFile, "%" PRIuDADDR " ", addr); if (++(print->idx) == NTFS_PRINT_WIDTH) { tsk_fprintf(print->hFile, "\n"); print->idx = 0; } return TSK_WALK_CONT; } /** * Print details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File name to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ static uint8_t ntfs_istat(TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew) { TSK_FS_FILE *fs_file; const TSK_FS_ATTR *fs_attr; NTFS_INFO *ntfs = (NTFS_INFO *) fs; // clean up any error messages that are lying around tsk_error_reset(); if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) { strncat(tsk_errstr2, " - istat", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } tsk_fprintf(hFile, "MFT Entry Header Values:\n"); tsk_fprintf(hFile, "Entry: %" PRIuINUM " Sequence: %" PRIu32 "\n", inum, fs_file->meta->seq); if (tsk_getu48(fs->endian, ntfs->mft->base_ref) != 0) { tsk_fprintf(hFile, "Base File Record: %" PRIu64 "\n", (uint64_t) tsk_getu48(fs->endian, ntfs->mft->base_ref)); } tsk_fprintf(hFile, "$LogFile Sequence Number: %" PRIu64 "\n", tsk_getu64(fs->endian, ntfs->mft->lsn)); tsk_fprintf(hFile, "%sAllocated %s\n", (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) ? "" : "Not ", (fs_file->meta->type == TSK_FS_META_TYPE_DIR) ? "Directory" : "File"); tsk_fprintf(hFile, "Links: %u\n", fs_file->meta->nlink); /* STANDARD_INFORMATION info */ fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_SI); if (fs_attr) { ntfs_attr_si *si = (ntfs_attr_si *) fs_attr->rd.buf; char *sid_str; int a = 0; tsk_fprintf(hFile, "\n$STANDARD_INFORMATION Attribute Values:\n"); tsk_fprintf(hFile, "Flags: "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_RO) tsk_fprintf(hFile, "%sRead Only", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_HID) tsk_fprintf(hFile, "%sHidden", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_SYS) tsk_fprintf(hFile, "%sSystem", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_ARCH) tsk_fprintf(hFile, "%sArchive", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_DEV) tsk_fprintf(hFile, "%sDevice", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_NORM) tsk_fprintf(hFile, "%sNormal", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_TEMP) tsk_fprintf(hFile, "%sTemporary", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_SPAR) tsk_fprintf(hFile, "%sSparse", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_REP) tsk_fprintf(hFile, "%sReparse Point", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_COMP) tsk_fprintf(hFile, "%sCompressed", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_OFF) tsk_fprintf(hFile, "%sOffline", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_NOIDX) tsk_fprintf(hFile, "%sNot Content Indexed", a++ == 0 ? "" : ", "); if (tsk_getu32(fs->endian, si->dos) & NTFS_SI_ENC) tsk_fprintf(hFile, "%sEncrypted", a++ == 0 ? "" : ", "); tsk_fprintf(hFile, "\n"); tsk_fprintf(hFile, "Owner ID: %" PRIu32 "\n", tsk_getu32(fs->endian, si->own_id)); #if TSK_USE_SID ntfs_file_get_sidstr(fs_file, &sid_str); tsk_fprintf(hFile, "Security ID: %" PRIu32 " (%s)\n", tsk_getu32(fs->endian, si->sec_id), sid_str ? sid_str : ""); free(sid_str); sid_str = NULL; #endif if (tsk_getu32(fs->endian, si->maxver) != 0) { tsk_fprintf(hFile, "Version %" PRIu32 " of %" PRIu32 "\n", tsk_getu32(fs->endian, si->ver), tsk_getu32(fs->endian, si->maxver)); } if (tsk_getu64(fs->endian, si->quota) != 0) { tsk_fprintf(hFile, "Quota Charged: %" PRIu64 "\n", tsk_getu64(fs->endian, si->quota)); } if (tsk_getu64(fs->endian, si->usn) != 0) { tsk_fprintf(hFile, "Last User Journal Update Sequence Number: %" PRIu64 "\n", tsk_getu64(fs->endian, si->usn)); } /* Times - take it from fs_file->meta instead of redoing the work */ if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted times:\n"); fs_file->meta->mtime -= sec_skew; fs_file->meta->atime -= sec_skew; fs_file->meta->ctime -= sec_skew; fs_file->meta->crtime -= sec_skew; tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "MFT Modified:\t%s", ctime(&fs_file->meta->ctime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); fs_file->meta->mtime += sec_skew; fs_file->meta->atime += sec_skew; fs_file->meta->ctime += sec_skew; fs_file->meta->crtime += sec_skew; tsk_fprintf(hFile, "\nOriginal times:\n"); } tsk_fprintf(hFile, "Created:\t%s", ctime(&fs_file->meta->crtime)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&fs_file->meta->mtime)); tsk_fprintf(hFile, "MFT Modified:\t%s", ctime(&fs_file->meta->ctime)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&fs_file->meta->atime)); } /* $FILE_NAME Information */ fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_FNAME); if (fs_attr) { ntfs_attr_fname *fname = (ntfs_attr_fname *) fs_attr->rd.buf; time_t cr_time, m_time, c_time, a_time; uint64_t flags; int a = 0; tsk_fprintf(hFile, "\n$FILE_NAME Attribute Values:\n"); flags = tsk_getu64(fs->endian, fname->flags); tsk_fprintf(hFile, "Flags: "); if (flags & NTFS_FNAME_FLAGS_DIR) tsk_fprintf(hFile, "%sDirectory", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_DEV) tsk_fprintf(hFile, "%sDevice", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_NORM) tsk_fprintf(hFile, "%sNormal", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_RO) tsk_fprintf(hFile, "%sRead Only", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_HID) tsk_fprintf(hFile, "%sHidden", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_SYS) tsk_fprintf(hFile, "%sSystem", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_ARCH) tsk_fprintf(hFile, "%sArchive", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_TEMP) tsk_fprintf(hFile, "%sTemp", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_SPAR) tsk_fprintf(hFile, "%sSparse", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_REP) tsk_fprintf(hFile, "%sReparse Point", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_COMP) tsk_fprintf(hFile, "%sCompressed", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_ENC) tsk_fprintf(hFile, "%sEncrypted", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_OFF) tsk_fprintf(hFile, "%sOffline", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_NOIDX) tsk_fprintf(hFile, "%sNot Content Indexed", a++ == 0 ? "" : ", "); if (flags & NTFS_FNAME_FLAGS_IDXVIEW) tsk_fprintf(hFile, "%sIndex View", a++ == 0 ? "" : ", "); tsk_fprintf(hFile, "\n"); /* We could look this up in the attribute, but we already did * the work */ if (fs_file->meta->name2) { TSK_FS_META_NAME_LIST *fs_name = fs_file->meta->name2; tsk_fprintf(hFile, "Name: "); while (fs_name) { tsk_fprintf(hFile, "%s", fs_name->name); fs_name = fs_name->next; if (fs_name) tsk_fprintf(hFile, ", "); else tsk_fprintf(hFile, "\n"); } } tsk_fprintf(hFile, "Parent MFT Entry: %" PRIu64 " \tSequence: %" PRIu16 "\n", (uint64_t) tsk_getu48(fs->endian, fname->par_ref), tsk_getu16(fs->endian, fname->par_seq)); tsk_fprintf(hFile, "Allocated Size: %" PRIu64 " \tActual Size: %" PRIu64 "\n", tsk_getu64(fs->endian, fname->alloc_fsize), tsk_getu64(fs->endian, fname->real_fsize)); /* * Times */ cr_time = nt2unixtime(tsk_getu64(fs->endian, fname->crtime)); /* altered - modified */ m_time = nt2unixtime(tsk_getu64(fs->endian, fname->mtime)); /* MFT modified */ c_time = nt2unixtime(tsk_getu64(fs->endian, fname->ctime)); /* Access */ a_time = nt2unixtime(tsk_getu64(fs->endian, fname->atime)); if (sec_skew != 0) { tsk_fprintf(hFile, "\nAdjusted times:\n"); cr_time -= sec_skew; m_time -= sec_skew; a_time -= sec_skew; c_time -= sec_skew; tsk_fprintf(hFile, "Created:\t%s", ctime(&cr_time)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&m_time)); tsk_fprintf(hFile, "MFT Modified:\t%s", ctime(&c_time)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&a_time)); cr_time += sec_skew; m_time += sec_skew; a_time += sec_skew; c_time += sec_skew; tsk_fprintf(hFile, "\nOriginal times:\n"); } tsk_fprintf(hFile, "Created:\t%s", ctime(&cr_time)); tsk_fprintf(hFile, "File Modified:\t%s", ctime(&m_time)); tsk_fprintf(hFile, "MFT Modified:\t%s", ctime(&c_time)); tsk_fprintf(hFile, "Accessed:\t%s", ctime(&a_time)); } /* $OBJECT_ID Information */ fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_OBJID); if (fs_attr) { ntfs_attr_objid *objid = (ntfs_attr_objid *) fs_attr->rd.buf; uint64_t id1, id2; tsk_fprintf(hFile, "\n$OBJECT_ID Attribute Values:\n"); id1 = tsk_getu64(fs->endian, objid->objid1); id2 = tsk_getu64(fs->endian, objid->objid2); tsk_fprintf(hFile, "Object Id: %.8" PRIx32 "-%.4" PRIx16 "-%.4" PRIx16 "-%.4" PRIx16 "-%.12" PRIx64 "\n", (uint32_t) (id2 >> 32) & 0xffffffff, (uint16_t) (id2 >> 16) & 0xffff, (uint16_t) (id2 & 0xffff), (uint16_t) (id1 >> 48) & 0xffff, (uint64_t) (id1 & (uint64_t) 0x0000ffffffffffffULL)); /* The rest of the fields do not always exist. Check the attr size */ if (fs_attr->size > 16) { id1 = tsk_getu64(fs->endian, objid->orig_volid1); id2 = tsk_getu64(fs->endian, objid->orig_volid2); tsk_fprintf(hFile, "Birth Volume Id: %.8" PRIx32 "-%.4" PRIx16 "-%.4" PRIx16 "-%.4" PRIx16 "-%.12" PRIx64 "\n", (uint32_t) (id2 >> 32) & 0xffffffff, (uint16_t) (id2 >> 16) & 0xffff, (uint16_t) (id2 & 0xffff), (uint16_t) (id1 >> 48) & 0xffff, (uint64_t) (id1 & (uint64_t) 0x0000ffffffffffffULL)); } if (fs_attr->size > 32) { id1 = tsk_getu64(fs->endian, objid->orig_objid1); id2 = tsk_getu64(fs->endian, objid->orig_objid2); tsk_fprintf(hFile, "Birth Object Id: %.8" PRIx32 "-%.4" PRIx16 "-%.4" PRIx16 "-%.4" PRIx16 "-%.12" PRIx64 "\n", (uint32_t) (id2 >> 32) & 0xffffffff, (uint16_t) (id2 >> 16) & 0xffff, (uint16_t) (id2 & 0xffff), (uint16_t) (id1 >> 48) & 0xffff, (uint64_t) (id1 & (uint64_t) 0x0000ffffffffffffULL)); } if (fs_attr->size > 48) { id1 = tsk_getu64(fs->endian, objid->orig_domid1); id2 = tsk_getu64(fs->endian, objid->orig_domid2); tsk_fprintf(hFile, "Birth Domain Id: %.8" PRIx32 "-%.4" PRIx16 "-%.4" PRIx16 "-%.4" PRIx16 "-%.12" PRIx64 "\n", (uint32_t) (id2 >> 32) & 0xffffffff, (uint16_t) (id2 >> 16) & 0xffff, (uint16_t) (id2 & 0xffff), (uint16_t) (id1 >> 48) & 0xffff, (uint64_t) (id1 & (uint64_t) 0x0000ffffffffffffULL)); } } /* Attribute List Information */ fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, NTFS_ATYPE_ATTRLIST); if (fs_attr) { char *buf; ntfs_attrlist *list; uintptr_t endaddr; TSK_FS_LOAD_FILE load_file; tsk_fprintf(hFile, "\n$ATTRIBUTE_LIST Attribute Values:\n"); /* Get a copy of the attribute list stream */ load_file.total = load_file.left = (size_t) fs_attr->size; load_file.cur = load_file.base = buf = tsk_malloc((size_t) fs_attr->size); if (buf == NULL) { return 1; } endaddr = (uintptr_t) buf + (uintptr_t) fs_attr->size; if (tsk_fs_attr_walk(fs_attr, 0, tsk_fs_load_file_action, (void *) &load_file)) { tsk_fprintf(hFile, "error reading attribute list buffer\n"); tsk_error_reset(); goto egress; } /* this value should be zero, if not then we didn't read all of the * buffer */ if (load_file.left > 0) { tsk_fprintf(hFile, "error reading attribute list buffer\n"); goto egress; } /* Process the list & print the details */ for (list = (ntfs_attrlist *) buf; (list) && ((uintptr_t) list < endaddr) && (tsk_getu16(fs->endian, list->len) > 0); list = (ntfs_attrlist *) ((uintptr_t) list + tsk_getu16(fs->endian, list->len))) { tsk_fprintf(hFile, "Type: %" PRIu32 "-%" PRIu16 " \tMFT Entry: %" PRIu64 " \tVCN: %" PRIu64 "\n", tsk_getu32(fs->endian, list->type), tsk_getu16(fs->endian, list->id), (uint64_t) tsk_getu48(fs->endian, list->file_ref), tsk_getu64(fs->endian, list->start_vcn)); } egress: free(buf); } /* Print all of the attributes */ tsk_fprintf(hFile, "\nAttributes: \n"); if (fs_file->meta->attr) { int cnt, i; // cycle through the attributes cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { char type[512]; const TSK_FS_ATTR *fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; if (ntfs_attrname_lookup(fs, fs_attr->type, type, 512)) { tsk_fprintf(hFile, "error looking attribute name\n"); break; } /* print the layout if it is non-resident and not "special" */ if (fs_attr->flags & TSK_FS_ATTR_NONRES) { NTFS_PRINT_ADDR print_addr; tsk_fprintf(hFile, "Type: %s (%" PRIu32 "-%" PRIu16 ") Name: %s Non-Resident%s%s%s size: %" PRIuOFF " init_size: %" PRIuOFF "\n", type, fs_attr->type, fs_attr->id, (fs_attr->name) ? fs_attr->name : "N/A", (fs_attr->flags & TSK_FS_ATTR_ENC) ? ", Encrypted" : "", (fs_attr->flags & TSK_FS_ATTR_COMP) ? ", Compressed" : "", (fs_attr->flags & TSK_FS_ATTR_SPARSE) ? ", Sparse" : "", fs_attr->size, fs_attr->nrd.initsize); print_addr.idx = 0; print_addr.hFile = hFile; if (tsk_fs_file_walk_type(fs_file, fs_attr->type, fs_attr->id, (TSK_FS_FILE_WALK_FLAG_AONLY | TSK_FS_FILE_WALK_FLAG_SLACK), print_addr_act, (void *) &print_addr)) { tsk_fprintf(hFile, "\nError walking file\n"); tsk_error_print(hFile); tsk_error_reset(); } if (print_addr.idx != 0) tsk_fprintf(hFile, "\n"); } else { tsk_fprintf(hFile, "Type: %s (%" PRIu32 "-%" PRIu16 ") Name: %s Resident%s%s%s size: %" PRIuOFF "\n", type, fs_attr->type, fs_attr->id, (fs_attr->name) ? fs_attr->name : "N/A", (fs_attr->flags & TSK_FS_ATTR_ENC) ? ", Encrypted" : "", (fs_attr->flags & TSK_FS_ATTR_COMP) ? ", Compressed" : "", (fs_attr->flags & TSK_FS_ATTR_SPARSE) ? ", Sparse" : "", fs_attr->size); } } } tsk_fs_file_close(fs_file); return 0; } /* JOURNAL CODE - MOVE TO NEW FILE AT SOME POINT */ uint8_t ntfs_jopen(TSK_FS_INFO * fs, TSK_INUM_T inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "NTFS Journal is not yet supported\n"); return 1; } uint8_t ntfs_jentry_walk(TSK_FS_INFO * fs, int flags, TSK_FS_JENTRY_WALK_CB a_action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "NTFS Journal is not yet supported\n"); return 1; } uint8_t ntfs_jblk_walk(TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, int flags, TSK_FS_JBLK_WALK_CB a_action, void *ptr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "NTFS Journal is not yet supported\n"); return 1; } static TSK_FS_ATTR_TYPE_ENUM ntfs_get_default_attr_type(const TSK_FS_FILE * a_file) { if ((a_file == NULL) || (a_file->meta == NULL)) return TSK_FS_ATTR_TYPE_DEFAULT; /* Use DATA for files and IDXROOT for dirs */ if (a_file->meta->type == TSK_FS_META_TYPE_DIR) return TSK_FS_ATTR_TYPE_NTFS_IDXROOT; else return TSK_FS_ATTR_TYPE_NTFS_DATA; } static void ntfs_close(TSK_FS_INFO * fs) { NTFS_INFO *ntfs = (NTFS_INFO *) fs; if (fs == NULL) return; #if TSK_USE_SID if (ntfs->sii_data.buffer) free(ntfs->sii_data.buffer); ntfs->sii_data.buffer = NULL; if (ntfs->sds_data.buffer) free(ntfs->sds_data.buffer); ntfs->sds_data.buffer = NULL; #endif fs->tag = 0; free((char *) ntfs->mft); free((char *) ntfs->fs); tsk_fs_attr_run_free(ntfs->bmap); free(ntfs->bmap_buf); tsk_fs_file_close(ntfs->mft_file); if (fs->list_inum_named) { tsk_list_free(fs->list_inum_named); fs->list_inum_named = NULL; } if (ntfs->orphan_map) ntfs_orphan_map_free(ntfs); free(fs); } /** * Open part of a disk image as an NTFS file system. * * @param img_info Disk image to analyze * @param offset Byte offset where NTFS file system starts * @param ftype Specific type of NTFS file system * @param test NOT USED * @returns NULL on error or if data is not an NTFS file system */ TSK_FS_INFO * ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype, uint8_t test) { char *myname = "ntfs_open"; NTFS_INFO *ntfs; TSK_FS_INFO *fs; unsigned int len; ssize_t cnt; // clean up any error messages that are lying around tsk_error_reset(); if (TSK_FS_TYPE_ISNTFS(ftype) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "Invalid FS type in ntfs_open"); return NULL; } if ((ntfs = (NTFS_INFO *) tsk_malloc(sizeof(*ntfs))) == NULL) { return NULL; } fs = &(ntfs->fs_info); fs->ftype = TSK_FS_TYPE_NTFS; fs->duname = "Cluster"; fs->flags = TSK_FS_INFO_FLAG_HAVE_SEQ; fs->tag = TSK_FS_INFO_TAG; fs->img_info = img_info; fs->offset = offset; ntfs->loading_the_MFT = 0; ntfs->bmap = NULL; ntfs->bmap_buf = NULL; /* Read the boot sector */ len = roundup(sizeof(ntfs_sb), img_info->sector_size); ntfs->fs = (ntfs_sb *) tsk_malloc(len); if (ntfs->fs == NULL) { fs->tag = 0; free(ntfs); return NULL; } cnt = tsk_fs_read(fs, (TSK_OFF_T) 0, (char *) ntfs->fs, len); if (cnt != len) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "%s: Error reading boot sector.", myname); fs->tag = 0; free(ntfs->fs); free(ntfs); return NULL; } /* Check the magic value */ if (tsk_fs_guessu16(fs, ntfs->fs->magic, NTFS_FS_MAGIC)) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (magic)"); return NULL; } /* * block calculations : although there are no blocks in ntfs, * we are using a cluster as a "block" */ ntfs->ssize_b = tsk_getu16(fs->endian, ntfs->fs->ssize); if ((ntfs->ssize_b == 0) || (ntfs->ssize_b % 512)) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (invalid sector size)"); return NULL; } if ((ntfs->fs->csize != 0x01) && (ntfs->fs->csize != 0x02) && (ntfs->fs->csize != 0x04) && (ntfs->fs->csize != 0x08) && (ntfs->fs->csize != 0x10) && (ntfs->fs->csize != 0x20) && (ntfs->fs->csize != 0x40) && (ntfs->fs->csize != 0x80)) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (invalid cluster size)"); return NULL; } ntfs->csize_b = ntfs->fs->csize * ntfs->ssize_b; fs->first_block = 0; /* This field is defined as 64-bits but according to the * NTFS drivers in Linux, windows only uses 32-bits */ fs->block_count = (TSK_DADDR_T) tsk_getu32(fs->endian, ntfs->fs->vol_size_s) / ntfs->fs->csize; if (fs->block_count == 0) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (volume size is 0)"); return NULL; } fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = ntfs->csize_b; fs->dev_bsize = img_info->sector_size; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < fs->block_count) fs->last_block_act = (img_info->size - offset) / fs->block_size - 1; if (ntfs->fs->mft_rsize_c > 0) ntfs->mft_rsize_b = ntfs->fs->mft_rsize_c * ntfs->csize_b; else /* if the mft_rsize_c is not > 0, then it is -log2(rsize_b) */ ntfs->mft_rsize_b = 1 << -ntfs->fs->mft_rsize_c; if ((ntfs->mft_rsize_b == 0) || (ntfs->mft_rsize_b % 512)) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (invalid MFT entry size)"); return NULL; } if (ntfs->fs->idx_rsize_c > 0) ntfs->idx_rsize_b = ntfs->fs->idx_rsize_c * ntfs->csize_b; else /* if the idx_rsize_c is not > 0, then it is -log2(rsize_b) */ ntfs->idx_rsize_b = 1 << -ntfs->fs->idx_rsize_c; if ((ntfs->idx_rsize_b == 0) || (ntfs->idx_rsize_b % 512)) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (invalid idx record size)"); return NULL; } ntfs->root_mft_addr = tsk_getu64(fs->endian, ntfs->fs->mft_clust) * ntfs->csize_b; if (tsk_getu64(fs->endian, ntfs->fs->mft_clust) > fs->last_block) { fs->tag = 0; free(ntfs->fs); free(ntfs); tsk_error_reset(); tsk_errno = TSK_ERR_FS_MAGIC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Not a NTFS file system (invalid starting MFT clust)"); return NULL; } /* * Set the function pointers (before we start calling internal functions) */ fs->inode_walk = ntfs_inode_walk; fs->block_walk = ntfs_block_walk; fs->block_getflags = ntfs_block_getflags; fs->get_default_attr_type = ntfs_get_default_attr_type; fs->load_attrs = ntfs_load_attrs; fs->file_add_meta = ntfs_inode_lookup; fs->dir_open_meta = ntfs_dir_open_meta; fs->fsstat = ntfs_fsstat; fs->fscheck = ntfs_fscheck; fs->istat = ntfs_istat; fs->close = ntfs_close; fs->name_cmp = ntfs_name_cmp; fs->fread_owner_sid = ntfs_file_get_sidstr; fs->jblk_walk = ntfs_jblk_walk; fs->jentry_walk = ntfs_jentry_walk; fs->jopen = ntfs_jopen; fs->journ_inum = 0; /* * inode */ /* allocate the buffer to hold mft entries */ ntfs->mft = (ntfs_mft *) tsk_malloc(ntfs->mft_rsize_b); if (ntfs->mft == NULL) { fs->tag = 0; free(ntfs->fs); free(ntfs); return NULL; } ntfs->mnum = 0; fs->root_inum = NTFS_ROOTINO; fs->first_inum = NTFS_FIRSTINO; fs->last_inum = NTFS_LAST_DEFAULT_INO; ntfs->mft_data = NULL; /* load the data run for the MFT table into ntfs->mft */ ntfs->loading_the_MFT = 1; if ((ntfs->mft_file = tsk_fs_file_open_meta(fs, NULL, NTFS_MFT_MFT)) == NULL) { fs->tag = 0; free(ntfs->mft); free(ntfs->fs); free(ntfs); return NULL; } /* cache the data attribute * * This will likely be done already by proc_attrseq, but this * should be quick */ ntfs->mft_data = tsk_fs_attrlist_get(ntfs->mft_file->meta->attr, NTFS_ATYPE_DATA); if (!ntfs->mft_data) { fs->tag = 0; tsk_fs_file_close(ntfs->mft_file); free(ntfs->mft); free(ntfs->fs); free(ntfs); strncat(tsk_errstr2, " - Data Attribute not found in $MFT", TSK_ERRSTR_L - strlen(tsk_errstr2)); return NULL; } /* Get the inode count based on the table size */ fs->inum_count = ntfs->mft_data->size / ntfs->mft_rsize_b + 1; // we are adding 1 in this calc to account for Orphans directory fs->last_inum = fs->inum_count - 1; /* reset the flag that we are no longer loading $MFT */ ntfs->loading_the_MFT = 0; /* Volume ID */ for (fs->fs_id_used = 0; fs->fs_id_used < 8; fs->fs_id_used++) { fs->fs_id[fs->fs_id_used] = ntfs->fs->serial[fs->fs_id_used]; } /* load the version of the file system */ if (ntfs_load_ver(ntfs)) { fs->tag = 0; tsk_fs_file_close(ntfs->mft_file); free(ntfs->mft); free(ntfs->fs); free(ntfs); return NULL; } /* load the data block bitmap data run into ntfs_info */ if (ntfs_load_bmap(ntfs)) { fs->tag = 0; tsk_fs_file_close(ntfs->mft_file); free(ntfs->mft); free(ntfs->fs); free(ntfs); return NULL; } /* load the SID data into ntfs_info ($Secure - $SDS, $SDH, $SII */ #if TSK_USE_SID if (ntfs_load_secure(ntfs)) { fs->tag = 0; tsk_fs_file_close(ntfs->mft_file); free(ntfs->mft); free(ntfs->fs); free(ntfs); return NULL; } #endif // initialize the caches ntfs->attrdef = NULL; fs->list_inum_named = NULL; ntfs->orphan_map = NULL; if (tsk_verbose) { tsk_fprintf(stderr, "ssize: %" PRIu16 " csize: %d serial: %" PRIx64 "\n", tsk_getu16(fs->endian, ntfs->fs->ssize), ntfs->fs->csize, tsk_getu64(fs->endian, ntfs->fs->serial)); tsk_fprintf(stderr, "mft_rsize: %d idx_rsize: %d vol: %d mft: %" PRIu64 " mft_mir: %" PRIu64 "\n", ntfs->mft_rsize_b, ntfs->idx_rsize_b, (int) fs->block_count, tsk_getu64(fs->endian, ntfs->fs->mft_clust), tsk_getu64(fs->endian, ntfs->fs->mftm_clust)); } return fs; } sleuthkit-3.2.3/tsk3/fs/ntfs_dent.c000644 000765 000024 00000132534 11643647440 017772 0ustar00carrierstaff000000 000000 /* ** ntfs_dent ** The Sleuth Kit ** ** name layer support for the NTFS file system ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2009 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** ** Unicode added with support from I.D.E.A.L. Technology Corp (Aug '05) ** */ #include "tsk_fs_i.h" #include "tsk_ntfs.h" /** * \file ntfs_dent.c * NTFS file name processing internal functions. */ /* When we list deleted files in a directory, we need to look at all MFT entries * to find unallocated ones that point to the given directory as teh parent directory. * We cache these results in an "orphan map". */ /** \internal * Extend the number of addresses in the map buffer. * @param map map entry to extend * @returns 1 on error and 0 otherwise */ static uint8_t ntfs_orphan_map_extend(NTFS_PAR_MAP * map) { map->alloc_cnt += 8; if ((map->addrs = (TSK_INUM_T *) tsk_realloc(map->addrs, sizeof(TSK_INUM_T) * map->alloc_cnt)) == NULL) return 1; return 0; } /** \internal * Allocate a new map entry with a default address buffer. * @returns NULL on error */ static NTFS_PAR_MAP * ntfs_orphan_map_alloc() { NTFS_PAR_MAP *map; if ((map = (NTFS_PAR_MAP *) tsk_malloc((size_t) sizeof(NTFS_PAR_MAP))) == NULL) { return NULL; } map->alloc_cnt = 8; if ((map->addrs = (TSK_INUM_T *) tsk_malloc(sizeof(TSK_INUM_T) * map->alloc_cnt)) == NULL) { free(map); return NULL; } return map; } /** \internal * Add a parent and child pair to the map stored in NTFS_INFO * @param ntfs structure to add the pair to * @param par Parent address * @param child Child address * @returns 1 on error */ static uint8_t ntfs_orphan_map_add(NTFS_INFO * ntfs, TSK_INUM_T par, TSK_INUM_T child) { NTFS_PAR_MAP *map = NULL; NTFS_PAR_MAP *tmp = NULL; // look for the parent in an existing list for (tmp = ntfs->orphan_map; tmp; tmp = tmp->next) { if (tmp->par_addr == par) { map = tmp; break; } else if (tmp->par_addr > par) { break; } } // add a new entry for it if (map == NULL) { if ((map = ntfs_orphan_map_alloc()) == NULL) { return 1; } map->par_addr = par; if (ntfs->orphan_map == NULL) { ntfs->orphan_map = map; } else { NTFS_PAR_MAP *prev = NULL; for (tmp = ntfs->orphan_map; tmp; tmp = tmp->next) { if (tmp->par_addr > par) { map->next = tmp; if (prev == NULL) ntfs->orphan_map = map; else prev->next = map; break; } prev = tmp; } // at the end of the list if (map->next == NULL) prev->next = map; } } // add this address to it if (map->used_cnt == map->alloc_cnt) if (ntfs_orphan_map_extend(map)) return 1; map->addrs[map->used_cnt] = child; map->used_cnt++; return 0; } /** \internal * Look up a map entry by the parent address. * @param ntfs File system that has already been analyzed * @param par Parent inode to find child files for * @returns NULL on error */ static NTFS_PAR_MAP * ntfs_orphan_map_get(NTFS_INFO * ntfs, TSK_INUM_T par) { NTFS_PAR_MAP *tmp = NULL; // look for the parent in an existing list for (tmp = ntfs->orphan_map; tmp; tmp = tmp->next) { if (tmp->par_addr == par) { return tmp; } else if (tmp->par_addr > par) { return NULL; } } return NULL; } void ntfs_orphan_map_free(NTFS_INFO * a_ntfs) { NTFS_PAR_MAP *tmp = NULL; if (a_ntfs->orphan_map == NULL) return; tmp = a_ntfs->orphan_map; while (tmp) { NTFS_PAR_MAP *tmp2; free(tmp->addrs); tmp2 = tmp->next; free(tmp); tmp = tmp2; } a_ntfs->orphan_map = NULL; } /* inode_walk callback that is used to populate the orphan_map * structure in NTFS_INFO */ static TSK_WALK_RET_ENUM ntfs_orphan_act(TSK_FS_FILE * fs_file, void *ptr) { NTFS_INFO *ntfs = (NTFS_INFO *) fs_file->fs_info; TSK_FS_META_NAME_LIST *fs_name_list; /* go through each file name structure */ fs_name_list = fs_file->meta->name2; while (fs_name_list) { if (ntfs_orphan_map_add(ntfs, fs_name_list->par_inode, fs_file->meta->addr)) return TSK_WALK_ERROR; fs_name_list = fs_name_list->next; } return TSK_WALK_CONT; } /****************/ static uint8_t ntfs_dent_copy(NTFS_INFO * ntfs, ntfs_idxentry * idxe, TSK_FS_NAME * fs_name) { ntfs_attr_fname *fname = (ntfs_attr_fname *) & idxe->stream; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; UTF16 *name16; UTF8 *name8; int retVal; fs_name->meta_addr = tsk_getu48(fs->endian, idxe->file_ref); fs_name->meta_seq = tsk_getu16(fs->endian, idxe->seq_num); name16 = (UTF16 *) & fname->name; name8 = (UTF8 *) fs_name->name; retVal = tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) ((uintptr_t) name16 + fname->nlen * 2), &name8, (UTF8 *) ((uintptr_t) name8 + fs_name->name_size), TSKlenientConversion); if (retVal != TSKconversionOK) { *name8 = '\0'; if (tsk_verbose) tsk_fprintf(stderr, "Error converting NTFS name to UTF8: %d %" PRIuINUM, retVal, fs_name->meta_addr); } /* Make sure it is NULL Terminated */ if ((uintptr_t) name8 > (uintptr_t) fs_name->name + fs_name->name_size) fs_name->name[fs_name->name_size] = '\0'; else *name8 = '\0'; if (tsk_getu64(fs->endian, fname->flags) & NTFS_FNAME_FLAGS_DIR) fs_name->type = TSK_FS_NAME_TYPE_DIR; else fs_name->type = TSK_FS_NAME_TYPE_REG; fs_name->flags = 0; return 0; } /* This is a sanity check to see if the time is valid * it is divided by 100 to keep it in a 32-bit integer */ static uint8_t is_time(uint64_t t) { #define SEC_BTWN_1601_1970_DIV100 ((369*365 + 89) * 24 * 36) #define SEC_BTWN_1601_2010_DIV100 (SEC_BTWN_1601_1970_DIV100 + (40*365 + 6) * 24 * 36) t /= 1000000000; /* put the time in seconds div by additional 100 */ if (!t) return 0; if (t < SEC_BTWN_1601_1970_DIV100) return 0; if (t > SEC_BTWN_1601_2010_DIV100) return 0; return 1; } /** * Process a lsit of index entries and add to FS_DIR * * @param a_is_del Set to 1 if these entries are for a deleted directory * @param idxe Buffer with index entries to process * @param idxe_len Length of idxe buffer (in bytes) * @param used_len Length of data as reported by idexlist header (everything * after which and less then idxe_len is considered deleted) * * @returns 1 to stop, 0 on success, and -1 on error */ // @@@ Should make a_idxe const and use internal pointer in function loop static TSK_RETVAL_ENUM ntfs_proc_idxentry(NTFS_INFO * a_ntfs, TSK_FS_DIR * a_fs_dir, uint8_t a_is_del, ntfs_idxentry * a_idxe, uint32_t a_idxe_len, uint32_t a_used_len) { uintptr_t endaddr, endaddr_alloc; TSK_FS_NAME *fs_name; TSK_FS_INFO *fs = (TSK_FS_INFO *) & a_ntfs->fs_info; if ((fs_name = tsk_fs_name_alloc(NTFS_MAXNAMLEN_UTF8, 0)) == NULL) { return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Processing index entry: %" PRIu64 " Size: %" PRIu32 " Len: %" PRIu32 "\n", (uint64_t) ((uintptr_t) a_idxe), a_idxe_len, a_used_len); /* Sanity check */ if (a_idxe_len < a_used_len) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_proc_idxentry: Allocated length of index entries is larger than buffer length"); return TSK_ERR; } /* where is the end of the buffer */ endaddr = ((uintptr_t) a_idxe + a_idxe_len); /* where is the end of the allocated data */ endaddr_alloc = ((uintptr_t) a_idxe + a_used_len); /* cycle through the index entries, based on provided size */ while (((uintptr_t) & (a_idxe->stream) + sizeof(ntfs_attr_fname)) < endaddr) { ntfs_attr_fname *fname = (ntfs_attr_fname *) & a_idxe->stream; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: New IdxEnt: %" PRIu64 " $FILE_NAME Entry: %" PRIu64 " File Ref: %" PRIu64 " IdxEnt Len: %" PRIu16 " StrLen: %" PRIu16 "\n", (uint64_t) ((uintptr_t) a_idxe), (uint64_t) ((uintptr_t) fname), (uint64_t) tsk_getu48(fs->endian, a_idxe->file_ref), tsk_getu16(fs->endian, a_idxe->idxlen), tsk_getu16(fs->endian, a_idxe->strlen)); /* perform some sanity checks on index buffer head * and advance by 4-bytes if invalid */ if ((tsk_getu48(fs->endian, a_idxe->file_ref) > fs->last_inum) || (tsk_getu48(fs->endian, a_idxe->file_ref) < fs->first_inum) || (tsk_getu16(fs->endian, a_idxe->idxlen) <= tsk_getu16(fs->endian, a_idxe->strlen)) || (tsk_getu16(fs->endian, a_idxe->idxlen) % 4) || (tsk_getu16(fs->endian, a_idxe->idxlen) > a_idxe_len)) { a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + 4); continue; } /* do some sanity checks on the deleted entries */ if ((tsk_getu16(fs->endian, a_idxe->strlen) == 0) || (((uintptr_t) a_idxe + tsk_getu16(fs->endian, a_idxe->idxlen)) > endaddr_alloc)) { /* name space checks */ if ((fname->nspace != NTFS_FNAME_POSIX) && (fname->nspace != NTFS_FNAME_WIN32) && (fname->nspace != NTFS_FNAME_DOS) && (fname->nspace != NTFS_FNAME_WINDOS)) { a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + 4); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Skipping because of invalid name space\n"); continue; } if ((tsk_getu64(fs->endian, fname->alloc_fsize) < tsk_getu64(fs->endian, fname->real_fsize)) || (fname->nlen == 0) || (*(uint8_t *) & fname->name == 0)) { a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + 4); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Skipping because of reported file sizes, name length, or NULL name\n"); continue; } if ((is_time(tsk_getu64(fs->endian, fname->crtime)) == 0) || (is_time(tsk_getu64(fs->endian, fname->atime)) == 0) || (is_time(tsk_getu64(fs->endian, fname->mtime)) == 0)) { a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + 4); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Skipping because of invalid times\n"); continue; } } /* For all fname entries, there will exist a DOS style 8.3 * entry. We don't process those because we already processed * them before in their full version. If the type is * full POSIX or WIN32 that does not satisfy DOS, then a * type NTFS_FNAME_DOS will exist. If the name is WIN32, * but already satisfies DOS, then a type NTFS_FNAME_WINDOS * will exist * * Note that we could be missing some info from deleted files * if the windows version was deleted and the DOS wasn't... * * @@@ This should be added to the shrt_name entry of TSK_FS_NAME. The short * name entry typically comes after the long name */ if (fname->nspace == NTFS_FNAME_DOS) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Skipping because of name space: %d\n", fname->nspace); goto incr_entry; } /* Copy it into the generic form */ if (ntfs_dent_copy(a_ntfs, a_idxe, fs_name)) { if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Skipping because error copying dent_entry\n"); goto incr_entry; } /* * Check if this entry is deleted * * The final check is to see if the end of this entry is * within the space that the idxallocbuf claimed was valid OR * if the parent directory is deleted */ if ((a_is_del == 1) || (tsk_getu16(fs->endian, a_idxe->strlen) == 0) || (((uintptr_t) a_idxe + tsk_getu16(fs->endian, a_idxe->idxlen)) > endaddr_alloc)) { fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; } else { fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_proc_idxentry: Entry Details of %s: Str Len: %" PRIu16 " Len to end after current: %" PRIu64 " flags: %x\n", fs_name->name, tsk_getu16(fs->endian, a_idxe->strlen), (uint64_t) (endaddr_alloc - (uintptr_t) a_idxe - tsk_getu16(fs->endian, a_idxe->idxlen)), fs_name->flags); if (tsk_fs_dir_add(a_fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } incr_entry: /* the theory here is that deleted entries have strlen == 0 and * have been found to have idxlen == 16 * * if the strlen is 0, then guess how much the indexlen was * before it was deleted */ /* 16: size of idxentry before stream * 66: size of fname before name * 2*nlen: size of name (in unicode) */ if (tsk_getu16(fs->endian, a_idxe->strlen) == 0) { a_idxe = (ntfs_idxentry *) ((((uintptr_t) a_idxe + 16 + 66 + 2 * fname->nlen + 3) / 4) * 4); } else { a_idxe = (ntfs_idxentry *) ((uintptr_t) a_idxe + tsk_getu16(fs->endian, a_idxe->idxlen)); } } /* end of loop of index entries */ tsk_fs_name_free(fs_name); return TSK_OK; } /* * remove the update sequence values that are changed in the last two * bytes of each sector * * return 1 on error and 0 on success */ static uint8_t ntfs_fix_idxrec(NTFS_INFO * ntfs, ntfs_idxrec * idxrec, uint32_t len) { int i; uint16_t orig_seq; TSK_FS_INFO *fs = (TSK_FS_INFO *) & ntfs->fs_info; ntfs_upd *upd; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_fix_idxrec: Fixing idxrec: %" PRIu64 " Len: %" PRIu32 "\n", (uint64_t) ((uintptr_t) idxrec), len); /* sanity check so we don't run over in the next loop */ if ((unsigned int) ((tsk_getu16(fs->endian, idxrec->upd_cnt) - 1) * ntfs->ssize_b) > len) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "fix_idxrec: More Update Sequence Entries than idx record size"); return 1; } /* Apply the update sequence structure template */ upd = (ntfs_upd *) ((uintptr_t) idxrec + tsk_getu16(fs->endian, idxrec->upd_off)); /* Get the sequence value that each 16-bit value should be */ orig_seq = tsk_getu16(fs->endian, upd->upd_val); /* cycle through each sector */ for (i = 1; i < tsk_getu16(fs->endian, idxrec->upd_cnt); i++) { /* The offset into the buffer of the value to analyze */ int offset = i * ntfs->ssize_b - 2; uint8_t *new_val, *old_val; /* get the current sequence value */ uint16_t cur_seq = tsk_getu16(fs->endian, (uintptr_t) idxrec + offset); if (cur_seq != orig_seq) { /* get the replacement value */ uint16_t cur_repl = tsk_getu16(fs->endian, &upd->upd_seq + (i - 1) * 2); tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "fix_idxrec: Incorrect update sequence value in index buffer\nUpdate Value: 0x%" PRIx16 " Actual Value: 0x%" PRIx16 " Replacement Value: 0x%" PRIx16 "\nThis is typically because of a corrupted entry", orig_seq, cur_seq, cur_repl); return 1; } new_val = &upd->upd_seq + (i - 1) * 2; old_val = (uint8_t *) ((uintptr_t) idxrec + offset); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_fix_idxrec: upd_seq %i Replacing: %.4" PRIx16 " With: %.4" PRIx16 "\n", i, tsk_getu16(fs->endian, old_val), tsk_getu16(fs->endian, new_val)); *old_val++ = *new_val++; *old_val = *new_val; } return 0; } /** \internal * Process a directory and load up FS_DIR with the entries. If a pointer to * an already allocated FS_DIR struture is given, it will be cleared. If no existing * FS_DIR structure is passed (i.e. NULL), then a new one will be created. If the return * value is error or corruption, then the FS_DIR structure could * have entries (depending on when the error occured). * * @param a_fs File system to analyze * @param a_fs_dir Pointer to FS_DIR pointer. Can contain an already allocated * structure or a new structure. * @param a_addr Address of directory to process. * @returns error, corruption, ok etc. */ TSK_RETVAL_ENUM ntfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr) { NTFS_INFO *ntfs = (NTFS_INFO *) a_fs; TSK_FS_DIR *fs_dir; const TSK_FS_ATTR *fs_attr_root = NULL; const TSK_FS_ATTR *fs_attr_idx; char *idxalloc; ntfs_idxentry *idxe; ntfs_idxroot *idxroot; ntfs_idxelist *idxelist; ntfs_idxrec *idxrec_p, *idxrec; int off; TSK_OFF_T idxalloc_len; TSK_FS_LOAD_FILE load_file; NTFS_PAR_MAP *map; /* In this function, we will return immediately if we get an error. * If we get corruption though, we will record that in 'retval_final' * and continue processing. */ TSK_RETVAL_ENUM retval_final = TSK_OK; TSK_RETVAL_ENUM retval_tmp; /* sanity check */ if (a_addr < a_fs->first_inum || a_addr > a_fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_WALK_RNG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_dir_open_meta: inode value: %" PRIuINUM "\n", a_addr); return TSK_ERR; } else if (a_fs_dir == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_dir_open_meta: NULL fs_attr argument given"); return TSK_ERR; } if (tsk_verbose) tsk_fprintf(stderr, "ntfs_open_dir: Processing directory %" PRIuINUM "\n", a_addr); fs_dir = *a_fs_dir; if (fs_dir) { tsk_fs_dir_reset(fs_dir); } else { if ((*a_fs_dir = fs_dir = tsk_fs_dir_alloc(a_fs, a_addr, 128)) == NULL) { return TSK_ERR; } } // handle the orphan directory if its contents were requested if (a_addr == TSK_FS_ORPHANDIR_INUM(a_fs)) { return tsk_fs_dir_find_orphans(a_fs, fs_dir); } /* Get the inode and verify it has attributes */ if ((fs_dir->fs_file = tsk_fs_file_open_meta(a_fs, NULL, a_addr)) == NULL) { strncat(tsk_errstr2, " - ntfs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_COR; } if (!(fs_dir->fs_file->meta->attr)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "dent_walk: Error: Directory address %" PRIuINUM " has no attributes", a_addr); return TSK_COR; } /* * Read the Index Root Attribute -- we do some sanity checking here * to report errors before we start to make up data for the "." and ".." * entries */ fs_attr_root = tsk_fs_attrlist_get(fs_dir->fs_file->meta->attr, NTFS_ATYPE_IDXROOT); if (!fs_attr_root) { strncat(tsk_errstr2, " - dent_walk: $IDX_ROOT not found", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_COR; } if (fs_attr_root->flags & TSK_FS_ATTR_NONRES) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "dent_walk: $IDX_ROOT is not resident - it should be"); return TSK_COR; } idxroot = (ntfs_idxroot *) fs_attr_root->rd.buf; /* Verify that the attribute type is $FILE_NAME */ if (tsk_getu32(a_fs->endian, idxroot->type) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "dent_walk: Attribute type in index root is 0"); return TSK_COR; } else if (tsk_getu32(a_fs->endian, idxroot->type) != NTFS_ATYPE_FNAME) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "ERROR: Directory index is sorted by type: %" PRIu32 ".\nOnly $FNAME is currently supported", tsk_getu32(a_fs->endian, idxroot->type)); return TSK_COR; } /* Get the header of the index entry list */ idxelist = &idxroot->list; /* Get the offset to the start of the index entry list */ idxe = (ntfs_idxentry *) ((uintptr_t) idxelist + tsk_getu32(a_fs->endian, idxelist->begin_off)); /* * NTFS does not have "." and ".." entries in the index trees * (except for a "." entry in the root directory) * * So, we'll make 'em up by making a TSK_FS_NAME structure for * a '.' and '..' entry and call the action */ if (a_addr != a_fs->root_inum) { // && (flags & TSK_FS_NAME_FLAG_ALLOC)) { TSK_FS_NAME *fs_name; TSK_FS_META_NAME_LIST *fs_name_list; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Creating . and .. entries\n"); if ((fs_name = tsk_fs_name_alloc(16, 0)) == NULL) { return TSK_ERR; } /* * "." */ fs_name->meta_addr = a_addr; fs_name->meta_seq = fs_dir->fs_file->meta->seq; fs_name->type = TSK_FS_NAME_TYPE_DIR; strcpy(fs_name->name, "."); fs_name->flags = TSK_FS_NAME_FLAG_ALLOC; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } /* * ".." */ strcpy(fs_name->name, ".."); fs_name->type = TSK_FS_NAME_TYPE_DIR; /* The fs_name structure holds the parent inode value, so we * just cycle using those */ for (fs_name_list = fs_dir->fs_file->meta->name2; fs_name_list != NULL; fs_name_list = fs_name_list->next) { fs_name->meta_addr = fs_name_list->par_inode; fs_name->meta_seq = fs_name_list->par_seq; if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } } tsk_fs_name_free(fs_name); fs_name = NULL; } /* Now we return to processing the Index Root Attribute */ if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Processing $IDX_ROOT of inum %" PRIuINUM "\n", a_addr); /* Verify the offset pointers */ if ((tsk_getu32(a_fs->endian, idxelist->seqend_off) < tsk_getu32(a_fs->endian, idxelist->begin_off)) || (tsk_getu32(a_fs->endian, idxelist->bufend_off) < tsk_getu32(a_fs->endian, idxelist->seqend_off)) || (((uintptr_t) idxe + tsk_getu32(a_fs->endian, idxelist->bufend_off)) > ((uintptr_t) fs_attr_root->rd.buf + fs_attr_root->rd.buf_size))) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error: Index list offsets are invalid on entry: %" PRIuINUM, fs_dir->fs_file->meta->addr); return TSK_COR; } retval_tmp = ntfs_proc_idxentry(ntfs, fs_dir, (fs_dir->fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, tsk_getu32(a_fs->endian, idxelist->bufend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off), tsk_getu32(a_fs->endian, idxelist->seqend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off)); // stop if we get an error, continue if we got corruption if (retval_tmp == TSK_ERR) { return TSK_ERR; } else if (retval_tmp == TSK_COR) { retval_final = TSK_COR; } /* * get the index allocation attribute if it exists (it doesn't for * small directories */ fs_attr_idx = tsk_fs_attrlist_get(fs_dir->fs_file->meta->attr, NTFS_ATYPE_IDXALLOC); /* if we don't have an index alloc then return, we have processed * all of the entries */ if (!fs_attr_idx) { if (tsk_getu32(a_fs->endian, idxelist->flags) & NTFS_IDXELIST_CHILD) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error: $IDX_ROOT says there should be children, but there isn't"); return TSK_COR; } } else { if (fs_attr_idx->flags & TSK_FS_ATTR_RES) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "$IDX_ALLOC is Resident - it shouldn't be"); return TSK_COR; } /* * Copy the index allocation run into a big buffer */ idxalloc_len = fs_attr_idx->nrd.allocsize; if ((idxalloc = tsk_malloc((size_t) idxalloc_len)) == NULL) { return TSK_ERR; } /* Fill in the loading data structure */ load_file.total = load_file.left = (size_t) idxalloc_len; load_file.cur = load_file.base = idxalloc; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Copying $IDX_ALLOC into buffer\n"); if (tsk_fs_attr_walk(fs_attr_idx, TSK_FS_FILE_WALK_FLAG_SLACK, tsk_fs_load_file_action, (void *) &load_file)) { free(idxalloc); strncat(tsk_errstr2, " - ntfs_dir_open_meta", TSK_ERRSTR_L - strlen(tsk_errstr2)); return TSK_COR; // this could be an error though } /* Not all of the directory was copied, so we exit */ if (load_file.left > 0) { free(idxalloc); tsk_error_reset(); tsk_errno = TSK_ERR_FS_FWALK; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error reading directory contents: %" PRIuINUM "\n", a_addr); return TSK_COR; } /* * The idxalloc is a big buffer that contains one or more * idx buffer structures. Each idxrec is a node in the B-Tree. * We do not process the tree as a tree because then we could * not find the deleted file names. * * Therefore, we scan the big buffer looking for the index record * structures. We save a pointer to the known beginning (idxrec_p). * Then we scan for the beginning of the next one (idxrec) and process * everything in the middle as an ntfs_idxrec. We can't use the * size given because then we wouldn't see the deleted names */ /* Set the previous pointer to NULL */ idxrec_p = idxrec = NULL; /* Loop by cluster size */ for (off = 0; off < idxalloc_len; off += ntfs->csize_b) { uint32_t list_len, rec_len; idxrec = (ntfs_idxrec *) & idxalloc[off]; if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Index Buffer Offset: %d Magic: %" PRIx32 "\n", off, tsk_getu32(a_fs->endian, idxrec->magic)); /* Is this the begining of an index record? */ if (tsk_getu32(a_fs->endian, idxrec->magic) != NTFS_IDXREC_MAGIC) continue; /* idxrec_p is only NULL for the first time * Set it and start again to find the next one */ if (idxrec_p == NULL) { idxrec_p = idxrec; continue; } /* Process the previous structure */ /* idxrec points to the next idxrec structure, idxrec_p * points to the one we are going to process */ rec_len = (uint32_t) ((uintptr_t) idxrec - (uintptr_t) idxrec_p); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Processing previous index record (len: %" PRIu32 ")\n", rec_len); /* remove the update sequence in the index record */ if (ntfs_fix_idxrec(ntfs, idxrec_p, rec_len)) { free(idxalloc); return TSK_COR; } /* Locate the start of the index entry list */ idxelist = &idxrec_p->list; idxe = (ntfs_idxentry *) ((uintptr_t) idxelist + tsk_getu32(a_fs->endian, idxelist->begin_off)); /* the length from the start of the next record to where our * list starts. * This should be the same as bufend_off in idxelist, but we don't * trust it. */ list_len = (uint32_t) ((uintptr_t) idxrec - (uintptr_t) idxe); /* Verify the offset pointers */ if (((uintptr_t) idxe > (uintptr_t) idxrec) || ((uintptr_t) idxelist + tsk_getu32(a_fs->endian, idxelist->seqend_off) > (uintptr_t) idxrec)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error: Index list offsets are invalid on entry: %" PRIuINUM, fs_dir->fs_file->meta->addr); free(idxalloc); return TSK_COR; } /* process the list of index entries */ retval_tmp = ntfs_proc_idxentry(ntfs, fs_dir, (fs_dir->fs_file->meta-> flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, list_len, tsk_getu32(a_fs->endian, idxelist->seqend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off)); // stop if we get an error, record if we get corruption if (retval_tmp == TSK_ERR) { free(idxalloc); return TSK_ERR; } else if (retval_tmp == TSK_COR) { retval_final = TSK_COR; } /* reset the pointer to the next record */ idxrec_p = idxrec; } /* end of cluster loop */ /* Process the final record */ if (idxrec_p) { uint32_t list_len, rec_len; /* Length from end of attribute to start of this */ rec_len = (uint32_t) (idxalloc_len - (uintptr_t) idxrec_p - (uintptr_t) idxalloc); if (tsk_verbose) tsk_fprintf(stderr, "ntfs_dir_open_meta: Processing final index record (len: %" PRIu32 ")\n", rec_len); /* remove the update sequence */ if (ntfs_fix_idxrec(ntfs, idxrec_p, rec_len)) { free(idxalloc); return TSK_COR; } idxelist = &idxrec_p->list; idxe = (ntfs_idxentry *) ((uintptr_t) idxelist + tsk_getu32(a_fs->endian, idxelist->begin_off)); /* This is the length of the idx entries */ list_len = (uint32_t) ((uintptr_t) idxalloc + idxalloc_len) - (uintptr_t) idxe; /* Verify the offset pointers */ if ((list_len > rec_len) || ((uintptr_t) idxelist + tsk_getu32(a_fs->endian, idxelist->seqend_off) > (uintptr_t) idxalloc + idxalloc_len)) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error: Index list offsets are invalid on entry: %" PRIuINUM, fs_dir->fs_file->meta->addr); free(idxalloc); return TSK_COR; } /* process the list of index entries */ retval_tmp = ntfs_proc_idxentry(ntfs, fs_dir, (fs_dir->fs_file->meta-> flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, list_len, tsk_getu32(a_fs->endian, idxelist->seqend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off)); // stop if we get an error, record if we get corruption if (retval_tmp == TSK_ERR) { free(idxalloc); return TSK_ERR; } else if (retval_tmp == TSK_COR) { retval_final = TSK_COR; } } free(idxalloc); } // get the orphan files // load and cache the map if it has not already been done if (ntfs->orphan_map == NULL) { if (a_fs->inode_walk(a_fs, a_fs->first_inum, a_fs->last_inum, TSK_FS_META_FLAG_UNALLOC, ntfs_orphan_act, NULL)) { return TSK_ERR; } } // see if there are any entries for this dir map = ntfs_orphan_map_get(ntfs, a_addr); if (map != NULL) { int a; TSK_FS_NAME *fs_name; TSK_FS_FILE *fs_file_orp = NULL; if ((fs_name = tsk_fs_name_alloc(256, 0)) == NULL) return TSK_ERR; fs_name->flags = TSK_FS_NAME_FLAG_UNALLOC; fs_name->type = TSK_FS_NAME_TYPE_UNDEF; for (a = 0; a < map->used_cnt; a++) { /* Fill in the basics of the fs_name entry * so we can print in the fls formats */ fs_name->meta_addr = map->addrs[a]; // lookup the file to get its name (we did not cache that) fs_file_orp = tsk_fs_file_open_meta(a_fs, fs_file_orp, map->addrs[a]); if ((fs_file_orp) && (fs_file_orp->meta) && (fs_file_orp->meta->name2)) { TSK_FS_META_NAME_LIST *n2 = fs_file_orp->meta->name2; while (n2) { if (n2->par_inode == a_addr) { strncpy(fs_name->name, n2->name, fs_name->name_size); tsk_fs_dir_add(fs_dir, fs_name); } n2 = n2->next; } } } tsk_fs_name_free(fs_name); } // if we are listing the root directory, add the Orphan directory entry if (a_addr == a_fs->root_inum) { TSK_FS_NAME *fs_name; if ((fs_name = tsk_fs_name_alloc(256, 0)) == NULL) return TSK_ERR; if (tsk_fs_dir_make_orphan_dir_name(a_fs, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } if (tsk_fs_dir_add(fs_dir, fs_name)) { tsk_fs_name_free(fs_name); return TSK_ERR; } tsk_fs_name_free(fs_name); } return retval_final; } /**************************************************************************** * FIND_FILE ROUTINES * */ #define MAX_DEPTH 128 #define DIR_STRSZ 4096 typedef struct { /* Recursive path stuff */ /* how deep in the directory tree are we */ unsigned int depth; /* pointer in dirs string to where '/' is for given depth */ char *didx[MAX_DEPTH]; /* The current directory name string */ char dirs[DIR_STRSZ]; } NTFS_DINFO; /* * Looks up the parent inode described in fs_name. * * fs_name was filled in by ntfs_find_file and will get the final path * added to it before action is called * * return 1 on error and 0 on success */ static uint8_t ntfs_find_file_rec(TSK_FS_INFO * fs, NTFS_DINFO * dinfo, TSK_FS_FILE * fs_file, TSK_FS_META_NAME_LIST * fs_name_list, TSK_FS_DIR_WALK_CB action, void *ptr) { TSK_FS_FILE *fs_file_par; TSK_FS_META_NAME_LIST *fs_name_list_par; uint8_t decrem = 0; size_t len = 0, i; char *begin = NULL; int retval; if (fs_name_list->par_inode < fs->first_inum || fs_name_list->par_inode > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "invalid inode value: %" PRIuINUM "\n", fs_name_list->par_inode); return 1; } fs_file_par = tsk_fs_file_open_meta(fs, NULL, fs_name_list->par_inode); if (fs_file_par == NULL) { strncat(tsk_errstr2, " - ntfs_find_file_rec", TSK_ERRSTR_L - strlen(tsk_errstr2)); return 1; } /* * Orphan File * This occurs when the file is deleted and either: * - The parent is no longer a directory * - The sequence number of the parent is no longer correct */ if ((fs_file_par->meta->type != TSK_FS_META_TYPE_DIR) || (fs_file_par->meta->seq != fs_name_list->par_seq)) { char *str = TSK_FS_ORPHAN_STR; len = strlen(str); /* @@@ There should be a sanity check here to verify that the * previous name was unallocated ... but how do I get it again? */ if ((((uintptr_t) dinfo->didx[dinfo->depth - 1] - len) >= (uintptr_t) & dinfo->dirs[0]) && (dinfo->depth < MAX_DEPTH)) { begin = dinfo->didx[dinfo->depth] = (char *) ((uintptr_t) dinfo->didx[dinfo->depth - 1] - len); dinfo->depth++; decrem = 1; for (i = 0; i < len; i++) begin[i] = str[i]; } retval = action(fs_file, begin, ptr); if (decrem) dinfo->depth--; tsk_fs_file_close(fs_file_par); return (retval == TSK_WALK_ERROR) ? 1 : 0; } for (fs_name_list_par = fs_file_par->meta->name2; fs_name_list_par != NULL; fs_name_list_par = fs_name_list_par->next) { len = strlen(fs_name_list_par->name); /* do some length checks on the dir structure * if we can't fit it then forget about it */ if ((((uintptr_t) dinfo->didx[dinfo->depth - 1] - len - 1) >= (uintptr_t) & dinfo->dirs[0]) && (dinfo->depth < MAX_DEPTH)) { begin = dinfo->didx[dinfo->depth] = (char *) ((uintptr_t) dinfo->didx[dinfo->depth - 1] - len - 1); dinfo->depth++; decrem = 1; *begin = '/'; for (i = 0; i < len; i++) begin[i + 1] = fs_name_list_par->name[i]; } else { begin = dinfo->didx[dinfo->depth]; decrem = 0; } /* if we are at the root, then fill out the rest of fs_name with * the full path and call the action */ if (fs_name_list_par->par_inode == NTFS_ROOTINO) { /* increase the path by one so that we do not pass the '/' * if we do then the printed result will have '//' at * the beginning */ if (TSK_WALK_ERROR == action(fs_file, (const char *) ((uintptr_t) begin + 1), ptr)) { tsk_fs_file_close(fs_file_par); return 1; } } /* otherwise, recurse some more */ else { if (ntfs_find_file_rec(fs, dinfo, fs_file, fs_name_list_par, action, ptr)) { tsk_fs_file_close(fs_file_par); return 1; } } /* if we incremented before, then decrement the depth now */ if (decrem) dinfo->depth--; } tsk_fs_file_close(fs_file_par); return 0; } /* * this is a much faster way of doing it in NTFS * * the inode that is passed in this case is the one to find the name * for * * This can not be called with dent_walk because the path * structure will get messed up! */ uint8_t ntfs_find_file(TSK_FS_INFO * fs, TSK_INUM_T inode_toid, uint32_t type_toid, uint8_t type_used, uint16_t id_toid, uint8_t id_used, TSK_FS_DIR_WALK_FLAG_ENUM dir_walk_flags, TSK_FS_DIR_WALK_CB action, void *ptr) { TSK_FS_META_NAME_LIST *fs_name_list; NTFS_INFO *ntfs = (NTFS_INFO *) fs; char *attr = NULL; NTFS_DINFO dinfo; TSK_FS_FILE *fs_file; /* sanity check */ if (inode_toid < fs->first_inum || inode_toid > fs->last_inum) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "ntfs_find_file: invalid inode value: %" PRIuINUM "\n", inode_toid); return 1; } // open the file to ID fs_file = tsk_fs_file_open_meta(fs, NULL, inode_toid); if (fs_file == NULL) { strncat(tsk_errstr2, " - ntfs_find_file", TSK_ERRSTR_L - strlen(tsk_errstr2)); tsk_fs_file_close(fs_file); return 1; } // see if its allocation status meets the callback needs if ((fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) && ((dir_walk_flags & TSK_FS_DIR_WALK_FLAG_ALLOC) == 0)) { tsk_fs_file_close(fs_file); return 1; } else if ((fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) && ((dir_walk_flags & TSK_FS_DIR_WALK_FLAG_UNALLOC) == 0)) { tsk_fs_file_close(fs_file); return 1; } /* Allocate a name and fill in some details */ if ((fs_file->name = tsk_fs_name_alloc(NTFS_MAXNAMLEN_UTF8, 0)) == NULL) { return 1; } fs_file->name->meta_addr = inode_toid; fs_file->name->meta_seq = 0; fs_file->name->flags = ((tsk_getu16(fs->endian, ntfs->mft-> flags) & NTFS_MFT_INUSE) ? TSK_FS_NAME_FLAG_ALLOC : TSK_FS_NAME_FLAG_UNALLOC); memset(&dinfo, 0, sizeof(NTFS_DINFO)); /* in this function, we use the dinfo->dirs array in the opposite order. * we set the end of it to NULL and then prepend the * directories to it * * dinfo->didx[dinfo->depth] will point to where the current level started their * dir name */ dinfo.dirs[DIR_STRSZ - 2] = '/'; dinfo.dirs[DIR_STRSZ - 1] = '\0'; dinfo.didx[0] = &dinfo.dirs[DIR_STRSZ - 2]; dinfo.depth = 1; /* Get the name for the attribute - if specified */ if (type_used) { const TSK_FS_ATTR *fs_attr; if (id_used) fs_attr = tsk_fs_attrlist_get_id(fs_file->meta->attr, type_toid, id_toid); else fs_attr = tsk_fs_attrlist_get(fs_file->meta->attr, type_toid); if (!fs_attr) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "find_file: Type %" PRIu32 " Id %" PRIu16 " not found in MFT %" PRIuINUM "", type_toid, id_toid, inode_toid); tsk_fs_file_close(fs_file); return 1; } /* only add the attribute name if it is the non-default data stream */ if (fs_attr->name != NULL) attr = fs_attr->name; } /* loop through all the names it may have */ for (fs_name_list = fs_file->meta->name2; fs_name_list != NULL; fs_name_list = fs_name_list->next) { int retval; /* Append on the attribute name, if it exists */ if (attr != NULL) { snprintf(fs_file->name->name, fs_file->name->name_size, "%s:%s", fs_name_list->name, attr); } else { strncpy(fs_file->name->name, fs_name_list->name, fs_file->name->name_size); } /* if this is in the root directory, then call back */ if (fs_name_list->par_inode == NTFS_ROOTINO) { retval = action(fs_file, dinfo.didx[0], ptr); if (retval == TSK_WALK_STOP) { tsk_fs_file_close(fs_file); return 0; } else if (retval == TSK_WALK_ERROR) { tsk_fs_file_close(fs_file); return 1; } } /* call the recursive function on the parent to get the full path */ else { if (ntfs_find_file_rec(fs, &dinfo, fs_file, fs_name_list, action, ptr)) { tsk_fs_file_close(fs_file); return 1; } } } /* end of name loop */ tsk_fs_file_close(fs_file); return 0; } int ntfs_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { return strcasecmp(s1, s2); } sleuthkit-3.2.3/tsk3/fs/rawfs.c000644 000765 000024 00000005173 11643647440 017126 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2004-2005 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ #include "tsk_fs_i.h" /** *\file rawfs.c * Contains internal "raw" specific file system functions. The raw file system is used to process * an arbitrary chunk of data as 512-byte sectors that have no other structure. * This means that you can use the data-level tools, but that is it. Because raw and swapfs * are very similar implementations, they share many of the tsk_fs_nofs_XXX functions, such as * tsk_fs_nofs_close(); */ /** \internal * Open part of a disk image as a raw file system -- which basically means that it has no file system structure. * The data is considered to be in 512-byte sectors. * * @param img_info Disk image to analyze * @param offset Byte offset where "file system" starts * @returns NULL on error */ TSK_FS_INFO * rawfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset) { TSK_OFF_T len; TSK_FS_INFO *fs; // clean up any error messages that are lying around tsk_error_reset(); fs = (TSK_FS_INFO *) tsk_malloc(sizeof(TSK_FS_INFO)); if (fs == NULL) return NULL; /* All we need to set are the block sizes and max block size etc. */ fs->img_info = img_info; fs->offset = offset; fs->ftype = TSK_FS_TYPE_RAW; fs->duname = "Sector"; fs->flags = 0; fs->tag = TSK_FS_INFO_TAG; fs->inum_count = 0; fs->root_inum = 0; fs->first_inum = 0; fs->last_inum = 0; len = img_info->size; fs->block_size = 512; fs->block_count = len / fs->block_size; if (len % fs->block_size) fs->block_count++; fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->dev_bsize = img_info->sector_size; /* Pointer to functions */ fs->close = tsk_fs_nofs_close; fs->fsstat = tsk_fs_nofs_fsstat; fs->block_walk = tsk_fs_nofs_block_walk; fs->block_getflags = tsk_fs_nofs_block_getflags; fs->inode_walk = tsk_fs_nofs_inode_walk; fs->file_add_meta = tsk_fs_nofs_file_add_meta; fs->istat = tsk_fs_nofs_istat; fs->get_default_attr_type = tsk_fs_nofs_get_default_attr_type; fs->load_attrs = tsk_fs_nofs_make_data_run; fs->dir_open_meta = tsk_fs_nofs_dir_open_meta; fs->name_cmp = tsk_fs_nofs_name_cmp; fs->jblk_walk = tsk_fs_nofs_jblk_walk; fs->jentry_walk = tsk_fs_nofs_jentry_walk; fs->jopen = tsk_fs_nofs_jopen; fs->journ_inum = 0; return (fs); } sleuthkit-3.2.3/tsk3/fs/swapfs.c000644 000765 000024 00000005265 11643647440 017311 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All Rights reserved ** Copyright (c) 2004-2005 Brian Carrier. All rights reserved ** ** ** This software is distributed under the Common Public License 1.0 ** */ #include "tsk_fs_i.h" /** *\file swapfs.c * Contains the internal "swapfs" specific functions. The "swap" file system is used to process * an arbitrary chunk of data as 4096-byte pages that have no other structure. * This means that you can use the data-level tools, but that is it. This is similar to * the rawfs code, but a different block size. This is primarily intended for Unix systems * that have a swap space partition. Much of the code for swap and rawfs are similar and therefore * share tsk_fs_nofs_XXXX functions, such as tsk_fs_nofs_close() */ /** \internal * Open part of a disk image as "swap" space. This assumes no structure exists. * Data are organized into 4096-byte pages. * * @param img_info Disk image to analyze * @param offset Byte offset where swap space starts. * @returns NULL on error */ TSK_FS_INFO * swapfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset) { TSK_OFF_T len; TSK_FS_INFO *fs; // clean up any error messages that are lying around tsk_error_reset(); fs = (TSK_FS_INFO *) tsk_malloc(sizeof(*fs)); if (fs == NULL) return NULL; /* All we need to set are the block sizes and max bloc size etc. */ fs->img_info = img_info; fs->offset = offset; fs->ftype = TSK_FS_TYPE_SWAP; fs->duname = "Page"; fs->flags = 0; fs->tag = TSK_FS_INFO_TAG; fs->inum_count = 0; fs->root_inum = 0; fs->first_inum = 0; fs->last_inum = 0; len = img_info->size; fs->block_count = len / 4096; if (len % 4096) fs->block_count++; fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = 4096; fs->dev_bsize = img_info->sector_size; /* Pointers to functions */ fs->close = tsk_fs_nofs_close; fs->fsstat = tsk_fs_nofs_fsstat; fs->block_walk = tsk_fs_nofs_block_walk; fs->block_getflags = tsk_fs_nofs_block_getflags; fs->inode_walk = tsk_fs_nofs_inode_walk; fs->istat = tsk_fs_nofs_istat; fs->file_add_meta = tsk_fs_nofs_file_add_meta; fs->get_default_attr_type = tsk_fs_nofs_get_default_attr_type; fs->load_attrs = tsk_fs_nofs_make_data_run; fs->dir_open_meta = tsk_fs_nofs_dir_open_meta; fs->name_cmp = tsk_fs_nofs_name_cmp; fs->jblk_walk = tsk_fs_nofs_jblk_walk; fs->jentry_walk = tsk_fs_nofs_jentry_walk; fs->jopen = tsk_fs_nofs_jopen; fs->journ_inum = 0; return (fs); } sleuthkit-3.2.3/tsk3/fs/tsk_ext2fs.h000644 000765 000024 00000032231 11643647440 020100 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2008 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /* * Contains the structures and function APIs for EXT2FS file system support. */ #ifndef _TSK_EXT2FS_H #define _TSK_EXT2FS_H #ifdef __cplusplus extern "C" { #endif typedef uint32_t EXT2_GRPNUM_T; #define PRI_EXT2GRP PRIu32 /* ** Constants */ #define EXT2FS_FIRSTINO 1 /* inode 1 contains the bad blocks */ #define EXT2FS_ROOTINO 2 /* location of root directory inode */ #define EXT2FS_NDADDR 12 #define EXT2FS_NIADDR 3 #define EXT2FS_SBOFF 1024 #define EXT2FS_FS_MAGIC 0xef53 #define EXT2FS_MAXNAMLEN 255 #define EXT2FS_MAXPATHLEN 4096 #define EXT2FS_MIN_BLOCK_SIZE 1024 #define EXT2FS_MAX_BLOCK_SIZE 4096 #define EXT2FS_FILE_CONTENT_LEN ((EXT2FS_NDADDR + EXT2FS_NIADDR) * sizeof(TSK_DADDR_T)) /* ** Super Block */ typedef struct { uint8_t s_inodes_count[4]; /* u32 */ uint8_t s_blocks_count[4]; /* u32 */ uint8_t s_r_blocks_count[4]; uint8_t s_free_blocks_count[4]; /* u32 */ uint8_t s_free_inode_count[4]; /* u32 */ uint8_t s_first_data_block[4]; /* u32 */ uint8_t s_log_block_size[4]; /* u32 */ uint8_t s_log_frag_size[4]; /* s32 */ uint8_t s_blocks_per_group[4]; /* u32 */ uint8_t s_frags_per_group[4]; /* u32 */ uint8_t s_inodes_per_group[4]; /* u32 */ uint8_t s_mtime[4]; /* u32 *//* mount time */ uint8_t s_wtime[4]; /* u32 *//* write time */ uint8_t s_mnt_count[2]; /* u16 *//* mount count */ uint8_t s_max_mnt_count[2]; /* s16 */ uint8_t s_magic[2]; /* u16 */ uint8_t s_state[2]; /* u16 *//* fs state */ uint8_t s_errors[2]; /* u16 */ uint8_t s_minor_rev_level[2]; /* u16 */ uint8_t s_lastcheck[4]; /* u32 */ uint8_t s_checkinterval[4]; /* u32 */ uint8_t s_creator_os[4]; /* u32 */ uint8_t s_rev_level[4]; /* u32 */ uint8_t s_def_resuid[2]; /* u16 */ uint8_t s_def_resgid[2]; /* u16 */ uint8_t s_first_ino[4]; /* u32 */ uint8_t s_inode_size[2]; /* u16 */ uint8_t s_block_group_nr[2]; /* u16 */ uint8_t s_feature_compat[4]; /* u32 */ uint8_t s_feature_incompat[4]; /* u32 */ uint8_t s_feature_ro_compat[4]; /* u32 */ uint8_t s_uuid[16]; /* u8[16] */ char s_volume_name[16]; char s_last_mounted[64]; uint8_t s_algorithm_usage_bitmap[4]; /* u32 */ uint8_t s_prealloc_blocks; /* u8 */ uint8_t s_prealloc_dir_blocks; /* u8 */ uint8_t s_padding1[2]; /* u16 */ uint8_t s_journal_uuid[16]; /* u8[16] */ uint8_t s_journal_inum[4]; /* u32 */ uint8_t s_journal_dev[4]; /* u32 */ uint8_t s_last_orphan[4]; /* u32 */ uint8_t s_padding[788]; } ext2fs_sb; /* File system State Values */ #define EXT2FS_STATE_VALID 0x0001 /* unmounted correctly */ #define EXT2FS_STATE_ERROR 0x0002 /* errors detected */ /* Operating System Codes */ #define EXT2FS_OS_LINUX 0 #define EXT2FS_OS_HURD 1 #define EXT2FS_OS_MASIX 2 #define EXT2FS_OS_FREEBSD 3 #define EXT2FS_OS_LITES 4 /* Revision Levels */ #define EXT2FS_REV_ORIG 0 #define EXT2FS_REV_DYN 1 /* feature flags */ #define EXT2FS_FEATURE_COMPAT_DIR_PREALLOC 0x0001 #define EXT2FS_FEATURE_COMPAT_IMAGIC_INODES 0x0002 #define EXT2FS_FEATURE_COMPAT_HAS_JOURNAL 0x0004 #define EXT2FS_FEATURE_COMPAT_EXT_ATTR 0x0008 #define EXT2FS_FEATURE_COMPAT_RESIZE_INO 0x0010 #define EXT2FS_FEATURE_COMPAT_DIR_INDEX 0x0020 #define EXT2FS_FEATURE_INCOMPAT_COMPRESSION 0x0001 #define EXT2FS_FEATURE_INCOMPAT_FILETYPE 0x0002 #define EXT2FS_FEATURE_INCOMPAT_RECOVER 0x0004 #define EXT2FS_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 #define EXT2FS_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 #define EXT2FS_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 #define EXT2FS_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* * Group Descriptor */ typedef struct { uint8_t bg_block_bitmap[4]; /* u32: block of blocks bitmap */ uint8_t bg_inode_bitmap[4]; /* u32: block of inodes bitmap */ uint8_t bg_inode_table[4]; /* u32: block of inodes table */ uint8_t bg_free_blocks_count[2]; /* u16: num of free blocks */ uint8_t bg_free_inodes_count[2]; /* u16: num of free inodes */ uint8_t bg_used_dirs_count[2]; /* u16: num of use directories */ uint8_t f1[14]; } ext2fs_gd; /* data address to group number */ #define ext2_dtog_lcl(fsi, fs, d) \ (EXT2_GRPNUM_T)(((d) - tsk_getu32(fsi->endian, fs->s_first_data_block)) / \ tsk_getu32(fsi->endian, fs->s_blocks_per_group)) /* first fragment of group */ #define ext2_cgbase_lcl(fsi, fs, c) \ ((TSK_DADDR_T)((tsk_getu32(fsi->endian, fs->s_blocks_per_group) * (c)) + \ tsk_getu32(fsi->endian, fs->s_first_data_block))) /* * Inode */ typedef struct { uint8_t i_mode[2]; /* u16 */ uint8_t i_uid[2]; /* u16 */ uint8_t i_size[4]; /* u32 */ uint8_t i_atime[4]; /* u32 */ uint8_t i_ctime[4]; /* u32 */ uint8_t i_mtime[4]; /* u32 */ uint8_t i_dtime[4]; /* u32 */ uint8_t i_gid[2]; /* u16 */ uint8_t i_nlink[2]; /* u16 */ uint8_t i_nblk[4]; uint8_t i_flags[4]; uint8_t i_f5[4]; uint8_t i_block[15][4]; /*s32 */ uint8_t i_generation[4]; uint8_t i_file_acl[4]; uint8_t i_size_high[4]; /* u32 - also i_dir_acl for non-regular */ uint8_t i_faddr[4]; uint8_t i_frag; uint8_t i_fsize; uint8_t f1[2]; uint8_t i_uid_high[2]; uint8_t i_gid_high[2]; uint8_t f7[4]; } ext2fs_inode; /* MODE */ #define EXT2_IN_FMT 0170000 #define EXT2_IN_SOCK 0140000 #define EXT2_IN_LNK 0120000 #define EXT2_IN_REG 0100000 #define EXT2_IN_BLK 0060000 #define EXT2_IN_DIR 0040000 #define EXT2_IN_CHR 0020000 #define EXT2_IN_FIFO 0010000 #define EXT2_IN_ISUID 0004000 #define EXT2_IN_ISGID 0002000 #define EXT2_IN_ISVTX 0001000 #define EXT2_IN_IRUSR 0000400 #define EXT2_IN_IWUSR 0000200 #define EXT2_IN_IXUSR 0000100 #define EXT2_IN_IRGRP 0000040 #define EXT2_IN_IWGRP 0000020 #define EXT2_IN_IXGRP 0000010 #define EXT2_IN_IROTH 0000004 #define EXT2_IN_IWOTH 0000002 #define EXT2_IN_IXOTH 0000001 #define EXT2_IN_SECDEL 0x00000001 /* Secure deletion */ #define EXT2_IN_UNRM 0x00000002 /* Undelete */ #define EXT2_IN_COMP 0x00000004 /* Compress file */ #define EXT2_IN_SYNC 0x00000008 /* Synchronous updates */ #define EXT2_IN_IMM 0x00000010 /* Immutable file */ #define EXT2_IN_APPEND 0x00000020 /* writes to file may only append */ #define EXT2_IN_NODUMP 0x00000040 /* do not dump file */ #define EXT2_IN_NOA 0x00000080 /* do not update atime */ /* * directory entries */ typedef struct { uint8_t inode[4]; /* u32 */ uint8_t rec_len[2]; /* u16 */ uint8_t name_len[2]; /* u16 */ char name[EXT2FS_MAXNAMLEN]; } ext2fs_dentry1; /* new structure starting at 2.2 */ typedef struct { uint8_t inode[4]; /* u32 */ uint8_t rec_len[2]; /* u16 */ uint8_t name_len; uint8_t type; char name[EXT2FS_MAXNAMLEN]; } ext2fs_dentry2; #define EXT2FS_DIRSIZ_lcl(len) \ ((len + 8 + 3) & ~(3)) /* Ext2 directory file types */ #define EXT2_DE_UNKNOWN 0 #define EXT2_DE_REG 1 #define EXT2_DE_DIR 2 #define EXT2_DE_CHR 3 #define EXT2_DE_BLK 4 #define EXT2_DE_FIFO 5 #define EXT2_DE_SOCK 6 #define EXT2_DE_LNK 7 #define EXT2_DE_MAX 8 #define EXT2_DE_V1 1 #define EXT2_DE_V2 2 /* Extended Attributes */ #define EXT2_EA_MAGIC 0xEA020000 typedef struct { uint8_t magic[4]; uint8_t refcount[4]; uint8_t blocks[4]; uint8_t hash[4]; uint8_t f1[16]; uint8_t entry; } ext2fs_ea_header; #define EXT2_EA_IDX_USER 1 #define EXT2_EA_IDX_POSIX_ACL_ACCESS 2 #define EXT2_EA_IDX_POSIX_ACL_DEFAULT 3 #define EXT2_EA_IDX_TRUSTED 4 #define EXT2_EA_IDX_LUSTRE 5 #define EXT2_EA_IDX_SECURITY 6 /* Entries follow the header and are aligned to 4-byte boundaries * the value of the attribute is stored at the bottom of the block */ typedef struct { uint8_t nlen; uint8_t nidx; uint8_t val_off[2]; uint8_t val_blk[4]; uint8_t val_size[4]; uint8_t hash[4]; uint8_t name; } ext2fs_ea_entry; #define EXT2_EA_LEN(nlen) \ ((((nlen) + 19 ) / 4) * 4) typedef struct { uint8_t ver[4]; } ext2fs_pos_acl_head; #define EXT2_PACL_TAG_USERO 0x01 #define EXT2_PACL_TAG_USER 0x02 #define EXT2_PACL_TAG_GRPO 0x04 #define EXT2_PACL_TAG_GRP 0x08 #define EXT2_PACL_TAG_MASK 0x10 #define EXT2_PACL_TAG_OTHER 0x20 #define EXT2_PACL_PERM_EXEC 0x01 #define EXT2_PACL_PERM_WRITE 0x02 #define EXT2_PACL_PERM_READ 0x04 typedef struct { uint8_t tag[2]; uint8_t perm[2]; } ext2fs_pos_acl_entry_sh; typedef struct { uint8_t tag[2]; uint8_t perm[2]; uint8_t id[4]; } ext2fs_pos_acl_entry_lo; /************** JOURNAL ******************/ /* These values are always in big endian */ #define EXT2_JMAGIC 0xC03b3998 typedef struct { uint8_t magic[4]; uint8_t entrytype[4]; uint8_t entryseq[4]; /* sequence of this entry */ uint8_t bsize[4]; /* size of block */ uint8_t num_blk[4]; /* num of blks in journal */ uint8_t first_blk[4]; /* bl where log starts */ uint8_t start_seq[4]; /* first commit ID in log */ uint8_t start_blk[4]; /* journ blk for 1st valid entry */ uint8_t j_errno[4]; /* signed error number */ /* the rest are not valid for v1 sb */ uint8_t feature_compat[4]; uint8_t feature_incompat[4]; uint8_t feature_ro_incompat[4]; uint8_t uuid[16]; uint8_t num_fs[4]; /* num of fs sharing log */ uint8_t dynsuper[4]; /* fs block of sb copy */ uint8_t max_trans[4]; /* limit of blk per trans */ uint8_t max_trans_data[4]; /* limit of data blocks per */ uint8_t reserved[176]; uint8_t id_fs[16][48]; /* Ids of fs sharing log */ } ext2fs_journ_sb; #define EXT2_J_ETYPE_DESC 1 /* descriptor block */ #define EXT2_J_ETYPE_COM 2 /* commit */ #define EXT2_J_ETYPE_SB1 3 /* super block v1 */ #define EXT2_J_ETYPE_SB2 4 /* sb v2 */ #define EXT2_J_ETYPE_REV 5 /* revoke */ /* Header that is used for all structures */ typedef struct { uint8_t magic[4]; uint8_t entry_type[4]; uint8_t entry_seq[4]; } ext2fs_journ_head; /* dentry flags */ #define EXT2_J_DENTRY_ESC 1 /* The orig block starts with magic */ #define EXT2_J_DENTRY_SAMEID 2 /* Entry is for same id, so do not skip 16 ahead */ #define EXT2_J_DENTRY_DEL 4 /* not currently used in src */ #define EXT2_J_DENTRY_LAST 8 /* Last tag */ /* Entry in the descriptor table */ typedef struct { uint8_t fs_blk[4]; uint8_t flag[4]; } ext2fs_journ_dentry; /* Journal Info */ typedef struct { TSK_FS_FILE *fs_file; TSK_INUM_T j_inum; uint32_t bsize; TSK_DADDR_T first_block; TSK_DADDR_T last_block; uint32_t start_seq; TSK_DADDR_T start_blk; } EXT2FS_JINFO; /* * Structure of an ext2fs file system handle. */ typedef struct { TSK_FS_INFO fs_info; /* super class */ ext2fs_sb *fs; /* super block */ ext2fs_gd *grp_buf; /* cached group descriptor */ EXT2_GRPNUM_T grp_num; /* cached group number */ uint8_t *bmap_buf; /* cached block allocation bitmap */ EXT2_GRPNUM_T bmap_grp_num; /* cached block bitmap nr */ uint8_t *imap_buf; /* cached inode allocation bitmap */ EXT2_GRPNUM_T imap_grp_num; /* cached inode bitmap nr */ ext2fs_inode *dino_buf; /* cached disk inode */ TSK_INUM_T dino_inum; /* cached inode number */ TSK_OFF_T groups_offset; /* offset to first group desc */ EXT2_GRPNUM_T groups_count; /* nr of descriptor group blocks */ uint8_t deentry_type; /* v1 or v2 of dentry */ uint16_t inode_size; /* size of each inode */ TSK_DADDR_T first_data_block; EXT2FS_JINFO *jinfo; } EXT2FS_INFO; extern TSK_RETVAL_ENUM ext2fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); extern uint8_t ext2fs_jentry_walk(TSK_FS_INFO *, int, TSK_FS_JENTRY_WALK_CB, void *); extern uint8_t ext2fs_jblk_walk(TSK_FS_INFO *, TSK_DADDR_T, TSK_DADDR_T, int, TSK_FS_JBLK_WALK_CB, void *); extern uint8_t ext2fs_jopen(TSK_FS_INFO *, TSK_INUM_T); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/tsk_fatfs.h000644 000765 000024 00000031675 11643647440 020003 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2008 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 ** */ /* * Contains the structures and function APIs for FATFS file system support. */ #ifndef _TSK_FATFS_H #define _TSK_FATFS_H #ifdef __cplusplus extern "C" { #endif /* ** Constants */ #define FATFS_FIRSTINO 2 #define FATFS_ROOTINO 2 /* location of root directory inode */ #define FATFS_FIRST_NORMINO 3 // special files go at end of inode list (before $OrphanFiles) #define FATFS_NUM_SPECFILE 4 // includes MBR, FAT1, FAT2, and Orphans #define FATFS_MBRINO(fs_info) \ (TSK_FS_ORPHANDIR_INUM(fs_info) - 3) // inode for master boot record "special file" #define FATFS_MBRNAME "$MBR" #define FATFS_FAT1INO(fs_info) \ (TSK_FS_ORPHANDIR_INUM(fs_info) - 2) // inode for FAT1 "special file" #define FATFS_FAT1NAME "$FAT1" #define FATFS_FAT2INO(fs_info) \ (TSK_FS_ORPHANDIR_INUM(fs_info) - 1) // inode for FAT2 "special file" #define FATFS_FAT2NAME "$FAT2" #define FATFS_SBOFF 0 #define FATFS_FS_MAGIC 0xaa55 #define FATFS_MAXNAMLEN 256 #define FATFS_MAXNAMLEN_UTF8 1024 #define FATFS_FILE_CONTENT_LEN sizeof(TSK_DADDR_T) // we will store the starting cluster /* size of FAT to read into FATFS_INFO each time */ /* This must be at least 1024 bytes or else fat12 will get messed up */ #define FAT_CACHE_N 4 // number of caches #define FAT_CACHE_B 4096 #define FAT_CACHE_S 8 // number of sectors in cache /* MASK values for FAT entries */ #define FATFS_12_MASK 0x00000fff #define FATFS_16_MASK 0x0000ffff #define FATFS_32_MASK 0x0fffffff /* Constants for the FAT entry */ #define FATFS_UNALLOC 0 #define FATFS_BAD 0x0ffffff7 #define FATFS_EOFS 0x0ffffff8 #define FATFS_EOFE 0x0fffffff /* macro to identify if the FAT value is End of File * returns 1 if it is and 0 if it is not */ #define FATFS_ISEOF(val, mask) \ ((val >= (FATFS_EOFS & mask)) && (val <= (FATFS_EOFE))) #define FATFS_ISBAD(val, mask) \ ((val) == (FATFS_BAD & mask)) #define FATFS_CLUST_2_SECT(fatfs, c) \ (TSK_DADDR_T)(fatfs->firstclustsect + ((((c) & fatfs->mask) - 2) * fatfs->csize)) #define FATFS_SECT_2_CLUST(fatfs, s) \ (TSK_DADDR_T)(2 + ((s) - fatfs->firstclustsect) / fatfs->csize) /* given an inode address, determine in which sector it is located * i must be larger than 3 (2 is the root and it doesn't have a sector) */ #define FATFS_INODE_2_SECT(fatfs, i) \ (TSK_DADDR_T)((i - FATFS_FIRST_NORMINO)/(fatfs->dentry_cnt_se) + fatfs->firstdatasect) #define FATFS_INODE_2_OFF(fatfs, i) \ (size_t)(((i - FATFS_FIRST_NORMINO) % fatfs->dentry_cnt_se) * sizeof(fatfs_dentry)) /* given a sector IN THE DATA AREA, return the base inode for it */ #define FATFS_SECT_2_INODE(fatfs, s) \ (TSK_INUM_T)((s - fatfs->firstdatasect) * fatfs->dentry_cnt_se + FATFS_FIRST_NORMINO) /* * Boot Sector Structure for TSK_FS_INFO_TYPE_FAT_12, TSK_FS_INFO_TYPE_FAT_16, and TSK_FS_INFO_TYPE_FAT_32 */ typedef struct { uint8_t f1[3]; char oemname[8]; uint8_t ssize[2]; /* sector size in bytes */ uint8_t csize; /* cluster size in sectors */ uint8_t reserved[2]; /* number of reserved sectors for boot sectors */ uint8_t numfat; /* Number of FATs */ uint8_t numroot[2]; /* Number of Root dentries */ uint8_t sectors16[2]; /* number of sectors in FS */ uint8_t f2[1]; uint8_t sectperfat16[2]; /* size of FAT */ uint8_t f3[4]; uint8_t prevsect[4]; /* number of sectors before FS partition */ uint8_t sectors32[4]; /* 32-bit value of number of FS sectors */ /* The following are different for fat12/fat16 and fat32 */ union { struct { uint8_t f5[3]; uint8_t vol_id[4]; uint8_t vol_lab[11]; uint8_t fs_type[8]; uint8_t f6[448]; } f16; struct { uint8_t sectperfat32[4]; uint8_t ext_flag[2]; uint8_t fs_ver[2]; uint8_t rootclust[4]; /* cluster where root directory is stored */ uint8_t fsinfo[2]; /* TSK_FS_INFO Location */ uint8_t bs_backup[2]; /* sector of backup of boot sector */ uint8_t f5[12]; uint8_t drvnum; uint8_t f6[2]; uint8_t vol_id[4]; uint8_t vol_lab[11]; uint8_t fs_type[8]; uint8_t f7[420]; } f32; } a; uint8_t magic[2]; /* MAGIC for all versions */ } fatfs_sb; typedef struct { uint8_t magic1[4]; /* 41615252 */ uint8_t f1[480]; uint8_t magic2[4]; /* 61417272 */ uint8_t freecnt[4]; /* free clusters 0xfffffffff if unknown */ uint8_t nextfree[4]; /* next free cluster */ uint8_t f2[12]; uint8_t magic3[4]; /* AA550000 */ } fatfs_fsinfo; /* directory entry short name structure */ typedef struct { uint8_t name[8]; uint8_t ext[3]; uint8_t attrib; uint8_t lowercase; uint8_t ctimeten; /* create times (ctimeten is 0-199) */ uint8_t ctime[2]; uint8_t cdate[2]; uint8_t adate[2]; /* access time */ uint8_t highclust[2]; uint8_t wtime[2]; /* last write time */ uint8_t wdate[2]; uint8_t startclust[2]; uint8_t size[4]; } fatfs_dentry; /* Macro to combine the upper and lower 2-byte parts of the starting * cluster */ #define FATFS_DENTRY_CLUST(fsi, de) \ (TSK_DADDR_T)((tsk_getu16(fsi->endian, de->startclust)) | (tsk_getu16(fsi->endian, de->highclust)<<16)) /* constants for first byte of name[] */ #define FATFS_SLOT_EMPTY 0x00 #define FATFS_SLOT_E5 0x05 /* actual value is 0xe5 */ #define FATFS_SLOT_DELETED 0xe5 /* *Return 1 if c is an valid charactor for a short file name * * NOTE: 0x05 is allowed in name[0], and 0x2e (".") is allowed for name[0] * and name[1] and 0xe5 is allowed for name[0] */ #define FATFS_IS_83_NAME(c) \ ((((c) < 0x20) || \ ((c) == 0x22) || \ (((c) >= 0x2a) && ((c) <= 0x2c)) || \ ((c) == 0x2e) || \ ((c) == 0x2f) || \ (((c) >= 0x3a) && ((c) <= 0x3f)) || \ (((c) >= 0x5b) && ((c) <= 0x5d)) || \ ((c) == 0x7c)) == 0) // extensions are to be ascii / latin #define FATFS_IS_83_EXT(c) \ (FATFS_IS_83_NAME((c)) && ((c) < 0x7f)) /* flags for attributes field */ #define FATFS_ATTR_NORMAL 0x00 /* normal file */ #define FATFS_ATTR_READONLY 0x01 /* file is readonly */ #define FATFS_ATTR_HIDDEN 0x02 /* file is hidden */ #define FATFS_ATTR_SYSTEM 0x04 /* file is a system file */ #define FATFS_ATTR_VOLUME 0x08 /* entry is a volume label */ #define FATFS_ATTR_DIRECTORY 0x10 /* entry is a directory name */ #define FATFS_ATTR_ARCHIVE 0x20 /* file is new or modified */ #define FATFS_ATTR_LFN 0x0f /* A long file name entry */ #define FATFS_ATTR_ALL 0x3f /* all flags set */ /* flags for lowercase field */ #define FATFS_CASE_LOWER_BASE 0x08 /* base is lower case */ #define FATFS_CASE_LOWER_EXT 0x10 /* extension is lower case */ #define FATFS_CASE_LOWER_ALL 0x18 /* both are lower */ #define FATFS_SEC_MASK 0x1f /* number of seconds div by 2 */ #define FATFS_SEC_SHIFT 0 #define FATFS_SEC_MIN 0 #define FATFS_SEC_MAX 30 #define FATFS_MIN_MASK 0x7e0 /* number of minutes 0-59 */ #define FATFS_MIN_SHIFT 5 #define FATFS_MIN_MIN 0 #define FATFS_MIN_MAX 59 #define FATFS_HOUR_MASK 0xf800 /* number of hours 0-23 */ #define FATFS_HOUR_SHIFT 11 #define FATFS_HOUR_MIN 0 #define FATFS_HOUR_MAX 23 /* return 1 if x is a valid FAT time */ #define FATFS_ISTIME(x) \ (((((x & FATFS_SEC_MASK) >> FATFS_SEC_SHIFT) > FATFS_SEC_MAX) || \ (((x & FATFS_MIN_MASK) >> FATFS_MIN_SHIFT) > FATFS_MIN_MAX) || \ (((x & FATFS_HOUR_MASK) >> FATFS_HOUR_SHIFT) > FATFS_HOUR_MAX) ) == 0) #define FATFS_DAY_MASK 0x1f /* day of month 1-31 */ #define FATFS_DAY_SHIFT 0 #define FATFS_DAY_MIN 1 #define FATFS_DAY_MAX 31 #define FATFS_MON_MASK 0x1e0 /* month 1-12 */ #define FATFS_MON_SHIFT 5 #define FATFS_MON_MIN 1 #define FATFS_MON_MAX 12 #define FATFS_YEAR_MASK 0xfe00 /* year, from 1980 0-127 */ #define FATFS_YEAR_SHIFT 9 #define FATFS_YEAR_MIN 0 #define FATFS_YEAR_MAX 127 /* return 1 if x is a valid FAT date */ #define FATFS_ISDATE(x) \ (((((x & FATFS_DAY_MASK) >> FATFS_DAY_SHIFT) > FATFS_DAY_MAX) || \ (((x & FATFS_DAY_MASK) >> FATFS_DAY_SHIFT) < FATFS_DAY_MIN) || \ (((x & FATFS_MON_MASK) >> FATFS_MON_SHIFT) > FATFS_MON_MAX) || \ (((x & FATFS_MON_MASK) >> FATFS_MON_SHIFT) < FATFS_MON_MIN) || \ (((x & FATFS_YEAR_MASK) >> FATFS_YEAR_SHIFT) > FATFS_YEAR_MAX) ) == 0) /* * Long file name support for windows * * Contents of this are in UNICODE, not ASCII */ typedef struct { uint8_t seq; uint8_t part1[10]; uint8_t attributes; uint8_t reserved1; uint8_t chksum; uint8_t part2[12]; uint8_t reserved2[2]; uint8_t part3[4]; } fatfs_dentry_lfn; /* flags for seq field */ #define FATFS_LFN_SEQ_FIRST 0x40 /* This bit is set for the first lfn entry */ #define FATFS_LFN_SEQ_MASK 0x3f /* These bits are a mask for the decreasing * sequence number for the entries */ /* internal FATFS_INFO structure */ typedef struct { TSK_FS_INFO fs_info; /* super class */ //TSK_DATA_BUF *table; /* cached section of file allocation table */ /* FAT cache */ char fatc_buf[FAT_CACHE_N][FAT_CACHE_B]; TSK_DADDR_T fatc_addr[FAT_CACHE_N]; uint8_t fatc_ttl[FAT_CACHE_N]; // ttl of 0 means is not in use char *dinodes; /* cluster size buffer of inode list */ fatfs_sb *sb; fatfs_dentry *dep; /* FIrst sector of FAT */ TSK_DADDR_T firstfatsect; /* First sector after FAT - For TSK_FS_INFO_TYPE_FAT_12 and TSK_FS_INFO_TYPE_FAT_16, this is where the * root directory entries are. For TSK_FS_INFO_TYPE_FAT_32, this is the the first * cluster */ TSK_DADDR_T firstdatasect; /* The sector number were cluster 2 (the first one) is * for TSK_FS_INFO_TYPE_FAT_32, it will be the same as firstdatasect, but for TSK_FS_INFO_TYPE_FAT_12 & 16 * it will be the first sector after the Root directory */ TSK_DADDR_T firstclustsect; /* size of data area in clusters, starting at firstdatasect */ TSK_DADDR_T clustcnt; TSK_DADDR_T lastclust; /* sector where the root directory is located */ TSK_DADDR_T rootsect; uint32_t dentry_cnt_se; /* max number of dentries per sector */ uint32_t dentry_cnt_cl; /* max number of dentries per cluster */ uint16_t ssize; /* size of sectors in bytes */ uint16_t ssize_sh; /* power of 2 for size of sectors */ uint8_t csize; /* size of clusters in sectors */ //uint16_t reserved; /* number of reserved sectors */ uint8_t numfat; /* number of fat tables */ uint32_t sectperfat; /* sectors per fat table */ uint16_t numroot; /* number of 32-byte dentries in root dir */ uint32_t mask; /* the mask to use for the sectors */ TSK_INUM_T *dir_buf; // array that holds inode address of directories TSK_INUM_T *par_buf; // array that holds parent directory address of corresponding dir_buf entry size_t dir_buf_size; // number of entries in both dif_buf and par_buf size_t dir_buf_next; // index to the next place to store an address in dir_buf and par_buf } FATFS_INFO; extern int8_t fatfs_is_sectalloc(FATFS_INFO *, TSK_DADDR_T); extern int8_t fatfs_is_clustalloc(FATFS_INFO * fatfs, TSK_DADDR_T clust); extern uint8_t fatfs_isdentry(FATFS_INFO *, fatfs_dentry *, uint8_t); extern uint8_t fatfs_make_root(FATFS_INFO *, TSK_FS_META *); extern uint8_t fatfs_inode_lookup(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum); extern uint8_t fatfs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_action, void *a_ptr); extern uint8_t fatfs_make_data_run(TSK_FS_FILE * a_fs_file); extern uint8_t fatfs_getFAT(FATFS_INFO * fatfs, TSK_DADDR_T clust, TSK_DADDR_T * value); extern TSK_RETVAL_ENUM fatfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); extern int fatfs_name_cmp(TSK_FS_INFO *, const char *, const char *); extern uint8_t fatfs_dir_buf_add(FATFS_INFO * fatfs, TSK_INUM_T par_inum, TSK_INUM_T dir_inum); extern void fatfs_cleanup_ascii(char *name); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/tsk_ffs.h000644 000765 000024 00000035677 11643647440 017464 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2008 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /* * Contains the structures and function APIs for FFS file system support. */ #ifndef _TSK_FFS_H #define _TSK_FFS_H #ifdef __cplusplus extern "C" { #endif typedef uint32_t FFS_GRPNUM_T; #define PRI_FFSGRP PRIu32 /* ** CONSTANTS **/ #define FFS_FIRSTINO 0 /* 0 & 1 are reserved (1 was bad blocks) */ #define FFS_ROOTINO 2 /* location of root directory inode */ #define FFS_NDADDR 12 #define FFS_NIADDR 3 #define UFS1_SBOFF 8192 #define UFS2_SBOFF 65536 #define UFS2_SBOFF2 262144 #define UFS1_FS_MAGIC 0x011954 #define UFS2_FS_MAGIC 0x19540119 #define FFS_MAXNAMLEN 255 #define FFS_MAXPATHLEN 1024 #define FFS_DIRBLKSIZ 512 #define FFS_FILE_CONTENT_LEN ((FFS_NDADDR + FFS_NIADDR) * sizeof(TSK_DADDR_T)) typedef struct { uint8_t dir_num[4]; uint8_t blk_free[4]; uint8_t ino_free[4]; uint8_t frag_free[4]; } ffs_csum1; typedef struct { uint8_t dir_num[8]; uint8_t blk_free[8]; uint8_t ino_free[8]; uint8_t frag_free[8]; uint8_t clust_free[8]; uint8_t f1[24]; } ffs_csum2; /* * Super Block Structure */ // UFS 1 typedef struct { uint8_t f1[8]; /* Offsets in each cylinder group */ uint8_t sb_off[4]; /* s32 */ uint8_t gd_off[4]; /* s32 */ uint8_t ino_off[4]; /* s32 */ uint8_t dat_off[4]; /* s32 */ /* How much the base of the admin data in each cyl group changes */ uint8_t cg_delta[4]; /* s32 */ uint8_t cg_cyc_mask[4]; /* s32 */ uint8_t wtime[4]; /* u32 : last written time */ uint8_t frag_num[4]; /* s32 - number of fragments in FS */ uint8_t data_frag_num[4]; /* s32 - number of frags not being used for admin data */ uint8_t cg_num[4]; /* s32 - number of cyl grps in FS */ uint8_t bsize_b[4]; /* s32 - size of block */ uint8_t fsize_b[4]; /* s32 - size of fragment */ uint8_t bsize_frag[4]; /* s32 - num of frag in block */ uint8_t f5[36]; uint8_t fs_fragshift[4]; /* s32 */ uint8_t f6[20]; uint8_t fs_inopb[4]; /* s32 */ uint8_t f7[20]; uint8_t fs_id[8]; uint8_t cg_saddr[4]; /* s32 */ uint8_t cg_ssize_b[4]; /* s32 */ uint8_t fs_cgsize[4]; /* s32 */ uint8_t f7c[12]; uint8_t fs_ncyl[4]; /* s32 */ uint8_t fs_cpg[4]; /* s32 */ uint8_t cg_inode_num[4]; /* s32 */ uint8_t cg_frag_num[4]; /* s32 */ ffs_csum1 cstotal; uint8_t fs_fmod; uint8_t fs_clean; uint8_t fs_ronly; uint8_t fs_flags; uint8_t last_mnt[512]; uint8_t f8[648]; uint8_t magic[4]; /* s32 */ uint8_t f9[160]; /* filler so it is a multiple of 512 */ } ffs_sb1; // UFS 2 typedef struct { uint8_t f0[8]; /* Offsets in each cylinder group */ uint8_t sb_off[4]; /* s32 */ uint8_t gd_off[4]; /* s32 */ uint8_t ino_off[4]; /* s32 */ uint8_t dat_off[4]; /* s32 */ uint8_t f1[20]; /* s32 */ uint8_t cg_num[4]; /* s32 - number of cyl grps in FS */ uint8_t bsize_b[4]; /* s32 - size of block */ uint8_t fsize_b[4]; /* s32 - size of fragment */ uint8_t bsize_frag[4]; /* s32 - num of frag in block */ uint8_t f2[36]; uint8_t fs_fragshift[4]; /* s32 */ uint8_t f3[20]; uint8_t fs_inopb[4]; /* s32 */ uint8_t f4[32]; uint8_t cg_ssize_b[4]; /* s32 */ uint8_t fs_cgsize[4]; /* s32 */ uint8_t f5[20]; uint8_t cg_inode_num[4]; /* s32 */ uint8_t cg_frag_num[4]; /* s32 - fs_fpg */ uint8_t f6[16]; uint8_t fs_fmod; uint8_t fs_clean; uint8_t fs_ronly; uint8_t f7; uint8_t last_mnt[468]; uint8_t volname[32]; uint8_t swuid[8]; uint8_t f8[288]; ffs_csum2 cstotal; uint8_t wtime[8]; /* u32 : last written time */ uint8_t frag_num[8]; /* s32 - number of fragments in FS */ uint8_t blk_num[8]; /* s32 - number of blocks in FS */ uint8_t cg_saddr[8]; uint8_t f9[208]; uint8_t fs_flags[4]; uint8_t f10[56]; uint8_t magic[4]; /* s32 */ uint8_t f11[160]; /* filler so it is a multiple of 512 */ } ffs_sb2; #define FFS_SB_FLAG_UNCLEAN 0x01 #define FFS_SB_FLAG_SOFTDEP 0x02 #define FFS_SB_FLAG_NEEDFSCK 0x04 #define FFS_SB_FLAG_INDEXDIR 0x08 #define FFS_SB_FLAG_ACL 0x10 #define FFS_SB_FLAG_MULTILABEL 0x20 #define FFS_SB_FLAG_UPDATED 0x80 /* How the file system is optimized */ #define FFS_SB_OPT_TIME 0 #define FFS_SB_OPT_SPACE 1 /* * Cylinder Group Descriptor * * UFS1 and UFS2 are the same for the data that we care about unless we * want the wtime for 'fsstat'. */ typedef struct { uint8_t f1[4]; uint8_t magic[4]; /* 0x090255 */ uint8_t wtime[4]; /* last written time */ uint8_t cg_cgx[4]; /* s32 - my group number */ uint8_t cyl_num[2]; /* number of cyl in this group */ uint8_t ino_num[2]; /* number of inodes in this group */ uint8_t frag_num[4]; /* number of fragments in this group */ ffs_csum1 cs; uint8_t last_alloc_blk[4]; /* last allocated blk relative to start */ uint8_t last_alloc_frag[4]; /* last alloc frag relative to start */ uint8_t last_alloc_ino[4]; uint8_t avail_frag[8][4]; uint8_t f2b[8]; uint8_t cg_iusedoff[4]; /* s32 */ uint8_t cg_freeoff[4]; /* s32 */ uint8_t f3[72]; } ffs_cgd; typedef struct { uint8_t f1[4]; uint8_t magic[4]; /* 0x090255 */ uint8_t f2[4]; uint8_t cg_cgx[4]; /* s32 - my group number */ uint8_t f2a[4]; /* number of cyl in this group */ uint8_t frag_num[4]; /* number of fragments in this group */ ffs_csum1 cs; uint8_t last_alloc_blk[4]; /* last allocated blk relative to start */ uint8_t last_alloc_frag[4]; /* last alloc frag relative to start */ uint8_t last_alloc_ino[4]; uint8_t avail_frag[8][4]; uint8_t f2b[8]; uint8_t cg_iusedoff[4]; /* s32 */ uint8_t cg_freeoff[4]; /* s32 */ uint8_t cg_nextfreeoff[4]; uint8_t cg_clustersumoff[4]; uint8_t cg_clusteroff[4]; uint8_t cg_nclustersblks[4]; uint8_t cg_niblk[4]; uint8_t cg_initediblk[4]; uint8_t f3a[12]; uint8_t wtime[8]; uint8_t f3[24]; } ffs_cgd2; /* * inode */ /* ffs_inode1: OpenBSD & FreeBSD etc. */ typedef struct { uint8_t di_mode[2]; /* u16 */ uint8_t di_nlink[2]; /* s16 */ uint8_t f1[4]; uint8_t di_size[8]; /* u64 */ uint8_t di_atime[4]; /* s32 */ uint8_t di_atimensec[4]; uint8_t di_mtime[4]; /* s32 */ uint8_t di_mtimensec[4]; uint8_t di_ctime[4]; /* s32 */ uint8_t di_ctimensec[4]; uint8_t di_db[12][4]; /* s32 */ uint8_t di_ib[3][4]; /* s32 */ uint8_t f5[8]; uint8_t gen[4]; uint8_t di_uid[4]; /* u32 */ uint8_t di_gid[4]; /* u32 */ uint8_t f6[8]; } ffs_inode1; /* ffs_inode1b: Solaris */ typedef struct { uint8_t di_mode[2]; /* u16 */ uint8_t di_nlink[2]; /* s16 */ uint8_t f1[4]; uint8_t di_size[8]; /* u64 */ uint8_t di_atime[4]; /* s32 */ uint8_t f2[4]; uint8_t di_mtime[4]; /* s32 */ uint8_t f3[4]; uint8_t di_ctime[4]; /* s32 */ uint8_t f4[4]; uint8_t di_db[12][4]; /* s32 */ uint8_t di_ib[3][4]; /* s32 */ uint8_t f5[16]; uint8_t di_uid[4]; /* u32 */ uint8_t di_gid[4]; /* u32 */ uint8_t f6[4]; } ffs_inode1b; typedef struct { uint8_t di_mode[2]; /* u16 */ uint8_t di_nlink[2]; /* s16 */ uint8_t di_uid[4]; uint8_t di_gid[4]; uint8_t di_blksize[4]; /* u32 inode block size */ uint8_t di_size[8]; /* u64 */ uint8_t di_blocks[8]; /* u64 - bytes held */ uint8_t di_atime[8]; /* s64 */ uint8_t di_mtime[8]; /* s64 */ uint8_t di_ctime[8]; /* s64 */ uint8_t di_crtime[8]; /* s64 */ uint8_t di_mtimensec[4]; /* s32 */ uint8_t di_atimensec[4]; uint8_t di_ctimensec[4]; uint8_t di_crtimensec[4]; uint8_t di_gen[4]; /* s32 generation number */ uint8_t di_kflags[4]; /* u32 kernel flags */ uint8_t di_flags[4]; /* u32 flags */ uint8_t di_extsize[4]; /* s32 size of ext attributes block */ uint8_t di_extb[2][8]; /* Address of ext attribute blocks */ uint8_t di_db[12][8]; /* s32 */ uint8_t di_ib[3][8]; /* s32 */ uint8_t f2[24]; /* s32 */ } ffs_inode2; #define FFS_IN_FMT 0170000 /* Mask of file type. */ #define FFS_IN_FIFO 0010000 /* Named pipe (fifo). */ #define FFS_IN_CHR 0020000 /* Character device. */ #define FFS_IN_DIR 0040000 /* Directory file. */ #define FFS_IN_BLK 0060000 /* Block device. */ #define FFS_IN_REG 0100000 /* Regular file. */ #define FFS_IN_LNK 0120000 /* Symbolic link. */ #define FFS_IN_SHAD 0130000 /* SOLARIS ONLY */ #define FFS_IN_SOCK 0140000 /* UNIX domain socket. */ #define FFS_IN_WHT 0160000 /* Whiteout. */ #define FFS_IN_ISUID 0004000 #define FFS_IN_ISGID 0002000 #define FFS_IN_ISVTX 0001000 #define FFS_IN_IRUSR 0000400 #define FFS_IN_IWUSR 0000200 #define FFS_IN_IXUSR 0000100 #define FFS_IN_IRGRP 0000040 #define FFS_IN_IWGRP 0000020 #define FFS_IN_IXGRP 0000010 #define FFS_IN_IROTH 0000004 #define FFS_IN_IWOTH 0000002 #define FFS_IN_IXOTH 0000001 typedef struct { uint8_t reclen[4]; uint8_t nspace; uint8_t contpad; uint8_t nlen; uint8_t name[1]; /* of length nlen and padded so contents are on 8-byte boundary */ } ffs_extattr; #define FFS_ATTR_CONT(x) \ ((((x) + 7 + 7) / 8) * 2) /* * Directory Entries */ /* ffs_dentry1: new OpenBSD & FreeBSD etc. */ typedef struct { uint8_t d_ino[4]; /* u32 */ uint8_t d_reclen[2]; /* u16 */ uint8_t d_type; /* u8 */ uint8_t d_namlen; /* u8 */ char d_name[256]; } ffs_dentry1; /* type field values */ #define FFS_DT_UNKNOWN 0 #define FFS_DT_FIFO 1 #define FFS_DT_CHR 2 #define FFS_DT_DIR 4 #define FFS_DT_BLK 6 #define FFS_DT_REG 8 #define FFS_DT_LNK 10 #define FFS_DT_SOCK 12 #define FFS_DT_WHT 14 /* ffs_dentry2: Solaris and old xBSDs (no type field) */ typedef struct { uint8_t d_ino[4]; /* u32 */ uint8_t d_reclen[2]; /* u16 */ uint8_t d_namlen[2]; /* u16 */ char d_name[256]; } ffs_dentry2; #define FFS_DIRSIZ_lcl(len) \ ((len + 8 + 3) & ~(3)) /* Return the base fragment for group c */ #define cgbase_lcl(fsi, fs, c) \ ((TSK_DADDR_T)(tsk_gets32(fsi->endian, (fs)->cg_frag_num) * (c))) /* Macros to calc the locations of structures in cyl groups */ #define cgstart_lcl(fsi, fs, c) \ ((TSK_DADDR_T)((tsk_getu32((fsi)->endian, (fs)->magic) == UFS2_FS_MAGIC) ? \ (cgbase_lcl(fsi, fs, c)) : \ (cgbase_lcl(fsi, fs, c) + tsk_gets32((fsi)->endian, (fs)->cg_delta) * \ ((c) & ~(tsk_gets32((fsi)->endian, (fs)->cg_cyc_mask)))) )) /* cyl grp block */ #define cgtod_lcl(fsi, fs, c) \ ((TSK_DADDR_T)(cgstart_lcl(fsi, fs, c) + tsk_gets32(fsi->endian, (fs)->gd_off))) /* Offset to inode table in cylinder group */ #define cgimin_lcl(fsi, fs, c) \ ((TSK_DADDR_T)(cgstart_lcl(fsi, fs, c) + tsk_gets32(fsi->endian, (fs)->ino_off))) /* 1st data block in cyl grp*/ #define cgdmin_lcl(fsi, fs, c) \ ((TSK_DADDR_T)(cgstart_lcl(fsi, fs, c) + tsk_gets32(fsi->endian, (fs)->dat_off))) /* super blk in cyl grp*/ #define cgsblock_lcl(fsi, fs, c) \ ((TSK_DADDR_T)(cgstart_lcl(fsi, fs, c) + tsk_gets32(fsi->endian, (fs)->sb_off))) /* original: ** blkstofrags(fs, blks) ** ((blks) << (fs)->fs_fragshift) */ #define blkstofrags_lcl(fsi, fs, blks) \ ((blks) << tsk_gets32(fsi->endian, (fs)->fs_fragshift)) /* original: ** itod(fs, x) \ ** ((TSK_DADDR_T)(cgimin(fs, itog(fs, x)) + \ ** (blkstofrags((fs), (((x)%(ulong_t)(fs)->cg_inode_num)/(ulong_t)INOPB(fs)))))) */ #define itod_lcl(fsi, fs, x) \ ((TSK_DADDR_T)(cgimin_lcl(fsi, fs, itog_lcl(fsi, fs, x)) + \ (blkstofrags_lcl(fsi, (fs), (((x)%(TSK_DADDR_T)tsk_gets32(fsi->endian, (fs)->cg_inode_num))/ \ (TSK_DADDR_T)tsk_gets32(fsi->endian, (fs)->fs_inopb)))))) /* original: ** itoo(fs, x) ((x) % (uint32_t)INOPB(fs)) */ #define itoo_lcl(fsi, fs, x) \ ((x) % (uint32_t)tsk_getu32(fsi->endian, (fs)->fs_inopb)) /* original: ** #define itog(fs, x) ((x) / (fs)->fs_cg_inode_num) */ #define itog_lcl(fsi, fs, x) \ (FFS_GRPNUM_T)((x) / tsk_gets32(fsi->endian, (fs)->cg_inode_num)) /* original: ** dtog(fs, d) ((d) / (fs)->fs_cg_frag_num) */ #define dtog_lcl(fsi, fs, d) \ (FFS_GRPNUM_T)((d) / tsk_gets32(fsi->endian, (fs)->cg_frag_num)) #define cg_inosused_lcl(fsi, cgp) \ ((uint8_t *)((uint8_t *)(cgp) + tsk_gets32(fsi->endian, (cgp)->cg_iusedoff))) #define cg_blksfree_lcl(fsi, cgp) \ ((uint8_t *)((uint8_t *)(cgp) + tsk_gets32(fsi->endian, (cgp)->cg_freeoff))) /* * Structure of a fast file system handle. */ typedef struct { TSK_FS_INFO fs_info; /* super class */ union { ffs_sb1 *sb1; /* super block buffer */ ffs_sb2 *sb2; /* super block buffer */ } fs; char *dino_buf; /* cached disk inode */ TSK_INUM_T dino_inum; /* address of cached disk inode */ char *itbl_buf; ///< Cached inode block buffer TSK_DADDR_T itbl_addr; ///< Address where inode block buf was read from:w char *grp_buf; ///< Cached cylinder group buffer FFS_GRPNUM_T grp_num; ///< Cyl grp num that is cached TSK_DADDR_T grp_addr; ///< Address where cached cyl grp data was read from FFS_GRPNUM_T groups_count; /* nr of descriptor group blocks */ unsigned int ffsbsize_f; /* num of frags in an FFS block */ unsigned int ffsbsize_b; /* size of an FFS block in bytes */ } FFS_INFO; extern TSK_RETVAL_ENUM ffs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); #ifdef __cplusplus } #endif #endif /* _FFS_H */ sleuthkit-3.2.3/tsk3/fs/tsk_fs.h000644 000765 000024 00000132605 11643647440 017303 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2008 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /** \file tsk_fs.h * External header file for file system support. * Note that this file is not meant to be directly included. * It is included by both libtsk.h and tsk_fs_i.h. */ /* LICENSE * .ad * .fi * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** * \defgroup fslib File System Functions */ #ifndef _TSK_FS_H #define _TSK_FS_H #include #ifdef __cplusplus extern "C" { #endif typedef struct TSK_FS_INFO TSK_FS_INFO; typedef struct TSK_FS_FILE TSK_FS_FILE; /**************** BLOCK Structure *******************/ /** \name Generic File System Block Data Structure */ //@{ /** Flags that are used in TSK_FS_BLOCK and in callback of file_walk. * Note that some of these are dependent. A block can be either TSK_FS_BLOCK_FLAG_ALLOC * or TSK_FS_BLOCK_FLAG_UNALLOC. It can be one of TSK_FS_BLOCK_FLAG_RAW, TSK_FS_BLOCK_FLAG_BAD, * TSK_FS_BLOCK_FLAG_RES, TSK_FS_BLOCK_FLAG_SPARSE, or TSK_FS_BLOCK_FLAG_COMP. Note that some of * these are set only by file_walk because they are file-level details, such as compression and sparse. */ enum TSK_FS_BLOCK_FLAG_ENUM { TSK_FS_BLOCK_FLAG_UNUSED = 0x0000, ///< Used to show that TSK_FS_BLOCK structure has no data in it TSK_FS_BLOCK_FLAG_ALLOC = 0x0001, ///< Block is allocated (and not TSK_FS_BLOCK_FLAG_UNALLOC) TSK_FS_BLOCK_FLAG_UNALLOC = 0x0002, ///< Block is unallocated (and not TSK_FS_BLOCK_FLAG_ALLOC) TSK_FS_BLOCK_FLAG_CONT = 0x0004, ///< Block (could) contain file content (and not TSK_FS_BLOCK_FLAG_META) TSK_FS_BLOCK_FLAG_META = 0x0008, ///< Block (could) contain file system metadata (and not TSK_FS_BLOCK_FLAG_CONT) TSK_FS_BLOCK_FLAG_BAD = 0x0010, ///< Block has been marked as bad by the file system TSK_FS_BLOCK_FLAG_RAW = 0x0020, ///< The data has been read raw from the disk (and not COMP or SPARSE) TSK_FS_BLOCK_FLAG_SPARSE = 0x0040, ///< The data passed in the file_walk calback was stored as sparse (all zeros) (and not RAW or COMP) TSK_FS_BLOCK_FLAG_COMP = 0x0080, ///< The data passed in the file_walk callback was stored in a compressed form (and not RAW or SPARSE) TSK_FS_BLOCK_FLAG_RES = 0x0100 ///< The data passed in the file_walk callback is from an NTFS resident file }; typedef enum TSK_FS_BLOCK_FLAG_ENUM TSK_FS_BLOCK_FLAG_ENUM; /** * Flags that are used to specify which blocks to call the tsk_fs_block_walk() callback function with. */ enum TSK_FS_BLOCK_WALK_FLAG_ENUM { TSK_FS_BLOCK_WALK_FLAG_NONE = 0x00, ///< No Flags TSK_FS_BLOCK_WALK_FLAG_ALLOC = 0x01, ///< Allocated blocks TSK_FS_BLOCK_WALK_FLAG_UNALLOC = 0x02, ///< Unallocated blocks TSK_FS_BLOCK_WALK_FLAG_CONT = 0x04, ///< Blocks that could store file content TSK_FS_BLOCK_WALK_FLAG_META = 0x08, ///< Blocks that could store file system metadata }; typedef enum TSK_FS_BLOCK_WALK_FLAG_ENUM TSK_FS_BLOCK_WALK_FLAG_ENUM; #define TSK_FS_BLOCK_TAG 0x1b7c3f4a /** * Generic data strcture to hold block data with metadata */ typedef struct { int tag; ///< \internal Will be set to TSK_FS_BLOCK_TAG if structure is valid / allocated TSK_FS_INFO *fs_info; ///< Pointer to file system that block is from char *buf; ///< Buffer with block data (of size TSK_FS_INFO::block_size) TSK_DADDR_T addr; ///< Address of block TSK_FS_BLOCK_FLAG_ENUM flags; /// < Flags for block (alloc or unalloc) } TSK_FS_BLOCK; /** * Function definition used for callback to tsk_fs_block_walk(). * * @param a_block Pointer to block structure that holds block content and flags * @param a_ptr Pointer that was supplied by the caller who called tsk_fs_block_walk * @returns Value to identify if walk should continue, stop, or stop because of error */ typedef TSK_WALK_RET_ENUM(*TSK_FS_BLOCK_WALK_CB) (const TSK_FS_BLOCK * a_block, void *a_ptr); // external block-level functions extern void tsk_fs_block_free(TSK_FS_BLOCK * a_fs_block); extern TSK_FS_BLOCK *tsk_fs_block_get(TSK_FS_INFO * fs, TSK_FS_BLOCK * fs_block, TSK_DADDR_T addr); extern uint8_t tsk_fs_block_walk(TSK_FS_INFO * a_fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr); //@} /**************** DATA and DATA_LIST Structures ************/ /** \name Generic File System File Content Data Structures */ //@{ /* The location of "most" file content is stored in the generic TSK * data structures as runs (starting address and length). */ /** * Flags used for a TSK_FS_ATTR_RUN entry. */ typedef enum { TSK_FS_ATTR_RUN_FLAG_NONE = 0x00, ///< No Flag TSK_FS_ATTR_RUN_FLAG_FILLER = 0x01, ///< Entry is a filler for a run that has not been seen yet in the processing (or has been lost) TSK_FS_ATTR_RUN_FLAG_SPARSE = 0x02 ///< Entry is a sparse run where all data in the run is zeros } TSK_FS_ATTR_RUN_FLAG_ENUM; typedef struct TSK_FS_ATTR_RUN TSK_FS_ATTR_RUN; /** * Holds information about a single data run, which has a starting address and length. * A run describes a consecutive list of blocks that have been allocated to a file. * A file may have many such runs and they are stringed together in a linked list. * The entries in the list must be stored in sequential order (based on offset in file). */ struct TSK_FS_ATTR_RUN { TSK_FS_ATTR_RUN *next; ///< Pointer to the next run in the attribute (or NULL) TSK_DADDR_T offset; ///< Offset (in blocks) of this run in the file TSK_DADDR_T addr; ///< Starting block address (in file system) of run TSK_DADDR_T len; ///< Number of blocks in run (0 when entry is not in use) TSK_FS_ATTR_RUN_FLAG_ENUM flags; ///< Flags for run }; /** * Flags used for the TSK_FS_ATTR structure, which is used to * store file content metadata. */ typedef enum { TSK_FS_ATTR_FLAG_NONE = 0x00, ///< No Flag TSK_FS_ATTR_INUSE = 0x01, ///< data structure is in use TSK_FS_ATTR_NONRES = 0x02, ///< Contains non-resident data (i.e. located in blocks) TSK_FS_ATTR_RES = 0x04, ///< Contains resident data (i.e. in a small buffer) TSK_FS_ATTR_ENC = 0x10, ///< Contains encrypted data TSK_FS_ATTR_COMP = 0x20, ///< Contains compressed data TSK_FS_ATTR_SPARSE = 0x40, ///< Contains sparse data TSK_FS_ATTR_RECOVERY = 0x80, ///< Data was determined in file recovery mode } TSK_FS_ATTR_FLAG_ENUM; /** * File walk callback function definition. This is called for * chunks of content in the file being processed. * @param a_fs_file Pointer to file being processed * @param a_off Byte offset in file that this data is for * @param a_addr Address of data being passed (valid only if a_flags have RAW set) * @param a_buf Pointer to buffer with file content * @param a_len Size of data in buffer (in bytes) * @param a_flags Flags about the file content * @param a_ptr Pointer that was specified by caller to inode_walk * @returns Value that tells file walk to continue or stop */ typedef TSK_WALK_RET_ENUM(*TSK_FS_FILE_WALK_CB) (TSK_FS_FILE * a_fs_file, TSK_OFF_T a_off, TSK_DADDR_T a_addr, char *a_buf, size_t a_len, TSK_FS_BLOCK_FLAG_ENUM a_flags, void *a_ptr); /** * Flags used by tsk_fs_file_walk to determine when the callback function should * be used. */ typedef enum { TSK_FS_FILE_WALK_FLAG_NONE = 0x00, ///< No Flag TSK_FS_FILE_WALK_FLAG_SLACK = 0x01, ///< Include the file's slack space in the callback. TSK_FS_FILE_WALK_FLAG_NOID = 0x02, ///< Ignore the Id argument given in the API (use only the type) TSK_FS_FILE_WALK_FLAG_AONLY = 0x04, ///< Provide callback with only addresses and no file content. TSK_FS_FILE_WALK_FLAG_NOSPARSE = 0x08, ///< Do not include sparse blocks in the callback. } TSK_FS_FILE_WALK_FLAG_ENUM; /** * These are based on the NTFS type values. */ typedef enum { TSK_FS_ATTR_TYPE_DEFAULT = 0x01, // 1 TSK_FS_ATTR_TYPE_NTFS_SI = 0x10, // 16 TSK_FS_ATTR_TYPE_NTFS_ATTRLIST = 0x20, // 32 TSK_FS_ATTR_TYPE_NTFS_FNAME = 0x30, // 48 TSK_FS_ATTR_TYPE_NTFS_VVER = 0x40, // 64 (NT) TSK_FS_ATTR_TYPE_NTFS_OBJID = 0x40, // 64 (2K) TSK_FS_ATTR_TYPE_NTFS_SEC = 0x50, // 80 TSK_FS_ATTR_TYPE_NTFS_VNAME = 0x60, // 96 TSK_FS_ATTR_TYPE_NTFS_VINFO = 0x70, // 112 TSK_FS_ATTR_TYPE_NTFS_DATA = 0x80, // 128 TSK_FS_ATTR_TYPE_NTFS_IDXROOT = 0x90, // 144 TSK_FS_ATTR_TYPE_NTFS_IDXALLOC = 0xA0, // 160 TSK_FS_ATTR_TYPE_NTFS_BITMAP = 0xB0, // 176 TSK_FS_ATTR_TYPE_NTFS_SYMLNK = 0xC0, // 192 (NT) TSK_FS_ATTR_TYPE_NTFS_REPARSE = 0xC0, // 192 (2K) TSK_FS_ATTR_TYPE_NTFS_EAINFO = 0xD0, // 208 TSK_FS_ATTR_TYPE_NTFS_EA = 0xE0, // 224 TSK_FS_ATTR_TYPE_NTFS_PROP = 0xF0, // (NT) TSK_FS_ATTR_TYPE_NTFS_LOG = 0x100, // (2K) TSK_FS_ATTR_TYPE_UNIX_INDIR = 0x1001 // Indirect blocks for UFS and ExtX file systems } TSK_FS_ATTR_TYPE_ENUM; #define TSK_FS_ATTR_ID_DEFAULT 0 ///< Default Data ID used if file system does not assign one. typedef struct TSK_FS_ATTR TSK_FS_ATTR; /** * Holds information about the location of file content (or a file attribute). For most file systems, a file * has only a single attribute that stores the file content. * Other file systems, such as NTFS, have multiple * attributes. If multiple attributes exist, they are stored in a linked list. * Attributes can be "resident", which means the data is stored * in a small buffer instead of being stored in a full file system block. * "Non-resident" attributes store data in blocks and they are stored in * the data structure as a series of runs. * This structure is used to represent both of these cases. * * The non-resident data has several size values. * \verbatim * |--------------------------------------------------------------------| * |skiplen|---------------allocsize------------------------------------| * |skiplen|---------------size-----------------------------------| * |skiplen|---------------initsize------------| * \endverbatim */ struct TSK_FS_ATTR { TSK_FS_ATTR *next; ///< Pointer to next attribute in list TSK_FS_FILE *fs_file; ///< Pointer to the file that this is from TSK_FS_ATTR_FLAG_ENUM flags; ///< Flags for attribute char *name; ///< Name of attribute (in UTF-8). Will be NULL if attribute doesn't have a name. size_t name_size; ///< Number of bytes allocated to name TSK_FS_ATTR_TYPE_ENUM type; ///< Type of attribute uint16_t id; ///< Id of attribute TSK_OFF_T size; ///< Size in bytes of attribute (does not include skiplen for non-resident) /** * Data associated with a non-resident file / attribute. * The data is stored in one or more data runs. */ struct { TSK_FS_ATTR_RUN *run; ///< Linked list of runs for non-resident attributes TSK_FS_ATTR_RUN *run_end; ///< Pointer to final run in the list uint32_t skiplen; ///< Number of initial bytes in run to skip before content begins. The size field does not include this length. TSK_OFF_T allocsize; ///< Number of bytes that are allocated in all clusters of non-resident run (will be larger than size - does not include skiplen). This is defined when the attribute is created and used to determine slack space. TSK_OFF_T initsize; ///< Number of bytes (starting from offset 0) that have data (including FILLER) saved for them (smaller then or equal to size). This is defined when the attribute is created. uint32_t compsize; ///< Size of compression units (needed only if NTFS file is compressed) } nrd; /** * Data associated with a resident attribute / file. * The data is stored in a buffer. */ struct { uint8_t *buf; ///< Buffer for resident data size_t buf_size; ///< Number of bytes allocated to buf } rd; /* Special file (compressed, encrypted, etc.) */ ssize_t(*r) (const TSK_FS_ATTR * fs_attr, TSK_OFF_T a_offset, char *a_buf, size_t a_len); uint8_t(*w) (const TSK_FS_ATTR * fs_attr, int flags, TSK_FS_FILE_WALK_CB, void *); }; /** * Structure used as the head of an attribute list. */ typedef struct { TSK_FS_ATTR *head; } TSK_FS_ATTRLIST; extern uint8_t tsk_fs_attr_walk(const TSK_FS_ATTR * a_fs_attr, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr); //@} /**************** META_NAME_LIST Structure *******************/ /** \name Generic File System File Metadata Data Structures */ //@{ /** * Size of name array in TSK_FS_META_NAME_LIST structure */ #define TSK_FS_META_NAME_LIST_NSIZE 512 typedef struct TSK_FS_META_NAME_LIST TSK_FS_META_NAME_LIST; /** * Relatively generic structure to hold file names that are stored with * the file metadata. Note that this is different from the * file name stored in the directory heirarchy, which is * part of the tsk_fs_name_... code. This is currently * used for NTFS and FAT file systems only. */ struct TSK_FS_META_NAME_LIST { TSK_FS_META_NAME_LIST *next; ///< Pointer to next name (or NULL) char name[TSK_FS_META_NAME_LIST_NSIZE]; ///< Name in UTF-8 (does not include parent directory name) TSK_INUM_T par_inode; ///< Inode address of parent directory (NTFS only) uint32_t par_seq; ///< Sequence number of parent directory (NTFS only) }; /****************** META Structure ***************/ /** * Metadata flags used in TSK_FS_META.flags and in request to inode_walk */ enum TSK_FS_META_FLAG_ENUM { TSK_FS_META_FLAG_ALLOC = 0x01, ///< Metadata structure is currently in an allocated state TSK_FS_META_FLAG_UNALLOC = 0x02, ///< Metadata structure is currently in an unallocated state TSK_FS_META_FLAG_USED = 0x04, ///< Metadata structure has been allocated at least once TSK_FS_META_FLAG_UNUSED = 0x08, ///< Metadata structure has never been allocated. TSK_FS_META_FLAG_COMP = 0x10, ///< The file contents are compressed. TSK_FS_META_FLAG_ORPHAN = 0x20, ///< Return only metadata structures that have no file name pointing to the (inode_walk flag only) }; typedef enum TSK_FS_META_FLAG_ENUM TSK_FS_META_FLAG_ENUM; enum TSK_FS_META_ATTR_FLAG_ENUM { TSK_FS_META_ATTR_EMPTY, ///< The data in the attributes (if any) is not for this file TSK_FS_META_ATTR_STUDIED, ///< The data in the attributes are for this file TSK_FS_META_ATTR_ERROR, ///< The attributes for this file could not be loaded }; typedef enum TSK_FS_META_ATTR_FLAG_ENUM TSK_FS_META_ATTR_FLAG_ENUM; /** * Values for the mode field -- which identifies the file type * and permissions. */ enum TSK_FS_META_TYPE_ENUM { TSK_FS_META_TYPE_UNDEF = 0x00, TSK_FS_META_TYPE_REG = 0x01, ///< Regular file TSK_FS_META_TYPE_DIR = 0x02, ///< Directory file TSK_FS_META_TYPE_FIFO = 0x03, ///< Named pipe (fifo) TSK_FS_META_TYPE_CHR = 0x04, ///< Character device TSK_FS_META_TYPE_BLK = 0x05, ///< Block device TSK_FS_META_TYPE_LNK = 0x06, ///< Symbolic link TSK_FS_META_TYPE_SHAD = 0x07, ///< SOLARIS ONLY TSK_FS_META_TYPE_SOCK = 0x08, ///< UNIX domain socket TSK_FS_META_TYPE_WHT = 0x09, ///< Whiteout TSK_FS_META_TYPE_VIRT = 0x0a, ///< "Virtual File" created by TSK for file system areas }; typedef enum TSK_FS_META_TYPE_ENUM TSK_FS_META_TYPE_ENUM; #define TSK_FS_META_TYPE_STR_MAX 0x0b ///< Number of file types in shortname array extern char tsk_fs_meta_type_str[TSK_FS_META_TYPE_STR_MAX][2]; enum TSK_FS_META_MODE_ENUM { /* The following describe the file permissions */ TSK_FS_META_MODE_ISUID = 0004000, ///< set user id on execution TSK_FS_META_MODE_ISGID = 0002000, ///< set group id on execution TSK_FS_META_MODE_ISVTX = 0001000, ///< sticky bit TSK_FS_META_MODE_IRUSR = 0000400, ///< R for owner TSK_FS_META_MODE_IWUSR = 0000200, ///< W for owner TSK_FS_META_MODE_IXUSR = 0000100, ///< X for owner TSK_FS_META_MODE_IRGRP = 0000040, ///< R for group TSK_FS_META_MODE_IWGRP = 0000020, ///< W for group TSK_FS_META_MODE_IXGRP = 0000010, ///< X for group TSK_FS_META_MODE_IROTH = 0000004, ///< R for other TSK_FS_META_MODE_IWOTH = 0000002, ///< W for other TSK_FS_META_MODE_IXOTH = 0000001 ///< X for other }; typedef enum TSK_FS_META_MODE_ENUM TSK_FS_META_MODE_ENUM; #define TSK_FS_META_TAG 0x13524635 /** * TSK data structure to store general file and directory metadata. * Note that the file in the file * system may have more metadata than is stored here. * For performance reasons, the run list of the file content is not always known * when the file is loaded. It may be loaded only when needed by the internal code. * The TSK_FS_META::content_ptr pointer contains file system-specific data that will be * used to determine the full run. After it has been loaded, the TSK_FS_META::attr field * will contain that info. */ typedef struct { int tag; ///< \internal Will be set to TSK_FS_META_TAG if structure is allocated TSK_FS_META_FLAG_ENUM flags; ///< Flags for this file for its allocation status etc. TSK_INUM_T addr; ///< Address of the meta data structure for this file TSK_FS_META_TYPE_ENUM type; ///< File type TSK_FS_META_MODE_ENUM mode; ///< Unix-style permissions int nlink; ///< link count (number of file names pointing to this) TSK_OFF_T size; ///< file size (in bytes) TSK_UID_T uid; ///< owner id TSK_GID_T gid; ///< group id /* @@@ Need to make these 64-bits ... ? */ time_t mtime; ///< last file content modification time (stored in number of seconds since Jan 1, 1970 UTC) uint32_t mtime_nano; ///< nano-second resolution in addition to m_time time_t atime; ///< last file content accessed time (stored in number of seconds since Jan 1, 1970 UTC) uint32_t atime_nano; ///< nano-second resolution in addition to a_time time_t ctime; ///< last file / metadata status change time (stored in number of seconds since Jan 1, 1970 UTC) uint32_t ctime_nano; ///< nano-second resolution in addition to c_time time_t crtime; ///< Created time (stored in number of seconds since Jan 1, 1970 UTC) uint32_t crtime_nano; ///< nano-second resolution in addition to cr_time /* filesystem specific times */ union { struct { time_t dtime; ///< Linux deletion time uint32_t dtime_nano; ///< nano-second resolution in addition to d_time } ext2; struct { time_t bkup_time; ///< HFS+ backup time uint32_t bkup_time_nano; ///< nano-second resolution in addition to bkup_time } hfs; } time2; void *content_ptr; ///< Pointer to file system specific data that is used to store references to file content size_t content_len; ///< size of content buffer uint32_t seq; ///< Sequence number for file (NTFS only, is incremented when entry is reallocated) /** Contains run data on the file content (specific locations where content is stored). * Check attr_state to determine if data in here is valid because not all file systems * load this data when a file is loaded. It may not be loaded until needed by one * of the APIs. Most file systems will have only one attribute, but NTFS will have several. */ TSK_FS_ATTRLIST *attr; TSK_FS_META_ATTR_FLAG_ENUM attr_state; ///< State of the data in the TSK_FS_META::attr structure TSK_FS_META_NAME_LIST *name2; ///< Name of file stored in metadata (FAT and NTFS Only) char *link; ///< Name of target file if this is a symbolic link } TSK_FS_META; /** String that is prepended to orphan FAT & NTFS files when the file * name is known, but the parent is not */ #define TSK_FS_ORPHAN_STR "-ORPHAN_FILE-" /* we are using the last inode as the special inode for the orphan directory. Note that this * macro is defined to abstract this convention, but there are many places in the code where * there is implied logic about this convention. For example, inode_walks will stop before * this value so that special handling can occur. */ #define TSK_FS_ORPHANDIR_INUM(fs_info) \ (fs_info->last_inum) /** * inode walk callback function definition. This is called for every file * that meets the critera specified when inode_walk was called. * @param a_fs_file Pointer to the current file * @param a_ptr Pointer that was specified by caller to inode_walk * @returns Value that tells inode walk to continue or stop */ typedef TSK_WALK_RET_ENUM(*TSK_FS_META_WALK_CB) (TSK_FS_FILE * a_fs_file, void *a_ptr); extern uint8_t tsk_fs_meta_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_start, TSK_INUM_T a_end, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_cb, void *a_ptr); extern uint8_t tsk_fs_meta_make_ls(TSK_FS_META * a_fs_meta, char *a_buf, size_t a_len); //@} /************* NAME / DIR structures **********/ /** \name Generic File System File Name Data Structures */ //@{ /** * File name flags that are used when specifying the status of * a name in the TSK_FS_NAME structure */ typedef enum { TSK_FS_NAME_FLAG_ALLOC = 0x01, ///< Name is in an allocated state TSK_FS_NAME_FLAG_UNALLOC = 0x02, ///< Name is in an unallocated state } TSK_FS_NAME_FLAG_ENUM; /** * File type values -- as specified in the directory entry structure. */ typedef enum { TSK_FS_NAME_TYPE_UNDEF = 0, ///< Unknown type TSK_FS_NAME_TYPE_FIFO = 1, ///< Named pipe TSK_FS_NAME_TYPE_CHR = 2, ///< Character device TSK_FS_NAME_TYPE_DIR = 3, ///< Directory TSK_FS_NAME_TYPE_BLK = 4, ///< Block device TSK_FS_NAME_TYPE_REG = 5, ///< Regular file TSK_FS_NAME_TYPE_LNK = 6, ///< Symbolic link TSK_FS_NAME_TYPE_SOCK = 7, ///< Socket TSK_FS_NAME_TYPE_SHAD = 8, ///< Shadow inode (solaris) TSK_FS_NAME_TYPE_WHT = 9, ///< Whiteout (openbsd) TSK_FS_NAME_TYPE_VIRT = 10, ///< Special (TSK added "Virtual" files) } TSK_FS_NAME_TYPE_ENUM; #define TSK_FS_NAME_TYPE_STR_MAX 11 ///< Number of types that have a short string name /* ascii representation of above types */ extern char tsk_fs_name_type_str[TSK_FS_NAME_TYPE_STR_MAX][2]; #define TSK_FS_NAME_TAG 0x23147869 /** * Generic structure to store the file name information that is stored in * a directory. Most file systems seperate the file name from the metadata, but * some do not (such as FAT). This structure contains the name and address of the * metadata. */ typedef struct { int tag; ///< \internal Set to TSK_FS_NAME_ID if allocated, 0 if not char *name; ///< The name of the file (in UTF-8) size_t name_size; ///< The number of bytes allocated to name char *shrt_name; ///< The short name of the file or null (in UTF-8) size_t shrt_name_size; ///< The number of bytes allocated to shrt_name TSK_INUM_T meta_addr; ///< Address of the metadata structure that the name points to. uint32_t meta_seq; ///< Sequence number for metadata structure (NTFS only) TSK_INUM_T par_addr; ///< Metadata address of parent directory (equal to meta_addr if this entry is for root directory). TSK_FS_NAME_TYPE_ENUM type; ///< File type information (directory, file, etc.) TSK_FS_NAME_FLAG_ENUM flags; ///< Flags that describe allocation status etc. } TSK_FS_NAME; /** * Definition of callback function that is used by tsk_fs_dir_walk(). This is * is called for each file in a directory. * @param a_fs_file Pointer to the current file in the directory * @param a_path Path of the file * @param a_ptr Pointer that was originally passed by caller to tsk_fs_dir_walk. * @returns Value to signal if tsk_fs_dir_walk should stop or continue. */ typedef TSK_WALK_RET_ENUM(*TSK_FS_DIR_WALK_CB) (TSK_FS_FILE * a_fs_file, const char *a_path, void *a_ptr); #define TSK_FS_DIR_TAG 0x97531246 /** * A handle to a directory so that its files can be individually accessed. */ typedef struct { int tag; ///< \internal Will be set to TSK_FS_DIR_TAG if structure is still allocated, 0 if not TSK_FS_FILE *fs_file; ///< Pointer to the file structure for the directory. TSK_FS_NAME *names; ///< Pointer to list of names in directory. size_t names_used; ///< Number of name structures in queue being used size_t names_alloc; ///< Number of name structures that were allocated TSK_INUM_T addr; ///< Metadata address of this directory TSK_FS_INFO *fs_info; ///< Pointer to file system the directory is located in } TSK_FS_DIR; /** * Flags that are used when walking names in directories. These are used to identify * which files to call the callback function on. */ typedef enum { TSK_FS_DIR_WALK_FLAG_NONE = 0x00, ///< No Flags TSK_FS_DIR_WALK_FLAG_ALLOC = 0x01, ///< Return allocated names in callback TSK_FS_DIR_WALK_FLAG_UNALLOC = 0x02, ///< Return unallocated names in callback TSK_FS_DIR_WALK_FLAG_RECURSE = 0x04, ///< Recurse into sub-directories TSK_FS_DIR_WALK_FLAG_NOORPHAN = 0x08, ///< Do not return (or recurse into) the special Orphan directory } TSK_FS_DIR_WALK_FLAG_ENUM; extern TSK_FS_DIR *tsk_fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr); extern TSK_FS_DIR *tsk_fs_dir_open(TSK_FS_INFO * a_fs, const char *a_dir); extern uint8_t tsk_fs_dir_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_inode, TSK_FS_DIR_WALK_FLAG_ENUM a_flags, TSK_FS_DIR_WALK_CB a_action, void *a_ptr); extern size_t tsk_fs_dir_getsize(const TSK_FS_DIR *); extern TSK_FS_FILE *tsk_fs_dir_get(const TSK_FS_DIR *, size_t); extern void tsk_fs_dir_close(TSK_FS_DIR *); extern int8_t tsk_fs_path2inum(TSK_FS_INFO * a_fs, const char *a_path, TSK_INUM_T * a_result, TSK_FS_NAME * a_fs_name); //@} /********************* FILE Structure *************************/ /** \name Generic File System File Data Structures */ //@{ #define TSK_FS_FILE_TAG 0x11212212 /** * Generic structure used to refer to files in the file system. A file will * typically have a name and metadata. This structure holds that type of information. * When deleted files are being processed, this structure may have the name defined * but not metadata because it no longer exists. Or, if you are calling meta_walk * and are not processing at the name level, then the name will not be defined. * always check these to make sure they are not null before they are read. */ struct TSK_FS_FILE { int tag; ///< \internal Will be set to TSK_FS_FILE_TAG if structure is allocated TSK_FS_NAME *name; ///< Pointer to name of file (or NULL if file was opened using metadata address) TSK_FS_META *meta; ///< Pointer to metadata of file (or NULL if name has invalid metadata address) TSK_FS_INFO *fs_info; ///< Pointer to file system that the file is located in. }; /** * Flags used by tsk_fs_file_read */ typedef enum { TSK_FS_FILE_READ_FLAG_NONE = 0x00, ///< No Flags TSK_FS_FILE_READ_FLAG_SLACK = 0x01, ///< Allow read access into slack space TSK_FS_FILE_READ_FLAG_NOID = 0x02, ///< Ignore the Id argument given in the API (use only the type) } TSK_FS_FILE_READ_FLAG_ENUM; extern void tsk_fs_file_close(TSK_FS_FILE * a_fs_file); extern TSK_FS_FILE *tsk_fs_file_open(TSK_FS_INFO * a_fs, TSK_FS_FILE * a_fs_file, const char *a_path); extern TSK_FS_FILE *tsk_fs_file_open_meta(TSK_FS_INFO * fs, TSK_FS_FILE * fs_file, TSK_INUM_T addr); extern ssize_t tsk_fs_file_read(TSK_FS_FILE *, TSK_OFF_T, char *, size_t, TSK_FS_FILE_READ_FLAG_ENUM); extern ssize_t tsk_fs_file_read_type(TSK_FS_FILE *, TSK_FS_ATTR_TYPE_ENUM, uint16_t, TSK_OFF_T, char *, size_t, TSK_FS_FILE_READ_FLAG_ENUM); extern const TSK_FS_ATTR *tsk_fs_file_attr_get(TSK_FS_FILE * a_fs_file); extern int tsk_fs_file_attr_getsize(TSK_FS_FILE * a_fs_file); extern const TSK_FS_ATTR *tsk_fs_file_attr_get_idx(TSK_FS_FILE * a_fs_file, int a_idx); extern const TSK_FS_ATTR *tsk_fs_file_attr_get_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM, uint16_t, uint8_t); extern uint8_t tsk_fs_file_walk(TSK_FS_FILE * a_fs_file, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr); extern uint8_t tsk_fs_file_walk_type(TSK_FS_FILE * a_fs_file, TSK_FS_ATTR_TYPE_ENUM a_type, uint16_t a_id, TSK_FS_FILE_WALK_FLAG_ENUM a_flags, TSK_FS_FILE_WALK_CB a_action, void *a_ptr); extern ssize_t tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, char *a_buf, size_t a_len, TSK_FS_FILE_READ_FLAG_ENUM a_flags); extern uint8_t tsk_fs_file_get_owner_sid(TSK_FS_FILE *, char **); //@} /****************** Journal Structures *************/ /** \name Generic File System Journal Data Structures */ //@{ typedef struct { TSK_DADDR_T jblk; /* journal block address */ TSK_DADDR_T fsblk; /* fs block that journal entry is about */ } TSK_FS_JENTRY; typedef TSK_WALK_RET_ENUM(*TSK_FS_JBLK_WALK_CB) (TSK_FS_INFO *, char *, int, void *); typedef TSK_WALK_RET_ENUM(*TSK_FS_JENTRY_WALK_CB) (TSK_FS_INFO *, TSK_FS_JENTRY *, int, void *); //@} /******************************* TSK_FS_INFO ******************/ /** \name Generic File System Handle Data Structure */ //@{ /** * Values for the file system type. Each bit corresponds to a file * system. */ enum TSK_FS_TYPE_ENUM { TSK_FS_TYPE_DETECT = 0x00000000, ///< Use autodetection methods TSK_FS_TYPE_NTFS = 0x00000001, ///< NTFS file system TSK_FS_TYPE_NTFS_DETECT = 0x00000001, ///< NTFS auto detection TSK_FS_TYPE_FAT12 = 0x00000002, ///< FAT12 file system TSK_FS_TYPE_FAT16 = 0x00000004, ///< FAT16 file system TSK_FS_TYPE_FAT32 = 0x00000008, ///< FAT32 file system TSK_FS_TYPE_FAT_DETECT = 0x0000000e, ///< FAT auto detection TSK_FS_TYPE_FFS1 = 0x00000010, ///< UFS1 (FreeBSD, OpenBSD, BSDI ...) TSK_FS_TYPE_FFS1B = 0x00000020, ///< UFS1b (Solaris - has no type) TSK_FS_TYPE_FFS2 = 0x00000040, ///< UFS2 - FreeBSD, NetBSD TSK_FS_TYPE_FFS_DETECT = 0x00000070, ///< UFS auto detection TSK_FS_TYPE_EXT2 = 0x00000080, ///< Ext2 file system TSK_FS_TYPE_EXT3 = 0x00000100, ///< Ext3 file system TSK_FS_TYPE_EXT_DETECT = 0x00000180, ///< ExtX auto detection TSK_FS_TYPE_SWAP = 0x00000200, ///< SWAP file system TSK_FS_TYPE_SWAP_DETECT = 0x00000200, ///< SWAP auto detection TSK_FS_TYPE_RAW = 0x00000400, ///< RAW file system TSK_FS_TYPE_RAW_DETECT = 0x00000400, ///< RAW auto detection TSK_FS_TYPE_ISO9660 = 0x00000800, ///< ISO9660 file system TSK_FS_TYPE_ISO9660_DETECT = 0x00000800, ///< ISO9660 auto detection TSK_FS_TYPE_HFS = 0x00001000, ///< HFS file system TSK_FS_TYPE_HFS_DETECT = 0x00001000, ///< HFS auto detection TSK_FS_TYPE_UNSUPP = 0xffffffff, ///< Unsupported file system }; typedef enum TSK_FS_TYPE_ENUM TSK_FS_TYPE_ENUM; /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for an NTFS file system. */ #define TSK_FS_TYPE_ISNTFS(ftype) \ (((ftype) & TSK_FS_TYPE_NTFS_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a FAT file system. */ #define TSK_FS_TYPE_ISFAT(ftype) \ (((ftype) & TSK_FS_TYPE_FAT_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a FFS file system. */ #define TSK_FS_TYPE_ISFFS(ftype) \ (((ftype) & TSK_FS_TYPE_FFS_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a ExtX file system. */ #define TSK_FS_TYPE_ISEXT(ftype) \ (((ftype) & TSK_FS_TYPE_EXT_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a ISO9660 file system. */ #define TSK_FS_TYPE_ISISO9660(ftype) \ (((ftype) & TSK_FS_TYPE_ISO9660_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a HFS file system. */ #define TSK_FS_TYPE_ISHFS(ftype) \ (((ftype) & TSK_FS_TYPE_HFS_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a swap "file system". */ #define TSK_FS_TYPE_ISSWAP(ftype) \ (((ftype) & TSK_FS_TYPE_SWAP_DETECT)?1:0) /** * \ingroup fslib * Macro that takes a file system type and returns 1 if the type * is for a raw "file system". */ #define TSK_FS_TYPE_ISRAW(ftype) \ (((ftype) & TSK_FS_TYPE_RAW_DETECT)?1:0) /** * Flags for the FS_INFO structure */ enum TSK_FS_INFO_FLAG_ENUM { TSK_FS_INFO_FLAG_NONE = 0x00, ///< No Flags TSK_FS_INFO_FLAG_HAVE_SEQ = 0x01 ///< File system has sequence numbers in the inode addresses. }; typedef enum TSK_FS_INFO_FLAG_ENUM TSK_FS_INFO_FLAG_ENUM; #define TSK_FS_INFO_TAG 0x10101010 #define TSK_FS_INFO_FS_ID_LEN 32 // set based on largest file system / volume ID supported /** * Stores state information for an open file system. * One of these are generated for each open files system and it contains * file system-type specific data. These values are all filled in by * the file system code and not the caller functions. */ struct TSK_FS_INFO { int tag; ///< \internal Will be set to TSK_FS_INFO_TAG if structure is still allocated, 0 if not TSK_IMG_INFO *img_info; ///< Pointer to the image layer state TSK_OFF_T offset; ///< Byte offset into img_info that fs starts /* meta data */ TSK_INUM_T inum_count; ///< Number of metadata addresses TSK_INUM_T root_inum; ///< Metadata address of root directory TSK_INUM_T first_inum; ///< First valid metadata address TSK_INUM_T last_inum; ///< Last valid metadata address /* content */ TSK_DADDR_T block_count; ///< Number of blocks in fs TSK_DADDR_T first_block; ///< Address of first block TSK_DADDR_T last_block; ///< Address of last block as reported by file system (could be larger than last_block in image if end of image does not exist) TSK_DADDR_T last_block_act; ///< Address of last block -- adjusted so that it is equal to the last block in the image or volume (if image is not complete) unsigned int block_size; ///< Size of each block (in bytes) unsigned int dev_bsize; ///< Size of device block (typically always 512) /* The following are used for really RAW images that contain data before and after the actual user sector. For example, a raw cd image may have 16 bytes before the start of each sector. */ unsigned int block_pre_size; ///< Number of bytes that preceed each block (currently only used for RAW CDs) unsigned int block_post_size; ///< Number of bytes that follow each block (currently only used for RAW CDs) /* Journal */ TSK_INUM_T journ_inum; ///< Address of journal inode TSK_FS_TYPE_ENUM ftype; ///< type of file system const char *duname; ///< string "name" of data unit type TSK_FS_INFO_FLAG_ENUM flags; ///< flags for file system uint8_t fs_id[TSK_FS_INFO_FS_ID_LEN]; ///< File system id (as reported in boot sector) size_t fs_id_used; ///< Number of bytes in fs_id that are being used TSK_ENDIAN_ENUM endian; ///< Endian order of data TSK_LIST *list_inum_named; /**< List of unallocated inodes that * are pointed to by a file name -- * Used to find orphan files. Is filled when looking for orphans * or when a full name_walk is performed. */ TSK_FS_DIR *orphan_dir; ///< Files and dirs in the top level of the $OrphanFiles directory. NULL if orphans have not been hunted for yet. uint8_t isOrphanHunting; ///< Set to 1 if TSK is currently looking for Orphan files uint8_t(*block_walk) (TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, TSK_FS_BLOCK_WALK_FLAG_ENUM flags, TSK_FS_BLOCK_WALK_CB cb, void *ptr); ///< FS-specific function: Call tsk_fs_block_walk() instead. TSK_FS_BLOCK_FLAG_ENUM(*block_getflags) (TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr); ///< \internal uint8_t(*inode_walk) (TSK_FS_INFO * fs, TSK_INUM_T start, TSK_INUM_T end, TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB cb, void *ptr); ///< FS-specific function: Call tsk_fs_meta_walk() instead. uint8_t(*file_add_meta) (TSK_FS_INFO * fs, TSK_FS_FILE * fs_file, TSK_INUM_T addr); ///< \internal TSK_FS_ATTR_TYPE_ENUM(*get_default_attr_type) (const TSK_FS_FILE *); ///< \internal uint8_t(*load_attrs) (TSK_FS_FILE *); ///< \internal /** * Pointer to file system specific function that prints details on a specific file to a file handle. * * @param fs File system file is located in * @param hFile File handle to print text to * @param inum Address of file in file system * @param numblock The number of blocks in file to force print (can go beyond file size) * @param sec_skew Clock skew in seconds to also print times in * * @returns 1 on error and 0 on success */ uint8_t(*istat) (TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew); TSK_RETVAL_ENUM(*dir_open_meta) (TSK_FS_INFO * fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T inode); ///< \internal Call tsk_fs_dir_open_meta() instead. uint8_t(*jopen) (TSK_FS_INFO *, TSK_INUM_T); ///< \internal uint8_t(*jblk_walk) (TSK_FS_INFO *, TSK_DADDR_T, TSK_DADDR_T, int, TSK_FS_JBLK_WALK_CB, void *); ///< \internal uint8_t(*jentry_walk) (TSK_FS_INFO *, int, TSK_FS_JENTRY_WALK_CB, void *); ///< \internal uint8_t(*fsstat) (TSK_FS_INFO * fs, FILE * hFile); ///< \internal int (*name_cmp) (TSK_FS_INFO *, const char *, const char *); ///< \internal uint8_t(*fscheck) (TSK_FS_INFO *, FILE *); ///< \internal void (*close) (TSK_FS_INFO * fs); ///< FS-specific function: Call tsk_fs_close() instead. uint8_t(*fread_owner_sid) (TSK_FS_FILE *, char **); // FS-specific function. Call tsk_fs_file_get_owner_sid() instead. }; /* File system level */ extern TSK_FS_INFO *tsk_fs_open_img(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM); extern TSK_FS_INFO *tsk_fs_open_vol(const TSK_VS_PART_INFO *, TSK_FS_TYPE_ENUM); extern void tsk_fs_close(TSK_FS_INFO *); extern TSK_FS_TYPE_ENUM tsk_fs_type_toid(const TSK_TCHAR *); extern void tsk_fs_type_print(FILE *); extern const char *tsk_fs_type_toname(TSK_FS_TYPE_ENUM); extern TSK_FS_TYPE_ENUM tsk_fs_type_supported(); extern ssize_t tsk_fs_read(TSK_FS_INFO * a_fs, TSK_OFF_T a_off, char *a_buf, size_t a_len); extern ssize_t tsk_fs_read_block(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr, char *a_buf, size_t a_len); //@} /***** LIBRARY ROUTINES FOR COMMAND LINE FUNCTIONS */ enum TSK_FS_BLKCALC_FLAG_ENUM { TSK_FS_BLKCALC_DD = 0x01, TSK_FS_BLKCALC_BLKLS = 0x02, TSK_FS_BLKCALC_SLACK = 0x04 }; typedef enum TSK_FS_BLKCALC_FLAG_ENUM TSK_FS_BLKCALC_FLAG_ENUM; extern int8_t tsk_fs_blkcalc(TSK_FS_INFO * fs, TSK_FS_BLKCALC_FLAG_ENUM flags, TSK_DADDR_T cnt); enum TSK_FS_BLKCAT_FLAG_ENUM { TSK_FS_BLKCAT_NONE = 0x00, TSK_FS_BLKCAT_HEX = 0x01, TSK_FS_BLKCAT_ASCII = 0x02, TSK_FS_BLKCAT_HTML = 0x04, TSK_FS_BLKCAT_STAT = 0x08 }; typedef enum TSK_FS_BLKCAT_FLAG_ENUM TSK_FS_BLKCAT_FLAG_ENUM; extern uint8_t tsk_fs_blkcat(TSK_FS_INFO * fs, TSK_FS_BLKCAT_FLAG_ENUM flags, TSK_DADDR_T addr, TSK_DADDR_T read_num_units); enum TSK_FS_BLKLS_FLAG_ENUM { TSK_FS_BLKLS_NONE = 0x00, TSK_FS_BLKLS_CAT = 0x01, TSK_FS_BLKLS_LIST = 0x02, TSK_FS_BLKLS_SLACK = 0x04, }; typedef enum TSK_FS_BLKLS_FLAG_ENUM TSK_FS_BLKLS_FLAG_ENUM; extern uint8_t tsk_fs_blkls(TSK_FS_INFO * fs, TSK_FS_BLKLS_FLAG_ENUM lclflags, TSK_DADDR_T bstart, TSK_DADDR_T bend, TSK_FS_BLOCK_FLAG_ENUM flags); extern uint8_t tsk_fs_blkstat(TSK_FS_INFO * fs, TSK_DADDR_T addr, TSK_FS_BLOCK_FLAG_ENUM flags); enum TSK_FS_FFIND_FLAG_ENUM { TSK_FS_FFIND_ALL = 0x01, }; typedef enum TSK_FS_FFIND_FLAG_ENUM TSK_FS_FFIND_FLAG_ENUM; extern uint8_t tsk_fs_ffind(TSK_FS_INFO * fs, TSK_FS_FFIND_FLAG_ENUM lclflags, TSK_INUM_T inode, TSK_FS_ATTR_TYPE_ENUM type, uint8_t type_used, uint16_t id, uint8_t id_used, TSK_FS_DIR_WALK_FLAG_ENUM flags); enum TSK_FS_FLS_FLAG_ENUM { TSK_FS_FLS_NONE = 0x00, TSK_FS_FLS_DOT = 0x01, TSK_FS_FLS_LONG = 0x02, TSK_FS_FLS_FILE = 0x04, TSK_FS_FLS_DIR = 0x08, TSK_FS_FLS_FULL = 0x10, TSK_FS_FLS_MAC = 0x20, }; typedef enum TSK_FS_FLS_FLAG_ENUM TSK_FS_FLS_FLAG_ENUM; extern uint8_t tsk_fs_fls(TSK_FS_INFO * fs, TSK_FS_FLS_FLAG_ENUM lclflags, TSK_INUM_T inode, TSK_FS_DIR_WALK_FLAG_ENUM flags, TSK_TCHAR * pre, int32_t skew); extern uint8_t tsk_fs_icat(TSK_FS_INFO * fs, TSK_INUM_T inum, TSK_FS_ATTR_TYPE_ENUM type, uint8_t type_used, uint16_t id, uint8_t id_used, TSK_FS_FILE_WALK_FLAG_ENUM flags); enum TSK_FS_IFIND_FLAG_ENUM { TSK_FS_IFIND_NONE = 0x00, TSK_FS_IFIND_ALL = 0x01, TSK_FS_IFIND_PAR_LONG = 0x02, }; typedef enum TSK_FS_IFIND_FLAG_ENUM TSK_FS_IFIND_FLAG_ENUM; extern int8_t tsk_fs_ifind_path(TSK_FS_INFO * fs, TSK_TCHAR * path, TSK_INUM_T * result); extern uint8_t tsk_fs_ifind_data(TSK_FS_INFO * fs, TSK_FS_IFIND_FLAG_ENUM flags, TSK_DADDR_T blk); extern uint8_t tsk_fs_ifind_par(TSK_FS_INFO * fs, TSK_FS_IFIND_FLAG_ENUM flags, TSK_INUM_T par); enum TSK_FS_ILS_FLAG_ENUM { TSK_FS_ILS_NONE = 0x00, TSK_FS_ILS_OPEN = 0x01, TSK_FS_ILS_MAC = 0x02, TSK_FS_ILS_LINK = 0x04, TSK_FS_ILS_UNLINK = 0x08, }; typedef enum TSK_FS_ILS_FLAG_ENUM TSK_FS_ILS_FLAG_ENUM; extern uint8_t tsk_fs_ils(TSK_FS_INFO * fs, TSK_FS_ILS_FLAG_ENUM lclflags, TSK_INUM_T istart, TSK_INUM_T ilast, TSK_FS_META_FLAG_ENUM flags, int32_t skew, const TSK_TCHAR * img); /* ** Is this string a "." or ".." */ #define TSK_FS_ISDOT(str) ( ((str[0] == '.') && \ ( ((str[1] == '.') && (str[2] == '\0')) || (str[1] == '\0') ) ) ? 1 : 0 ) extern int tsk_fs_parse_inum(const TSK_TCHAR * str, TSK_INUM_T *, TSK_FS_ATTR_TYPE_ENUM *, uint8_t *, uint16_t *, uint8_t *); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/tsk_fs_i.h000644 000765 000024 00000021214 11643647440 017604 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2008 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* LICENSE * .ad * .fi * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /** * \file tsk_fs_i.h * Contains the internal library definitions for the file system functions. This should * be included by the code in the file system library. */ #ifndef _TSK_FS_I_H #define _TSK_FS_I_H #ifdef __cplusplus extern "C" { #endif // Include the other internal TSK header files #include "tsk3/base/tsk_base_i.h" #include "tsk3/img/tsk_img_i.h" #include "tsk3/vs/tsk_vs_i.h" // Include the external file #include "tsk_fs.h" #include #include #if !defined (TSK_WIN32) #include #include #endif // set to 1 to open HFS+ file systems -- which is not fully tested #ifndef TSK_USE_HFS #define TSK_USE_HFS 1 #endif #ifndef NBBY #define NBBY 8 #endif #ifndef isset #define isset(a,i) (((uint8_t *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) #endif #ifndef setbit #define setbit(a,i) (((uint8_t *)(a))[(i)/NBBY] |= (1<<((i)%NBBY))) #endif /* Data structure and action to internally load a file */ typedef struct { char *base; char *cur; size_t total; size_t left; } TSK_FS_LOAD_FILE; extern TSK_WALK_RET_ENUM tsk_fs_load_file_action(TSK_FS_FILE * fs_file, TSK_OFF_T, TSK_DADDR_T, char *, size_t, TSK_FS_BLOCK_FLAG_ENUM, void *); /* BLOCK */ extern TSK_FS_BLOCK *tsk_fs_block_alloc(TSK_FS_INFO * fs); extern int tsk_fs_block_set(TSK_FS_INFO * fs, TSK_FS_BLOCK * fs_block, TSK_DADDR_T a_addr, TSK_FS_BLOCK_FLAG_ENUM a_flags, char *a_buf); /* FS_DATA */ extern TSK_FS_ATTR *tsk_fs_attr_alloc(TSK_FS_ATTR_FLAG_ENUM); extern void tsk_fs_attr_free(TSK_FS_ATTR *); extern void tsk_fs_attr_clear(TSK_FS_ATTR *); extern uint8_t tsk_fs_attr_set_str(TSK_FS_FILE *, TSK_FS_ATTR *, const char *, TSK_FS_ATTR_TYPE_ENUM, uint16_t, void *, size_t); extern uint8_t tsk_fs_attr_set_run(TSK_FS_FILE *, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * data_run_new, const char *name, TSK_FS_ATTR_TYPE_ENUM type, uint16_t id, TSK_OFF_T size, TSK_OFF_T initsize, TSK_OFF_T allocsize, TSK_FS_ATTR_FLAG_ENUM flags, uint32_t compsize); extern uint8_t tsk_fs_attr_add_run(TSK_FS_INFO * fs, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * data_run_new); extern void tsk_fs_attr_append_run(TSK_FS_INFO * fs, TSK_FS_ATTR * a_fs_attr, TSK_FS_ATTR_RUN * a_data_run); /* FS_DATALIST */ extern TSK_FS_ATTRLIST *tsk_fs_attrlist_alloc(); extern void tsk_fs_attrlist_free(TSK_FS_ATTRLIST *); extern uint8_t tsk_fs_attrlist_add(TSK_FS_ATTRLIST *, TSK_FS_ATTR *); extern TSK_FS_ATTR *tsk_fs_attrlist_getnew(TSK_FS_ATTRLIST *, TSK_FS_ATTR_FLAG_ENUM a_atype); extern void tsk_fs_attrlist_markunused(TSK_FS_ATTRLIST *); extern const TSK_FS_ATTR *tsk_fs_attrlist_get(const TSK_FS_ATTRLIST *, TSK_FS_ATTR_TYPE_ENUM); extern const TSK_FS_ATTR *tsk_fs_attrlist_get_id(const TSK_FS_ATTRLIST *, TSK_FS_ATTR_TYPE_ENUM, uint16_t); extern const TSK_FS_ATTR *tsk_fs_attrlist_get_name_type(const TSK_FS_ATTRLIST *, TSK_FS_ATTR_TYPE_ENUM, const char *); extern const TSK_FS_ATTR *tsk_fs_attrlist_get_idx(const TSK_FS_ATTRLIST *, int); extern int tsk_fs_attrlist_get_len(const TSK_FS_ATTRLIST * a_fs_attrlist); /* FS_DATA_RUN */ extern TSK_FS_ATTR_RUN *tsk_fs_attr_run_alloc(); extern void tsk_fs_attr_run_free(TSK_FS_ATTR_RUN *); /* FS_META */ extern TSK_FS_META *tsk_fs_meta_alloc(size_t); extern TSK_FS_META *tsk_fs_meta_realloc(TSK_FS_META *, size_t); extern void tsk_fs_meta_reset(TSK_FS_META *); extern void tsk_fs_meta_close(TSK_FS_META * fs_meta); /* FS_FILE */ extern TSK_FS_FILE *tsk_fs_file_alloc(TSK_FS_INFO *); /* FS_DIR */ extern TSK_FS_DIR *tsk_fs_dir_alloc(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr, size_t a_cnt); extern uint8_t tsk_fs_dir_realloc(TSK_FS_DIR * a_fs_dir, size_t a_cnt); extern uint8_t tsk_fs_dir_add(TSK_FS_DIR * a_fs_dir, const TSK_FS_NAME * a_fs_dent); extern void tsk_fs_dir_reset(TSK_FS_DIR * a_fs_dir); /* Orphan Directory Support */ TSK_RETVAL_ENUM tsk_fs_dir_load_inum_named(TSK_FS_INFO * a_fs); extern uint8_t tsk_fs_dir_make_orphan_dir_meta(TSK_FS_INFO * a_fs, TSK_FS_META * a_fs_meta); extern uint8_t tsk_fs_dir_make_orphan_dir_name(TSK_FS_INFO * a_fs, TSK_FS_NAME * a_fs_name); extern TSK_RETVAL_ENUM tsk_fs_dir_find_orphans(TSK_FS_INFO * a_fs, TSK_FS_DIR * a_fs_dir); /* FS_DENT */ extern TSK_FS_NAME *tsk_fs_name_alloc(size_t, size_t); extern uint8_t tsk_fs_name_realloc(TSK_FS_NAME *, size_t); extern void tsk_fs_name_free(TSK_FS_NAME *); extern void tsk_fs_name_print(FILE *, const TSK_FS_FILE *, const char *, TSK_FS_INFO *, const TSK_FS_ATTR *, uint8_t); extern void tsk_fs_name_print_long(FILE *, const TSK_FS_FILE *, const char *, TSK_FS_INFO *, const TSK_FS_ATTR *, uint8_t, int32_t); extern void tsk_fs_name_print_mac(FILE *, const TSK_FS_FILE *, const char *, const TSK_FS_ATTR * fs_attr, const char *, int32_t); extern uint8_t tsk_fs_name_copy(TSK_FS_NAME * a_fs_name_to, const TSK_FS_NAME * a_fs_name_from); extern void tsk_fs_name_reset(TSK_FS_NAME * a_fs_name); /* Utilities */ extern uint8_t tsk_fs_unix_make_data_run(TSK_FS_FILE * fs_file); extern TSK_FS_ATTR_TYPE_ENUM tsk_fs_unix_get_default_attr_type(const TSK_FS_FILE * a_file); extern int tsk_fs_unix_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2); /* Specific file system routines */ extern TSK_FS_INFO *ext2fs_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM, uint8_t); extern TSK_FS_INFO *fatfs_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM, uint8_t); extern TSK_FS_INFO *ffs_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM); extern TSK_FS_INFO *ntfs_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM, uint8_t); extern TSK_FS_INFO *rawfs_open(TSK_IMG_INFO *, TSK_OFF_T); extern TSK_FS_INFO *swapfs_open(TSK_IMG_INFO *, TSK_OFF_T); extern TSK_FS_INFO *iso9660_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM, uint8_t); extern TSK_FS_INFO *hfs_open(TSK_IMG_INFO *, TSK_OFF_T, TSK_FS_TYPE_ENUM, uint8_t); /* Generic functions for swap and raw -- many say "not supported" */ extern uint8_t tsk_fs_nofs_fsstat(TSK_FS_INFO * fs, FILE * hFile); extern void tsk_fs_nofs_close(TSK_FS_INFO * fs); extern TSK_FS_ATTR_TYPE_ENUM tsk_fs_nofs_get_default_attr_type(const TSK_FS_FILE * a_file); extern uint8_t tsk_fs_nofs_make_data_run(TSK_FS_FILE *); extern int tsk_fs_nofs_name_cmp(TSK_FS_INFO *, const char *, const char *); extern TSK_FS_BLOCK_FLAG_ENUM tsk_fs_nofs_block_getflags(TSK_FS_INFO * a_fs, TSK_DADDR_T a_addr); extern uint8_t tsk_fs_nofs_block_walk(TSK_FS_INFO * fs, TSK_DADDR_T a_start_blk, TSK_DADDR_T a_end_blk, TSK_FS_BLOCK_WALK_FLAG_ENUM a_flags, TSK_FS_BLOCK_WALK_CB a_action, void *a_ptr); extern uint8_t tsk_fs_nofs_file_add_meta(TSK_FS_INFO * fs, TSK_FS_FILE * a_fs_file, TSK_INUM_T inum); extern uint8_t tsk_fs_nofs_inode_walk(TSK_FS_INFO * fs, TSK_INUM_T a_start_inum, TSK_INUM_T a_end_inum, TSK_FS_META_FLAG_ENUM a_flags, TSK_FS_META_WALK_CB a_action, void *a_ptr); extern uint8_t tsk_fs_nofs_istat(TSK_FS_INFO * a_fs, FILE * hFile, TSK_INUM_T inum, TSK_DADDR_T numblock, int32_t sec_skew); extern TSK_RETVAL_ENUM tsk_fs_nofs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); extern uint8_t tsk_fs_nofs_jopen(TSK_FS_INFO * a_fs, TSK_INUM_T inum); extern uint8_t tsk_fs_nofs_jentry_walk(TSK_FS_INFO * a_fs, int a_flags, TSK_FS_JENTRY_WALK_CB a_action, void *a_ptr); extern uint8_t tsk_fs_nofs_jblk_walk(TSK_FS_INFO * a_fs, TSK_INUM_T start, TSK_INUM_T end, int a_flags, TSK_FS_JBLK_WALK_CB a_action, void *a_ptr); // Endian macros - actual functions in misc/ #define tsk_fs_guessu16(fs, x, mag) \ tsk_guess_end_u16(&(fs->endian), (x), (mag)) #define tsk_fs_guessu32(fs, x, mag) \ tsk_guess_end_u32(&(fs->endian), (x), (mag)) #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/tsk_hfs.h000644 000765 000024 00000060016 11643647440 017447 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Copyright (c) 2009 Brian Carrier. All rights reserved. ** ** Judson Powers [jpowers@atc-nycorp.com] ** Copyright (c) 2008 ATC-NY. All rights reserved. ** This file contains data developed with support from the National ** Institute of Justice, Office of Justice Programs, U.S. Department of Justice. ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier@sleuthkit.org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /** * Contains the structures and function APIs for HFS+ file system support. */ #ifndef _TSK_HFS_H #define _TSK_HFS_H /* * All structures created using technote 1150 from Apple.com * http://developer.apple.com/technotes/tn/tn1150.html */ /* * Constants */ #define HFS_FILE_CONTENT_LEN 160 // size of two hfs_fork data structures #define HFS_MAXNAMLEN 765 /* maximum HFS+ name length in bytes, when encoded in UTF8, not including terminating null */ /* * HFS uses its own time system, which is seconds since Jan 1 1904 * instead of the typical Jan 1 1970. This number is the seconds between * 1 Jan 1904 and 1 Jan 1970 which will make ctime(3) work instead of * re-writing the Apple library function to convert this time. */ #define NSEC_BTWN_1904_1970 (uint32_t) 2082844800U /* predefined files */ #define HFS_ROOT_PARENT_ID 1 #define HFS_ROOT_FOLDER_ID 2 #define HFS_EXTENTS_FILE_ID 3 // extents overflow file #define HFS_EXTENTS_FILE_NAME "$ExtentsFile" #define HFS_CATALOG_FILE_ID 4 // catalog file #define HFS_CATALOG_FILE_NAME "$CatalogFile" #define HFS_BAD_BLOCK_FILE_ID 5 #define HFS_BAD_BLOCK_FILE_NAME "$BadBlockFile" #define HFS_ALLOCATION_FILE_ID 6 // allocation file (HFS+) #define HFS_ALLOCATION_FILE_NAME "$AllocationFile" #define HFS_STARTUP_FILE_ID 7 // startup file (HFS+) #define HFS_STARTUP_FILE_NAME "$StartupFile" #define HFS_ATTRIBUTES_FILE_ID 8 // Attributes file (HFS+) #define HFS_ATTRIBUTES_FILE_NAME "$AttributesFile" #define HFS_REPAIR_CATALOG_FILE_ID 14 // Temp file during fsck #define HFS_REPAIR_CATALOG_FILE_NAME "$RepairCatalogFile" #define HFS_BOGUS_EXTENT_FILE_ID 15 // Temp file during fsck #define HFS_BOGUS_EXTENT_FILE_NAME "$BogusExtentFile" #define HFS_FIRST_USER_CNID 16 #define HFS_ROOT_INUM HFS_ROOT_FOLDER_ID #define HFS_HARDLINK_FILE_TYPE 0x686C6E6B /* hlnk */ #define HFS_HARDLINK_FILE_CREATOR 0x6866732B /* hfs+ */ #define HFS_CATALOGNAME "$CatalogFile" #define HFS_EXTENTSNAME "$ExtentsFile" #define HFS_ALLOCATIONNAME "$BitMapFile" #define HFS_STARTUPNAME "$BootFile" #define HFS_ATTRIBUTESNAME "$AttributesFile" /* * HFS structures */ /* File and Folder name struct */ typedef struct { uint8_t length[2]; uint8_t unicode[510]; } hfs_uni_str; /* access permissions */ // admin flag values #define HFS_PERM_AFLAG_ARCHIVED 0x01 /* file has been archived */ #define HFS_PERM_AFLAG_IMMUTABLE 0x02 /* file may not be changed */ #define HFS_PERM_AFLAG_APPEND 0x04 /* writes to file may only append */ // owner flag values #define HFS_PERM_OFLAG_NODUMP 0x01 /* do not dump (back up or archive) this file */ #define HFS_PERM_OFLAG_IMMUTABLE 0x02 /* file may not be changed */ #define HFS_PERM_OFLAG_APPEND 0x04 /* writes to file may only append */ #define HFS_PERM_OFLAG_OPAQUE 0x08 /* directory is opaque */ #define HFS_PERM_OFLAG_COMPRESSED 0x20 /* file is HFS-compressed (see 10.6 sys/stat.h) */ // mode flag values #define HFS_IN_ISUID 0004000 /* set user id */ #define HFS_IN_ISGID 0002000 /* set group id */ #define HFS_IN_ISVTX 0001000 /* sticky bit (directories only) */ #define HFS_IN_IRUSR 0000400 /* R for user */ #define HFS_IN_IWUSR 0000200 /* W for user */ #define HFS_IN_IXUSR 0000100 /* X for user */ #define HFS_IN_IRGRP 0000040 /* R for group */ #define HFS_IN_IWGRP 0000020 /* W for group */ #define HFS_IN_IXGRP 0000010 /* X for group */ #define HFS_IN_IROTH 0000004 /* R for other */ #define HFS_IN_IWOTH 0000002 /* W for other */ #define HFS_IN_IXOTH 0000001 /* X for other */ #define HFS_IN_IFMT 0170000 /* filetype mask */ #define HFS_IN_IFIFO 0010000 /* named pipe */ #define HFS_IN_IFCHR 0020000 /* character special */ #define HFS_IN_IFDIR 0040000 /* directory */ #define HFS_IN_IFBLK 0060000 /* block special */ #define HFS_IN_IFREG 0100000 /* regular file */ #define HFS_IN_IFLNK 0120000 /* symbolic link */ #define HFS_IN_IFSOCK 0140000 /* socket */ #define HFS_IFWHT 0160000 /* whiteout */ #define HFS_IFXATTR 0200000 /* extended attributes */ typedef struct { uint8_t owner[4]; /* file owner */ uint8_t group[4]; /* file group */ uint8_t a_flags; /* admin flags */ uint8_t o_flags; /* owner flags */ uint8_t mode[2]; /* file mode */ union { uint8_t inum[4]; /* inode number (for hard link files) */ uint8_t nlink[4]; /* link count (for direct node files) */ uint8_t raw[4]; /* device id (for block and char device files) */ } special; } hfs_access_perm; /* HFS extent descriptor */ typedef struct { uint8_t start_blk[4]; /* start block */ uint8_t blk_cnt[4]; /* block count */ } hfs_ext_desc; /* Structre used in the extents tree */ typedef struct { hfs_ext_desc extents[8]; } hfs_extents; /* Fork data structure. This is used in both the volume header and catalog tree. */ typedef struct { uint8_t logic_sz[8]; /* The size (in bytes) of the fork */ uint8_t clmp_sz[4]; /* For "special files" in volume header, clump size. For * catalog files, this is number of blocks read or not used. */ uint8_t total_blk[4]; /* total blocks in all extents of the fork */ hfs_ext_desc extents[8]; } hfs_fork; /**************************************************** * Super block / volume header */ #define HFS_VH_OFF 1024 // byte offset in volume to volume header // signature values #define HFS_VH_SIG_HFS 0x4244 /* BD in big endian */ #define HFS_VH_SIG_HFSPLUS 0x482b /* H+ in big endian */ #define HFS_VH_SIG_HFSX 0x4858 /* HX in big endian */ // version values #define HFS_VH_VER_HFSPLUS 0x0004 /* all HFS+ volumes are version 4 */ #define HFS_VH_VER_HFSX 0x0005 /* HFSX volumes start with version 5 */ // attr values ( // bits 0 to 7 are reserved #define HFS_VH_ATTR_UNMOUNTED (uint32_t)(1<<8) /* set if the volume was unmounted properly; as per TN 1150, modern Macintosh OSes always leave this bit set for the boot volume */ #define HFS_VH_ATTR_BADBLOCKS (uint32_t)(1<<9) /* set if there are any bad blocks for this volume (in the Extents B-tree) */ #define HFS_VH_ATTR_NOCACHE (uint32_t)(1<<10) /* set if volume should not be cached */ #define HFS_VH_ATTR_INCONSISTENT (uint32_t)(1<<11) /* cleared if the volume was unmounted properly */ #define HFS_VH_ATTR_CNIDS_REUSED (uint32_t)(1<<12) /* set if CNIDs have wrapped around past the maximum value and are being reused; in this case, there are CNIDs on the disk larger than the nextCatalogId field */ #define HFS_VH_ATTR_JOURNALED (uint32_t)(1<<13) // 14 is reserved #define HFS_VH_ATTR_SOFTWARE_LOCK (uint32_t)(1 << 15) /* set if volume should be write-protected in software */ // 16 to 31 are reserved // last_mnt_ver values #define HFS_VH_MVER_HFSPLUS 0x31302e30 /* '10.0' for Mac OS X */ #define HFS_VH_MVER_HFSJ 0x4846534a /* 'HFSJ' for journaled HFS+ on Mac OS X */ #define HFS_VH_MVER_FSK 0x46534b21 /* 'FSK!' for failed journal replay */ #define HFS_VH_MVER_FSCK 0x6673636b /* 'fsck' for fsck_hfs */ #define HFS_VH_MVER_OS89 0x382e3130 /* '8.10' for Mac OS 8.1-9.2.2 */ /* Index values for finder_info array */ #define HFS_VH_FI_BOOT 0 /*Directory ID of bootable directory */ #define HFS_VH_FI_START 1 /* Parent dir ID of startup app */ #define HFS_VH_FI_OPEN 2 /* Directory to open when volume is mounted */ #define HFS_VH_FI_BOOT9 3 /* Directory ID of OS 8 or 9 bootable sys folder */ #define HFS_VH_FI_RESV1 4 #define HFS_VH_FI_BOOTX 5 /* Directory ID of OS X bootable system (CoreServices dir) */ #define HFS_VH_FI_ID1 6 /* OS X Volume ID part 1 */ #define HFS_VH_FI_ID2 7 /* OS X Volume ID part 2 */ /* ** HFS+/HFSX Super Block */ typedef struct { uint8_t signature[2]; /* "H+" for HFS+, "HX" for HFSX */ uint8_t version[2]; /* 4 for HFS+, 5 for HFSX */ uint8_t attr[4]; /* volume attributes */ uint8_t last_mnt_ver[4]; /* last mounted version */ uint8_t jinfo_blk[4]; /* journal info block */ uint8_t cr_date[4]; /* volume creation date (NOT in GMT) */ uint8_t m_date[4]; /* volume last modified date (GMT) */ uint8_t bkup_date[4]; /* volume last backup date (GMT) */ uint8_t chk_date[4]; /* date of last consistency check (GMT) */ uint8_t file_cnt[4]; /* number of files on volume (not incl. special files) */ uint8_t fldr_cnt[4]; /* number of folders on volume (not incl. root dir) */ uint8_t blk_sz[4]; /* allocation block size (in bytes) */ uint8_t blk_cnt[4]; /* number of blocks on disk */ uint8_t free_blks[4]; /* unused block count */ uint8_t next_alloc[4]; /* block addr to start allocation search from */ uint8_t rsrc_clmp_sz[4]; /* default clump size for resource forks (in bytes) */ uint8_t data_clmp_sz[4]; /* default clump size for data forks (in bytes) */ uint8_t next_cat_id[4]; /* next catalog id for allocation */ uint8_t write_cnt[4]; /* write count: incremented each time it is mounted and modified */ uint8_t enc_bmp[8]; /* encoding bitmap (identifies which encodings were used in FS) */ uint8_t finder_info[8][4]; /* Special finder details */ hfs_fork alloc_file; /* location and size of allocation bitmap file */ hfs_fork ext_file; /* location and size of extents file */ hfs_fork cat_file; /* location and size of catalog file */ hfs_fork attr_file; /* location and size of attributes file */ hfs_fork start_file; /* location and size of startup file */ } hfs_plus_vh; /* ** HFS (non-Plus) Master Directory Block (volume header-like) (used with wrapped HFS+/HFSX file systems) */ typedef struct { uint8_t drSigWord[2]; /* "BD" for HFS (same location as hfs_plus_vh.signature) */ uint8_t drCrDate[4]; /* volume creation date */ uint8_t drLsMod[4]; /* volume last modified date */ uint8_t drAtrb[2]; /* volume attributes */ uint8_t drNmFls[2]; /* number of files on volume */ uint8_t drVBMSt[2]; /* starting block for volume bitmap */ uint8_t drAllocPtr[2]; /* start of next allocation search */ uint8_t drNmAlBlks[2]; /* number of blocks on disk */ uint8_t drAlBlkSiz[4]; /* size in bytes of each allocation block */ uint8_t drClpSiz[4]; /* default clump size for volume */ uint8_t drAlBlSt[2]; /* first allocation block, in 512-byte sectors */ uint8_t drNxtCNID[4]; /* next unused catalog node ID */ uint8_t drFreeBlks[2]; /* number of unused allocation blocks */ uint8_t drVN[28]; /* volume name, where first byte is length */ uint8_t drVolBkUp[4]; /* volume last backup date */ uint8_t drVSeqNum[2]; /* volume sequence number */ uint8_t drWrCnt[4]; /* write count */ uint8_t drXTClpSiz[4]; /* clump size for extents overflow file */ uint8_t drCTClpSiz[4]; /* clump size for catalog file */ uint8_t drNmRtDirs[2]; /* number of folders in root directory */ uint8_t drFilCnt[4]; /* number of files on volume */ uint8_t drDirCnt[4]; /* number of directories on volume */ uint8_t drFndrInfo[32]; /* Finder info */ uint8_t drEmbedSigWord[2]; /* signature of the embedded HFS+ volume (eg, "H+") - 0x7c offset */ uint8_t drEmbedExtent_startBlock[2]; /* extent descriptor for start of embedded volume */ uint8_t drEmbedExtent_blockCount[2]; /* extent descriptor for num of blks in of embedded volume */ uint8_t drXTFlSize[4]; /* size of the extents overflow file */ uint8_t drXTExtRec[12]; /* extent record with size and location of extents overflow file */ uint8_t drCTFlSize[4]; /* size of the catalog file */ uint8_t drCTExtRec[12]; /* extent record with size and location of catalog file */ } hfs_mdb; /********* B-Tree data structures **********/ /* Node descriptor that starts each node in a B-tree */ // type values #define HFS_BT_NODE_TYPE_LEAF -1 #define HFS_BT_NODE_TYPE_IDX 0 #define HFS_BT_NODE_TYPE_HEAD 1 #define HFS_BT_NODE_TYPE_MAP 2 // header that starts every B-tree node typedef struct { uint8_t flink[4]; /* node num of next node of same type */ uint8_t blink[4]; /* node num of prev node of same type */ int8_t type; /* type of this node */ uint8_t height; /* level in B-tree (0 for root, 1 for leaf) */ uint8_t num_rec[2]; /* number of records this node */ uint8_t res[2]; /* reserved */ } hfs_btree_node; /*****************/ // structure for the 1st record in the B-Tree header node // type values #define HFS_BT_HEAD_TYPE_CNTL 0 // control file (catalog, extents, attributes) #define HFS_BT_HEAD_TYPE_USER 128 // hot file #define HFS_BT_HEAD_TYPE_RSV 255 // compType values #define HFS_BT_HEAD_COMP_SENS 0xBC // case sensitive #define HFS_BT_HEAD_COMP_INSENS 0xC7 // case insensitive // attr values #define HFS_BT_HEAD_ATTR_BIGKEYS 0x00000002 /* key length field is 16 bits (req'd for HFS+) */ #define HFS_BT_HEAD_ATTR_VARIDXKEYS 0x00000004 /* Keys in INDEX nodes are variable length */ // NOTE: VARIDXKEYS is required for the Catalog B-tree and cleared for the Extents B-tree typedef struct { uint8_t depth[2]; /* current depth of btree */ uint8_t rootNode[4]; /* node number of root node */ uint8_t leafRecords[4]; /* number of records in leaf nodes */ uint8_t firstLeafNode[4]; /* number of first leaf node (0 if no leafs) */ uint8_t lastLeafNode[4]; /* number of last leaf node (0 if no leafs) */ uint8_t nodesize[2]; /* byte size of each node (512..32768) */ uint8_t maxKeyLen[2]; /* max key length in an index or leaf node */ uint8_t totalNodes[4]; /* number of nodes in btree (free or in use) */ uint8_t freeNodes[4]; /* unused nodes in btree */ uint8_t res[2]; /* reserved */ uint8_t clumpSize[4]; /* clump size */ uint8_t type; /* btree type (control or user) */ uint8_t compType; /* HFSX Only: identifies of key comparisons are case sensitive */ uint8_t attr[4]; /* attributes */ uint8_t res2[64]; /* reserved */ } hfs_btree_header_record; /* key for category records */ typedef struct { uint8_t key_len[2]; // length of key minus 2 uint8_t parent_cnid[4]; hfs_uni_str name; } hfs_btree_key_cat; /* Key for extents records */ // fork_type values #define HFS_EXT_KEY_TYPE_DATA 0x00 // extents key is for data fork #define HFS_EXT_KEY_TYPE_RSRC 0xFF // extents key is for resource fork typedef struct { uint8_t key_len[2]; // length of key minus 2 (should always be 10) uint8_t fork_type; // data or resource fork uint8_t pad; // reserved uint8_t file_id[4]; // the cnid that this key is for uint8_t start_block[4]; // the offset in the file (in blocks) that this run is for } hfs_btree_key_ext; /* Record contents for index record after key */ typedef struct { uint8_t childNode[4]; } hfs_btree_index_record; /********* CATALOG Record structures *********/ typedef struct { int8_t v[2]; int8_t h[2]; } hfs_point; #define HFS_FINDER_FLAG_NAME_LOCKED 0x1000 #define HFS_FINDER_FLAG_HAS_BUNDLE 0x2000 #define HFS_FINDER_FLAG_IS_INVISIBLE 0x4000 #define HFS_FINDER_FLAG_IS_ALIAS 0x8000 // Finder info stored in file and folder structures typedef struct { uint8_t file_type[4]; /* file type */ uint8_t file_cr[4]; /* file creator */ uint8_t flags[2]; /* finder flags */ hfs_point loc; /* location in the folder */ uint8_t res[2]; /* reserved */ } hfs_fileinfo; typedef struct { uint8_t res1[8]; /* reserved 1 */ uint8_t extflags[2]; /* extended finder flags */ uint8_t res2[2]; /* reserved 2 */ uint8_t folderid[4]; /* putaway folder id */ } hfs_extendedfileinfo; /* Note that the file, folder, and thread structures all * start with a 2-byte type field. */ // values for rec_type Record Type fields #define HFS_FOLDER_RECORD 0x0001 #define HFS_FILE_RECORD 0X0002 #define HFS_FOLDER_THREAD 0x0003 #define HFS_FILE_THREAD 0x0004 // the start of the folder and file catalog entries are the same typedef struct { uint8_t rec_type[2]; /* record type */ uint8_t flags[2]; /* Flags (reserved (0) for folders) */ uint8_t valence[4]; /* valence - items in this folder (folders only) */ uint8_t cnid[4]; /* CNID of this file or folder */ uint8_t crtime[4]; /* create date */ uint8_t cmtime[4]; /* content modification date (m-time) */ uint8_t amtime[4]; /* attribute mod date (c-time) */ uint8_t atime[4]; /* access date */ uint8_t bkup_date[4]; /* backup date */ hfs_access_perm perm; /* permissions */ hfs_fileinfo u_info; /* user info (Used by Finder) */ hfs_extendedfileinfo f_info; /* finder info */ uint8_t text_enc[4]; /* text encoding hint for file name */ uint8_t res2[4]; /* reserved 2 */ } hfs_file_fold_std; // structure for folder data in catalog leaf records typedef struct { hfs_file_fold_std std; /* standard data that files and folders share */ } hfs_folder; // value for flags in hfs_file #define HFS_FILE_FLAG_LOCKED 0x0001 /* file is locked */ #define HFS_FILE_FLAG_THREAD 0x0002 /* File has a thread entry */ // @@@ BC: I Can't find a reference to these values... #define HFS_FILE_FLAG_ATTR 0x0004 /* file has extended attributes */ #define HFS_FILE_FLAG_ACL 0x0008 /* file has security data (ACLs) */ // structure for file data in catalog leaf records typedef struct { hfs_file_fold_std std; /* standard data that files and folders share */ hfs_fork data; /* data fork */ hfs_fork resource; /* resource fork */ } hfs_file; // structure for thread data in catalog leaf records typedef struct { uint8_t rec_type[2]; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */ uint8_t res[2]; /* reserved - initialized as zero */ uint8_t parent_cnid[4]; /* parent ID for this catalog node */ hfs_uni_str name; /* name of this catalog node (variable length) */ } hfs_thread; // internally used structure to pass around both files and folders typedef union { hfs_folder folder; hfs_file file; } hfs_file_folder; typedef struct { TSK_FS_INFO fs_info; /* SUPER CLASS */ hfs_plus_vh *fs; /* cached superblock */ char is_case_sensitive; TSK_FS_FILE *blockmap_file; const TSK_FS_ATTR *blockmap_attr; char blockmap_cache[4096]; ///< Cache for blockmap TSK_OFF_T blockmap_cache_start; ///< Byte offset of blockmap where cache starts size_t blockmap_cache_len; ///< Length of cache that is being used TSK_FS_FILE *catalog_file; const TSK_FS_ATTR *catalog_attr; hfs_btree_header_record catalog_header; TSK_FS_FILE *extents_file; const TSK_FS_ATTR *extents_attr; hfs_btree_header_record extents_header; TSK_OFF_T hfs_wrapper_offset; /* byte offset of this FS within an HFS wrapper */ } HFS_INFO; typedef struct { hfs_file cat; /* on-disk catalog record (either hfs_file or hfs_folder) */ int flags; /* flags for on-disk record */ TSK_INUM_T inum; /* cnid */ hfs_thread thread; /* thread record */ } HFS_ENTRY; /************** JOURNAL ******************/ /* HFS Journal Info Block */ typedef struct { uint8_t flags[4]; uint8_t dev_sig[32]; uint8_t offs[8]; uint8_t size[8]; uint8_t res[128]; } hfs_journ_sb; /* * Prototypes */ extern uint8_t hfs_checked_read_random(TSK_FS_INFO *, char *, size_t, TSK_OFF_T); extern uint8_t hfs_uni2ascii(TSK_FS_INFO *, uint8_t *, int, char *, int); extern int hfs_unicode_compare(HFS_INFO *, const hfs_uni_str *, const hfs_uni_str *); extern uint16_t hfs_get_idxkeylen(HFS_INFO * hfs, uint16_t keylen, const hfs_btree_header_record * header); extern TSK_RETVAL_ENUM hfs_dir_open_meta(TSK_FS_INFO *, TSK_FS_DIR **, TSK_INUM_T); extern int hfs_name_cmp(TSK_FS_INFO *, const char *, const char *); extern uint8_t hfs_jopen(TSK_FS_INFO *, TSK_INUM_T); extern uint8_t hfs_jblk_walk(TSK_FS_INFO *, TSK_DADDR_T, TSK_DADDR_T, int, TSK_FS_JBLK_WALK_CB, void *); extern uint8_t hfs_jentry_walk(TSK_FS_INFO *, int, TSK_FS_JENTRY_WALK_CB, void *); typedef uint8_t(*TSK_HFS_BTREE_CB) (HFS_INFO *, int8_t level_type, const void *targ_key, const hfs_btree_key_cat * cur_key, TSK_OFF_T key_off, void *); // return values for callback #define HFS_BTREE_CB_IDX_LT 1 // current key is less than target (keeps looking in node) #define HFS_BTREE_CB_IDX_EQGT 2 // current key is equal or greater than target (stops) #define HFS_BTREE_CB_LEAF_GO 3 // keep on going to the next key in the leaf node #define HFS_BTREE_CB_LEAF_STOP 4 // stop processing keys in the leaf node #define HFS_BTREE_CB_ERR 5 extern uint8_t hfs_cat_traverse(HFS_INFO * hfs, const void *targ_data, TSK_HFS_BTREE_CB a_cb, void *ptr); #endif sleuthkit-3.2.3/tsk3/fs/tsk_iso9660.h000644 000765 000024 00000055566 11643647440 020024 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** This software is subject to the IBM Public License ver. 1.0, ** which was displayed prior to download and is included in the readme.txt ** file accompanying the Sleuth Kit files. It may also be requested from: ** Crucial Security Inc. ** 14900 Conference Center Drive ** Chantilly, VA 20151 ** ** Wyatt Banks [wbanks@crucialsecurity.com] ** Copyright (c) 2005 Crucial Security Inc. All rights reserved. ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2005 Brian Carrier. All rights reserved ** ** Copyright (c) 1997,1998,1999, International Business Machines ** Corporation and others. All Rights Reserved. */ /* TCT * LICENSE * This software is distributed under the IBM Public License. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA --*/ /* ** You may distribute the Sleuth Kit, or other software that incorporates ** part of all of the Sleuth Kit, in object code form under a license agreement, ** provided that: ** a) you comply with the terms and conditions of the IBM Public License ** ver 1.0; and ** b) the license agreement ** i) effectively disclaims on behalf of all Contributors all warranties ** and conditions, express and implied, including warranties or ** conditions of title and non-infringement, and implied warranties ** or conditions of merchantability and fitness for a particular ** purpose. ** ii) effectively excludes on behalf of all Contributors liability for ** damages, including direct, indirect, special, incidental and ** consequential damages such as lost profits. ** iii) states that any provisions which differ from IBM Public License ** ver. 1.0 are offered by that Contributor alone and not by any ** other party; and ** iv) states that the source code for the program is available from you, ** and informs licensees how to obtain it in a reasonable manner on or ** through a medium customarily used for software exchange. ** ** When the Sleuth Kit or other software that incorporates part or all of ** the Sleuth Kit is made available in source code form: ** a) it must be made available under IBM Public License ver. 1.0; and ** b) a copy of the IBM Public License ver. 1.0 must be included with ** each copy of the program. */ /* * Contains the structures and function APIs for ISO9660 file system support. */ /* refernece documents used: * IEEE P1281 - System Use Sharing Protocol, version 1.12 * IEEE P1282 - Rock Ridge Interchange Protocol, version 1.12 * ECMA-119 - Volume and File Structure of CDROM for Information Interchange, * 2nd Edition */ #ifndef _TSK_ISO9660_H #define _TSK_ISO9660_H /* This part borrowed from the bsd386 isofs */ #define ISODCL(from, to) (to - from + 1) /* * Constants */ #define ISO9660_FIRSTINO 0 #define ISO9660_ROOTINO 0 #define ISO9660_FILE_CONTENT_LEN sizeof(TSK_DADDR_T) #define ISO9660_SBOFF 32768 #define ISO9660_SSIZE_B 2048 #define ISO9660_MIN_BLOCK_SIZE 512 #define ISO9660_MAX_BLOCK_SIZE 2048 #define ISO9660_MAGIC "CD001" /* values used in volume descriptor type */ #define ISO9660_BOOT_RECORD 0 /* boot record */ #define ISO9660_PRIM_VOL_DESC 1 /* primary volume descriptor */ #define ISO9660_SUPP_VOL_DESC 2 /* supplementary volume descriptor */ #define ISO9660_VOL_PART_DESC 3 /* volume partition descriptor */ #define ISO9660_RESERVE_FLOOR 4 /* 4-254 are reserved */ #define ISO9660_RESERVE_CEIL 254 #define ISO9660_VOL_DESC_SET_TERM 255 /* volume descriptor set terminator */ #define ISO9660_MAXNAMLEN_STD 128 ///< Maximum length of standard name #define ISO9660_MAXNAMLEN_JOL 128 ///< maximum UTF-16 joliet name (in bytes) #define ISO9660_MAXNAMLEN (ISO9660_MAXNAMLEN_JOL << 1) // mult jol by 2 to account for UTF-16 to UTF-8 conversion /* Bits in permissions used in extended attribute records. */ #define ISO9660_BIT_UR 0x0010 #define ISO9660_BIT_UX 0x0040 #define ISO9660_BIT_GR 0x0100 #define ISO9660_BIT_GX 0x0400 #define ISO9660_BIT_AR 0x1000 #define ISO9660_BIT_AX 0x4000 /* directory descriptor flags */ #define ISO9660_FLAG_HIDE 0x01 /* Hide file -- called EXISTENCE */ #define ISO9660_FLAG_DIR 0x02 /* Directory */ #define ISO9660_FLAG_ASSOC 0x04 /* File is associated */ #define ISO9660_FLAG_RECORD 0X08 /* Record format in extended attr */ #define ISO9660_FLAG_PROT 0X10 /* No read / exec perm in ext attr */ #define ISO9660_FLAG_RES1 0X20 /* reserved */ #define ISO9660_FLAG_RES2 0x40 /* reserved */ #define ISO9660_FLAG_MULT 0X80 /* not final entry of mult ext file */ /* POSIX modes used in ISO9660 not already defined */ #define MODE_IFSOCK 0140000 /* socket */ #define MODE_IFLNK 0120000 /* symbolic link */ #define MODE_IFDIR 0040000 /* directory */ #define MODE_IFIFO 0010000 /* pipe or fifo */ #define MODE_IFBLK 0060000 /* block special */ #define MODE_IFCHR 0020000 /* character special */ /* used to determine if get directory entry function needs to handle Joliet */ #define ISO9660_TYPE_PVD 0 #define ISO9660_TYPE_SVD 1 #define ISO9660_CTYPE_ASCII 0 #define ISO9660_CTYPE_UTF16 1 /* recording date and time */ typedef struct { uint8_t year; /* years since 1900 */ uint8_t month; /* 1-12 */ uint8_t day; /* 1-31 */ uint8_t hour; /* 0-23 */ uint8_t min; /* 0-59 */ uint8_t sec; /* 0-59 */ int8_t gmt_off; /* greenwich mean time offset (in 15 minute intervals) */ } record_data; /* iso 9660 directory record */ typedef struct { uint8_t entry_len; /* length of directory record */ uint8_t ext_len; /* extended attribute record length */ uint8_t ext_loc_l[4]; /* location of extent - le */ uint8_t ext_loc_m[4]; /* location of extent - be */ uint8_t data_len_l[4]; /* data length - le */ uint8_t data_len_m[4]; /* data length - be */ record_data rec_time; /* recording date and time (7 bytes) */ int8_t flags; /* file flags */ uint8_t unit_sz; /* file unit size */ uint8_t gap_sz; /* interleave gap size */ uint8_t seq[4]; /* volume sequence number (2|16) */ uint8_t fi_len; /* length of file identifier in bytes */ } iso9660_dentry; /* This is a dummy struct used to make reading an entire PVD easier, * due to the fact that the root directory has a 1 byte name that * wouldn't be worth adding to the regular struct. */ typedef struct { uint8_t length; /* length of directory record */ uint8_t ext_len; /* extended attribute record length */ uint8_t ext_loc_l[4]; /* location of extent - le */ uint8_t ext_loc_m[4]; /* location of extent - be */ uint8_t data_len_l[4]; /* data length - le */ uint8_t data_len_m[4]; /* data length - be */ record_data rec; /* recording date and time */ int8_t flags; /* file flags */ uint8_t unit_sz; /* file unit size */ uint8_t gap_sz; /* interleave gap size */ uint8_t seq[4]; /* volume sequence number (2|16) */ uint8_t len; /* length of file identifier */ char name; } iso9660_root_dentry; /* data and time format * all are stored as "digits" according to specifications for iso9660 */ typedef struct { uint8_t year[4]; /* 1 to 9999 */ uint8_t month[2]; /* 1 to 12 */ uint8_t day[2]; /* 1 to 31 */ uint8_t hour[2]; /* 0 to 23 */ uint8_t min[2]; /* 0 to 59 */ uint8_t sec[2]; /* 0 to 59 */ uint8_t hun[2]; /* hundredths of a second */ uint8_t gmt_off; /* GMT offset */ } date_time; /* generic volume descriptor */ typedef struct { uint8_t type; ///< volume descriptor type char magic[ISODCL(2, 6)]; ///< magic number. "CD001" char ver[ISODCL(7, 7)]; ///< volume descriptor version char x[ISODCL(8, 2048)]; ///< Depends on descriptor type } iso9660_gvd; /* primary volume descriptor */ typedef struct { char unused1[ISODCL(1, 8)]; /* should be 0. unused. */ char sys_id[ISODCL(9, 40)]; /* system identifier */ char vol_id[ISODCL(41, 72)]; /* volume identifier */ char unused2[ISODCL(73, 80)]; /* should be 0. unused. */ uint8_t vs_sz_l[ISODCL(81, 84)]; /* volume space size in blocks - le */ uint8_t vs_sz_m[ISODCL(85, 88)]; /* volume space size in blocks - be */ char unused3[ISODCL(89, 120)]; /* should be 0. unused. */ uint8_t vol_set_l[ISODCL(121, 122)]; /* volume set size - le */ uint8_t vol_set_m[ISODCL(123, 124)]; /* volume set size - be */ uint8_t vol_seq_l[ISODCL(125, 126)]; /* volume sequence number -le */ uint8_t vol_seq_m[ISODCL(127, 128)]; /* volume sequence number - be */ uint8_t blk_sz_l[ISODCL(129, 130)]; /* logical block size - le */ uint8_t blk_sz_m[ISODCL(131, 132)]; /* logical block size - be */ uint8_t pt_size_l[ISODCL(133, 136)]; /* path table size in bytes - le */ uint8_t pt_size_m[ISODCL(137, 140)]; /* path table size in bytes - be */ uint8_t pt_loc_l[ISODCL(141, 144)]; /* log block addr of type L path tbl. */ uint8_t pt_opt_loc_l[ISODCL(145, 148)]; /* log block addr of optional L path tbl */ uint8_t pt_loc_m[ISODCL(149, 152)]; /* log block addr of type M path tbl. */ uint8_t pt_opt_loc_m[ISODCL(153, 156)]; /* log block addr of optional M path tbl */ iso9660_root_dentry dir_rec; /* directory record for root dir */ char vol_setid[ISODCL(191, 318)]; /* volume set identifier */ unsigned char pub_id[ISODCL(319, 446)]; /* publisher identifier */ unsigned char prep_id[ISODCL(447, 574)]; /* data preparer identifier */ unsigned char app_id[ISODCL(575, 702)]; /* application identifier */ unsigned char copy_id[ISODCL(703, 739)]; /* copyright file identifier */ unsigned char abs_id[ISODCL(740, 776)]; /* abstract file identifier */ unsigned char bib_id[ISODCL(777, 813)]; /* bibliographic file identifier */ date_time make_date; /* volume creation date/time */ date_time mod_date; /* volume modification date/time */ date_time exp_date; /* volume expiration date/time */ date_time ef_date; /* volume effective date/time */ uint8_t fs_ver; /* file structure version */ char res[ISODCL(883, 883)]; /* reserved */ char app_use[ISODCL(884, 1395)]; /* application use */ char reserv[ISODCL(1396, 2048)]; /* reserved */ } iso9660_pvd; /* supplementary volume descriptor */ typedef struct { uint8_t flags[ISODCL(1, 8)]; /* volume flags */ char sys_id[ISODCL(9, 40)]; /* system identifier */ char vol_id[ISODCL(41, 72)]; /* volume identifier */ char unused2[ISODCL(73, 80)]; /* should be 0. unused. */ uint8_t vs_sz_l[ISODCL(81, 84)]; /* volume space size in blocks - le */ uint8_t vs_sz_m[ISODCL(85, 88)]; /* volume space size in blocks - be */ uint8_t esc_seq[ISODCL(89, 120)]; /* escape sequences */ uint8_t vol_set_l[ISODCL(121, 122)]; /* volume set size - le */ uint8_t vol_set_m[ISODCL(123, 124)]; /* volume set size - be */ uint8_t vol_seq_l[ISODCL(125, 126)]; /* volume sequence number -le */ uint8_t vol_seq_m[ISODCL(127, 128)]; /* volume sequence number - be */ uint8_t blk_sz_l[ISODCL(129, 130)]; /* logical block size - le */ uint8_t blk_sz_m[ISODCL(131, 132)]; /* logical block size - be */ uint8_t pt_size_l[ISODCL(133, 136)]; /* path table size in bytes - le */ uint8_t pt_size_m[ISODCL(137, 140)]; /* path table size in bytes - be */ uint8_t pt_loc_l[ISODCL(141, 144)]; /* log block addr of type L path tbl. */ uint8_t pt_opt_loc_l[ISODCL(145, 148)]; /* log block addr of optional type L path tbl. */ uint8_t pt_loc_m[ISODCL(149, 152)]; /* log block addr of type M path tbl. */ uint8_t pt_opt_loc_m[ISODCL(153, 156)]; /* log block addr of optional type M path tbl. */ iso9660_root_dentry dir_rec; /* directory record for root dir */ char vol_setid[ISODCL(191, 318)]; /* volume set identifier */ unsigned char pub_id[ISODCL(319, 446)]; /* publisher identifier */ unsigned char prep_id[ISODCL(447, 574)]; /* data preparer identifier */ unsigned char app_id[ISODCL(575, 702)]; /* application identifier */ unsigned char copy_id[ISODCL(703, 739)]; /* copyright file identifier */ unsigned char abs_id[ISODCL(740, 776)]; /* abstract file identifier */ unsigned char bib_id[ISODCL(777, 813)]; /* bibliographic file identifier */ date_time make_date; /* volume creation date/time */ date_time mod_date; /* volume modification date/time */ date_time exp_date; /* volume expiration date/time */ date_time ef_date; /* volume effective date/time */ char fs_ver[ISODCL(882, 882)]; /* file structure version */ char res[ISODCL(883, 883)]; /* reserved */ char app_use[ISODCL(884, 1395)]; /* application use */ char reserv[ISODCL(1396, 2048)]; /* reserved */ } iso9660_svd; /* iso 9660 boot record */ typedef struct { char boot_sys_id[ISODCL(8, 39)]; /* boot system identifier */ char boot_id[ISODCL(40, 71)]; /* boot identifier */ char system_use[ISODCL(72, 2048)]; /* system use */ } iso_bootrec; /* path table record */ typedef struct { uint8_t len_di; /* length of directory identifier */ uint8_t attr_len; /* extended attribute record length */ uint8_t ext_loc[4]; /* location of extent */ uint8_t par_dir[2]; /* parent directory number (its entry in the path table) */ } path_table_rec; /* extended attribute record */ typedef struct { uint8_t uid[ISODCL(1, 4)]; /* owner identification */ uint8_t gid[ISODCL(5, 8)]; /* group identification */ uint8_t mode[ISODCL(9, 10)]; /* permissions */ uint8_t cre[ISODCL(11, 27)]; /* file creation date/time */ uint8_t mod[ISODCL(28, 44)]; /* file modification d/t */ uint8_t exp[ISODCL(45, 61)]; /* file expiration d/t */ uint8_t eff[ISODCL(62, 78)]; /* file effective d/t */ uint8_t fmt[ISODCL(79, 79)]; /* record format */ uint8_t attr[ISODCL(80, 80)]; /* record attributes */ uint8_t len[ISODCL(81, 84)]; /* record length */ uint8_t sys_id[ISODCL(85, 116)]; /* system identifier */ uint8_t uns[ISODCL(117, 180)]; /* system use, not specified */ uint8_t e_ver[ISODCL(181, 181)]; /* extended attribute record version */ uint8_t len_esc[ISODCL(182, 182)]; /* length of escape sequences */ } ext_attr_rec; #define ISO_EA_IRSYS 0x0001 #define ISO_EA_IWSYS 0x0002 #define ISO_EA_IXSYS 0x0004 #define ISO_EA_IRUSR 0x0010 #define ISO_EA_IWUSR 0x0020 #define ISO_EA_IXUSR 0x0040 #define ISO_EA_IRGRP 0x0100 #define ISO_EA_IWGRP 0x0200 #define ISO_EA_IXGRP 0x0400 #define ISO_EA_IROTH 0x1000 #define ISO_EA_IWOTH 0x2000 #define ISO_EA_IXOTH 0x4000 /* primary volume descriptor linked list node */ typedef struct iso9660_pvd_node { iso9660_pvd pvd; struct iso9660_pvd_node *next; } iso9660_pvd_node; /* supplementary volume descriptor linked list node */ typedef struct iso9660_svd_node { iso9660_svd svd; struct iso9660_svd_node *next; } iso9660_svd_node; /* RockRidge extension info */ typedef struct { TSK_UID_T uid /* owner */ ; TSK_GID_T gid; /* group */ uint16_t mode; /* posix file mode */ uint32_t nlink; /* number of links */ char fn[ISO9660_MAXNAMLEN_STD]; /* alternate filename */ } rockridge_ext; /** \internal * Internally used structure to hold basic inode information. */ typedef struct { iso9660_dentry dr; /* directory record */ ext_attr_rec *ea; /* extended attribute record */ char fn[ISO9660_MAXNAMLEN + 1]; /* file name */ rockridge_ext *rr; /* RockRidge Extensions */ int version; uint8_t is_orphan; /* 1 if the file was found from processing other volume descriptors besides the first one, 0 otherwise */ TSK_OFF_T susp_off; ///< Byte offset in image of SUSP (or NULL) TSK_OFF_T susp_len; ///< Length in bytes of SUSP } iso9660_inode; /* inode linked list node */ typedef struct iso9660_inode_node { iso9660_inode inode; TSK_OFF_T offset; /* byte offset of first block of file in file system */ TSK_OFF_T dentry_offset; /* byte offset of directory entry structure in file system */ TSK_INUM_T inum; /* identifier of inode (assigned by TSK) */ int size; /* number of bytes in file */ int ea_size; /* length of ext attributes */ struct iso9660_inode_node *next; } iso9660_inode_node; /* The all important ISO_INFO struct */ typedef struct { TSK_FS_INFO fs_info; /* SUPER CLASS */ TSK_INUM_T dinum; /* cached inode number */ iso9660_inode *dinode; /* cached disk inode */ uint32_t path_tab_addr; /* address of path table */ uint32_t root_addr; /* address of root dir extent */ iso9660_pvd_node *pvd; ///< Head of primary volume descriptor list (there should be only one...) iso9660_svd_node *svd; ///< Head of secondary volume descriptor list iso9660_inode_node *in_list; /* list of inodes */ uint8_t rr_found; /* 1 if rockridge found */ } ISO_INFO; extern TSK_RETVAL_ENUM iso9660_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); extern uint8_t iso9660_dinode_load(ISO_INFO * iso, TSK_INUM_T inum); extern int iso9660_name_cmp(TSK_FS_INFO *, const char *, const char *); /********************************************************** * * RockRidge Extensions * **********************************************************/ typedef struct { char sig[2]; uint8_t len; char ver; } iso9660_susp_head; /** \internal * SUSP Continuation Entry (CE) */ typedef struct { char sig[2]; uint8_t len; char ver; uint8_t blk_l[4]; ///< Block location of continuation area uint8_t blk_m[4]; uint8_t offset_l[4]; ///< Offset to start of continuation area (in bytes) uint8_t offset_m[4]; uint8_t celen_l[4]; ///< Length of continuation area (in bytes) uint8_t celen_m[4]; } iso9660_susp_ce; /** \internal * SUSP SP entry */ typedef struct { char sig[2]; uint8_t len; char ver; uint8_t chk[2]; uint8_t skip; } iso9660_susp_sp; typedef struct { char sig[2]; uint8_t len; char ver; uint8_t len_id; ///< length of extension id (in bytes) uint8_t len_des; ///< length of extension desc (in bytes) uint8_t len_src; ///< Length of extension spec source (in bytes) uint8_t ext_ver; ///< Version id char ext_id[1]; ///< Extension ID text (with length of len_id); // next is the extension descriptor text // next is the extension source text } iso9660_susp_er; /* Rockridge ISO9660 system use field entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "RR" */ uint8_t len[ISODCL(3, 3)]; /* length of system use entry */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version */ uint8_t foo[ISODCL(5, 5)]; /* foo */ } rr_sys_use; /* Rockridge PX entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "PX" */ uint8_t len; /* length, should be 44 */ uint8_t ver; /* system use entry version (1) */ uint8_t mode_l[ISODCL(5, 8)]; /* POSIX file mode - le */ uint8_t mode_m[ISODCL(9, 12)]; /* POSIX file mode - be */ uint8_t links_l[ISODCL(13, 16)]; /* POSIX file links - le */ uint8_t links_m[ISODCL(17, 20)]; /* POSIX file links - be */ uint8_t uid_l[ISODCL(21, 24)]; /* POSIX user id - le */ uint8_t uid_m[ISODCL(25, 28)]; /* POSIX user id - be */ uint8_t gid_l[ISODCL(29, 32)]; /* POSIX group id - le */ uint8_t gid_m[ISODCL(23, 36)]; /* POSIX group id - be */ /* rockridge docs say this is here, k3b disagrees... hmmmm */ // uint8_t serial[ISODCL(37,44)]; /* POSIX file serial number */ } iso9660_rr_px_entry; /* Rockridge PN entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "PN" */ uint8_t len; /* length, should be 20 */ uint8_t ver; /* system use entry version (1) */ uint8_t dev_h_l[ISODCL(5, 8)]; /* top 32 bits of device # */ uint8_t dev_h_m[ISODCL(9, 12)]; /* top 32 bits of device # */ uint8_t dev_l_l[ISODCL(13, 16)]; /* low 32 bits of device # */ uint8_t dev_l_m[ISODCL(17, 20)]; /* low 32 bits of device # */ } iso9660_rr_pn_entry; /* Rockridge SL entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "SL" */ uint8_t len; /* length */ uint8_t ver; /* system use entry version (1) */ uint8_t flags; /* flags */ } iso9660_rr_sl_entry; /* Rockridge NM entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "NM" */ uint8_t len; /* length of alternate name */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version (1) */ uint8_t flags[ISODCL(5, 5)]; /* flags */ char name[1]; // start of the name } iso9660_rr_nm_entry; /* Rockridge CL entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "CL" */ uint8_t len[ISODCL(3, 3)]; /* length, should be 12 */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version (1) */ uint8_t par_loc[ISODCL(5, 12)]; /* location of parent directory */ } iso9660_rr_cl_entry; /* Rockridge RE entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "RE" */ uint8_t len[ISODCL(3, 3)]; /* length, should be 4 */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version (1) */ } iso9660_rr_re_entry; /* Rockridge TF entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "TF" */ uint8_t len[ISODCL(3, 3)]; /* length of TF entry */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version (1) */ uint8_t flags[ISODCL(5, 5)]; /* flags */ } iso9660_rr_tf_entry; /* Rockridge SF entry */ typedef struct { char sig[ISODCL(1, 2)]; /* signature, should be "SF" */ uint8_t len[ISODCL(3, 3)]; /* length, should be 21 */ uint8_t ver[ISODCL(4, 4)]; /* system use entry version (1) */ uint8_t vfs_h[ISODCL(5, 12)]; /* virtual file size high */ uint8_t vfs_l[ISODCL(13, 20)]; /* virtual file size low */ uint8_t depth[ISODCL(21, 21)]; /* table depth */ } iso9660_rr_sf_entry; #endif sleuthkit-3.2.3/tsk3/fs/tsk_ntfs.h000644 000765 000024 00000054466 11643647440 017655 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2003-2009 Brian Carrier. All rights reserved ** ** TASK ** Copyright (c) 2002 @stake Inc. All rights reserved ** ** This software is distributed under the Common Public License 1.0 */ /* * Contains the structures and function APIs for NTFS file system support. */ #ifndef _TSK_NTFS_H #define _TSK_NTFS_H #ifdef __cplusplus extern "C" { #endif // the SID code has been buggy on some systems and byitself it does // not provide much security info. It is being disabled until fixed. #define TSK_USE_SID 1 //#define NTFS_FS_MAGIC 0x5346544E /* "NTFS" in little endian */ #define NTFS_FS_MAGIC 0xAA55 #define NTFS_MAXNAMLEN 256 #define NTFS_MAXNAMLEN_UTF8 4 * NTFS_MAXNAMLEN /* location of the Root Directory inode */ #define NTFS_ROOTINO NTFS_MFT_ROOT #define NTFS_FIRSTINO 0 /* location of the $Mft Record */ #define NTFS_LAST_DEFAULT_INO 16 /* A guess for right now */ #define NTFS_FILE_CONTENT_LEN 0 /* uncompression values */ #define NTFS_TOKEN_MASK 1 #define NTFS_SYMBOL_TOKEN 0 #define NTFS_TOKEN_LENGTH 8 /* (64 * 1024) = 65536 */ #define NTFS_MAX_UNCOMPRESSION_BUFFER_SIZE 65536 /************************************************************************ * Update sequence structure. This is located at upd_off from the * begining of the original structure */ typedef struct { uint8_t upd_val[2]; // what they should be uint8_t upd_seq; // array of size 2*(upd_cnt-1) w/orig vals } ntfs_upd; /************************************************************************ * bootsector * * located in sector 0 in $Boot */ typedef struct { uint8_t f1[3]; // 0 char oemname[8]; // 3 uint8_t ssize[2]; // 11 /* sector size in bytes */ uint8_t csize; // 13 /* sectors per cluster */ uint8_t f2[26]; // 14 uint8_t vol_size_s[8]; // 40 /*size of volume in sectors */ uint8_t mft_clust[8]; // 48 /* location of MFT */ uint8_t mftm_clust[8]; // 56 /* location of MFT mirror */ int8_t mft_rsize_c; // 64 /* number of clusters per mft record */ uint8_t f3[3]; int8_t idx_rsize_c; // 68 /* number of clus per idx rec */ uint8_t f4[3]; uint8_t serial[8]; // 72 /* serial number */ uint8_t f5[430]; //80 uint8_t magic[2]; } ntfs_sb; /************************************************************************ * MFT Entry * * One entry in the MFT - there exists one for each file */ typedef struct { uint8_t magic[4]; uint8_t upd_off[2]; // 4 uint8_t upd_cnt[2]; // 6 size+1 uint8_t lsn[8]; // 8 $LogFile Sequence Number uint8_t seq[2]; // 16 uint8_t link[2]; // 18 uint8_t attr_off[2]; // 20 uint8_t flags[2]; // 22 uint8_t size[4]; // 24 uint8_t alloc_size[4]; //28 uint8_t base_ref[6]; // 32 uint8_t base_seq[2]; // 38 uint8_t next_attrid[2]; // 40 The next id to be assigned uint8_t f1[2]; // XP Only uint8_t entry[4]; // XP Only - Number of this entry } ntfs_mft; /* Magic values for each MFT entry */ #define NTFS_MFT_MAGIC 0x454c4946 #define NTFS_MFT_MAGIC_BAAD 0x44414142 #define NTFS_MFT_MAGIC_ZERO 0x00000000 /* MFT entry flags */ #define NTFS_MFT_INUSE 0x0001 #define NTFS_MFT_DIR 0x0002 /* flags for file_ref */ #define NTFS_MFT_BASE 0 /* set when the base file record */ /* Mask when not zero, which indicates the base file record */ #define NTFS_MFT_FILE_REC 0x00ffffffffffffff /* DEFINED MFT entries - file system metadata files */ #define NTFS_MFT_MFT 0x0 #define NTFS_MFT_MFTMIR 0x1 #define NTFS_MFT_LOG 0x2 #define NTFS_MFT_VOL 0x3 #define NTFS_MFT_ATTR 0x4 #define NTFS_MFT_ROOT 0x5 #define NTFS_MFT_BMAP 0x6 #define NTFS_MFT_BOOT 0x7 #define NTFS_MFT_BAD 0x8 //#define NTFS_MFT_QUOT 0x9 #define NTFS_MFT_SECURE 0x9 #define NTFS_MFT_UPCASE 0xA /************************************************************************ * Attribute Header for resident and non-resident attributes */ typedef struct { uint8_t type[4]; uint8_t len[4]; // 4 - length including header uint8_t res; // 8 - resident flag uint8_t nlen; // 9 - name length uint8_t name_off[2]; // 10 - offset to name uint8_t flags[2]; // 12 uint8_t id[2]; // 14 - unique identifier union { /* Resident Values */ struct { uint8_t ssize[4]; // 16 - size of content uint8_t soff[2]; // 20 - offset to content (after name) uint8_t idxflag[2]; // 22 - indexed flag } r; /* Non-resident Values */ struct { uint8_t start_vcn[8]; // 16 - starting VCN of this attribute uint8_t last_vcn[8]; // 24 uint8_t run_off[2]; // 32 - offset to the data runs (after name) uint8_t compusize[2]; // 34 - compression unit size (2^x) uint8_t f1[4]; // 36 uint8_t alen[8]; // 40 allocated size of stream uint8_t ssize[8]; // 48 actual size of stream uint8_t initsize[8]; // 56 initialized steam size } nr; } c; } ntfs_attr; /* values for the res field */ #define NTFS_MFT_RES 0 /* resident */ #define NTFS_MFT_NONRES 1 /* non-resident */ /* Values for flag field * should only exist for $DATA attributes */ #define NTFS_ATTR_FLAG_COMP 0x0001 /* compressed */ #define NTFS_ATTR_FLAG_ENC 0x4000 /* encrypted */ #define NTFS_ATTR_FLAG_SPAR 0x8000 /* sparse */ /* values for the type field */ /* NOTE that the default TSK attribute types are based on these. * Any changes to these should be merged with the defines in tsk_fs.h */ #define NTFS_ATYPE_SI 0x10 // 16 #define NTFS_ATYPE_ATTRLIST 0x20 // 32 #define NTFS_ATYPE_FNAME 0x30 // 48 #define NTFS_ATYPE_VVER 0x40 // 64 (NT) #define NTFS_ATYPE_OBJID 0x40 // 64 (2K) #define NTFS_ATYPE_SEC 0x50 // 80 #define NTFS_ATYPE_VNAME 0x60 // 96 #define NTFS_ATYPE_VINFO 0x70 // 112 #define NTFS_ATYPE_DATA 0x80 // 128 #define NTFS_ATYPE_IDXROOT 0x90 // 144 #define NTFS_ATYPE_IDXALLOC 0xA0 // 160 #define NTFS_ATYPE_BITMAP 0xB0 // 176 #define NTFS_ATYPE_SYMLNK 0xC0 // 192 (NT) #define NTFS_ATYPE_REPARSE 0xC0 // 192 (2K) #define NTFS_ATYPE_EAINFO 0xD0 // 208 #define NTFS_ATYPE_EA 0xE0 // 224 #define NTFS_ATYPE_PROP 0xF0 // (NT) #define NTFS_ATYPE_LOG 0x100 // (2K) /************************************************************************ * File Name Attribute */ typedef struct { uint8_t par_ref[6]; /* file reference to base File Record of parent */ uint8_t par_seq[2]; /* seq num to base File Record of parent */ uint8_t crtime[8]; /* file creation */ uint8_t mtime[8]; /* file altered */ uint8_t ctime[8]; /* mod time for FILE record (MFT Entry) */ uint8_t atime[8]; /* access time */ uint8_t alloc_fsize[8]; uint8_t real_fsize[8]; uint8_t flags[8]; uint8_t nlen; /* length of file name */ uint8_t nspace; uint8_t name; /* in unicode */ } ntfs_attr_fname; /* values for the flags field of attr_fname */ #define NTFS_FNAME_FLAGS_RO 0x0000000000000001 #define NTFS_FNAME_FLAGS_HID 0x0000000000000002 #define NTFS_FNAME_FLAGS_SYS 0x0000000000000004 #define NTFS_FNAME_FLAGS_ARCH 0x0000000000000020 #define NTFS_FNAME_FLAGS_DEV 0x0000000000000040 #define NTFS_FNAME_FLAGS_NORM 0x0000000000000080 #define NTFS_FNAME_FLAGS_TEMP 0x0000000000000100 #define NTFS_FNAME_FLAGS_SPAR 0x0000000000000200 #define NTFS_FNAME_FLAGS_REP 0x0000000000000400 #define NTFS_FNAME_FLAGS_COMP 0x0000000000000800 #define NTFS_FNAME_FLAGS_OFF 0x0000000000001000 #define NTFS_FNAME_FLAGS_NOIDX 0x0000000000002000 #define NTFS_FNAME_FLAGS_ENC 0x0000000000004000 #define NTFS_FNAME_FLAGS_DIR 0x0000000010000000 #define NTFS_FNAME_FLAGS_IDXVIEW 0x0000000020000000 /* values for the name space values of nspace */ #define NTFS_FNAME_POSIX 0 /* case sensitive and any but NULL and \ */ #define NTFS_FNAME_WIN32 1 // insensitive and restricted #define NTFS_FNAME_DOS 2 // 8.3 format of 8-bit chars in uppercase #define NTFS_FNAME_WINDOS 3 // name in WIN32 space that is already DOS /************************************************************************ * Standard Information Attribute */ typedef struct { uint8_t crtime[8]; /* creation date */ uint8_t mtime[8]; /* file altered */ uint8_t ctime[8]; /* MFT Changed */ uint8_t atime[8]; /* last access (read) */ uint8_t dos[4]; /* permissions in DOS Format */ uint8_t maxver[4]; uint8_t ver[4]; uint8_t class_id[4]; uint8_t own_id[4]; uint8_t sec_id[4]; uint8_t quota[8]; uint8_t usn[8]; } ntfs_attr_si; /* DOS Flags values */ #define NTFS_SI_RO 0x0001 #define NTFS_SI_HID 0x0002 #define NTFS_SI_SYS 0x0004 #define NTFS_SI_ARCH 0x0020 #define NTFS_SI_DEV 0x0040 #define NTFS_SI_NORM 0x0080 #define NTFS_SI_TEMP 0x0100 #define NTFS_SI_SPAR 0x0200 #define NTFS_SI_REP 0x0400 #define NTFS_SI_COMP 0x0800 #define NTFS_SI_OFF 0x1000 #define NTFS_SI_NOIDX 0x2000 #define NTFS_SI_ENC 0x4000 /************************************************************************ * Volume Info Attribute */ typedef struct { uint8_t f1[8]; uint8_t maj_ver; uint8_t min_ver; uint8_t flags[2]; uint8_t f2[4]; } ntfs_attr_vinfo; #define NTFS_VINFO_DIRTY 0x0001 // Dirty #define NTFS_VINFO_RESLOG 0x0002 // Resize LogFile #define NTFS_VINFO_UPGRAD 0x0004 // Upgrade on Mount #define NTFS_VINFO_MNTNT4 0x0008 // Mounted on NT4 #define NTFS_VINFO_DELUSN 0x0010 // Delete USN Underway #define NTFS_VINFO_REPOBJ 0x0020 // Repair Object Ids #define NTFS_VINFO_MODCHK 0x8000 // Modified by chkdsk /* versions * NT = Maj=1 Min=2 * 2k = Maj=3 Min=0 * xp = Maj=3 Min=1 */ #define NTFS_VINFO_NT 0x21 #define NTFS_VINFO_2K 0x03 #define NTFS_VINFO_XP 0x13 /************************************************************************ * attribute list */ typedef struct { uint8_t type[4]; // Attribute Type uint8_t len[2]; // length of entry uint8_t nlen; // number of chars in name uint8_t f1; // 7 uint8_t start_vcn[8]; // starting VCN or NTFS_ATTRL_RES uint8_t file_ref[6]; // file reference to new MFT entry uint8_t seq[2]; // 22 uint8_t id[2]; // id (also in the attribute header) uint8_t name; // 26 name in unicode } ntfs_attrlist; #define NTFS_ATTRL_RES 0 /************************************************************************ * runlist * * Used to store the non-resident runs for an attribute. * It is located in the MFT and pointed to by the run_off in the header */ typedef struct { /* lsb 4 bits: num of bytes in run length field * msb 4 bits: num of bytes in run offset field - (LCN) */ uint8_t len; uint8_t buf[32]; } ntfs_runlist; #define NTFS_RUNL_LENSZ(runl) \ (uint8_t)(runl->len & 0x0f) #define NTFS_RUNL_OFFSZ(runl) \ (uint8_t)((runl->len & 0xf0) >> 4) /************************************************************************ * Index root for directories * * the attribute has two parts. The header is general to all index entries * and applies to $IDX_ALLOC as well. The buffer part contains the * index entries that are allocated to $IDX_ROOT. * */ /* * Starting at begin_off is a stream of ntfs_idxentry structures */ typedef struct { uint8_t begin_off[4]; /* offset to start of seq of idx entries */ uint8_t seqend_off[4]; /* offset to end of seq of idx entries */ uint8_t bufend_off[4]; /* offset to end of idx buffer */ uint8_t flags[4]; } ntfs_idxelist; /* value for flags */ #define NTFS_IDXELIST_CHILD 0x1 /* children exist below this node */ /* This is general index information and applies to $IDX_ALLOC as well */ typedef struct { uint8_t type[4]; /* ATYPE that tree is sorted by */ uint8_t collation_rule[4]; uint8_t idxalloc_size_b[4]; /* index alloc size in bytes */ uint8_t idx_size_c; /* index alloc size in clusters */ uint8_t pad[3]; ntfs_idxelist list; } ntfs_idxroot; /************************************************************************ * idxrec * * this is structure for the nodes of the B+ index trees * It contains a list of index entry data structures. Each * buffer corresponds to one node. The $IDX_ALLOC attribute * is an array of these data structures */ typedef struct { uint8_t magic[4]; /* INDX */ uint8_t upd_off[2]; uint8_t upd_cnt[2]; /* size + 1 */ uint8_t lsn[8]; /* $LogFile Sequence Number */ uint8_t idx_vcn[8]; /* vcn in idx alloc attr */ ntfs_idxelist list; } ntfs_idxrec; #define NTFS_IDXREC_MAGIC 0x58444e49 /* INDX */ /************************************************************************ * This structure exists for each file and directory in the tree */ typedef struct { uint8_t file_ref[6]; /* file reference (invalid for last entry) */ uint8_t seq_num[2]; /* file reference (invalid for last entry) */ uint8_t idxlen[2]; /* length of the index entry */ uint8_t strlen[2]; /* length of stream */ uint8_t flags; uint8_t f1[3]; uint8_t stream; /* length of strlen - invalid for last entry */ /* loc of subnode is found in last 8-bytes * of idx entry (idxlen - 8). use macro */ } ntfs_idxentry; #define NTFS_IDX_SUB 0x01 /* Entry points to a sub-node */ #define NTFS_IDX_LAST 0x02 /* last indx entry in the node */ /* return the address of the subnode entry, it is located in the last * 8 bytes of the structure */ #define GET_IDXENTRY_SUB(fs, e) \ (tsk_getu64(fs->endian, (int)e + tsk_getu16(fs->endian, e->idxlen) - 8)) /************************************************************************ */ typedef struct { char label[128]; /* label in unicode */ uint8_t type[4]; uint8_t disp[4]; /* display rule */ uint8_t coll[4]; /* collation rule */ uint8_t flags[4]; uint8_t minsize[8]; /* minimum size */ uint8_t maxsize[8]; /* maximum size */ } ntfs_attrdef; #define NTFS_ATTRDEF_FLAGS_IDX 0x02 #define NTFS_ATTRDEF_FLAGS_RES 0x40 /* always resident */ #define NTFS_ATTRDEF_FLAGS_NONRES 0x80 /* allowed to be non-resident */ /************************************************************************ * OBJECT_ID attribute */ typedef struct { uint8_t objid1[8]; /* object id of file or directory */ uint8_t objid2[8]; uint8_t orig_volid1[8]; /* id of "birth" volume */ uint8_t orig_volid2[8]; uint8_t orig_objid1[8]; /* original object id */ uint8_t orig_objid2[8]; uint8_t orig_domid1[8]; /* id of "birth" domain */ uint8_t orig_domid2[8]; } ntfs_attr_objid; #if TSK_USE_SID /************************************************************************ * Self-relative security descriptor */ typedef struct { uint8_t revision; /* Revision level of the security descriptor. */ uint8_t pad; uint8_t control[2]; /* Flags qualifying the type of the descriptor as well as the following fields. */ uint8_t owner[4]; /* Byte offset to a SID representing an object's owner. If this is NULL, no owner SID is present in the descriptor. */ uint8_t group[4]; /* Byte offset to a SID representing an object's primary group. If this is NULL, no primary group SID is present in the descriptor. */ uint8_t sacl[4]; /* Byte offset to a system ACL. Only valid, if SE_SACL_PRESENT is set in the control field. If SE_SACL_PRESENT is set but sacl is NULL, a NULL ACL is specified. */ uint8_t dacl[4]; /* Byte offset to a discretionary ACL. Only valid, if SE_DACL_PRESENT is set in the control field. If SE_DACL_PRESENT is set but dacl is NULL, a NULL ACL (unconditionally granting access) is specified. */ } ntfs_self_relative_security_descriptor; /************************************************************************ * Structure used in Security Descriptor lookups */ typedef struct { char *buffer; size_t size; size_t used; } NTFS_SXX_BUFFER; /************************************************************************ * SID attribute */ typedef struct { uint8_t revision; /* Revision */ uint8_t sub_auth_count; /* Sub Authority Count */ uint8_t ident_auth[6]; /* NT Authority ::NOTE:: big endian number */ uint32_t sub_auth[1]; /* At least one sub_auth */ } ntfs_sid; /************************************************************************ * SDS attribute */ typedef struct { uint8_t hash_sec_desc[4]; /* Hash of Security Descriptor */ uint8_t sec_id[4]; /* Security ID */ uint8_t file_off[8]; /* Offset of this entry in this file */ uint8_t ent_size[4]; /* Size of this entry */ ntfs_self_relative_security_descriptor self_rel_sec_desc; /* Self-relative Security Descriptor */ } ntfs_attr_sds; /************************************************************************ * SDH attribute */ typedef struct { uint8_t data_off[2]; /* Offset to data */ uint8_t size[2]; /* Size of data */ uint8_t pad1[4]; /* Padding */ uint8_t ent_size[2]; /* Size of Index Entry */ uint8_t key_size[2]; /* Size of Index Key */ uint8_t flags[2]; /* Flags */ uint8_t pad2[2]; /* Padding */ uint8_t key_hash_sec_desc[4]; /* Hash of Security Descriptor */ uint8_t key_sec_id[4]; /* Security ID */ uint8_t data_hash_sec_desc[4]; /* Hash of Security Descriptor */ uint8_t data_sec_id[4]; /* Security ID */ uint8_t sec_desc_off[8]; /* Offset to Security Descriptor (in $SDS) */ uint8_t sec_desc_size[4]; /* Size of Security Descriptor (in $SDS) */ uint8_t pad3[4]; /* Padding */ } ntfs_attr_sdh; /************************************************************************ * SII attribute */ typedef struct { uint8_t data_off[2]; /* Offset to data */ uint8_t size[2]; /* Size of data */ uint8_t pad1[4]; /* Padding */ uint8_t ent_size[2]; /* Size of Index Entry */ uint8_t key_size[2]; /* Size of Index Key */ uint8_t flags[2]; /* Flags */ uint8_t pad2[2]; /* Padding */ uint8_t key_sec_id[4]; /* Security ID */ uint8_t data_hash_sec_desc[4]; /* Hash of Security Descriptor */ uint8_t data_sec_id[4]; /* Security ID */ uint8_t sec_desc_off[8]; /* Offset to Security Descriptor (in $SDS) */ uint8_t sec_desc_size[4]; /* Size of Security Descriptor (in $SDS) */ } ntfs_attr_sii; #endif typedef struct NTFS_PAR_MAP NTFS_PAR_MAP; struct NTFS_PAR_MAP { TSK_INUM_T par_addr; // parent dir address this structure is for NTFS_PAR_MAP *next; // pointer to next structure in list int alloc_cnt; // number of allocated INUM_T structures in addr int used_cnt; // number of used entries in addr TSK_INUM_T *addrs; // array for address of unallocated files in this dir }; /************************************************************************ */ typedef struct { TSK_FS_INFO fs_info; /* super class */ ntfs_sb *fs; uint8_t ver; /* version of NTFS - uses the VINFO flag */ TSK_FS_FILE *mft_file; /* contains the data for the mft entry for the mft */ const TSK_FS_ATTR *mft_data; /* Data run for MFT entry for MFT */ ntfs_mft *mft; /* cache for on-disk inode */ TSK_INUM_T mnum; /* number of above cached mft */ uint32_t csize_b; /* number of bytes in a cluster */ uint16_t ssize_b; /* number of bytes in a sector */ uint32_t mft_rsize_b; /* number of bytes per mft record */ uint32_t idx_rsize_b; /* number of bytes per idx record */ TSK_DADDR_T root_mft_addr; /* address of first mft entry */ uint8_t loading_the_MFT; /* set to 1 when initializing the setup */ TSK_FS_ATTR_RUN *bmap; /* Run of bitmap for clusters (linked list) */ char *bmap_buf; /* buffer to hold cached copy of bitmap */ TSK_DADDR_T bmap_buf_off; /* offset cluster in cached bitmap */ ntfs_attrdef *attrdef; // buffer of attrdef file contents size_t attrdef_len; // length of addrdef buffer NTFS_PAR_MAP *orphan_map; // map that lists par directory to its orphans. #if TSK_USE_SID NTFS_SXX_BUFFER sii_data; NTFS_SXX_BUFFER sds_data; #endif } NTFS_INFO; extern uint32_t nt2unixtime(uint64_t ntdate); extern uint8_t ntfs_attrname_lookup(TSK_FS_INFO *, uint16_t, char *, int); extern TSK_RETVAL_ENUM ntfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, TSK_INUM_T a_addr); extern void ntfs_orphan_map_free(NTFS_INFO * a_ntfs); extern int ntfs_name_cmp(TSK_FS_INFO *, const char *, const char *); #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/fs/unix_misc.c000644 000765 000024 00000033237 11643647440 020004 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ /** * \file unix_misc.c * Contains code that is common to both UFS1/2 and Ext2/3 file systems. */ #include "tsk_fs_i.h" #include "tsk_ffs.h" #include "tsk_ext2fs.h" /*********** MAKE DATA RUNS ***************/ /** \internal * Process an array of addresses and turn them into runs * * @param fs File system to analyze * @param fs_attr Data attribute to add runs to * @param addrs Buffer of addresses to process and turn into runs * @param addr_len Number of addresses in buffer * @param length Length of file remaining * * @returns the number of bytes processed and -1 if an error occurred */ static TSK_OFF_T unix_make_data_run_direct(TSK_FS_INFO * fs, TSK_FS_ATTR * fs_attr, TSK_DADDR_T * addrs, size_t addr_len, TSK_OFF_T length) { TSK_DADDR_T run_start = 0; TSK_DADDR_T run_len = 0; TSK_DADDR_T blks_processed = 0; size_t i; size_t fs_blen; // how big is each "block" (in fragments) if (addr_len == 0) { return 0; } // block_size is a fragment size in UFS, so we need to maintain length in fragments if (TSK_FS_TYPE_ISFFS(fs->ftype)) { FFS_INFO *ffs = (FFS_INFO *) fs; fs_blen = ffs->ffsbsize_f; } else { fs_blen = 1; } run_start = addrs[0]; run_len = fs_blen; /* Note that we are lazy about length. We stop only when a run is past length, * we do not end exactly at length -- although that should happen anyway. */ for (i = 0; i < addr_len; i++) { /* Make a new run if: * - This is the last addresss in the buffer * - The next address is not part of the current run * -- special case for sparse since they use 0 as an address */ if ((i + 1 == addr_len) || ((run_start + run_len != addrs[i + 1]) && (run_start != 0)) || ((run_start == 0) && (addrs[i + 1] != 0))) { TSK_FS_ATTR_RUN *data_run; // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) return -1; data_run->addr = run_start; data_run->len = run_len; if (run_start == 0) data_run->flags = TSK_FS_ATTR_RUN_FLAG_SPARSE; // save the run tsk_fs_attr_append_run(fs, fs_attr, data_run); // get ready for the next run if (i + 1 != addr_len) run_start = addrs[i + 1]; run_len = 0; // stop if we are past the length requested if (blks_processed * fs->block_size > (TSK_DADDR_T) length) break; } run_len += fs_blen; blks_processed += fs_blen; } return blks_processed * fs->block_size; } /** \internal * Read an indirect block and process the contents to make a runlist from the pointers. * * @param fs File system to analyze * @param fs_attr Structure to save run data into * @param fs_attr_indir Structure to save addresses of indirect block pointers in * @param buf Buffers to read block data into (0 is block sized, 1+ are DADDR_T arrays based on FS type) * @param level Indirection level that this will process at (1+) * @param addr Address of block to read * @param length Length of file remaining * * @returns the number of bytes processed during call and -1 if an error occurred */ static TSK_OFF_T unix_make_data_run_indirect(TSK_FS_INFO * fs, TSK_FS_ATTR * fs_attr, TSK_FS_ATTR * fs_attr_indir, char *buf[], int level, TSK_DADDR_T addr, TSK_OFF_T length) { char *myname = "unix_make_data_run_indirect"; size_t addr_cnt = 0; TSK_DADDR_T *myaddrs = (TSK_DADDR_T *) buf[level]; TSK_OFF_T length_remain = length; TSK_OFF_T retval; size_t fs_bufsize; size_t fs_blen; TSK_FS_ATTR_RUN *data_run; if (tsk_verbose) tsk_fprintf(stderr, "%s: level %d block %" PRIuDADDR "\n", myname, level, addr); // block_size is a fragment size in UFS, so we need to maintain length in fragments if (TSK_FS_TYPE_ISFFS(fs->ftype)) { FFS_INFO *ffs = (FFS_INFO *) fs; fs_blen = ffs->ffsbsize_f; fs_bufsize = ffs->ffsbsize_b; } else { fs_blen = 1; fs_bufsize = fs->block_size; } if (addr > fs->last_block) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "unix: Indirect block address too large: %" PRIuDADDR "", addr); return -1; } // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) return -1; data_run->addr = addr; data_run->len = fs_blen; /* * Read a block of disk addresses. */ // sparse if (addr == 0) { memset(buf[0], 0, fs_bufsize); data_run->flags = TSK_FS_ATTR_RUN_FLAG_SPARSE; } else { ssize_t cnt; // read the data into the scratch buffer cnt = tsk_fs_read_block(fs, addr, buf[0], fs_bufsize); if (cnt != fs_bufsize) { if (cnt >= 0) { tsk_error_reset(); tsk_errno = TSK_ERR_FS_READ; } snprintf(tsk_errstr2, TSK_ERRSTR_L, "unix_make_data_run_indir: Block %" PRIuDADDR, addr); return -1; } } // save the run tsk_fs_attr_append_run(fs, fs_attr_indir, data_run); // convert the raw addresses to the correct endian ordering if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B) || (TSK_FS_TYPE_ISEXT(fs->ftype))) { size_t n; uint32_t *iaddr = (uint32_t *) buf[0]; addr_cnt = fs_bufsize / sizeof(*iaddr); for (n = 0; n < addr_cnt; n++) { myaddrs[n] = tsk_getu32(fs->endian, (uint8_t *) & iaddr[n]); } } else if (fs->ftype == TSK_FS_TYPE_FFS2) { size_t n; uint64_t *iaddr = (uint64_t *) buf[0]; addr_cnt = fs_bufsize / sizeof(*iaddr); for (n = 0; n < addr_cnt; n++) { myaddrs[n] = tsk_getu64(fs->endian, (uint8_t *) & iaddr[n]); } } // pass the addresses to the next level if (level == 1) { retval = unix_make_data_run_direct(fs, fs_attr, myaddrs, addr_cnt, length_remain); if (retval != -1) { length_remain -= retval; } } else { size_t i; retval = 0; for (i = 0; i < addr_cnt && retval != -1; i++) { retval = unix_make_data_run_indirect(fs, fs_attr, fs_attr_indir, buf, level - 1, myaddrs[i], length_remain); if (retval == -1) { break; } else { length_remain -= retval; } } } if (retval == -1) return -1; else return length - length_remain; } /** \internal * * @returns 1 on error and 0 on success */ uint8_t tsk_fs_unix_make_data_run(TSK_FS_FILE * fs_file) { TSK_OFF_T length = 0; TSK_OFF_T read_b = 0; TSK_FS_ATTR *fs_attr; TSK_FS_ATTR *fs_attr_indir; TSK_FS_META *fs_meta = fs_file->meta; TSK_FS_INFO *fs = fs_file->fs_info; // clean up any error messages that are lying around tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "unix_make_data_run: Processing file %" PRIuINUM "\n", fs_meta->addr); // see if we have already loaded the runs if ((fs_meta->attr != NULL) && (fs_meta->attr_state == TSK_FS_META_ATTR_STUDIED)) { return 0; } else if (fs_meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } // not sure why this would ever happen, but... else if (fs_meta->attr != NULL) { tsk_fs_attrlist_markunused(fs_meta->attr); } else if (fs_meta->attr == NULL) { fs_meta->attr = tsk_fs_attrlist_alloc(); } if ((TSK_FS_TYPE_ISFFS(fs->ftype) == 0) && (TSK_FS_TYPE_ISEXT(fs->ftype) == 0)) { tsk_errno = TSK_ERR_FS_INODE_COR; snprintf(tsk_errstr, TSK_ERRSTR_L, "unix_make_run: Called with non-Unix file system: %x", fs->ftype); return 1; } length = roundup(fs_meta->size, fs->block_size); if ((fs_attr = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { return 1; } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr, NULL, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, fs_meta->size, fs_meta->size, roundup(fs_meta->size, fs->block_size), 0, 0)) { return 1; } read_b = unix_make_data_run_direct(fs, fs_attr, (TSK_DADDR_T *) fs_meta->content_ptr, 12, length); if (read_b == -1) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; if (fs_meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; return 1; } length -= read_b; /* if there is still data left, read the indirect */ if (length > 0) { int level; char **buf; size_t fs_bufsize0; size_t fs_bufsize1; size_t ptrsperblock; int numBlocks = 0; int numSingIndirect = 0; int numDblIndirect = 0; int numTripIndirect = 0; /* With FFS/UFS a full block contains the addresses, but block_size is * only a fragment. Figure out the scratch buffer size and the buffers to * store the cleaned addresses (endian converted) */ if (TSK_FS_TYPE_ISFFS(fs->ftype)) { FFS_INFO *ffs = (FFS_INFO *) fs; fs_bufsize0 = ffs->ffsbsize_b; if ((fs->ftype == TSK_FS_TYPE_FFS1) || (fs->ftype == TSK_FS_TYPE_FFS1B)) { ptrsperblock = fs_bufsize0 / 4; } else { ptrsperblock = fs_bufsize0 / 8; } } else { fs_bufsize0 = fs->block_size; ptrsperblock = fs_bufsize0 / 4; } fs_bufsize1 = sizeof(TSK_DADDR_T) * ptrsperblock; /* * Initialize a buffer for the 3 levels of indirection that are supported by * this inode. Each level of indirection will have a buffer to store * addresses in. buf[0] is a special scratch buffer that is used to store * raw data from the image (before endian conversions are applied). It is * equal to one block size. The others will store TSK_DADDR_T structures * and will have a size depending on the FS type. */ if ((buf = (char **) tsk_malloc(sizeof(char *) * 4)) == NULL) return 1; if ((buf[0] = (char *) tsk_malloc(fs_bufsize0)) == NULL) { free(buf); return 1; } if ((fs_attr_indir = tsk_fs_attrlist_getnew(fs_meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { free(buf); return 1; } // determine number of indirect lbocks needed for file size... numBlocks = (int) (((fs_meta->size + fs_bufsize0 - 1) / fs_bufsize0) - 12); numSingIndirect = (int) ((numBlocks + ptrsperblock - 1) / ptrsperblock); numDblIndirect = 0; numTripIndirect = 0; // double block pointer? if (numSingIndirect > 1) { numDblIndirect = (int) ((numSingIndirect - 1 + ptrsperblock - 1) / ptrsperblock); if (numDblIndirect > 1) { numTripIndirect = (int) ((numDblIndirect - 1 + ptrsperblock - 1) / ptrsperblock); } } // initialize the data run if (tsk_fs_attr_set_run(fs_file, fs_attr_indir, NULL, NULL, TSK_FS_ATTR_TYPE_UNIX_INDIR, TSK_FS_ATTR_ID_DEFAULT, fs_bufsize0 * (numSingIndirect + numDblIndirect + numTripIndirect), fs_bufsize0 * (numSingIndirect + numDblIndirect + numTripIndirect), fs_bufsize0 * (numSingIndirect + numDblIndirect + numTripIndirect), 0, 0)) { free(buf); return 1; } for (level = 1; length > 0 && level < 4; level++) { TSK_DADDR_T *addr_ptr = (TSK_DADDR_T *) fs_meta->content_ptr; if ((buf[level] = (char *) tsk_malloc(fs_bufsize1)) == NULL) { int f; for (f = 0; f < level; f++) free(buf[f]); free(buf); return 1; } /* the indirect addresses are stored in addr_ptr after the 12 * direct addresses */ read_b = unix_make_data_run_indirect(fs, fs_attr, fs_attr_indir, buf, level, addr_ptr[12 + level - 1], length); if (read_b == -1) break; length -= read_b; } /* * Cleanup. */ for (level = 0; level < 4; level++) { if (buf[level]) free(buf[level]); } } if (read_b == -1) { fs_meta->attr_state = TSK_FS_META_ATTR_ERROR; if (fs_meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; return 1; } fs_meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0; } TSK_FS_ATTR_TYPE_ENUM tsk_fs_unix_get_default_attr_type(const TSK_FS_FILE * a_file) { return TSK_FS_ATTR_TYPE_DEFAULT; } int tsk_fs_unix_name_cmp(TSK_FS_INFO * a_fs_info, const char *s1, const char *s2) { return strcmp(s1, s2); } sleuthkit-3.2.3/tsk3/docs/auto.dox000644 000765 000024 00000012106 11643647437 017644 0ustar00carrierstaff000000 000000 /*! \page autopage File Extraction Automation This section describes the TskAuto C++ superclass that can be used to easily build automated applications that analyze a disk image and extract files from it. \section auto_over Overview The TSK API described in the previous sections of this User's Guide allows you to manually open a volume or file system and browse its contents to look at volumes and files. While this fine grained access is useful in some situations, there are others where you simply want to rip apart a disk image and see all of the files without worrying about how you get the files. The TskAuto class was designed to help in these situations. It is a C++ superclass that knows how to analyze a disk image. All you need to do is implement the TskAuto::processFile() method, which will get called for each file. Other methods in the class can also be implemented to get more details about the data being analyzed. \section auto_basics Basics To use TskAuto, you first need to create a C++ subclass of it and implement the TskAuto::processFile() method. The instructions in \ref basic_build will provide access to this class. To use your new TskAuto-based class, you must first open the disk images. This can be done with TskAuto::openImage(). Once you are done with the object, it should be closed with TskAuto::closeImage(). These methods have been defined as virtual so that you can override them if your class needs access to the list of image names (for a report, for example). To start the analysis after the image files have been opened, you must call either TskAuto::findFilesInImg(), TskAuto::findFilesInVs(), or TskAuto::findFilesInFs(). TskAuto::findFilesInImg() starts at sector 0 of the disk image and starts to analyze it. It looks for a volume system and, if it finds one, will examine the contents of each volume. If it doesn't find a volume system, it will assume that the image is of a volume and will analyze sector 0 as a file system. TskAuto::findFilesInVs() allows you to specify the sector offset where the volume system is located. It does the same analysis as TskAuto::findFilesInImg(), except that it doesn't always start in sector 0. In fact, TskAuto::findFilesInImg() simply calls TskAuto::findFilesInVs() with a starting offset of 0. TskAuto::findFilesInFs() allows you to specify the offset of a file system to process. This method will not look for a volume system, only a file system. Internally, this method is called from TskAuto::findFilesInVs() after a volume has been found. There is also a version that allows you to specify the directory start processing from. Regardless of the method that you use to start the processing, the TskAuto::processFile() method will be called for each file and directory that is found. You can specify if this method should be called for only allocated or unallocated files using the TskAuto::setFileFilterFlags() method. You can also specify what types of volumes to process by using the TskAuto::setVolFilterFlags() method. Inside of your TskAuto::processFile() method, you can read the contents of the file using either tsk_fs_file_read() or tsk_fs_file_walk(). If you want to see each attribute in a file, then you should call processAttributes() and implement the processAttribute() method, which will be called for each attribute. \section auto_filter Filtering Results With the methods defined above, TskAuto::processFile() will get called for all files and directories in an image. This maybe more files than you want though. There are thtree methods that will alert you when TskAuto is about to process a new volume or file system and will allow you to not process the volume or file system. You can implement the TskAuto::filterVs() method to learn about the volume system before it is processed. The return value of this method can cause TskAuto to skip the volume system or stop processing the disk image entirely. You can implement the TskAuto::filterVol() method to learn about each volume before it is processed. The return value of this method can cause TskAuto to skip the volume or stop processing the disk image entirely. You can implement the TskAuto::filterFs() method to learn about each file system before it is processed. The return value of this method can cause TskAuto to skip the file system or stop processing the disk image entirely. There are also a series of protected methods in TskAuto that will help you to skip files that may not be relevant to you. For example, TskAuto::isNtfsSystemFiles() will tell you if a file is one of the NTFS file system files (such as $MFT) that you may want to skip. You can use this method in TskAuto::processFile() to skip the big NTFS files. Refer to the protected methods in TskAuto for others that are defined for this purpose (they all begin with "is"). \section auto_examples Examples Refer to the source code in the tools/autotools directory of the distribution for examples of TskAuto-based classes. Files in this directory all use TskAuto to do things like recover deleted files or load data into a SQLite database. Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/base.dox000644 000765 000024 00000011747 11643647437 017620 0ustar00carrierstaff000000 000000 /*! \page basepage Base Functions This section describes some base API functions and concepts that are general to all of the other layers, such as error and Unicode handling. In addition to this documentation, there are sample programs in the samples directory in TSK that show these functions being used while processing a disk image. \section basic_encodings Encodings \subsection basic_enc_over Overview TSK supports Unicode volume or file system data and can process disk image files that contain non-Latin characters. This section describes how that is done. TSK runs on both Unix and Windows systems and these two systems differ on how they store Unicode. There are several storage methods for Unicode characters. The UTF-16 method stores the characters using either 2-bytes or 4-bytes (though most characters can be stored in 2-bytes). UTF-8 is a method where 1- to 4-bytes are used, depending on the character. UTF-8 is backward compatible with ASCII because the ASCII characters require only 1-byte. The FAT and NTFS file systems store file names in UTF-16 while UFS and Ext2/3 store file names in UTF-8. Unix internally uses UTF-8 to store Unicode text and Windows uses UTF-16 (if UNICODE is enabled). To support running on both Unix and Windows and to support file systems from both Unix and Windows, TSK must convert between UTF-8 and UTF-16. Internally, all TSK data structures store text in UTF-8. For example, the UTF-16 file names in NTFS are converted to UTF-8. However, the Windows functions that are used to open disk images require that the file name be in UTF-16. To account for this, special data types (as described in the next section) are used to handle disk image and local file names in the local storage method. \subsection basic_enc_t Special Data Types (TSK_TCHAR) At compile-time, TSK_TCHAR is defined to be a UTF-16 wide character on a Windows system and a UTF-8 character on a Unix system. This data type is used to store the disk image file name and other command line arguments that may need to be parsed. There are various definitions that can help to process the TSK_TCHAR strings, such as TSTRLEN, which maps to the appropriate function to find the length of the string. There are also functions that can be used to convert between UTF-8 and UTF-16 (see tsk_UTF16toUTF8() and tsk_UTF8toUTF16()). Note that in some environments, the TSK_TCHAR design is difficult to work with. For example, if you have a Windows environment where you are storing all strings in UTF-8. Some of the functions that take a TSK_TCHAR as an argument have been expanded to have versions that take a specific encoding. These are being added as needed, so send e-mail to sleuthkit-developers < at > lists < dot > sourceforge < dot > net if you find more that need to be updated. \section basic_error Error Handling The public API functions all return a value to indicate when an error occurs. More details about the error can be learned by reading the global tsk_errno value. This will be one of several predefined error codes. A description of the error can be obtained using the tsk_error_get() function or the error can be printed to a FILE handle using tsk_error_print(). \section basic_misc Miscellaneous Utilities The TSK library includes some basic utility structures and functions that can be used to manage lists and stacks. These are used internally and are part of the public API for convenience. The TSK_LIST structure is used to keep track of values that have been seen while processing. Values are added to the list using tsk_list_add(). The list can be searched using tsk_list_find() and closed using tsk_list_free(). The TSK_STACK structure is used to prevent infinite loops when recursing into directories. The stack can be created using tsk_stack_create() and data can pushed and popped using tsk_stack_push() and tsk_stack_pop(). To search the stack, tsk_stack_find() is used and tsk_stack_free() is used to free the stack. When recursing directories, the metadata address of the directory is stored on the stack when that directory is analyzed and popped off when that directory is done. \section basic_hash Hash Algorithms The TSK library includes support to calculate MD5 and SHA-1 hashes. To calculate the MD5 hash, a context must be first initialized with TSK_MD5_Init(). Data is added to the context with TSK_MD5_Update() and the hash is calculated with a call to TSK_MD5_Final(). A similar process is used for SHA-1 hashes using TSK_SHA_Init(), TSK_SHA_Update(), and TSK_SHA_Final(). \section basic_version Version To get the version number of the TSK library as a string, you can all the tsk_version_get_str() function to get a string representation. Or, you can call tsk_version_print() to print the library name and version to a FILE handle. There are also \#defines for the version as a string (in TSK_VERSION_STR) and as a number (in TSK_VERSION_NUM). Next to \ref imgpage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/basics.dox000644 000765 000024 00000015743 11643647437 020152 0ustar00carrierstaff000000 000000 /*! \page basicpage Library Basics This page describes some of the basic concepts of the TSK library. It is assumed that you have built and installed the TSK library based on either the instructions in the INSTALL.txt file or via a package. Refer to the files in the samples directory for examples on the topics in this and later sections. \section basic_layers Layers TSK is organized into several layers (and sub-layers). These layers represent layers of abstraction that are used with data storage. The User's Guide and API Reference are organized based on these layers. The lowest layer that TSK has is the Base Layer, which contains common programming and data structure functions that can be applied to all layers. This is where error handling, types, and convenience functions are defined. The next layer up is the Disk Image Layer, which allows disk images in various formats to be opened and processed. This layer hides the details associated with split, compressed, and encrypted image files from the other layers. All disk images must be first opened by the Disk Image Layer functions before they can be processed by other layers. The next layer up is the Volume System Layer. This layer focuses on processing data as a volume system, such as DOS partition tables or BSD disk label structures. If the disk image being analyzed has a volume system on it, then this set of functions will tell you starting and ending location of its partitions. The next layer up is the File System Layer. This layer focuses on processing data as a file system, such as FAT or NTFS. File systems can be located in a partition or can be the full disk image file. These set of functions allow you to read arbitrary data from the file system, list files, and open files. There are several sub-layers in the File System Layer and they are described in \ref fs_layers. There is an independent Hash Database Layer that handles hash databases, such as NSRL and md5sum outputs. This API allows you to create an index of hashes and perform fast lookups of them. These functions do not depend on the Disk Image, Volume System, or File System Layers. There is also an Automation Layer that integrates all of the previous layers in an automated fashion. It defines a C++ class named TskAuto that hides a lot of the details about analyzing file and volume systems. A basic diagram of the relationship between these layers is shown here. Note that if a disk image file does not have a volume system, then we can use the File System Layer functions directly on it.

 +==========================================================+
 |                                                          | 
 |                       +================+                 |
 |                       |      Base      |                 |
 |                       +================+                 |
 |                         /            \                   |
 |                        /              \                  |
 |              +==============+      +==================+  |
 |              |  Disk Image  |      |   Hash Database  |  |
 |              +==============+      +==================+  |
 |                 /       |                                |
 |                /        |                                |
 |   +===============+     |                                |
 |   | Volume System |     |                                |
 |   +===============+     |                                |
 |               \         |                                |
 |                \        |                                |
 |               +===============+                          |
 |               |  File System  |                          |
 |               +===============+                          |
 |                                                          |
 |                                                          |
 |                        Automation                        |
 +==========================================================+

\section basic_build Build Environment This section describes how to incorporate the TSK library into your application. In general, all you need to do is include a TSK header file and link in the library. \subsection ov_build_unix Unix This document assumes that you used 'make install' to install the library and header files and that you used the default location of /usr/local/. If you specified a different location, you will need to do the obvious path replacements in this document. To include the API definitions, you will need to include the tsk3/libtsk.h file in your source code. Depending on system configuration, you may need to add /usr/local/include to the list of directories that your compiler looks in for header files (using -I for example). \#include To include the library in your application during the linking phase, you will need to add -ltsk3 to add the libtsk3 library. Depending on system configuration, you may need to add /usr/local/lib/ to the list of directories that your compiler looks in for libraries (using -L for example). Note that if you built TSK with support for AFFLIB and libewf then you will also need to include -lewf and/or -lafflib. You may also need to include other libraries that AFFLIB and libewf require (my current system requires -lcrypto -lssl -lz -lncurses -lreadlin). Refer to the libewf and AFFLIB documentation for details. \subsection ov_build_win Windows The Windows setup is similar to the Unix setup, except that you need to include more libraries and there is no automated install or build process. The Visual Studio solution file is located in win32/tsk-win.sln. There are libauxtools, libimgtools, libmmtools, libfstools, and libhashdbtools projects for the five library layers (as described in \ref basic_layers). Build all five of these. These will create the static libraries in either the Debug or Release folders (depending on which version you built). To include the header files, configure your built environment to search in the root TSK directory (i.e. sleuthkit-3.0.0) and include the tsk3/libtsk.h file in your source code. The location of the TSK directory will depend on where you unpacked it. To link with the libraries, you must configure your environment to include the libraries. You can include all five of them or you can include only the ones you need. You will need to specify the directory where the libraries are located, which could be the Debug or Release subdirectories in the win32 directory. You can also move the libraries to a different location. Note that your Windows application must have UNICODE support enabled. Next to \ref basepage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/Doxyfile000644 000765 000024 00000175715 11643647437 017706 0ustar00carrierstaff000000 000000 # Doxyfile 1.5.9 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "The Sleuth Kit" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 3.2 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ../../../www/docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will rougly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = YES # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = NO # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = NO # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = NO # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = tsk3/docs/main.dox \ tsk3/docs/basics.dox \ tsk3/docs/base.dox \ tsk3/docs/img.dox \ tsk3/docs/vs.dox \ tsk3/docs/fs.dox \ tsk3/docs/hashdb.dox \ tsk3/docs/auto.dox \ tsk3/base \ tsk3/fs \ tsk3/hashdb \ tsk3/img \ tsk3/vs \ tsk3/auto # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.c *.cpp \ *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */auto/sqlite3* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = api-docs # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = tsk3/docs/footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # disables this behavior completely. For backwards compatibility with previous # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # respectively. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = __cplusplus # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO sleuthkit-3.2.3/tsk3/docs/footer.html000644 000765 000024 00000000451 11643647437 020344 0ustar00carrierstaff000000 000000

Copyright © 2007-2011 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

sleuthkit-3.2.3/tsk3/docs/fs.dox000644 000765 000024 00000045711 11643647437 017314 0ustar00carrierstaff000000 000000 /*! \page fspage File Systems This section describes the general file system analysis concepts and corresponding APIs in TSK. In addition to this documentation, there are sample programs in the samples directory in TSK that show these functions being used while processing a disk image. \section fs_gen General Concepts \subsection fs_layers File System Layers File systems are a collection of data structures that are stored in a disk or volume that allow you to save and open files. There are many different file systems and they all have unique data structures, but there are some general concepts that apply to all file systems. These general concepts are used in TSK to provide generic access to a variety of file systems. TSK organizes the data in file systems into five categories: File System, Data Units, Metadata, File Name, and Application. All data can be categorized into one of these:
  • File System Category: The data in this category describe the layout and general features of the file system. For example, how big each data unit is and how many data units there are.
  • Data Unit Category: This category contains the data units (i.e. blocks and clusters) in the file system that can store file content. Data units are a fixed size and most file systems require it to be a power of 2, 1024- or 4096-bytes for example.
  • Metadata Category: This is where the descriptive data about files and directories are stored. This layer includes the inode structures in UNIX, MFT entries in NTFS, and directory entry structures in FAT. This layer contains information such as last access times, permissions, and pointers to the data units that were allocated by the file or directory. The data in this category completely describes a file, but it is typically given a numeric address that is difficult to remember.
  • File Name Category: This is where the actual name of the file or directory is saved. In general, this is a different structure than the metadata structure. The exception to this is the FAT file system. File names are typically stored in data structures in the parent directory. The data structures contain a pointer to the metadata structure, which contains the rest of the file information.
  • Application Category: This is where a bunch of non-essential file system data exists. These are features that make life easier for the file system and operating system. Examples include journals that record file system updates and lists that record what files have recently been updated.
A basic ASCII diagram is shown here of the different categories. The file system category identifies the locations of the file name, metadata, data units, and application categories. The file names then point to the metadata, and the metadata points to the data units.
                     +-------------------------+
                     |       File System       |
                     +-------------------------+
                       /          |           \        +------------------+
                      /           |            \       |   Application    |
                     /            |             \      +------------------+
                    /             |              \
        +------------+      +-----------+      +-------------+
        | File Names | ---> | Metadata  | ---> | Data Units  |
        +------------+      +-----------+      +-------------+
The command line tools and the file system APIs are organized based on these layers. Data at each layer can be directly accessed and some functions combine layers. \subsection fs_del Deleted Files When a file is deleted, its data units, metadata structure, and file name structure are typically marked as being free and they can be reused when a new file is created. It is very easy for them to be reallocated at different times and therefore care must be taken when interpreting the data associated with deleted files. When you encounter an unallocated file name, check the allocation status of the metadata structure it points to. If the metadata structure is allocated, then either the metadata structure was reallocated to a new file or the the unallocated file name was created when a file was moved and the unallocated name is the old file name. In general, there is no way to differentiate between these two scenarios (the exception is in NTFS, which includes sequence numbers that increment each time the metadata structure is reallocated). One test that can be applied in this situation is to compare the type (i.e. file or directory) as reported in the file name structure versus the type as reported in the metadata structure. If one is a directory and one is a file, then the metadata structure was reallocated. You could also compare the file name extension with the file type (i.e. HTML, doc, JPEG). When you encounter an unallocated metadata entry, there may no longer be a file name structure that points to it. These are called orphan files. You will still be able to access them via their metadata address, but the their full path will be unknown. TSK makes a special directory to store the orphan files in so that they can be easily accessed. \section fs_open Opening the File System Typically, a file system exists in a \ref vspage "volume", but it can also exist on its own on a disk (such as a USB drive, CD-ROM, or floppy disk). You may also have an image file that is of only one partition (i.e. a logical image). Because of these different scenarios, TSK has two functions to open a file system. The tsk_fs_open_img() function allows you to open a file system using only a TSK_IMG_INFO structure and an offset. The offset indicates the location where the file system starts in the image. As a convenience, there is also the tsk_fs_open_vol() function that takes a TSK_VS_PART_INFO structure as an argument and determines the offset based on the volume information. Both of these functions return a TSK_FS_INFO structure that is used as a handle for more detailed file system analysis. Close the file system with the tsk_fs_close() function. The TSK_FS_INFO structure contains data regarding the number of data units, the number of metadata structures, etc. \subsection fs_types File System Types The functions that open the file system can detect the file system type, but sometimes you may need to specify it (if for example TSK detects multiple file system structures). Internally, TSK uses a numerical ID (TSK_FS_TYPE_ENUM) for each file system type, which is stored in TSK_FS_INFO::ftype. If you have an TSK_FS_INFO structure and want to know what file system type it is for, you can pass the TSK_FS_INFO::ftype value to one of the TSK_FS_TYPE_ISXXX macros, such as TSK_FS_TYPE_ISNTFS(). \code if (TSK_FS_TYPE_ISNTFS(fs_info->ftype)) { .... } \endcode To map from the numerical ID to a short name (such as "ntfs"), the tsk_fs_type_toname() function can be used. You can also map from the short name to the ID using the tsk_fs_type_toid() function. To determine the IDs of the supported file systems, the tsk_fs_type_supported() function can be used. The names and descriptions of the supported types can be printed to an open FILE handle using the tsk_fs_type_print() function. \subsection fs_read Reading General File System Data As you will see, there are many ways to access file system data from the different categories. One of the most generic methods is using the tsk_fs_read() function. It simply takes a byte offset relative to the start of the file system and a buffer to read the data into. It does not care about block addresses or files. In the following sections, there are smarter versions of this function that will take block addresses as an argument, instead of a byte offset. \section fs_block_open Opening and Reading File System Blocks TSK allows you to read the contents of any block in the file system. The size of each data unit is defined in the TSK_FS_INFO::block_size field and the number of data units (as defined by the file system) is defined in the TSK_FS_INFO::block_count field. The address of the first block is defined in TSK_FS_INFO::first_block and the last block address (as defined by the file system structures) is defined in TSK_FS_INFO::last_block. In some cases, the image may not be complete and the last block that can be read is less than TSK_FS_INFO::last_block. In that case, TSK_FS_INFO::last_block_act contains the actual last block in the image. When last_block_act is less than last_block, it means that the image is not complete. You can obtain the contents of a specific block by calling the tsk_fs_block_get() function. It returns a TSK_FS_BLOCK structure with the contents of the data unit and flags about its allocation status. You must free the TSK_FS_BLOCK structure by calling tsk_fs_block_free(). You can also walk the data units by calling tsk_fs_block_walk(). This function will call a callback function on data units that meet a certain criteria. Walking is useful if, for example, you want to focus on only allocated or unallocated data units. You can also read the contents of a data unit using the tsk_fs_read_block() function, which reads a block of data (given its data unit address) into a buffer. tsk_fs_read_block() does not provide the data unit's allocation status and is therefore more efficient than tsk_fs_block_get() if you want only the content. One FAT file system specific thing should be mentioned here. FAT stores its file content in clusters, but the first cluster does not start at the beginning of the file system. There is typically many megabytes of data (FAT tables) before it. If TSK were to use clusters as the standard data unit, it would have no way of addressing the sectors prior to the first cluster and a confusing addressing scheme would need to exist so that all data could be accessed. For simplicity, TSK uses sector addresses everywhere with FAT file systems. All data unit addresses used by the TSK API are in 512-byte sectors (and TSK_FS_INFO::block_size is 512 and not the original cluster size). \section fs_file Opening and Reading Files \subsection fs_file_open Opening a File With TSK, you can open a file from either the metadata or file name layer. To open at the metadata layer, you need the metadata address of the file. To open at the file name layer, you need the name of the file. Regardless of the method used to open a file, a TSK_FS_FILE structure will be returned. This structure can point to TSK_FS_NAME and TSK_FS_META structures, which store the file and metadata category data. The tsk_fs_file_open_meta() function takes a metadata address as an argument and returns a TSK_FS_FILE structure. The TSK_FS_FILE::name pointer will be NULL because the file name was not used to open the file and, for efficiency, TSK does not search the directory tree to locate the file name that points to the metadata address. The first and last metadata addresses in the file system are defined in TSK_FS_INFO::first_inum and TSK_FS_INFO::last_inum. The tsk_fs_file_open() function takes a file name as an argument and first identifies the metadata address that the file name points to. It then calls tsk_fs_file_open_meta(). Note that if you know the metadata address of a file, then using tsk_fs_file_open_meta() is more efficient then tsk_fs_file_open() because you can skip the process of mapping the file name to the metadata address. If you use tsk_fs_file_open() then the TSK_FS_FILE::name structure will be populated with the name details. The TSK_FS_FILE structure can be used to read file content and its fields can be used for processing. The structure must be closed with tsk_fs_file_close(). \subsection Reading File Content There are two basic approaches to reading file content after you have a TSK_FS_FILE structure. You can read data into a buffer from a specific offset in a file using tsk_fs_file_read(). You can also use the tsk_fs_file_walk() function, which takes a callback function as an argument and will call the callback with the contents of each data unit in the file. Note that there are several ways of storing file content. For example, NTFS can store the content in a compressed form and can store small amounts of data in buffers inside of the metadata structure (instead of allocating a full data unit). The callback for tsk_fs_file_walk() will be given the address from where the data came from, but it will be 0 and not be relevant if the TSK_FS_BLOCK_FLAG_ENUM flag is for a sparse, compressed, or non-resident file. \subsection fs_file_attrs Attributes TSK allows each file to have multiple attributes. An attribute is simply a data container. Files in most file systems will have only one attribute, which stores the file content. NTFS files will have multiple attributes because NTFS stores the file name, dates, and other information in different attributes. TSK stores UFS and ExtX indirect blocks in separate attribute. TSK allows you to read from all of the attributes. Each attribute has a type and an ID. The types are defined in the TSK_FS_ATTR_TYPE_ENUM structure and the ID is an integer that is unique to the file. A file can have multiple attributes with the same type, but it can have only one attribute with a given id. The TSK APIs that have been previously presented will use the default attribute. Many of the APIs have a variation that will allow you to specify a specific attribute type and ID. For example, tsk_fs_file_read_type() has the same basic operation as tsk_fs_file_read() except it allows the caller to specify the type and ID. There is also the tsk_fs_file_walk_type() function that is the more specific version of tsk_fs_file_walk() function. \subsection fs_file_attr_read Accessing Attributes The previous section outlined that some API functions allow you to access a specific attribute. Sometimes though, you may want access to the attribute, which is stored in a TSK_FS_ATTR structure. To access the default attribute use tsk_fs_file_attr_get(). If you know the type that you want to access, you can use the tsk_fs_file_attr_get_type() function. If you want to figure out what types exist or want to cycle through all of the attributes, you can use the tsk_fs_file_attr_getsize() function to get the number of attributes and the tsk_fs_file_attr_get_idx() function to get an attribute based on a 0 to n-1 based index. For example: \code int i, cnt; cnt = tsk_fs_file_attr_getsize(fs_file); for (i = 0; i < cnt; i++) { const TSK_FS_ATTR *fs_attr; fs_attr = tsk_fs_file_attr_get_idx(fs_file, i); if (!fs_attr) continue; ... } \endcode Once you have a TSK_FS_ATTR structure, you can read from it using the tsk_fs_attr_read() and tsk_fs_attr_walk() functions. These operate just like the tsk_fs_file_read() and tsk_fs_file_walk() functions and in fact the file-based functions simply load the relevant attribute and call the corresponding attribute-based function. \subsection fs_file_runs Data Runs This section provides some details on how the file content is stored in TSK. If you use the APIs previously described, you will not need to read this section. It is more of an FYI. TSK stores locations where file content is stored in run lists. A run is a set of consecutive blocks that a file has allocated. The run is stored based on the starting block and the length of the run. The run lists for the file attributes are stored in TSK_FS_META::attr, but note that the data may not be filled in until it is needed by TSK. For efficiency, TSK only loads this data as needed (for some file systems). The TSK_FS_META::attr_state field identifies if it has been loaded yet or not. \section fs_dir_open Opening and Reading a Directory The previous section outlined how to open a file when you know its name or address. In many cases, you will want to browse the files in a directory and see what files can be opened. There two methods for browsing the file names. The first is that a directory can be opened using tsk_fs_dir_open() or tsk_fs_dir_open_meta(). The difference between these two functions is that tsk_fs_dir_open() uses the directory name and tsk_fs_dir_open_meta() uses the directory metadata address. Like opening a file, the tsk_fs_dir_open_meta() is more efficient if you already know the metadata address because tsk_fs_dir_open() will first search the directory structure for the the metadata address and then call tsk_fs_dir_open_meta(). These return a TSK_FS_DIR structure that allows the caller to then access individual file names in the directory. The number of entries in the directory can be obtained using the tsk_fs_dir_getsize() function and individual entries can be returned with the tsk_fs_dir_get() function. You can close the open directory using tsk_fs_dir_close(). If you are recursing into directories, you could get into an infinite loop. You can use the TSK_STACK structure to prevent this, see \ref basic_misc. You can also walk the directory tree using tsk_fs_dir_walk(). This will call the callback for every file or subdirectory in a directory and can recurse into directories if the proper flag is given. To walk the entire directory structure, start the walk at the root directory (TSK_FS_INFO::root_inum) and set the recurse flag. These approaches all return a TSK_FS_FILE structure and these will all have the TSK_FS_FILE::name structure defined. However, some of the files may not have the TSK_FS_FILE::meta structure defined if the file is deleted and the link to the metadata has been lost. Another way to browse the files is using the tsk_fs_meta_walk() function, which will process a range of metadata structures and call a callback function on each one. The callback gets the corresponding TSK_FS_FILE structure with the file's metadata in TSK_FS_FILE::meta and TSK_FS_FILE::name set to NULL. \subsection fs_dir_spec Virtual Files When browsing the file system, using the directory structure is most convenient and therefore special files and directories were added to make finding all relevant data easier. Orphan files, which were discussed in \ref fs_del, can be accessed from the /$OrphanFiles directory. This is a virtual directory, but TSK allows you to treat it as a normal directory (its flags in TSK_FS_META::flags will show that it is virtual though). TSK also provides special files so that you can access the boot sector and FATs in a FAT file system. The $MBR, $FAT1, and $FAT2 files are virtual files that point to the sectors for the boot sector, primary FAT, and backup FAT. You can use these virtual files to read the contents of those structures. \section fs_map Mapping Data In some cases, you may want to identify which file has allocated a given block or which name points to a meta data structure. This can typically be done by using the tsk_fs_meta_walk() or tsk_fs_dir_walk() functions, respectively. But, there are some convenience functions to make this easier. The tsk_fs_path2inum() function takes a UTF-8 path as an argument and will identify the meta data address that it points to. Next to \ref hashdbpage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/hashdb.dox000644 000765 000024 00000004620 11643647437 020127 0ustar00carrierstaff000000 000000 /*! \page hashdbpage Hash Databases This section describes some the API functions and concepts associated with the Hash Database library. \section hash_over Overview Hash databases are frequently used to identify known good and known bad files. Text files of MD5 and SHA-1 hashes can be easily created and shared, but they are frequently not the most efficient to use to use when searching for a hash because they are in an unsorted order. The hash database functions in TSK create an index into text file hash databases and allow you to more quickly perform lookups. TSK uses the index to perform binary searches for the hashes (see Informer #6). \section hash_open Opening a Hash Database Before a database can be indexed or searched, it must first be opened. Use the tsk_hdb_open() function to open the database. There is a flag that can be specified to open only the index. This allows you to save storage space by keeping only the index around, but it means that you will not have access to other metadata that is stored in the database. The tsk_hdb_open() function will return a TSK_HDB_INFO structure that will be used as a handle to index and search the database. An open hash database can be closed with tsk_hdb_close(). \section hash_index Indexing a Hash Database A single database can have more than one index if the database contains multiple hash types. For example, both MD5 and SHA-1 indexes can be made for the NSRL database. Because multiple indexes can exist, you must specify the type when making or testing for an index. You can test if an open hash database has an index by using the tsk_hdb_hasindex(). If you need to create one, use the tsk_hdb_makeindex() function. This process may take several minutes (or longer). \section hash_search Searching a Hash Database An indexed database can be searched using either tsk_hdb_lookup_raw() or tsk_hdb_lookup_str(). The only difference is that tsk_hdb_lookup_raw() takes the hash value as a byte array and tsk_hdb_lookup_str() takes the hash value as a string. Both functions can call a callback with details of entries that are found, or the QUICK flag can be given in which case the callback is not called and instead the return value of the function identifies if the hash is in the database or not. Next to \ref autopage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/img.dox000644 000765 000024 00000005516 11643647437 017457 0ustar00carrierstaff000000 000000 /*! \page imgpage Disk Images This section describes the general disk image analysis concepts and corresponding APIs in TSK. In addition to this documentation, there are sample programs in the samples directory in TSK that show these functions being used while processing a disk image. \section img_open Opening the Disk Image Before the volume and file system structures can be analyzed, the disk image must be opened. The tsk_img_open() function is used to open one or more disk image files. The file format can be specified or auto-detection methods will be used. If the specific type cannot be determined, then the raw type will be assumed. Note that by default, TSK supports only single and split raw images. Other file formats, such as AFF and EWF, are supported only if the corresponding libraries existed and were configured when TSK was built and installed. If you are opening only a single disk image file (i.e. it is not split), then you can use the tsk_img_open_sing() function. It takes fewer arguments. The tsk_img_open() function returns a TSK_IMG_INFO structure. This structure has fields that contain the type and size (uncompressed, if applicable) of the disk image. When you are done analyzing the disk image, it can be closed with tsk_img_close(). Note that the tsk_img_open() and tsk_img_open_sing() functions use the TSK_TCHAR type to store the disk image paths. This type is system dependent and is a wchar_t on Windows and char on other sytems. See \ref basic_enc_t for more details. If you are in an environment where you will have UTF-8 text even in Windows, then you can use the tsk_img_open_utf8() and tsk_img_open_utf8_sing() functions. \section img_types File Format Types There are several functions that can be used to map between names and IDs of file format types. Internally, the TSK functions use a numerical ID for each type. The tsk_img_type_toname() function maps the ID to a single word name (such as "raw") and the tsk_img_type_todesc() function maps an ID to a longer description (such as "Single raw file"). The short name is used in the TSK command line tools when the user specifies a type and the tsk_img_type_toid() function maps the short name to an ID. There are also functions that identify which file formats are supported by the installation. The tsk_img_type_supported() function returns the IDs of the supported types. The tsk_img_type_print() prints the supported type names and descriptions to a handle. This function is used by the command line tools to print the supported types to the console. \section img_read Reading Data To read data from the disk image, the tsk_img_read() function is used. This function can read an arbitrary amount of data from an arbitrary byte offset. Next to \ref vspage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/docs/main.dox000644 000765 000024 00000003047 11643647437 017624 0ustar00carrierstaff000000 000000 /*! \mainpage The Sleuth Kit (TSK) Library User's Guide and API Reference \author Brian Carrier

Overview

This document was designed to help integrate the Sleuth Kit (TSK) library into an application that needs to analyze data from a disk image. Note that this document does not contain information about using the command line tools in TSK. The command line tools use the functionality of this library, but this document is for programmers who want to use the library. There are two main sections to this document. One is the User's Guide that describes the organization of TSK, the APIs, and how to use them together. The other is a list of the API functions and a description of their arguments and return values.

User's Guide

\anchor users_guide The User's Guide describes the various components of TSK and how to use them. It refers to specific functions and data structures with links to the details in the API Reference. - \subpage basicpage - \subpage basepage - \subpage imgpage - \subpage vspage - \subpage fspage - \subpage hashdbpage - \subpage autopage

API Reference

The API Reference lists the public API functions and the arguments and return values. The Users's Guide should be read first so that the interaction and use of the functions are understood. These pages can also be found in the Modules section. - \ref baselib - \ref imglib - \ref vslib - \ref fslib - \ref hashdblib - \ref autolib */ sleuthkit-3.2.3/tsk3/docs/vs.dox000644 000765 000024 00000011217 11643647437 017326 0ustar00carrierstaff000000 000000 /*! \page vspage Volume Systems This section describes the general volume system analysis concepts and corresponding APIs in TSK. In addition to this documentation, there are sample programs in the samples directory in TSK that show these functions being used while processing a disk image. \section vs_open Opening the Volume System Once the disk image has been opened, you can start to analyze it. If you have a physical disk image then you will need to check if a volume system exists. Volume systems organize contiguous sectors on a disk into volumes. Use TSK to determine the type of volume system that a disk is using and to determine the volume layout. Note that some USB storage devices and floppy disks do not have volume systems. The first step is to open the volume system using the tsk_vs_open() function. This function takes an offset as a argument. TSK uses this offset to start looking for volume systems. In general, an offset of 0 should be used. This function returns a TSK_VS_INFO structure that has values for the volume system type and number of volumes (also called partitions). The volume system is closed with the tsk_vs_close() function. \section vs_types Volume System Types tsk_vs_open() can detect the type of the volume system, but sometimes you may need to specify it (if for example TSK detects multiple volume system structures) or you may want to print the name of the volume system type. Internally, TSK uses a numerical ID for each volume system type. To map from the numerical ID to a short name (such as "dos"), the tsk_vs_type_toname() function can be used. To map the ID to a longer description (such as "DOS Partition Table"), use the tsk_vs_type_todesc() function. You can also map from the short name to the ID using the tsk_vs_type_toid() function. To determine the IDs of the supported volume systems, the tsk_vs_type_supported() function can be used. The names and descriptions of the supported types can be printed to an open FILE handle using the tsk_vs_type_print() function. \section vs_open2 Accessing Individual Volumes The TSK_VS_INFO structure that tsk_vs_open() returns is for all volumes in the volume system. Each volume will be assigned an address, starting with 0. There are two general ways for accessing the individual volumes. The tsk_vs_part_get() returns information about a specific volume while the tsk_vs_part_walk() function goes through a specified range of volumes and calls a callback function with data about each volume. Regardless of the method used, a TSK_VS_PART_INFO structure is used to describe each volume. This structure has fields for the volume starting offset (relative to the start of the disk image), length, and type. TSK defines several volume types. \b Allocated volumes are those that are defined by the volume system. An allocated volume has an entry in a partition table in the volume system. \b Unallocated volumes contain the sectors that are not allocated to a volume in the volume system. For example, if one volume has sectors 0 to 9 and another has sectors 50 to 99 then TSK would create an unallocated volume for sectors 10 to 49. Note that these volumes are virtually created by TSK and they are not defined in the volume system. Allocated and unallocated volumes will cover the entire disk image. The third type of volume is a metadata volume. \b Metadata volumes contain sectors that store volume system data, such as a partition table. With some volume systems, the metadata volumes will overlap allocated volumes (because those volume systems "allocate" space for the metadata structures). In other volume systems, the metadata volumes will overlap unallocated volumes (because those volume systems store metadata in unused space). In general, you will want to analyze the data in allocated volumes as a file system and analyze the data in unallocated volumes using file carving or other data recovery techniques. In many cases, you can ignore the metadata volumes. If you are using the tsk_vs_part_walk() function then you can specify what types of partitions that you would like returned via the callback. \section vs_read Reading Data There are three ways to read data from a volume system. The tsk_vs_read_block() function reads sectors using a sector address relative to the start of the volume system. However, to read sectors using an address that is relative to the start of a specific volume, use the tsk_vs_part_read_block() function. To read data in a volume in non-sector sized chunks, use the tsk_vs_part_read() function. Next to \ref fspage Back to \ref users_guide "Table of Contents" */ sleuthkit-3.2.3/tsk3/base/.indent.pro000644 000765 000024 00000000036 11643647437 020222 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nlp -nut sleuthkit-3.2.3/tsk3/base/Makefile.am000644 000765 000024 00000000514 11643647437 020176 0ustar00carrierstaff000000 000000 AM_CFLAGS = -I../.. -Wall noinst_LTLIBRARIES = libtskbase.la libtskbase_la_SOURCES = md5c.c mymalloc.c sha1c.c \ tsk_endian.c tsk_error.c tsk_list.c tsk_parse.c tsk_printf.c \ tsk_unicode.c tsk_version.c tsk_stack.c XGetopt.c tsk_base_i.h EXTRA_DIST = .indent.pro indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ sleuthkit-3.2.3/tsk3/base/Makefile.in000644 000765 000024 00000034210 11643647517 020206 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/base DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskbase_la_LIBADD = am_libtskbase_la_OBJECTS = md5c.lo mymalloc.lo sha1c.lo tsk_endian.lo \ tsk_error.lo tsk_list.lo tsk_parse.lo tsk_printf.lo \ tsk_unicode.lo tsk_version.lo tsk_stack.lo XGetopt.lo libtskbase_la_OBJECTS = $(am_libtskbase_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskbase_la_SOURCES) DIST_SOURCES = $(libtskbase_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -I../.. -Wall noinst_LTLIBRARIES = libtskbase.la libtskbase_la_SOURCES = md5c.c mymalloc.c sha1c.c \ tsk_endian.c tsk_error.c tsk_list.c tsk_parse.c tsk_printf.c \ tsk_unicode.c tsk_version.c tsk_stack.c XGetopt.c tsk_base_i.h EXTRA_DIST = .indent.pro all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/base/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/base/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskbase.la: $(libtskbase_la_OBJECTS) $(libtskbase_la_DEPENDENCIES) $(LINK) $(libtskbase_la_OBJECTS) $(libtskbase_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XGetopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5c.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mymalloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1c.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_endian.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_parse.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_printf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_stack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_unicode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsk_version.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.c *.h clean-local: -rm -f *.c~ *.h~ # 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: sleuthkit-3.2.3/tsk3/base/md5c.c000644 000765 000024 00000025466 11643647437 017153 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * */ /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ /** \file md5c.c * Local copy of RSA Data Security, Inc. MD5 Message-Digest Algorithm. */ #include "tsk_base_i.h" /* Constants for MD5Transform routine. */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 static void MD5Transform(UINT4[4], unsigned char[64]); static void Encode(unsigned char *, UINT4 *, unsigned int); static void Decode(UINT4 *, unsigned char *, unsigned int); static void MD5_memcpy(POINTER, POINTER, unsigned int); static void MD5_memset(POINTER, int, unsigned int); static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* F, G, H and I are basic MD5 functions. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } /** * \ingroup baselib * Initialize a MD5 context structure so that data can be added to it. * @param context Pointer to context to initialize */ void TSK_MD5_Init(TSK_MD5_CTX * context) { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } /** * \ingroup baselib * Add data to an initialized MD5 operation. * @param context Initialized context to add data to * @param input Buffer of data to process * @param inputLen Number of bytes in input */ void TSK_MD5_Update(TSK_MD5_CTX * context, unsigned char *input, unsigned int inputLen) { unsigned int i, index, partLen; /* Compute number of bytes mod 64 */ index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ if ((context->count[0] += ((UINT4) inputLen << 3)) < ((UINT4) inputLen << 3)) context->count[1]++; context->count[1] += ((UINT4) inputLen >> 29); partLen = 64 - index; /* Transform as many times as possible. */ if (inputLen >= partLen) { MD5_memcpy ((POINTER) & context->buffer[index], (POINTER) input, partLen); MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) MD5Transform(context->state, &input[i]); index = 0; } else i = 0; /* Buffer remaining input */ MD5_memcpy ((POINTER) & context->buffer[index], (POINTER) & input[i], inputLen - i); } /** * \ingroup baselib * Cacluate the MD5 hash of the data added to this context. Context * will be zeroed after this call. * @param digest Buffer to store MD5 value in. * @param context Context that has data added to it. */ void TSK_MD5_Final(unsigned char digest[16], TSK_MD5_CTX * context) { unsigned char bits[8]; unsigned int index, padLen; /* Save number of bits */ Encode(bits, context->count, 8); /* Pad out to 56 mod 64. */ index = (unsigned int) ((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); TSK_MD5_Update(context, PADDING, padLen); /* Append length (before padding) */ TSK_MD5_Update(context, bits, 8); /* Store state in digest */ Encode(digest, context->state, 16); /* Zeroize sensitive information. */ MD5_memset((POINTER) context, 0, sizeof(*context)); } /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform(state, block) UINT4 state[4]; unsigned char block[64]; { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode(x, block, 64); /* Round 1 */ FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; /* Zeroize sensitive information. */ MD5_memset((POINTER) x, 0, sizeof(x)); } /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode(output, input, len) unsigned char *output; UINT4 *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (unsigned char) (input[i] & 0xff); output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff); output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff); output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff); } } /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ static void Decode(output, input, len) UINT4 *output; unsigned char *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24); } /* Note: Replace "for loop" with standard memcpy if possible. */ static void MD5_memcpy(output, input, len) POINTER output; POINTER input; unsigned int len; { unsigned int i; for (i = 0; i < len; i++) output[i] = input[i]; } /* Note: Replace "for loop" with standard memset if possible. */ static void MD5_memset(output, value, len) POINTER output; int value; unsigned int len; { unsigned int i; for (i = 0; i < len; i++) ((char *) output)[i] = (char) value; } sleuthkit-3.2.3/tsk3/base/mymalloc.c000644 000765 000024 00000004214 11643647437 020124 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier, Basis Technology. All rights reserved. */ /** \file mymalloc.c * These functions allocate and realocate memory and set the error handling functions * when an error occurs. */ /*++ * NAME * tsk_malloc 3 * SUMMARY * memory management wrappers * SYNOPSIS * #include * * char *tsk_malloc(len) * int len; * * char *tsk_realloc(ptr, len) * char *ptr; * int len; * * char *mystrdup(str) *const char *str; *DESCRIPTION * This module performs low-level memory management with error * handling. A call of these functions either succeeds or it does * not return at all. * * tsk_malloc() allocates the requested amount of memory. The memory * is not set to zero. * * tsk_realloc() resizes memory obtained from tsk_malloc() or tsk_realloc() * to the requested size. The result pointer value may differ from * that given via the \fBptr\fR argument. * * mystrdup() returns a dynamic-memory copy of its null-terminated * argument. This routine uses tsk_malloc(). * SEE ALSO * error(3) error reporting module. * DIAGNOSTICS * Fatal errors: the requested amount of memory is not available. * LICENSE * .ad * .fi * The IBM Public Licence must be distributed with this software. * AUTHOR(S) * Wietse Venema * IBM T.J. Watson Research * P.O. Box 704 * Yorktown Heights, NY 10598, USA *--*/ #include "tsk_base_i.h" #include /* tsk_malloc - allocate and zero memory and set error values on error */ void * tsk_malloc(size_t len) { void *ptr; if ((ptr = malloc(len)) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_AUX_MALLOC; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_malloc: %s", strerror(errno)); } else { memset(ptr, 0, len); } return (ptr); } /* tsk_realloc - reallocate memory and set error values if needed */ void * tsk_realloc(void *ptr, size_t len) { if ((ptr = realloc(ptr, len)) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_AUX_MALLOC; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_realloc: %s", strerror(errno)); } return (ptr); } sleuthkit-3.2.3/tsk3/base/sha1c.c000644 000765 000024 00000033716 11643647437 017317 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * */ /* sha1c.c : Implementation of the Secure Hash Algorithm */ /* SHA: NIST's Secure Hash Algorithm */ /* This version written November 2000 by David Ireland of DI Management Services Pty Limited Adapted from code in the Python Cryptography Toolkit, version 1.0.0 by A.M. Kuchling 1995. */ /* AM Kuchling's posting:- Based on SHA code originally posted to sci.crypt by Peter Gutmann in message <30ajo5$oe8@ccu2.auckland.ac.nz>. Modified to test for endianness on creation of SHA objects by AMK. Also, the original specification of SHA was found to have a weakness by NSA/NIST. This code implements the fixed version of SHA. */ /* Here's the first paragraph of Peter Gutmann's posting: The following is my SHA (FIPS 180) code updated to allow use of the "fixed" SHA, thanks to Jim Gillogly and an anonymous contributor for the information on what's changed in the new version. The fix is a simple change which involves adding a single rotate in the initial expansion function. It is unknown whether this is an optimal solution to the problem which was discovered in the SHA or whether it's simply a bandaid which fixes the problem with a minimum of effort (for example the reengineering of a great many Capstone chips). */ /** \file sha1c.c * Local copy of the public domain SHA-1 library code by David Ireland. */ #include "tsk_base_i.h" /* The SHS block size and message digest sizes, in bytes */ #define SHS_DATASIZE 64 #define SHS_DIGESTSIZE 20 /* The SHS f()-functions. The f1 and f3 functions can be optimized to save one boolean operation each - thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering this */ /*#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) // Rounds 0-19 */ #define f1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) /* Rounds 0-19 */ #define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */ /*#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) // Rounds 40-59 */ #define f3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) /* Rounds 40-59 */ #define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */ /* The SHS Mysterious Constants */ #define K1 0x5A827999UL /* Rounds 0-19 */ #define K2 0x6ED9EBA1UL /* Rounds 20-39 */ #define K3 0x8F1BBCDCUL /* Rounds 40-59 */ #define K4 0xCA62C1D6UL /* Rounds 60-79 */ /* SHS initial values */ #define h0init 0x67452301UL #define h1init 0xEFCDAB89UL #define h2init 0x98BADCFEUL #define h3init 0x10325476UL #define h4init 0xC3D2E1F0UL /* Note that it may be necessary to add parentheses to these macros if they are to be called with expressions as arguments */ /* 32-bit rotate left - kludged with shifts */ #define ROTL(n,X) ( ( ( X ) << n ) | ( ( X ) >> ( 32 - n ) ) ) /* The initial expanding function. The hash function is defined over an 80-UINT2 expanded input array W, where the first 16 are copies of the input data, and the remaining 64 are defined by W[ i ] = W[ i - 16 ] ^ W[ i - 14 ] ^ W[ i - 8 ] ^ W[ i - 3 ] This implementation generates these values on the fly in a circular buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this optimization. The updated SHS changes the expanding function by adding a rotate of 1 bit. Thanks to Jim Gillogly, jim@rand.org, and an anonymous contributor for this information */ #define expand(W,i) ( W[ i & 15 ] = ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \ W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) ) /* The prototype SHS sub-round. The fundamental sub-round is: a' = e + ROTL( 5, a ) + f( b, c, d ) + k + data; b' = a; c' = ROTL( 30, b ); d' = c; e' = d; but this is implemented by unrolling the loop 5 times and renaming the variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration. This code is then replicated 20 times for each of the 4 functions, using the next 20 values from the W[] array each time */ #define subRound(a, b, c, d, e, f, k, data) \ ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) ) /* endian.c */ static void endianTest(int *endian_ness) { if ((*(unsigned short *) ("#S") >> 8) == '#') { /* printf("Big endian = no change\n"); */ *endian_ness = !(0); } else { /* printf("Little endian = swap\n"); */ *endian_ness = 0; } } /** * \ingroup baselib * Initialize a SHA-1 context so that data can be added to it. * @param shsInfo Pointer to context structure to initialize */ void TSK_SHA_Init(TSK_SHA_CTX * shsInfo) { endianTest(&shsInfo->Endianness); /* Set the h-vars to their initial values */ shsInfo->digest[0] = h0init; shsInfo->digest[1] = h1init; shsInfo->digest[2] = h2init; shsInfo->digest[3] = h3init; shsInfo->digest[4] = h4init; /* Initialise bit count */ shsInfo->countLo = shsInfo->countHi = 0; } /* Perform the SHS transformation. Note that this code, like MD5, seems to break some optimizing compilers due to the complexity of the expressions and the size of the basic block. It may be necessary to split it into sections, e.g. based on the four subrounds Note that this corrupts the shsInfo->data area */ static void SHSTransform(digest, data) UINT4 *digest, *data; { UINT4 A, B, C, D, E; /* Local vars */ UINT4 eData[16]; /* Expanded data */ /* Set up first buffer and local data buffer */ A = digest[0]; B = digest[1]; C = digest[2]; D = digest[3]; E = digest[4]; memcpy((POINTER) eData, (POINTER) data, SHS_DATASIZE); /* Heavy mangling, in 4 sub-rounds of 20 interations each. */ subRound(A, B, C, D, E, f1, K1, eData[0]); subRound(E, A, B, C, D, f1, K1, eData[1]); subRound(D, E, A, B, C, f1, K1, eData[2]); subRound(C, D, E, A, B, f1, K1, eData[3]); subRound(B, C, D, E, A, f1, K1, eData[4]); subRound(A, B, C, D, E, f1, K1, eData[5]); subRound(E, A, B, C, D, f1, K1, eData[6]); subRound(D, E, A, B, C, f1, K1, eData[7]); subRound(C, D, E, A, B, f1, K1, eData[8]); subRound(B, C, D, E, A, f1, K1, eData[9]); subRound(A, B, C, D, E, f1, K1, eData[10]); subRound(E, A, B, C, D, f1, K1, eData[11]); subRound(D, E, A, B, C, f1, K1, eData[12]); subRound(C, D, E, A, B, f1, K1, eData[13]); subRound(B, C, D, E, A, f1, K1, eData[14]); subRound(A, B, C, D, E, f1, K1, eData[15]); subRound(E, A, B, C, D, f1, K1, expand(eData, 16)); subRound(D, E, A, B, C, f1, K1, expand(eData, 17)); subRound(C, D, E, A, B, f1, K1, expand(eData, 18)); subRound(B, C, D, E, A, f1, K1, expand(eData, 19)); subRound(A, B, C, D, E, f2, K2, expand(eData, 20)); subRound(E, A, B, C, D, f2, K2, expand(eData, 21)); subRound(D, E, A, B, C, f2, K2, expand(eData, 22)); subRound(C, D, E, A, B, f2, K2, expand(eData, 23)); subRound(B, C, D, E, A, f2, K2, expand(eData, 24)); subRound(A, B, C, D, E, f2, K2, expand(eData, 25)); subRound(E, A, B, C, D, f2, K2, expand(eData, 26)); subRound(D, E, A, B, C, f2, K2, expand(eData, 27)); subRound(C, D, E, A, B, f2, K2, expand(eData, 28)); subRound(B, C, D, E, A, f2, K2, expand(eData, 29)); subRound(A, B, C, D, E, f2, K2, expand(eData, 30)); subRound(E, A, B, C, D, f2, K2, expand(eData, 31)); subRound(D, E, A, B, C, f2, K2, expand(eData, 32)); subRound(C, D, E, A, B, f2, K2, expand(eData, 33)); subRound(B, C, D, E, A, f2, K2, expand(eData, 34)); subRound(A, B, C, D, E, f2, K2, expand(eData, 35)); subRound(E, A, B, C, D, f2, K2, expand(eData, 36)); subRound(D, E, A, B, C, f2, K2, expand(eData, 37)); subRound(C, D, E, A, B, f2, K2, expand(eData, 38)); subRound(B, C, D, E, A, f2, K2, expand(eData, 39)); subRound(A, B, C, D, E, f3, K3, expand(eData, 40)); subRound(E, A, B, C, D, f3, K3, expand(eData, 41)); subRound(D, E, A, B, C, f3, K3, expand(eData, 42)); subRound(C, D, E, A, B, f3, K3, expand(eData, 43)); subRound(B, C, D, E, A, f3, K3, expand(eData, 44)); subRound(A, B, C, D, E, f3, K3, expand(eData, 45)); subRound(E, A, B, C, D, f3, K3, expand(eData, 46)); subRound(D, E, A, B, C, f3, K3, expand(eData, 47)); subRound(C, D, E, A, B, f3, K3, expand(eData, 48)); subRound(B, C, D, E, A, f3, K3, expand(eData, 49)); subRound(A, B, C, D, E, f3, K3, expand(eData, 50)); subRound(E, A, B, C, D, f3, K3, expand(eData, 51)); subRound(D, E, A, B, C, f3, K3, expand(eData, 52)); subRound(C, D, E, A, B, f3, K3, expand(eData, 53)); subRound(B, C, D, E, A, f3, K3, expand(eData, 54)); subRound(A, B, C, D, E, f3, K3, expand(eData, 55)); subRound(E, A, B, C, D, f3, K3, expand(eData, 56)); subRound(D, E, A, B, C, f3, K3, expand(eData, 57)); subRound(C, D, E, A, B, f3, K3, expand(eData, 58)); subRound(B, C, D, E, A, f3, K3, expand(eData, 59)); subRound(A, B, C, D, E, f4, K4, expand(eData, 60)); subRound(E, A, B, C, D, f4, K4, expand(eData, 61)); subRound(D, E, A, B, C, f4, K4, expand(eData, 62)); subRound(C, D, E, A, B, f4, K4, expand(eData, 63)); subRound(B, C, D, E, A, f4, K4, expand(eData, 64)); subRound(A, B, C, D, E, f4, K4, expand(eData, 65)); subRound(E, A, B, C, D, f4, K4, expand(eData, 66)); subRound(D, E, A, B, C, f4, K4, expand(eData, 67)); subRound(C, D, E, A, B, f4, K4, expand(eData, 68)); subRound(B, C, D, E, A, f4, K4, expand(eData, 69)); subRound(A, B, C, D, E, f4, K4, expand(eData, 70)); subRound(E, A, B, C, D, f4, K4, expand(eData, 71)); subRound(D, E, A, B, C, f4, K4, expand(eData, 72)); subRound(C, D, E, A, B, f4, K4, expand(eData, 73)); subRound(B, C, D, E, A, f4, K4, expand(eData, 74)); subRound(A, B, C, D, E, f4, K4, expand(eData, 75)); subRound(E, A, B, C, D, f4, K4, expand(eData, 76)); subRound(D, E, A, B, C, f4, K4, expand(eData, 77)); subRound(C, D, E, A, B, f4, K4, expand(eData, 78)); subRound(B, C, D, E, A, f4, K4, expand(eData, 79)); /* Build message digest */ digest[0] += A; digest[1] += B; digest[2] += C; digest[3] += D; digest[4] += E; } /* When run on a little-endian CPU we need to perform byte reversal on an array of long words. */ static void longReverse(UINT4 * buffer, int byteCount, int Endianness) { UINT4 value; if (Endianness == TRUE) return; byteCount /= sizeof(UINT4); while (byteCount--) { value = *buffer; value = ((value & 0xFF00FF00UL) >> 8) | ((value & 0x00FF00FFUL) << 8); *buffer++ = (value << 16) | (value >> 16); } } /** * \ingroup baselib * Add data to an initialized SHA-1 context. * @param shsInfo Context to add data to * @param buffer Data to process * @param count Number of bytes in buffer */ void TSK_SHA_Update(TSK_SHA_CTX * shsInfo, BYTE * buffer, int count) { UINT4 tmp; int dataCount; /* Update bitcount */ tmp = shsInfo->countLo; if ((shsInfo->countLo = tmp + ((UINT4) count << 3)) < tmp) shsInfo->countHi++; /* Carry from low to high */ shsInfo->countHi += count >> 29; /* Get count of bytes already in data */ dataCount = (int) (tmp >> 3) & 0x3F; /* Handle any leading odd-sized chunks */ if (dataCount) { BYTE *p = (BYTE *) shsInfo->data + dataCount; dataCount = SHS_DATASIZE - dataCount; if (count < dataCount) { memcpy(p, buffer, count); return; } memcpy(p, buffer, dataCount); longReverse(shsInfo->data, SHS_DATASIZE, shsInfo->Endianness); SHSTransform(shsInfo->digest, shsInfo->data); buffer += dataCount; count -= dataCount; } /* Process data in SHS_DATASIZE chunks */ while (count >= SHS_DATASIZE) { memcpy((POINTER) shsInfo->data, (POINTER) buffer, SHS_DATASIZE); longReverse(shsInfo->data, SHS_DATASIZE, shsInfo->Endianness); SHSTransform(shsInfo->digest, shsInfo->data); buffer += SHS_DATASIZE; count -= SHS_DATASIZE; } /* Handle any remaining bytes of data. */ memcpy((POINTER) shsInfo->data, (POINTER) buffer, count); } static void SHAtoByte(BYTE output[SHS_DIGESTSIZE], UINT4 * input) { /* Output SHA digest in byte array */ unsigned int i, j; for (i = 0, j = 0; j < SHS_DIGESTSIZE; i++, j += 4) { output[j + 3] = (BYTE) (input[i] & 0xff); output[j + 2] = (BYTE) ((input[i] >> 8) & 0xff); output[j + 1] = (BYTE) ((input[i] >> 16) & 0xff); output[j] = (BYTE) ((input[i] >> 24) & 0xff); } } /** * \ingroup baselib * Calculate the hash of the data added to the context. * @param output Buffer to store hash value * @param shsInfo Context that has data added to it. */ void TSK_SHA_Final(BYTE output[SHS_DIGESTSIZE], TSK_SHA_CTX * shsInfo) { int count; BYTE *dataPtr; /* Compute number of bytes mod 64 */ count = (int) shsInfo->countLo; count = (count >> 3) & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ dataPtr = (BYTE *) shsInfo->data + count; *dataPtr++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = SHS_DATASIZE - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(dataPtr, 0, count); longReverse(shsInfo->data, SHS_DATASIZE, shsInfo->Endianness); SHSTransform(shsInfo->digest, shsInfo->data); /* Now fill the next block with 56 bytes */ memset((POINTER) shsInfo->data, 0, SHS_DATASIZE - 8); } else /* Pad block to 56 bytes */ memset(dataPtr, 0, count - 8); /* Append length in bits and transform */ shsInfo->data[14] = shsInfo->countHi; shsInfo->data[15] = shsInfo->countLo; longReverse(shsInfo->data, SHS_DATASIZE - 8, shsInfo->Endianness); SHSTransform(shsInfo->digest, shsInfo->data); /* Output to an array of bytes */ SHAtoByte(output, shsInfo->digest); /* Zeroise sensitive stuff */ memset((POINTER) shsInfo, 0, sizeof(shsInfo)); } sleuthkit-3.2.3/tsk3/base/tsk_base.h000644 000765 000024 00000027641 11643647467 020123 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007-2010 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file tsk_base.h * Contains the type and function definitions that are needed * by external programs to use the TSK library. * Note that this file is not meant to be directly included. * It is included by both libtsk.h and tsk_base_i.h. */ /** * \defgroup baselib Base TSK Library Functions */ #ifndef _TSK_BASE_H #define _TSK_BASE_H // standard C header files #include #include /** Version of code in number form. * Upper byte is A, next is B, and next byte is C in version A.B.C. * Lowest byte is 0xff, except in beta releases, in which case it * increments from 1. Nightly snapshots will have upper byte as * 0xff and next bytes with year, month, and date, respectively. * Note that you will not be able to differentiate between snapshots * from the trunk or branches with this method... * For example, 3.1.2 would be stored as 0x030102FF. * 3.1.2b1 would be 0x03010201. Snapshot from Jan 2, 2003 would be * 0xFF030102. * See TSK_VERSION_STR for string form. */ #define TSK_VERSION_NUM 0x030203ff /** Version of code in string form. See TSK_VERSION_NUM for * integer form. */ #define TSK_VERSION_STR "3.2.3" /* include the TSK-specific header file that we created in autoconf * On Win32 (Visual Studio) though, we will not have this file... */ #if !defined(_MSC_VER) #include "tsk3/tsk_incs.h" #endif // get some other TSK / OS settings #include "tsk_os.h" #ifdef __cplusplus extern "C" { #endif /** * Return values for some TSK functions that need to differentiate between errors and corrupt data. */ typedef enum { TSK_OK, ///< Ok -- success TSK_ERR, ///< System error -- should abort TSK_COR, ///< Data is corrupt, can still process another set of data TSK_STOP ///< Stop further processing, not an error though. } TSK_RETVAL_ENUM; typedef struct TSK_LIST TSK_LIST; /** * Linked list structure that holds a 'key' and optional 'length'. * Note that the data is stored in reverse sort order so that inserts * are faster. Also note that the length is a negative number. A key of * '6' and a len of '2' means that the run contains 6 and 5. */ struct TSK_LIST { TSK_LIST *next; ///< Pointer to next entry in list uint64_t key; ///< Largest value in this run uint64_t len; ///< Length of run (negative number, stored as positive) }; extern uint8_t tsk_list_find(TSK_LIST * list, uint64_t key); extern uint8_t tsk_list_add(TSK_LIST ** list, uint64_t key); extern void tsk_list_free(TSK_LIST * list); // note that the stack code is in this file and not internal for convenience to users /** * Basic stack structure to push and pop (used for finding loops in recursion). */ typedef struct { uint64_t *vals; ///< Array that contains the values in the stack size_t top; ///< Index to the top stack entry size_t len; ///< Number of entries in the stack } TSK_STACK; extern uint8_t tsk_stack_push(TSK_STACK * stack, uint64_t key); extern void tsk_stack_pop(TSK_STACK * stack); extern uint8_t tsk_stack_find(TSK_STACK * stack, uint64_t key); extern void tsk_stack_free(TSK_STACK * stack); extern TSK_STACK *tsk_stack_create(); // print internal UTF-8 strings to local platform Unicode format extern void tsk_fprintf(FILE * fd, const char *msg, ...); extern void tsk_printf(const char *msg, ...); /** \name printf macros if system does not define them */ //@{ #ifndef PRIx64 #define PRIx64 "llx" #endif #ifndef PRIX64 #define PRIX64 "llX" #endif #ifndef PRIu64 #define PRIu64 "llu" #endif #ifndef PRId64 #define PRId64 "lld" #endif #ifndef PRIo64 #define PRIo64 "llo" #endif #ifndef PRIx32 #define PRIx32 "x" #endif #ifndef PRIX32 #define PRIX32 "X" #endif #ifndef PRIu32 #define PRIu32 "u" #endif #ifndef PRId32 #define PRId32 "d" #endif #ifndef PRIx16 #define PRIx16 "hx" #endif #ifndef PRIX16 #define PRIX16 "hX" #endif #ifndef PRIu16 #define PRIu16 "hu" #endif #ifndef PRIu8 #define PRIu8 "hhu" #endif #ifndef PRIx8 #define PRIx8 "hhx" #endif //@} /** @name Internal integer types and printf macros*/ //@{ typedef uint64_t TSK_INUM_T; ///< Data type used to internally store metadata / inode addresses #define PRIuINUM PRIu64 #define PRIxINUM PRIx64 #define PRIdINUM PRId64 typedef uint32_t TSK_UID_T; ///< Data type used to internally store User IDs #define PRIuUID PRIu32 #define PRIxUID PRIx32 #define PRIdUID PRId32 typedef uint32_t TSK_GID_T; ///< Data type used to internally store Group IDs #define PRIuGID PRIu32 #define PRIxGID PRIx32 #define PRIdGID PRId32 typedef uint64_t TSK_DADDR_T; ///< Data type used to internally store sector and block addresses #define PRIuDADDR PRIu64 #define PRIxDADDR PRIx64 #define PRIdDADDR PRId64 typedef int64_t TSK_OFF_T; ///< Data type used to internally store volume, file, etc. sizes and offsets #define PRIuOFF PRIu64 #define PRIxOFF PRIx64 #define PRIdOFF PRId64 typedef uint32_t TSK_PNUM_T; ///< Data type used to internally store partition addresses #define PRIuPNUM PRIu32 #define PRIxPNUM PRIx32 #define PRIdPNUM PRId32 //@} extern void tsk_version_print(FILE *); extern const char *tsk_version_get_str(); /*********** RETURN VALUES ************/ /** * Values that callback functions can return to calling walk function. */ typedef enum { TSK_WALK_CONT = 0x0, ///< Walk function should continue to next object TSK_WALK_STOP = 0x1, ///< Walk function should stop processing units and return OK TSK_WALK_ERROR = 0x2, ///< Walk function should stop processing units and return error } TSK_WALK_RET_ENUM; /************ ERROR HANDLING *************/ extern int tsk_verbose; ///< Set to 1 to have verbose debug messages printed to stderr /** \name Error Handling */ //@{ extern uint32_t tsk_errno; extern const char *tsk_error_get(); extern void tsk_error_print(FILE *); extern void tsk_error_reset(); #define TSK_ERR_AUX 0x01000000 #define TSK_ERR_IMG 0x02000000 #define TSK_ERR_VS 0x04000000 #define TSK_ERR_FS 0x08000000 #define TSK_ERR_HDB 0x10000000 #define TSK_ERR_AUTO 0x20000000 #define TSK_ERR_MASK 0x00ffffff #define TSK_ERR_AUX_MALLOC (TSK_ERR_AUX | 0) #define TSK_ERR_AUX_MAX 2 #define TSK_ERR_IMG_NOFILE (TSK_ERR_IMG | 0) #define TSK_ERR_IMG_OFFSET (TSK_ERR_IMG | 1) #define TSK_ERR_IMG_UNKTYPE (TSK_ERR_IMG | 2) #define TSK_ERR_IMG_UNSUPTYPE (TSK_ERR_IMG | 3) #define TSK_ERR_IMG_OPEN (TSK_ERR_IMG | 4) #define TSK_ERR_IMG_STAT (TSK_ERR_IMG | 5) #define TSK_ERR_IMG_SEEK (TSK_ERR_IMG | 6) #define TSK_ERR_IMG_READ (TSK_ERR_IMG | 7) #define TSK_ERR_IMG_READ_OFF (TSK_ERR_IMG | 8) #define TSK_ERR_IMG_ARG (TSK_ERR_IMG | 9) #define TSK_ERR_IMG_MAGIC (TSK_ERR_IMG | 10) #define TSK_ERR_IMG_WRITE (TSK_ERR_IMG | 11) #define TSK_ERR_IMG_CONVERT (TSK_ERR_IMG | 12) #define TSK_ERR_IMG_PASSWD (TSK_ERR_IMG | 13) #define TSK_ERR_IMG_MAX 14 #define TSK_ERR_VS_UNKTYPE (TSK_ERR_VS | 0) #define TSK_ERR_VS_UNSUPTYPE (TSK_ERR_VS | 1) #define TSK_ERR_VS_READ (TSK_ERR_VS | 2) #define TSK_ERR_VS_MAGIC (TSK_ERR_VS | 3) #define TSK_ERR_VS_WALK_RNG (TSK_ERR_VS | 4) #define TSK_ERR_VS_BUF (TSK_ERR_VS | 5) #define TSK_ERR_VS_BLK_NUM (TSK_ERR_VS | 6) #define TSK_ERR_VS_ARG (TSK_ERR_VS | 7) #define TSK_ERR_VS_MAX 8 #define TSK_ERR_FS_UNKTYPE (TSK_ERR_FS | 0) #define TSK_ERR_FS_UNSUPTYPE (TSK_ERR_FS | 1) #define TSK_ERR_FS_UNSUPFUNC (TSK_ERR_FS | 2) #define TSK_ERR_FS_WALK_RNG (TSK_ERR_FS | 3) #define TSK_ERR_FS_READ (TSK_ERR_FS | 4) #define TSK_ERR_FS_READ_OFF (TSK_ERR_FS | 5) #define TSK_ERR_FS_ARG (TSK_ERR_FS | 6) #define TSK_ERR_FS_BLK_NUM (TSK_ERR_FS | 7) #define TSK_ERR_FS_INODE_NUM (TSK_ERR_FS | 8) #define TSK_ERR_FS_INODE_COR (TSK_ERR_FS | 9) #define TSK_ERR_FS_MAGIC (TSK_ERR_FS | 10) #define TSK_ERR_FS_FWALK (TSK_ERR_FS | 11) #define TSK_ERR_FS_WRITE (TSK_ERR_FS | 12) #define TSK_ERR_FS_UNICODE (TSK_ERR_FS | 13) #define TSK_ERR_FS_RECOVER (TSK_ERR_FS | 14) #define TSK_ERR_FS_GENFS (TSK_ERR_FS | 15) #define TSK_ERR_FS_CORRUPT (TSK_ERR_FS | 16) #define TSK_ERR_FS_ATTR_NOTFOUND (TSK_ERR_FS | 17) #define TSK_ERR_FS_MAX 18 #define TSK_ERR_HDB_UNKTYPE (TSK_ERR_HDB | 0) #define TSK_ERR_HDB_UNSUPTYPE (TSK_ERR_HDB | 1) #define TSK_ERR_HDB_READDB (TSK_ERR_HDB | 2) #define TSK_ERR_HDB_READIDX (TSK_ERR_HDB | 3) #define TSK_ERR_HDB_ARG (TSK_ERR_HDB | 4) #define TSK_ERR_HDB_WRITE (TSK_ERR_HDB | 5) #define TSK_ERR_HDB_CREATE (TSK_ERR_HDB | 6) #define TSK_ERR_HDB_DELETE (TSK_ERR_HDB | 7) #define TSK_ERR_HDB_MISSING (TSK_ERR_HDB | 8) #define TSK_ERR_HDB_PROC (TSK_ERR_HDB | 9) #define TSK_ERR_HDB_OPEN (TSK_ERR_HDB | 10) #define TSK_ERR_HDB_CORRUPT (TSK_ERR_HDB | 11) #define TSK_ERR_HDB_MAX 12 #define TSK_ERR_AUTO_DB (TSK_ERR_AUTO | 0) #define TSK_ERR_AUTO_CORRUPT (TSK_ERR_AUTO | 1) #define TSK_ERR_AUTO_UNICODE (TSK_ERR_AUTO | 2) #define TSK_ERR_AUTO_NOTOPEN (TSK_ERR_AUTO | 3) #define TSK_ERR_AUTO_MAX 4 //@} /** \name Endian Ordering Functions */ //@{ /** * Flag that identifies the endian ordering of the data being read. */ typedef enum { TSK_LIT_ENDIAN = 0x01, ///< Data is in little endian TSK_BIG_ENDIAN = 0x02 ///< Data is in big endian } TSK_ENDIAN_ENUM; //@} extern TSK_OFF_T tsk_parse_offset(const TSK_TCHAR *); extern int tsk_parse_pnum(const TSK_TCHAR * a_pnum_str, TSK_PNUM_T * a_pnum); /** \name MD5 and SHA-1 hashing */ //@{ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; /* UINT2 defines a two byte word */ //typedef unsigned short int UINT2; typedef uint16_t UINT2; /* UINT4 defines a four byte word */ typedef uint32_t UINT4; /* Added for sha1 */ /* BYTE defines a unsigned character */ typedef uint8_t BYTE; #ifndef TRUE #define FALSE 0 #define TRUE ( !FALSE ) #endif /* TRUE */ /* MD5 context. */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } TSK_MD5_CTX; void TSK_MD5_Init(TSK_MD5_CTX *); void TSK_MD5_Update(TSK_MD5_CTX *, unsigned char *, unsigned int); void TSK_MD5_Final(unsigned char[16], TSK_MD5_CTX *); /* sha.h */ /* The structure for storing SHS info */ typedef struct { UINT4 digest[5]; /* Message digest */ UINT4 countLo, countHi; /* 64-bit bit count */ UINT4 data[16]; /* SHS data buffer */ int Endianness; } TSK_SHA_CTX; /* Message digest functions */ void TSK_SHA_Init(TSK_SHA_CTX *); void TSK_SHA_Update(TSK_SHA_CTX *, BYTE * buffer, int count); void TSK_SHA_Final(BYTE * output, TSK_SHA_CTX *); //@} #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/base/tsk_base_i.h000644 000765 000024 00000025757 11643647437 020436 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * */ /** \file tsk_base_i.h * Contains the general internal TSK type and function definitions. * This is needed by the library as it is built. */ #ifndef _TSK_BASE_I_H #define _TSK_BASE_I_H // include the autoconf header file #if HAVE_CONFIG_H #include "tsk3/tsk_config.h" #endif /* Some Linux systems need LARGEFILE64_SOURCE and autoconf does * not define it, so we hack it here */ #ifdef _LARGEFILE_SOURCE #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE 1 #endif #endif #include "tsk_base.h" // most of the local files need this, so we include it here #include #ifdef __cplusplus extern "C" { #endif #ifndef rounddown #define rounddown(x, y) \ ((((x) % (y)) == 0) ? (x) : \ (roundup((x),(y)) - (y))) #endif extern void *tsk_malloc(size_t); extern void *tsk_realloc(void *, size_t); // getopt for windows #ifdef TSK_WIN32 extern int tsk_optind; extern TSK_TCHAR *tsk_optarg; extern int tsk_getopt(int argc, TSK_TCHAR * const argv[], const TSK_TCHAR * optstring); #endif /* Error handling */ #define TSK_ERRSTR_L 512 #define TSK_ERRSTR_PR_L ((TSK_ERRSTR_L << 2) + 64) extern char tsk_errstr[TSK_ERRSTR_L]; extern char tsk_errstr2[TSK_ERRSTR_L]; extern char tsk_errstr_print[TSK_ERRSTR_PR_L]; /* Endian Ordering */ /* macros to read in multi-byte fields * file system is an array of 8-bit values, not 32-bit values */ extern uint8_t tsk_guess_end_u16(TSK_ENDIAN_ENUM *, uint8_t *, uint16_t); extern uint8_t tsk_guess_end_u32(TSK_ENDIAN_ENUM *, uint8_t *, uint32_t); /** \internal * Read a 16-bit unsigned value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 16-bit unsigned value */ #define tsk_getu16(endian, x) \ (uint16_t)(((endian) == TSK_LIT_ENDIAN) ? \ (((uint8_t *)(x))[0] + (((uint8_t *)(x))[1] << 8)) : \ (((uint8_t *)(x))[1] + (((uint8_t *)(x))[0] << 8)) ) /** \internal * Read a 16-bit signed value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 16-bit signed value */ #define tsk_gets16(endian, x) \ ((int16_t)tsk_getu16(endian, x)) /** \internal * Read a 32-bit unsigned value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 32-bit unsigned value */ #define tsk_getu32(endian, x) \ (uint32_t)( ((endian) == TSK_LIT_ENDIAN) ? \ ((((uint8_t *)(x))[0] << 0) + \ (((uint8_t *)(x))[1] << 8) + \ (((uint8_t *)(x))[2] << 16) + \ (((uint8_t *)(x))[3] << 24) ) \ : \ ((((uint8_t *)(x))[3] << 0) + \ (((uint8_t *)(x))[2] << 8) + \ (((uint8_t *)(x))[1] << 16) + \ (((uint8_t *)(x))[0] << 24) ) ) /** \internal * Read a 32-bit signed value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 32-bit signed value */ #define tsk_gets32(endian, x) \ ((int32_t)tsk_getu32(endian, x)) /** \internal * Read a 48-bit unsigned value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 48-bit unsigned value */ #define tsk_getu48(endian, x) \ (uint64_t)( ((endian) == TSK_LIT_ENDIAN) ? \ ((uint64_t) \ ((uint64_t)((uint8_t *)(x))[0] << 0)+ \ ((uint64_t)((uint8_t *)(x))[1] << 8) + \ ((uint64_t)((uint8_t *)(x))[2] << 16) + \ ((uint64_t)((uint8_t *)(x))[3] << 24) + \ ((uint64_t)((uint8_t *)(x))[4] << 32) + \ ((uint64_t)((uint8_t *)(x))[5] << 40)) \ : \ ((uint64_t) \ ((uint64_t)((uint8_t *)(x))[5] << 0)+ \ ((uint64_t)((uint8_t *)(x))[4] << 8) + \ ((uint64_t)((uint8_t *)(x))[3] << 16) + \ ((uint64_t)((uint8_t *)(x))[2] << 24) + \ ((uint64_t)((uint8_t *)(x))[1] << 32) + \ ((uint64_t)((uint8_t *)(x))[0] << 40)) ) /** \internal * Read a 64-bit unsigned value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 64-bit unsigned value */ #define tsk_getu64(endian, x) \ (uint64_t)( ((endian) == TSK_LIT_ENDIAN) ? \ ((uint64_t) \ ((uint64_t)((uint8_t *)(x))[0] << 0) + \ ((uint64_t)((uint8_t *)(x))[1] << 8) + \ ((uint64_t)((uint8_t *)(x))[2] << 16) + \ ((uint64_t)((uint8_t *)(x))[3] << 24) + \ ((uint64_t)((uint8_t *)(x))[4] << 32) + \ ((uint64_t)((uint8_t *)(x))[5] << 40) + \ ((uint64_t)((uint8_t *)(x))[6] << 48) + \ ((uint64_t)((uint8_t *)(x))[7] << 56)) \ : \ ((uint64_t) \ ((uint64_t)((uint8_t *)(x))[7] << 0) + \ ((uint64_t)((uint8_t *)(x))[6] << 8) + \ ((uint64_t)((uint8_t *)(x))[5] << 16) + \ ((uint64_t)((uint8_t *)(x))[4] << 24) + \ ((uint64_t)((uint8_t *)(x))[3] << 32) + \ ((uint64_t)((uint8_t *)(x))[2] << 40) + \ ((uint64_t)((uint8_t *)(x))[1] << 48) + \ ((uint64_t)((uint8_t *)(x))[0] << 56)) ) /** \internal * Read a 64-bit signed value. * @param endian Flag that identifies local ordering. * @param x Byte array to read from * @returns 64-bit signed value */ #define tsk_gets64(endian, x) \ ((int64_t)tsk_getu64(endian, x)) #define TSK_IS_CNTRL(x) \ (((x) < 0x20) && ((x) >= 0x00)) /** \name Unicode */ //@{ // basic check to see if a Unicode file has been included // in an app that is using this as a library #ifndef TSK_UNI_REPLACEMENT_CHAR /**************** UNICODE *******************/ /* * Copyright 2001-2004 Unicode, Inc. * * Disclaimer * * This source code is provided as is by Unicode, Inc. No claims are * made as to fitness for any particular purpose. No warranties of any * kind are expressed or implied. The recipient agrees to determine * applicability of information provided. If this file has been * purchased on magnetic or optical media from Unicode, Inc., the * sole remedy for any claim will be exchange of defective media * within 90 days of receipt. * * Limitations on Rights to Redistribute This Code * * Unicode, Inc. hereby grants the right to freely use the information * supplied in this file in the creation of products supporting the * Unicode Standard, and to make copies of this file in any form * for internal or external distribution as long as this notice * remains attached. */ /* --------------------------------------------------------------------- Conversions between UTF32, UTF-16, and UTF-8. Header file. Several funtions are included here, forming a complete set of conversions between the three formats. UTF-7 is not included here, but is handled in a separate source file. Each of these routines takes pointers to input buffers and output buffers. The input buffers are const. Each routine converts the text between *sourceStart and sourceEnd, putting the result into the buffer between *targetStart and targetEnd. Note: the end pointers are *after* the last item: e.g. *(sourceEnd - 1) is the last item. The return result indicates whether the conversion was successful, and if not, whether the problem was in the source or target buffers. (Only the first encountered problem is indicated.) After the conversion, *sourceStart and *targetStart are both updated to point to the end of last text successfully converted in the respective buffers. Input parameters: sourceStart - pointer to a pointer to the source buffer. The contents of this are modified on return so that it points at the next thing to be converted. targetStart - similarly, pointer to pointer to the target buffer. sourceEnd, targetEnd - respectively pointers to the ends of the two buffers, for overflow checking only. These conversion functions take a TSKConversionFlags argument. When this flag is set to strict, both irregular sequences and isolated surrogates will cause an error. When the flag is set to lenient, both irregular sequences and isolated surrogates are converted. Whether the flag is strict or lenient, all illegal sequences will cause an error return. This includes sequences such as: , , or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code must check for illegal sequences. When the flag is set to lenient, characters over 0x10FFFF are converted to the replacement character; otherwise (when the flag is set to strict) they constitute an error. Output parameters: The value "TSKsourceIllegal" is returned from some routines if the input sequence is malformed. When "TSKsourceIllegal" is returned, the source value will point to the illegal value that caused the problem. E.g., in UTF-8 when a sequence is malformed, it points to the start of the malformed sequence. Author: Mark E. Davis, 1994. Rev History: Rick McGowan, fixes & updates May 2001. Fixes & updates, Sept 2001. ------------------------------------------------------------------------ */ /* --------------------------------------------------------------------- The following 4 definitions are compiler-specific. The C standard does not guarantee that wchar_t has at least 16 bits, so wchar_t is no less portable than unsigned short! All should be unsigned values to avoid sign extension during bit mask & shift operations. ------------------------------------------------------------------------ */ typedef unsigned short UTF16; /* at least 16 bits */ typedef unsigned char UTF8; /* typically 8 bits */ typedef unsigned char Boolean; /* 0 or 1 */ typedef enum { TSKconversionOK, ///< conversion successful TSKsourceExhausted, ///< partial character in source, but hit end TSKtargetExhausted, ///< insuff. room in target for conversion TSKsourceIllegal ///< source sequence is illegal/malformed } TSKConversionResult; typedef enum { TSKstrictConversion = 0, ///< Error if invalid surrogate pairs are found TSKlenientConversion ///< Ignore invalid surrogate pairs } TSKConversionFlags; extern TSKConversionResult tsk_UTF8toUTF16(const UTF8 ** sourceStart, const UTF8 * sourceEnd, UTF16 ** targetStart, UTF16 * targetEnd, TSKConversionFlags flags); extern TSKConversionResult tsk_UTF16toUTF8(TSK_ENDIAN_ENUM, const UTF16 ** sourceStart, const UTF16 * sourceEnd, UTF8 ** targetStart, UTF8 * targetEnd, TSKConversionFlags flags); extern TSKConversionResult tsk_UTF16toUTF8_lclorder(const UTF16 ** sourceStart, const UTF16 * sourceEnd, UTF8 ** targetStart, UTF8 * targetEnd, TSKConversionFlags flags); extern Boolean tsk_isLegalUTF8Sequence(const UTF8 * source, const UTF8 * sourceEnd); #endif //@} #ifdef __cplusplus } #endif #endif sleuthkit-3.2.3/tsk3/base/tsk_endian.c000644 000765 000024 00000003565 11643647437 020436 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2003-2008 Brian Carrier. All rights reserved * * Copyright (c) 2002 Brian Carrier, @stake Inc. All rights reserved * * This software is distributed under the Common Public License 1.0 * */ #include "tsk_base_i.h" /** \file tsk_endian.c * Contains the routines to read data in different endian orderings. */ /* A temporary data structure with an endian field */ typedef struct { uint8_t endian; } tmp_ds; /** \internal * Analyze an array of bytes and compare it to a target value to * determine which byte order the array is stored in. * * @param flag Pointer to location where proper endian flag should be stored. * @param x Pointer to array of bytes to analyze. * @param val Target value to compare to * @returns 1 if match cannot be made, 0 if it can. */ uint8_t tsk_guess_end_u16(TSK_ENDIAN_ENUM * flag, uint8_t * x, uint16_t val) { /* try little */ if (tsk_getu16(TSK_LIT_ENDIAN, x) == val) { *flag = TSK_LIT_ENDIAN; return 0; } /* ok, big now */ if (tsk_getu16(TSK_BIG_ENDIAN, x) == val) { *flag = TSK_BIG_ENDIAN; return 0; } /* didn't find it */ return 1; } /** \internal * same idea as tsk_guess_end_u16 except that val is a 32-bit value * * @param flag Pointer to location where proper endian flag should be stored. * @param x Pointer to array of bytes to analyze. * @param val Target value to compare to * @returns 1 if match cannot be made, 0 if it can. */ uint8_t tsk_guess_end_u32(TSK_ENDIAN_ENUM * flag, uint8_t * x, uint32_t val) { /* try little */ if (tsk_getu32(TSK_LIT_ENDIAN, x) == val) { *flag = TSK_LIT_ENDIAN; return 0; } /* ok, big now */ if (tsk_getu32(TSK_BIG_ENDIAN, x) == val) { *flag = TSK_BIG_ENDIAN; return 0; } return 1; } sleuthkit-3.2.3/tsk3/base/tsk_error.c000644 000765 000024 00000016774 11643647437 020337 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2006-2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ #include "tsk_base_i.h" /** * \file tsk_error.c * Contains the error handling code and variables. */ /* Global variables that fit here as well as anywhere */ char *progname = "unknown"; int tsk_verbose = 0; /** * \ingroup baselib * Set when an error occurs and contains the error code. */ uint32_t tsk_errno = 0; /* \internal * Contains an error-specific string and is valid only * when tsk_errno is set. This should be set when errno is set, * if it is not needed, then set tsk_errstr[0] to '\0'. */ char tsk_errstr[TSK_ERRSTR_L]; /* \internal * Contains a caller-specific string and is valid only when tsk_errno is set * * This is typically set to start with a NULL char when errno is set and then set with * a string by the code that called the * function that had the error. For * example, the X_read() function may set why * the read failed in tsk_errstr and the * function that called X_read() can provide * more context about why X_read() was * called in the first place */ char tsk_errstr2[TSK_ERRSTR_L]; /* \internal * Buffer used to store the printed message formed by tsk_errstr and tsk_errstr2 */ char tsk_errstr_print[TSK_ERRSTR_PR_L]; /* Error messages */ static const char *tsk_err_aux_str[TSK_ERR_IMG_MAX] = { "Insufficient memory", "" }; /* imagetools specific error strings */ static const char *tsk_err_img_str[TSK_ERR_IMG_MAX] = { "Missing image file names", // 0 "Invalid image offset", "Cannot determine image type", "Unsupported image type", "Error opening image file", "Error stat(ing) image file", // 5 "Error seeking in image file", "Error reading image file", "Read offset too large for image file", "Invalid API argument", "Invalid magic value", // 10 "Error writing data", "Error converting file name", "Incorrect or missing password" }; static const char *tsk_err_mm_str[TSK_ERR_VS_MAX] = { "Cannot determine partition type", // 0 "Unsupported partition type", "Error reading image file", "Invalid magic value", "Invalid walk range", "Invalid buffer size", // 5 "Invalid sector address", "Invalid API argument", }; static const char *tsk_err_fs_str[TSK_ERR_FS_MAX] = { "Cannot determine file system type", // 0 "Unsupported file system type", "Function/Feature not supported", "Invalid walk range", "Error reading image file", "Invalid file offset", // 5 "Invalid API argument", "Invalid block address", "Invalid metadata address", "Error in metadata structure", "Invalid magic value", // 10 "Error extracting file from image", "Error writing data", "Error converting Unicode", "Error recovering deleted file", "General file system error", // 15 "File system is corrupt", "Attribute not found in file", }; static const char *tsk_err_hdb_str[TSK_ERR_HDB_MAX] = { "Cannot determine hash database type", // 0 "Unsupported hash database type", "Error reading hash database file", "Error reading hash database index", "Invalid argument", "Error writing data", // 5 "Error creating file", "Error deleting file", "Missing file", "Error creating process", "Error opening file", // 10 "Corrupt hash database" }; static const char *tsk_err_auto_str[TSK_ERR_AUTO_MAX] = { "Database Error", "Corrupt file data", "Error converting Unicode", "Image not opened yet" }; /** * \ingroup baselib * Return the string with the current error message. The string does not end with a * newline. * * @returns String with error message or NULL if there is no error */ const char * tsk_error_get() { size_t pidx = 0; if (tsk_errno == 0) return NULL; memset(tsk_errstr_print, 0, TSK_ERRSTR_PR_L); if (tsk_errno & TSK_ERR_AUX) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_AUX_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_aux_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "auxtools error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else if (tsk_errno & TSK_ERR_IMG) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_IMG_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_img_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "imgtools error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else if (tsk_errno & TSK_ERR_VS) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_VS_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_mm_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "mmtools error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else if (tsk_errno & TSK_ERR_FS) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_FS_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_fs_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "fstools error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else if (tsk_errno & TSK_ERR_HDB) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_HDB_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_hdb_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "hashtools error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else if (tsk_errno & TSK_ERR_AUTO) { if ((TSK_ERR_MASK & tsk_errno) < TSK_ERR_AUTO_MAX) snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "%s", tsk_err_auto_str[tsk_errno & TSK_ERR_MASK]); else snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "auto error: %" PRIu32, TSK_ERR_MASK & tsk_errno); } else { snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, "Unknown Error: %" PRIu32, tsk_errno); } pidx = strlen(tsk_errstr_print); /* Print the unique string, if it exists */ if (tsk_errstr[0] != '\0') { snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, " (%s)", tsk_errstr); pidx = strlen(tsk_errstr_print); } if (tsk_errstr2[0] != '\0') { snprintf(&tsk_errstr_print[pidx], TSK_ERRSTR_PR_L - pidx, " (%s)", tsk_errstr2); pidx = strlen(tsk_errstr_print); } return (char *) &tsk_errstr_print[0]; } /** * \ingroup baselib * Print the current error message to a file. * * @param hFile File to print message to */ void tsk_error_print(FILE * hFile) { const char *str; if (tsk_errno == 0) return; str = tsk_error_get(); if (str != NULL) { tsk_fprintf(hFile, "%s\n", str); } else { tsk_fprintf(hFile, "Error creating Sleuth Kit error string (Errno: %d)\n", tsk_errno); } } /** * \ingroup baselib * Clear the error number and error message. */ void tsk_error_reset() { tsk_errno = 0; tsk_errstr[0] = '\0'; tsk_errstr2[0] = '\0'; } sleuthkit-3.2.3/tsk3/base/tsk_list.c000644 000765 000024 00000012654 11643647437 020152 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007-2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ #include "tsk_base_i.h" /** \file tsk_list.c * tsk_lists are a linked list of buckets that store a key in REVERSE sorted order. * They are used to keep track of data as we walk along and prevent loops * from data corruption. Note that the len value is actually negative. An entry * with a key of 6 and a length of 2 covers the range of 5 to 6. */ /* * Create a list with teh first entry defined * @param a_key Key for initial entry * @returns newly created entry */ static TSK_LIST * tsk_list_create(uint64_t a_key) { TSK_LIST *ent; if ((ent = (TSK_LIST *) tsk_malloc(sizeof(TSK_LIST))) == NULL) { return NULL; } ent->key = a_key; ent->next = NULL; ent->len = 1; return ent; } /** * \ingroup baselib * Add an entry to a TSK_LIST (and create one if one does not exist) * @param a_tsk_list_head Pointer to pointer for head of list (can point to NULL if no list exists). * @param a_key Value to add to list * @returns 1 on error */ uint8_t tsk_list_add(TSK_LIST ** a_tsk_list_head, uint64_t a_key) { TSK_LIST *tmp; /* If the head is NULL, then create an entry */ if (*a_tsk_list_head == NULL) { TSK_LIST *ent; /* if (tsk_verbose) fprintf(stderr, "entry %" PRIu64 " is first on list\n", a_key); */ if ((ent = tsk_list_create(a_key)) == NULL) return 1; *a_tsk_list_head = ent; return 0; } /* If the new key is larger than the head, make it the head */ if (a_key > (*a_tsk_list_head)->key) { /* if (tsk_verbose) fprintf(stderr, "entry %" PRIu64 " added to head before %" PRIu64 "\n", a_key, (*a_tsk_list_head)->key); */ // If we can, update the length of the existing list entry if (a_key == (*a_tsk_list_head)->key + 1) { (*a_tsk_list_head)->key++; (*a_tsk_list_head)->len++; } else { TSK_LIST *ent; if ((ent = tsk_list_create(a_key)) == NULL) return 1; ent->next = *a_tsk_list_head; *a_tsk_list_head = ent; } return 0; } // get rid of duplicates else if (a_key == (*a_tsk_list_head)->key) { return 0; } /* At the start of this loop each time, we know that the key to add * is smaller than the entry being considered (tmp) */ tmp = *a_tsk_list_head; while (tmp != NULL) { /* First check if this is a duplicate and contained in tmp */ if (a_key > (tmp->key - tmp->len)) { return 0; } /* Can we append it to the end of tmp? */ else if (a_key == (tmp->key - tmp->len)) { // do a sanity check on the next entry if ((tmp->next) && (tmp->next->key == a_key)) { // @@@ We could fix this situation and remove the next entry... return 0; } tmp->len++; return 0; } /* The key is less than the current bucket and can't be added to it. * check if we are at the end of the list yet */ else if (tmp->next == NULL) { TSK_LIST *ent; /* if (tsk_verbose) fprintf(stderr, "entry %" PRIu64 " added to tail\n", a_key); */ if ((ent = tsk_list_create(a_key)) == NULL) return 1; tmp->next = ent; return 0; } // can we prepend it to the next bucket? else if (a_key == tmp->next->key + 1) { tmp->next->key++; tmp->next->len++; return 0; } // do we need a new bucket in between? else if (a_key > tmp->next->key) { TSK_LIST *ent; /* if (tsk_verbose) fprintf(stderr, "entry %" PRIu64 " added before %" PRIu64 "\n", a_key, tmp->next->key); */ if ((ent = tsk_list_create(a_key)) == NULL) return 1; ent->next = tmp->next; tmp->next = ent; return 0; } else if (a_key == tmp->next->key) { return 0; } tmp = tmp->next; } return 0; } /** * \ingroup baselib * Search a TSK_LIST for the existence of a value. * @param a_tsk_list_head Head of list to search * @param a_key Value to search for * @returns 1 if value is found and 0 if not */ uint8_t tsk_list_find(TSK_LIST * a_tsk_list_head, uint64_t a_key) { TSK_LIST *tmp; tmp = a_tsk_list_head; while (tmp != NULL) { // check this bucket // use the key+1 and then subtract for unsigned cases when key-len == -1 if ((a_key <= tmp->key) && (a_key >= tmp->key + 1 - tmp->len)) return 1; // Have we passed any potential buckets? else if (a_key > tmp->key) return 0; tmp = tmp->next; } return 0; } /** * \ingroup baselib * Free a TSK_LIST. * @param a_tsk_list_head Head of list to free */ void tsk_list_free(TSK_LIST * a_tsk_list_head) { TSK_LIST *tmp; while (a_tsk_list_head) { tmp = a_tsk_list_head->next; free(a_tsk_list_head); a_tsk_list_head = tmp; } } sleuthkit-3.2.3/tsk3/base/tsk_os.h000644 000765 000024 00000011162 11643647437 017616 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2004-2005 Brian Carrier. All rights reserved */ /** \file tsk_os.h * Contains some OS-specific type settings. */ #ifndef _TSK_OS_H #define _TSK_OS_H /* * Solaris 2.x. Build for large files when dealing with filesystems > 2GB. * With the 32-bit file model, needs pread() to access filesystems > 2GB. */ #if defined(sun) #include #endif #if defined(__CYGWIN__) #ifndef roundup #define roundup(x, y) \ ( ( ((x)+((y) - 1)) / (y)) * (y) ) #endif #endif #if defined(__INTERNIX) #define roundup(x, y) \ ( ( ((x)+((y) - 1)) / (y)) * (y) ) #endif // mingw Windows cross compile #ifdef __MINGW32__ #ifndef UNICODE #define UNICODE #endif #ifndef _UNICODE #define _UNICODE #endif #include #include #define TSK_WIN32 #define roundup(x, y) \ ( ( ((x)+((y) - 1)) / (y)) * (y) ) #define fseeko fseek #define daddr_t int #endif // Visual Studio / Windows #ifdef _MSC_VER #define TSK_WIN32 #ifndef UNICODE #define UNICODE #endif #ifndef _UNICODE #define _UNICODE #endif #define WIN32_LEAN_AND_MEAN /* somewhat limit Win32 pollution */ #define _CRT_SECURE_NO_DEPRECATE 1 #include #include #include #include #include "intrin.h" // define the sized int types typedef unsigned __int8 uint8_t; typedef __int8 int8_t; typedef unsigned __int16 uint16_t; typedef __int16 int16_t; typedef unsigned __int32 uint32_t; typedef __int32 int32_t; typedef unsigned __int64 uint64_t; typedef __int64 int64_t; // define the typical unix types typedef int mode_t; typedef int ssize_t; // remap some of the POSIX functions #define snprintf _snprintf #define strcasecmp(string1, string2) _stricmp(string1, string2) #define roundup(x, y) \ ( ( ((x)+((y) - 1)) / (y)) * (y) ) #define fseeko _fseeki64 #endif /* When TSK deals with the outside world (printing / input), the data will * be in either UTF-16 or UTF-8 (Windows or Unix). TSK_TCHAR is defined * as the data type needed and the following function map to the required * function. */ #ifdef TSK_WIN32 /* TSK_TCHAR is a wide 2-byte character */ typedef WCHAR TSK_TCHAR; ///< Character data type that is UTF-16 (wchar_t) in Windows and UTF-8 (char) in Unix #define _TSK_T(x) L ## x #define TSTRTOK wcstok #define TSTRLEN wcslen #define TSTRCMP wcscmp #define TSTRNCMP wcsncmp #define TSTRICMP _wcsicmp #define TSTRNCPY wcsncpy #define TSTRNCAT wcsncat #define TSTRCHR wcschr #define TSTRTOUL wcstoul #define TATOI _wtoi #define TFPRINTF fwprintf #define TSNPRINTF _snwprintf #define PUTENV _wputenv #define TZSET _tzset #define TSTAT _wstat #if defined(_MSC_VER) #define TSTRTOULL _wcstoui64 #define STAT_STR _stat64i32 #elif defined(__MINGW32__) #define TSTRTOULL wcstoull #define STAT_STR _stat #endif #define PRIcTSK _TSK_T("S") ///< sprintf macro to print a UTF-8 char string to TSK_TCHAR buffer #define PRIwTSK _TSK_T("s") ///< sprintf macro to print a UTF-16 wchar_t string to TSK_TCHAR buffer #define PRIttocTSK "S" ///< printf macro to print a TSK_TCHAR string to stderr or other char device #define PRIuSIZE "Iu" ///< printf macro to print a size_t value in Windows printf codes #define unlink _unlink #define GETOPT tsk_getopt // points to local wchar version #define OPTIND tsk_optind #define OPTARG tsk_optarg #define strtok_r(a,b,c) strtok(a,b) // Non-Win32 #else /* TSK_TCHAR is a 1-byte character */ typedef char TSK_TCHAR; ///< Character data type that is UTF-16 (wchar_t) in Windows and UTF-8 (char) in Unix #define _TSK_T(x) x #define TSTAT stat #define STAT_STR stat #define TSTRTOK strtok #define TSTRLEN strlen #define TSTRCMP strcmp #define TSTRNCMP strncmp #define TSTRICMP strcasecmp #define TSTRNCPY strncpy #define TSTRNCAT strncat #define TSTRCHR strchr #define TSTRTOUL strtoul #define TSTRTOULL strtoull #define TATOI atoi #define TFPRINTF fprintf #define TSNPRINTF snprintf #define PUTENV putenv #define TZSET tzset #define PRIcTSK _TSK_T("s") ///< sprintf macro to print a UTF-8 char string to TSK_TCHAR buffer #define PRIwTSK _TSK_T("S") ///< sprintf macro to print a UTF-16 wchar_t string to TSK_TCHAR buffer #define PRIttocTSK "s" ///< printf macro to print a TSK_TCHAR string to stderr or other char device #define PRIuSIZE "zu" ///< printf macro to print a size_t value in non-Windows printf codes #define GETOPT getopt // points to system char * version #define OPTIND optind // points to system char * variable #define OPTARG optarg // points to system char * variable #endif #endif sleuthkit-3.2.3/tsk3/base/tsk_parse.c000644 000765 000024 00000005600 11643647437 020302 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2005-2008 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ #include "tsk_base_i.h" /** * \file tsk_parse.c * Contains code to parse specific types of data from * the command line */ /** * \ingroup baselib * Parse a TSK_TCHAR block address string. * Note that the cnt\@size format is no longer supported. * Set the device sector size in img_open to set the block size. * * @param [in] a_offset_str The string version of the offset * @return -1 on error or block offset on success */ TSK_OFF_T tsk_parse_offset(const TSK_TCHAR * a_offset_str) { TSK_TCHAR offset_lcl[64], *offset_lcl_p; TSK_DADDR_T num_blk; TSK_TCHAR *cp; if (a_offset_str == NULL) { return 0; } if (TSTRLEN(a_offset_str) > 63) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OFFSET; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_parse: offset string is too long: %" PRIttocTSK, a_offset_str); return -1; } /* Make a local copy */ TSTRNCPY(offset_lcl, a_offset_str, 64); offset_lcl_p = offset_lcl; /* Check for the old x@y setup */ if (TSTRCHR(offset_lcl_p, '@') != NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OFFSET; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_parse: offset string format no longer supported. Use -b to specify sector size: %" PRIttocTSK, a_offset_str); return -1; } offset_lcl_p = offset_lcl; /* remove leading 0s */ while ((offset_lcl_p[0] != '\0') && (offset_lcl_p[0] == '0')) offset_lcl_p++; num_blk = 0; if (offset_lcl_p[0] != '\0') { num_blk = TSTRTOULL(offset_lcl_p, &cp, 0); if (*cp || *cp == *offset_lcl_p) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OFFSET; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_parse: invalid image offset: %" PRIttocTSK, offset_lcl_p); return -1; } } return num_blk; } /** * \ingroup baselib * Parse a TSK_TCHAR string of a partition byte offset and the * integer version of it. * * @param [in] a_pnum_str The string version of the address * @param [out] a_pnum The parsed integer version of the address * @return 1 on error and 0 on success */ int tsk_parse_pnum(const TSK_TCHAR * a_pnum_str, TSK_PNUM_T * a_pnum) { TSK_TCHAR *cp; if (a_pnum_str == NULL) { return 0; } *a_pnum = TSTRTOUL(a_pnum_str, &cp, 0); if (*cp || *cp == *a_pnum_str) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OFFSET; snprintf(tsk_errstr, TSK_ERRSTR_L, "tsk_parse: invalid partition address: %" PRIttocTSK, a_pnum_str); return 1; } return 0; } sleuthkit-3.2.3/tsk3/base/tsk_printf.c000644 000765 000024 00000005756 11643647437 020506 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file tsk_printf.c * These are printf wrappers that are needed so that we can * easily print in both Unix and Windows. For Unix, the * internal UTF-8 representation is kept and a normal printf * is performed. For Windows, the UTF-8 representation is first * converted to UTF-16 and then printed */ #include "tsk_base_i.h" #include /** \internal * Convert the UTF-8 printf arguments to UTF-16 and fill in the * printf types (%s, %d, etc.) * * @param wbuf wide char string to write result to * @param wlen number of characters in wbuf * @param msg printf message string * @param args Arguments to use when filling in message string * @returns 1 on error and 0 on success */ #ifdef TSK_WIN32 static int tsk_printf_conv(WCHAR * wbuf, int wlen, const char *msg, va_list * args) { char *cbuf; UTF8 *ptr8; UTF16 *ptr16; int retVal; size_t len, clen; wbuf[0] = '\0'; /* Allocate a UTF-8 buffer and process the printf args */ clen = wlen * 3; if (NULL == (cbuf = (char *) tsk_malloc(clen))) { return 1; } memset(cbuf, 0, clen); #ifdef _MSC_VER vsnprintf_s(cbuf, clen - 1, _TRUNCATE, msg, *args); #else vsnprintf(cbuf, clen - 1, msg, *args); #endif len = strlen(cbuf); //Convert to UTF-16 ptr8 = (UTF8 *) cbuf; ptr16 = (UTF16 *) wbuf; retVal = tsk_UTF8toUTF16((const UTF8 **) &ptr8, &ptr8[len + 1], &ptr16, &ptr16[wlen], TSKlenientConversion); if (retVal != TSKconversionOK) { *ptr16 = '\0'; if (tsk_verbose) tsk_fprintf(stderr, "tsk_printf_conv: error converting string to UTF-16\n"); } free(cbuf); return 0; } #endif /** * \ingroup baselib * fprintf wrapper function that takes UTF-8 strings as input * (on all platforms) and does what is necessary to output * strings in the correct encoding (UTF-8 on Unix and * UTF-16 on Windows). * * @param fd File to print to * @param msg printf message */ void tsk_fprintf(FILE * fd, const char *msg, ...) { va_list args; va_start(args, msg); #ifdef TSK_WIN32 { WCHAR wbuf[2048]; tsk_printf_conv(wbuf, 2048, msg, &args); fwprintf(fd, _TSK_T("%s"), wbuf); } #else vfprintf(fd, msg, args); #endif va_end(args); } /** * \ingroup baselib * printf wrapper function that takes UTF-8 strings as input * (on all platforms) and does what is necessary to output * strings in the correct encoding (UTF-8 on Unix and * UTF-16 on Windows). * * @param msg printf message */ void tsk_printf(const char *msg, ...) { va_list args; va_start(args, msg); #ifdef TSK_WIN32 { WCHAR wbuf[2048]; tsk_printf_conv(wbuf, 2048, msg, &args); wprintf(_TSK_T("%s"), wbuf); } #else vprintf(msg, args); #endif va_end(args); } sleuthkit-3.2.3/tsk3/base/tsk_stack.c000644 000765 000024 00000004445 11643647437 020303 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007 Brian Carrier. All Rights reserved * * This software is distributed under the Common Public License 1.0 */ #include "tsk_base_i.h" /** \file tsk_stack.c * Contains the functions to create and maintain a stack, which supports basic * popping, pushing, and searching. These are used for finding loops when * recursing structures */ /** * \ingroup baselib * Create a TSK_STACK structure * @returns Pointer to structure or NULL on error */ TSK_STACK * tsk_stack_create() { TSK_STACK *tsk_stack; if ((tsk_stack = (TSK_STACK *) tsk_malloc(sizeof(TSK_STACK))) == NULL) { return NULL; } tsk_stack->len = 64; tsk_stack->top = 0; if ((tsk_stack->vals = (uint64_t *) tsk_malloc(tsk_stack->len * sizeof(uint64_t))) == NULL) { free(tsk_stack); return NULL; } return tsk_stack; } /** * \ingroup baselib * Push a value to the top of TSK_STACK. * @param a_tsk_stack Pointer to stack to push onto * @param a_val Value to push on * @returns 1 on error */ uint8_t tsk_stack_push(TSK_STACK * a_tsk_stack, uint64_t a_val) { if (a_tsk_stack->top == a_tsk_stack->len) { a_tsk_stack->len += 64; if ((a_tsk_stack->vals = (uint64_t *) tsk_realloc((char *) a_tsk_stack->vals, a_tsk_stack->len * sizeof(uint64_t))) == NULL) { return 1; } } a_tsk_stack->vals[a_tsk_stack->top++] = a_val; return 0; } /** * \ingroup baselib * Pop a value from the top of the stack. * @param a_tsk_stack Stack to pop from */ void tsk_stack_pop(TSK_STACK * a_tsk_stack) { a_tsk_stack->top--; } /** * \ingroup baselib * Search a TSK_STACK for a given value * @param a_tsk_stack Stack to search * @param a_val Value to search for * @returns 1 if found and 0 if not */ uint8_t tsk_stack_find(TSK_STACK * a_tsk_stack, uint64_t a_val) { size_t i; for (i = 0; i < a_tsk_stack->top; i++) { if (a_tsk_stack->vals[i] == a_val) return 1; } return 0; } /** * \ingroup baselib * Free an allocated TSK_STACK structure * @param a_tsk_stack Stack to free */ void tsk_stack_free(TSK_STACK * a_tsk_stack) { free(a_tsk_stack->vals); free(a_tsk_stack); } sleuthkit-3.2.3/tsk3/base/tsk_unicode.c000644 000765 000024 00000045475 11643647437 020634 0ustar00carrierstaff000000 000000 /* * Copyright 2001-2004 Unicode, Inc. * * Disclaimer * * This source code is provided as is by Unicode, Inc. No claims are * made as to fitness for any particular purpose. No warranties of any * kind are expressed or implied. The recipient agrees to determine * applicability of information provided. If this file has been * purchased on magnetic or optical media from Unicode, Inc., the * sole remedy for any claim will be exchange of defective media * within 90 days of receipt. * * Limitations on Rights to Redistribute This Code * * Unicode, Inc. hereby grants the right to freely use the information * supplied in this file in the creation of products supporting the * Unicode Standard, and to make copies of this file in any form * for internal or external distribution as long as this notice * remains attached. */ /* --------------------------------------------------------------------- Conversions between UTF32, UTF-16, and UTF-8. Source code file. Author: Mark E. Davis, 1994. Rev History: Rick McGowan, fixes & updates May 2001. Sept 2001: fixed const & error conditions per mods suggested by S. Parent & A. Lillich. June 2002: Tim Dodd added detection and handling of incomplete source sequences, enhanced error detection, added casts to eliminate compiler warnings. July 2003: slight mods to back out aggressive FFFE detection. Jan 2004: updated switches in from-UTF8 conversions. Oct 2004: updated to use TSK_UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. See the header file "ConvertUTF.h" for complete documentation. ------------------------------------------------------------------------ */ /** \file tsk_unicode.c * A local copy of the Unicode conversion routines from unicode.org. */ #include "tsk_base_i.h" /* Some fundamental constants */ typedef unsigned long UTF32; /* at least 32 bits */ #define TSK_UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD #define TSK_UNI_MAX_BMP (UTF32)0x0000FFFF #define TSK_UNI_MAX_UTF16 (UTF32)0x0010FFFF #define TSK_UNI_MAX_UTF32 (UTF32)0x7FFFFFFF #define TSK_UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF static const int halfShift = 10; /* used for shifting by 10 bits */ static const UTF32 halfBase = 0x0010000UL; static const UTF32 halfMask = 0x3FFUL; #define UNI_SUR_HIGH_START (UTF32)0xD800 #define UNI_SUR_HIGH_END (UTF32)0xDBFF #define UNI_SUR_LOW_START (UTF32)0xDC00 #define UNI_SUR_LOW_END (UTF32)0xDFFF #define false 0 #define true 1 /* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */ /* * Index into the table below with the first byte of a UTF-8 sequence to * get the number of trailing bytes that are supposed to follow it. * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is * left as-is for anyone who may want to do such conversion, which was * allowed in earlier algorithms. */ static const char trailingBytesForUTF8[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; /* * Magic values subtracted from a buffer value during UTF8 conversion. * This table contains as many values as there might be trailing bytes * in a UTF-8 sequence. */ static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; /* * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed * into the first byte, depending on how many bytes follow. There are * as many entries in this table as there are UTF-8 sequence types. * (I.e., one byte sequence, two byte... etc.). Remember that sequencs * for *legal* UTF-8 will be 4 or fewer bytes total. */ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; /* --------------------------------------------------------------------- */ /* The interface converts a whole buffer to avoid function-call overhead. * Constants have been gathered. Loops & conditionals have been removed as * much as possible for efficiency, in favor of drop-through switches. * (See "Note A" at the bottom of the file for equivalent code.) * If your compiler supports it, the "isLegalUTF8" call can be turned * into an inline function. */ /* --------------------------------------------------------------------- */ /** * \ingroup baselib * Convert a UTF-16 string to UTF-8. * @param endian Endian ordering flag of UTF-16 text * @param sourceStart Pointer to pointer to start of UTF-16 string. Will be updated to last char proccessed. * @param sourceEnd Pointer to one entry past end of UTF-16 string * @param targetStart Pointer to pointer to place where UTF-8 string should be written. Will be updated to next place to write to. * @param targetEnd Pointer to end of UTF-8 buffer * @param flags Flags used during conversion * @returns error code */ TSKConversionResult tsk_UTF16toUTF8(TSK_ENDIAN_ENUM endian, const UTF16 ** sourceStart, const UTF16 * sourceEnd, UTF8 ** targetStart, UTF8 * targetEnd, TSKConversionFlags flags) { TSKConversionResult result = TSKconversionOK; const UTF16 *source = *sourceStart; UTF8 *target = *targetStart; while (source < sourceEnd) { UTF32 ch; unsigned short bytesToWrite = 0; const UTF32 byteMask = 0xBF; const UTF32 byteMark = 0x80; const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ ch = tsk_getu16(endian, (uint8_t *) source); source++; /* If we have a surrogate pair, convert to UTF32 first. */ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { /* If the 16 bits following the high surrogate are in the source buffer... */ if (source < sourceEnd) { UTF32 ch2 = tsk_getu16(endian, (uint8_t *) source); ++source; /* If it's a low surrogate, convert to UTF32. */ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + (ch2 - UNI_SUR_LOW_START) + halfBase; } else if (flags == TSKstrictConversion) { /* it's an unpaired high surrogate */ result = TSKsourceIllegal; break; } // replace with another character else { ch = '^'; } } else { /* We don't have the 16 bits following the high surrogate. */ --source; /* return to the high surrogate */ result = TSKsourceExhausted; break; } } /* UTF-16 surrogate values are illegal in UTF-32 */ else if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { if (flags == TSKstrictConversion) { --source; /* return to the illegal value itself */ result = TSKsourceIllegal; break; } // replace with another character else { ch = '^'; } } /* Figure out how many bytes the result will require */ if (ch < (UTF32) 0x80) { bytesToWrite = 1; } else if (ch < (UTF32) 0x800) { bytesToWrite = 2; } else if (ch < (UTF32) 0x10000) { bytesToWrite = 3; } else if (ch < (UTF32) 0x110000) { bytesToWrite = 4; } else { bytesToWrite = 3; ch = TSK_UNI_REPLACEMENT_CHAR; } target += bytesToWrite; if (target > targetEnd) { source = oldSource; /* Back up source pointer! */ target -= bytesToWrite; result = TSKtargetExhausted; break; } switch (bytesToWrite) { /* note: everything falls through. */ case 4: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 3: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 2: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); } target += bytesToWrite; } *sourceStart = source; *targetStart = target; return result; } /** * \ingroup baselib * Convert a UTF-16 string in local endian ordering to UTF-8. * @param sourceStart Pointer to pointer to start of UTF-16 string. Will be updated to last char proccessed. * @param sourceEnd Pointer to one entry past end of UTF-16 string * @param targetStart Pointer to pointer to place where UTF-8 string should be written. Will be updated to next place to write to. * @param targetEnd Pointer to end of UTF-8 buffer * @param flags Flags used during conversion * @returns error code */ TSKConversionResult tsk_UTF16toUTF8_lclorder(const UTF16 ** sourceStart, const UTF16 * sourceEnd, UTF8 ** targetStart, UTF8 * targetEnd, TSKConversionFlags flags) { TSKConversionResult result = TSKconversionOK; const UTF16 *source = *sourceStart; UTF8 *target = *targetStart; while (source < sourceEnd) { UTF32 ch; unsigned short bytesToWrite = 0; const UTF32 byteMask = 0xBF; const UTF32 byteMark = 0x80; const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ ch = *source++; /* If we have a surrogate pair, convert to UTF32 first. */ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { /* If the 16 bits following the high surrogate are in the source buffer... */ if (source < sourceEnd) { UTF32 ch2 = *source; source++; /* If it's a low surrogate, convert to UTF32. */ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + (ch2 - UNI_SUR_LOW_START) + halfBase; } else if (flags == TSKstrictConversion) { /* it's an unpaired high surrogate */ result = TSKsourceIllegal; break; } // replace with another character else { ch = '^'; } } else { /* We don't have the 16 bits following the high surrogate. */ --source; /* return to the high surrogate */ result = TSKsourceExhausted; break; } } /* UTF-16 surrogate values are illegal in UTF-32 */ else if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { if (flags == TSKstrictConversion) { --source; /* return to the illegal value itself */ result = TSKsourceIllegal; break; } // replace with another character else { ch = '^'; } } /* Figure out how many bytes the result will require */ if (ch < (UTF32) 0x80) { bytesToWrite = 1; } else if (ch < (UTF32) 0x800) { bytesToWrite = 2; } else if (ch < (UTF32) 0x10000) { bytesToWrite = 3; } else if (ch < (UTF32) 0x110000) { bytesToWrite = 4; } else { bytesToWrite = 3; ch = TSK_UNI_REPLACEMENT_CHAR; } target += bytesToWrite; if (target > targetEnd) { source = oldSource; /* Back up source pointer! */ target -= bytesToWrite; result = TSKtargetExhausted; break; } switch (bytesToWrite) { /* note: everything falls through. */ case 4: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 3: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 2: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); } target += bytesToWrite; } *sourceStart = source; *targetStart = target; return result; } /* --------------------------------------------------------------------- */ /* * Utility routine to tell whether a sequence of bytes is legal UTF-8. * This must be called with the length pre-determined by the first byte. * If not calling this from ConvertUTF8to*, then the length can be set by: * length = trailingBytesForUTF8[*source]+1; * and the sequence is illegal right away if there aren't that many bytes * available. * If presented with a length > 4, this returns false. The Unicode * definition of UTF-8 goes up to 4-byte sequences. */ static Boolean isLegalUTF8(const UTF8 * source, int length) { UTF8 a; const UTF8 *srcptr = source + length; switch (length) { default: return false; /* Everything else falls through when "true"... */ case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; case 2: if ((a = (*--srcptr)) > 0xBF) return false; switch (*source) { /* no fall-through in this inner switch */ case 0xE0: if (a < 0xA0) return false; break; case 0xED: if (a > 0x9F) return false; break; case 0xF0: if (a < 0x90) return false; break; case 0xF4: if (a > 0x8F) return false; break; default: if (a < 0x80) return false; } case 1: if (*source >= 0x80 && *source < 0xC2) return false; } if (*source > 0xF4) return false; return true; } /* --------------------------------------------------------------------- */ /* * Exported function to return whether a UTF-8 sequence is legal or not. * This is not used here; it's just exported. */ Boolean tsk_isLegalUTF8Sequence(const UTF8 * source, const UTF8 * sourceEnd) { int length = trailingBytesForUTF8[*source] + 1; if (source + length > sourceEnd) { return false; } return isLegalUTF8(source, length); } /* --------------------------------------------------------------------- */ /** * \ingroup baselib * Convert a UTF-8 string to UTF-16 (in local endian ordering). * @param sourceStart Pointer to pointer to start of UTF-8 string. Will be updated to last char proccessed. * @param sourceEnd Pointer to one entry past end of UTF-8 string * @param targetStart Pointer to pointer to place where UTF-16 string should be written. Will be updated to next place to write to. * @param targetEnd Pointer to end of UTF-16 buffer * @param flags Flags used during conversion * @returns error code */ TSKConversionResult tsk_UTF8toUTF16(const UTF8 ** sourceStart, const UTF8 * sourceEnd, UTF16 ** targetStart, UTF16 * targetEnd, TSKConversionFlags flags) { TSKConversionResult result = TSKconversionOK; const UTF8 *source = *sourceStart; UTF16 *target = *targetStart; while (source < sourceEnd) { UTF32 ch = 0; unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; if (source + extraBytesToRead >= sourceEnd) { result = TSKsourceExhausted; break; } /* Do this check whether lenient or strict */ if (!isLegalUTF8(source, extraBytesToRead + 1)) { result = TSKsourceIllegal; break; } /* * The cases all fall through. See "Note A" below. */ switch (extraBytesToRead) { case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ case 3: ch += *source++; ch <<= 6; case 2: ch += *source++; ch <<= 6; case 1: ch += *source++; ch <<= 6; case 0: ch += *source++; } ch -= offsetsFromUTF8[extraBytesToRead]; if (target >= targetEnd) { source -= (extraBytesToRead + 1); /* Back up source pointer! */ result = TSKtargetExhausted; break; } if (ch <= TSK_UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ /* UTF-16 surrogate values are illegal in UTF-32 */ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { if (flags == TSKstrictConversion) { source -= (extraBytesToRead + 1); /* return to the illegal value itself */ result = TSKsourceIllegal; break; } else { *target++ = TSK_UNI_REPLACEMENT_CHAR; } } else { *target++ = (UTF16) ch; /* normal case */ } } else if (ch > TSK_UNI_MAX_UTF16) { if (flags == TSKstrictConversion) { result = TSKsourceIllegal; source -= (extraBytesToRead + 1); /* return to the start */ break; /* Bail out; shouldn't continue */ } else { *target++ = TSK_UNI_REPLACEMENT_CHAR; } } else { /* target is a character in range 0xFFFF - 0x10FFFF. */ if (target + 1 >= targetEnd) { source -= (extraBytesToRead + 1); /* Back up source pointer! */ result = TSKtargetExhausted; break; } ch -= halfBase; *target++ = (UTF16) ((ch >> halfShift) + UNI_SUR_HIGH_START); *target++ = (UTF16) ((ch & halfMask) + UNI_SUR_LOW_START); } } *sourceStart = source; *targetStart = target; return result; } sleuthkit-3.2.3/tsk3/base/tsk_version.c000644 000765 000024 00000001434 11643647437 020656 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit * * Brian Carrier [carrier sleuthkit [dot] org] * Copyright (c) 2007 Brian Carrier. All rights reserved * * This software is distributed under the Common Public License 1.0 */ /** \file tsk_version.c * Contains functions to print and obtain the library version. */ #include "tsk_base_i.h" /** * \ingroup baselib * Print the library name and version to a handle (such as "The Sleuth Kit ver 1.00"). * @param hFile Handle to print to */ void tsk_version_print(FILE * hFile) { tsk_fprintf(hFile, "The Sleuth Kit ver %s\n", TSK_VERSION_STR); return; } /** * \ingroup baselib * Return the library version as a string. * @returns String version of version (1.00 for example) */ const char * tsk_version_get_str() { return TSK_VERSION_STR; } sleuthkit-3.2.3/tsk3/base/XGetopt.c000644 000765 000024 00000016223 11643647437 017704 0ustar00carrierstaff000000 000000 /* * The Sleuth Kit */ // XGetopt.cpp Version 1.2 // // Author: Hans Dietrich // hdietrich2@hotmail.com // // Description: // XGetopt.cpp implements getopt(), a function to parse command lines. // // History // Version 1.2 - 2003 May 17 // - Added Unicode support // // Version 1.1 - 2002 March 10 // - Added example to XGetopt.cpp module header // // This software is released into the public domain. // You are free to use it in any way you like. // // This software is provided "as is" with no expressed // or implied warranty. I accept no liability for any // damage or loss of business that this software may cause. // /////////////////////////////////////////////////////////////////////////////// /** \file XGetopt.c * Parses arguments for win32 programs -- written by Hans Dietrich. */ #include "tsk_base_i.h" #ifdef TSK_WIN32 /////////////////////////////////////////////////////////////////////////////// // if you are using precompiled headers then include this line: //#include "stdafx.h" /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // if you are not using precompiled headers then include these lines: #include /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // X G e t o p t . c p p // // // NAME // getopt -- parse command line options // // SYNOPSIS // int getopt(int argc, TSK_TCHAR *argv[], TSK_TCHAR *optstring) // // extern TSK_TCHAR *optarg; // extern int optind; // // DESCRIPTION // The getopt() function parses the command line arguments. Its // arguments argc and argv are the argument count and array as // passed into the application on program invocation. In the case // of Visual C++ programs, argc and argv are available via the // variables __argc and __argv (double underscores), respectively. // getopt returns the next option letter in argv that matches a // letter in optstring. (Note: Unicode programs should use // __targv instead of __argv. Also, all character and string // literals should be enclosed in _TSK_T( ) ). // // optstring is a string of recognized option letters; if a letter // is followed by a colon, the option is expected to have an argument // that may or may not be separated from it by white space. optarg // is set to point to the start of the option argument on return from // getopt. // // Option letters may be combined, e.g., "-ab" is equivalent to // "-a -b". Option letters are case sensitive. // // getopt places in the external variable optind the argv index // of the next argument to be processed. optind is initialized // to 0 before the first call to getopt. // // When all options have been processed (i.e., up to the first // non-option argument), getopt returns EOF, optarg will point // to the argument, and optind will be set to the argv index of // the argument. If there are no non-option arguments, optarg // will be set to NULL. // // The special option "--" may be used to delimit the end of the // options; EOF will be returned, and "--" (and everything after it) // will be skipped. // // RETURN VALUE // For option letters contained in the string optstring, getopt // will return the option letter. getopt returns a question mark (?) // when it encounters an option letter not included in optstring. // EOF is returned when processing is finished. // // BUGS // 1) Long options are not supported. // 2) The GNU double-colon extension is not supported. // 3) The environment variable POSIXLY_CORRECT is not supported. // 4) The + syntax is not supported. // 5) The automatic permutation of arguments is not supported. // 6) This implementation of getopt() returns EOF if an error is // encountered, instead of -1 as the latest standard requires. // // EXAMPLE // BOOL CMyApp::ProcessCommandLine(int argc, TSK_TCHAR *argv[]) // { // int c; // // while ((c = getopt(argc, argv, _TSK_T("aBn:"))) != EOF) // { // switch (c) // { // case _TSK_T('a'): // TRACE(_TSK_T("option a\n")); // // // // set some flag here // // // break; // // case _TSK_T('B'): // TRACE( _TSK_T("option B\n")); // // // // set some other flag here // // // break; // // case _TSK_T('n'): // TRACE(_TSK_T("option n: value=%d\n"), atoi(optarg)); // // // // do something with value here // // // break; // // case _TSK_T('?'): // TRACE(_TSK_T("ERROR: illegal option %s\n"), argv[optind-1]); // return FALSE; // break; // // default: // TRACE(_TSK_T("WARNING: no handler for option %c\n"), c); // return FALSE; // break; // } // } // // // // check for non-option args here // // // return TRUE; // } // /////////////////////////////////////////////////////////////////////////////// TSK_TCHAR *tsk_optarg; // global argument pointer int tsk_optind = 0; // global argv index int tsk_getopt(int argc, TSK_TCHAR * const argv[], const TSK_TCHAR * optstring) { static TSK_TCHAR *next = NULL; TSK_TCHAR c, *cp; if (tsk_optind == 0) next = NULL; tsk_optarg = NULL; if (next == NULL || *next == _TSK_T('\0')) { if (tsk_optind == 0) tsk_optind++; if (tsk_optind >= argc || argv[tsk_optind][0] != _TSK_T('-') || argv[tsk_optind][1] == _TSK_T('\0')) { tsk_optarg = NULL; if (tsk_optind < argc) tsk_optarg = argv[tsk_optind]; return EOF; } if (TSTRCMP(argv[tsk_optind], _TSK_T("--")) == 0) { tsk_optind++; tsk_optarg = NULL; if (tsk_optind < argc) tsk_optarg = argv[tsk_optind]; return EOF; } next = argv[tsk_optind]; next++; // skip past - tsk_optind++; } c = *next++; cp = (TSK_TCHAR *) TSTRCHR(optstring, c); if (cp == NULL || c == _TSK_T(':')) return _TSK_T('?'); cp++; if (*cp == _TSK_T(':')) { if (*next != _TSK_T('\0')) { tsk_optarg = next; next = NULL; } else if (tsk_optind < argc) { tsk_optarg = argv[tsk_optind]; tsk_optind++; } else { return _TSK_T('?'); } } return c; } #endif sleuthkit-3.2.3/tsk3/auto/.indent.pro000644 000765 000024 00000000036 11643647436 020257 0ustar00carrierstaff000000 000000 -kr -psl -nce -ip2 -nlp -nut sleuthkit-3.2.3/tsk3/auto/auto.cpp000644 000765 000024 00000042204 11643647437 017656 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2010-2011 Brian Carrier. All Rights reserved ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file auto.cpp * Contains C++ code that creates the base file extraction automation class. */ #include "tsk_auto_i.h" #include "tsk3/fs/tsk_fatfs.h" TskAuto::TskAuto() { m_img_info = NULL; m_tag = TSK_AUTO_TAG; m_volFilterFlags = TSK_VS_PART_FLAG_ALLOC; m_fileFilterFlags = TSK_FS_DIR_WALK_FLAG_RECURSE; } TskAuto::~TskAuto() { closeImage(); m_tag = 0; } /** * Opens the disk image to be analyzed. This must be called before any * of the findFilesInXXX() methods. * * @param a_numImg The number of images to open (will be > 1 for split images). * @param a_images The path to the image files (the number of files must * be equal to num_img and they must be in a sorted order) * @param a_imgType The disk image type (can be autodetection) * @param a_sSize Size of device sector in bytes (or 0 for default) * @returns 1 on error, 0 on success */ uint8_t TskAuto::openImage(int a_numImg, const TSK_TCHAR * const a_images[], TSK_IMG_TYPE_ENUM a_imgType, unsigned int a_sSize) { if (m_img_info) closeImage(); m_internalOpen = true; m_img_info = tsk_img_open(a_numImg, a_images, a_imgType, a_sSize); if (m_img_info) return 0; else return 1; } /** * Uses the already opened image for future analysis. This must be called before any * of the findFilesInXXX() methods. Note that the TSK_IMG_INFO will not * be freed when the TskAuto class is closed. * @param a_img_info Handle to an already opened disk image. * @returns 1 on error and 0 on success */ uint8_t TskAuto::openImage(TSK_IMG_INFO *a_img_info) { if (m_img_info) closeImage(); m_internalOpen = false; m_img_info = a_img_info; return 0; } /** * Closes the handles to the open disk image. Should be called after * you have completed analysis of the image. */ void TskAuto::closeImage() { if ((m_img_info) && (m_internalOpen)) { tsk_img_close(m_img_info); } m_img_info = NULL; } /** * Set the attributes for the volumes that should be processed. * The default settings are for Allocated Non-Meta volumes only. * This must be called before the findFilesInXX() method. * @param vs_flags Flags to use for filtering */ void TskAuto::setVolFilterFlags(TSK_VS_PART_FLAG_ENUM vs_flags) { m_volFilterFlags = vs_flags; } /** * Set the attributes for the files that should be processed. * The default settings are for all files (allocated and deleted). * This must be called before the findFilesInXX() method. * @param file_flags Flags to use for filtering */ void TskAuto::setFileFilterFlags(TSK_FS_DIR_WALK_FLAG_ENUM file_flags) { m_fileFilterFlags = file_flags; } /** * @return The size of the image in bytes or -1 if the * image is not open. */ TSK_OFF_T TskAuto::getImageSize() const { if (m_img_info == NULL) return -1; return m_img_info->size; } /** * Starts in sector 0 of the opened disk images and looks for a * volume or file system. Will call processFile() on each file * that is found. * @return 1 on error, 0 on success */ uint8_t TskAuto::findFilesInImg() { if (!m_img_info) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_NOTOPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "findFilesInImg\n"); return 1; } return findFilesInVs(0); } /** \internal * Volume system walk callback function that will analyze * each volume to find a file system. */ TSK_WALK_RET_ENUM TskAuto::vsWalkCb(TSK_VS_INFO * a_vs_info, const TSK_VS_PART_INFO * a_vs_part, void *a_ptr) { TskAuto *tsk = (TskAuto *) a_ptr; if (tsk->m_tag != TSK_AUTO_TAG) return TSK_WALK_STOP; TSK_FILTER_ENUM retval1 = tsk->filterVol(a_vs_part); if (retval1 == TSK_FILTER_SKIP) return TSK_WALK_CONT; else if (retval1 == TSK_FILTER_STOP) return TSK_WALK_STOP; TSK_RETVAL_ENUM retval2 = tsk->findFilesInFsRet(a_vs_part->start * a_vs_part->vs->block_size, TSK_FS_TYPE_DETECT); if (retval2 == TSK_STOP) { return TSK_WALK_STOP; } else if (retval2 != TSK_OK) { // if we return ERROR here, then the walk will stop. But, the // error could just be because we looked into an unallocated volume. // do any special error handling / reporting here. tsk_error_reset(); } return TSK_WALK_CONT; } /** * Starts in a specified byte offset of the opened disk images and looks for a * volume system or file system. Will call processFile() on each file * that is found. * @param a_start Byte offset to start analyzing from. * @param a_vtype Volume system type to analyze * @return 1 on error, 0 on success */ uint8_t TskAuto::findFilesInVs(TSK_OFF_T a_start, TSK_VS_TYPE_ENUM a_vtype) { if (!m_img_info) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_NOTOPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "findFilesInVs\n"); return 1; } TSK_VS_INFO * vs_info; // USE mm_walk to get the volumes if ((vs_info = tsk_vs_open(m_img_info, a_start, a_vtype)) == NULL) { char msg[1024]; snprintf(msg, 1024, "Unable to open volume system at offset %"PRIuOFF" (%s)", a_start, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); /* There was no volume system, but there could be a file system */ tsk_error_reset(); if (findFilesInFs(a_start)) { return 1; } } else { TSK_FILTER_ENUM retval = filterVs(vs_info); if (retval == TSK_FILTER_STOP) return TSK_STOP; else if (retval == TSK_FILTER_SKIP) return TSK_OK; /* Walk the allocated volumes (skip metadata and unallocated volumes) */ if (tsk_vs_part_walk(vs_info, 0, vs_info->part_count - 1, m_volFilterFlags, vsWalkCb, this)) { tsk_vs_close(vs_info); return 1; } tsk_vs_close(vs_info); } return 0; } /** * Starts at a specified byte offset of the opened disk images and looks * for a volume or file system. Will call processFile() on each file * that is found. * @param a_start Byte offset to start analyzing from. * @return 1 on error, 0 on success */ uint8_t TskAuto::findFilesInVs(TSK_OFF_T a_start) { return findFilesInVs(a_start, TSK_VS_TYPE_DETECT); } /** * Starts at a specified byte offset of the opened disk images and looks * for a file system. Will call processFile() on each file that is found. * Same as findFilesInFs, but gives more detailed return values. * @param a_start Byte offset to start analyzing from. * @param a_ftype File system type. * @returns values that allow the caller to differentiate stop from ok. */ TSK_RETVAL_ENUM TskAuto::findFilesInFsRet(TSK_OFF_T a_start, TSK_FS_TYPE_ENUM a_ftype) { if (!m_img_info) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_NOTOPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "findFilesInFsRet\n"); return TSK_ERR; } TSK_FS_INFO * fs_info; /* Try it as a file system */ if ((fs_info = tsk_fs_open_img(m_img_info, a_start, a_ftype)) == NULL) { char msg[1024]; snprintf(msg, 1024, "Unable to open file system at offset %"PRIuOFF" (%s)", a_start, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); /* We could do some carving on the volume data at this point */ return TSK_ERR; } TSK_RETVAL_ENUM retval = findFilesInFsInt(fs_info, fs_info->root_inum); tsk_fs_close(fs_info); return retval; } /** * Starts at a specified byte offset of the opened disk images and looks * for a file system. Will call processFile() on each file that is found. * * @param a_start Byte offset of file system starting location. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_OFF_T a_start) { if (findFilesInFsRet(a_start, TSK_FS_TYPE_DETECT) == TSK_ERR) return 1; else return 0; } /** * Processes the file system represented by the given TSK_FS_INFO * pointer. Will Call processFile() on each file that is found. * * @param a_fs_info Pointer to a previously opened file system. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_FS_INFO *a_fs_info) { if (a_fs_info == NULL) return 1; if (findFilesInFsInt(a_fs_info, a_fs_info->root_inum) == TSK_ERR) return 1; else return 0; } /** * Starts at a specified byte offset of the opened disk images and looks * for a file system. Will call processFile() on each file that is found. * * @param a_start Byte offset of file system starting location. * @param a_ftype Type of file system that is located at the offset. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_OFF_T a_start, TSK_FS_TYPE_ENUM a_ftype) { if (findFilesInFsRet(a_start, a_ftype) == TSK_ERR) return 1; else return 0; } /** * Starts at a specified byte offset of the opened disk images and looks for a * file system. Will start processing the file system at a specified * file system. Will call processFile() on each file * that is found in that directory. * * @param a_start Byte offset of file system starting location. * @param a_ftype Type of file system that will be analyzed. * @param a_inum inum to start walking files system at. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_OFF_T a_start, TSK_FS_TYPE_ENUM a_ftype, TSK_INUM_T a_inum) { if (!m_img_info) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_NOTOPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "findFilesInFs\n"); return 1; } TSK_FS_INFO * fs_info; /* Try it as a file system */ if ((fs_info = tsk_fs_open_img(m_img_info, a_start, a_ftype)) == NULL) { char msg[1024]; snprintf(msg, 1024, "Unable to open file system at offset %"PRIuOFF" (%s)", a_start, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); /* We could do some carving on the volume data at this point */ return 1; } TSK_RETVAL_ENUM retval = findFilesInFsInt(fs_info, a_inum); tsk_fs_close(fs_info); if (retval == TSK_ERR) return 1; else return 0; } /** * Starts at a specified byte offset of the opened disk images and looks for a * file system. Will start processing the file system at a specified * file system. Will call processFile() on each file * that is found in that directory. * * @param a_start Byte offset of file system starting location. * @param a_inum inum to start walking files system at. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_OFF_T a_start, TSK_INUM_T a_inum) { return TskAuto::findFilesInFs(a_start, TSK_FS_TYPE_DETECT, a_inum); } /** \internal * file name walk callback. Walk the contents of each file * that is found. */ TSK_WALK_RET_ENUM TskAuto::dirWalkCb(TSK_FS_FILE * a_fs_file, const char *a_path, void *a_ptr) { TskAuto *tsk = (TskAuto *) a_ptr; if (tsk->m_tag != TSK_AUTO_TAG) return TSK_WALK_STOP; TSK_RETVAL_ENUM retval = tsk->processFile(a_fs_file, a_path); if (retval != TSK_OK){ if(retval == TSK_STOP) return TSK_WALK_STOP; else return TSK_WALK_ERROR; } else return TSK_WALK_CONT; } /* Internal method that the other findFilesInFs can call after they * have opened FS_INFO. */ TSK_RETVAL_ENUM TskAuto::findFilesInFsInt(TSK_FS_INFO * a_fs_info, TSK_INUM_T a_inum) { TSK_FILTER_ENUM retval = filterFs(a_fs_info); if (retval == TSK_FILTER_STOP) return TSK_STOP; else if (retval == TSK_FILTER_SKIP) return TSK_OK; /* Walk the files, starting at the given inum */ if (tsk_fs_dir_walk(a_fs_info, a_inum, (TSK_FS_DIR_WALK_FLAG_ENUM) (TSK_FS_DIR_WALK_FLAG_RECURSE | m_fileFilterFlags), dirWalkCb, this)) { char msg[1024]; snprintf(msg, 1024, "Error walking directory in file system at offset %"PRIuOFF" (%s)", a_fs_info->offset, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); return TSK_ERR; } /* We could do some analysis of unallocated blocks at this point... */ return TSK_OK; } /** * Method that can be used from within processFile() to look at each * attribute that a file may have. This will call the processAttribute() * method (which you must implement) on each of the attributes in the file. * @param fs_file file details * @param path full path of parent directory * @returns 1 if the file system processing should stop and not process more files. */ TSK_RETVAL_ENUM TskAuto::processAttributes(TSK_FS_FILE * fs_file, const char *path) { int count = tsk_fs_file_attr_getsize(fs_file), i; for (i = 0; i < count; i++) { TSK_RETVAL_ENUM retval = processAttribute(fs_file, tsk_fs_file_attr_get_idx(fs_file, i), path); if (retval != TSK_OK) return retval; } return TSK_OK; } /** * Utility method to help determine if a file is an NTFS file system file (such as $MFT). * * @returns 1 if the file is an NTFS System file, 0 if not. */ uint8_t TskAuto::isNtfsSystemFiles(TSK_FS_FILE * a_fs_file, const char *a_path) { if ((a_fs_file) && (a_fs_file->fs_info) && (TSK_FS_TYPE_ISNTFS(a_fs_file->fs_info->ftype)) && (a_fs_file->name) && (a_fs_file->name->name[0] == '$') && (a_fs_file->name->meta_addr < 20)) return 1; else return 0; } /** * Utility method to help determine if a file is a FAT file system file (such as $MBR). * * @returns 1 if the file is an FAT System file, 0 if not. */ uint8_t TskAuto::isFATSystemFiles(TSK_FS_FILE * a_fs_file) { if ((a_fs_file) && (a_fs_file->fs_info) && (TSK_FS_TYPE_ISFAT(a_fs_file->fs_info->ftype)) && (a_fs_file->name->meta_addr == FATFS_MBRINO(a_fs_file->fs_info) || a_fs_file->name->meta_addr == FATFS_FAT1INO(a_fs_file->fs_info) || a_fs_file->name->meta_addr == FATFS_FAT2INO(a_fs_file->fs_info))) return 1; else return 0; } /** * Utility method to help determine if a file is a . or .. directory. * * @returns 1 if the file is a dot directory, 0 if not. */ uint8_t TskAuto::isDotDir(TSK_FS_FILE * a_fs_file, const char *a_path) { if ((!a_fs_file) || (!a_fs_file->name) || (a_fs_file->name->type != TSK_FS_NAME_TYPE_DIR)) return 0; if ((a_fs_file->name->name_size >= 2) && (a_fs_file->name->name[0] == '.') && ((a_fs_file->name->name[1] == '\0') || ((a_fs_file->name->name_size > 2) && (a_fs_file->name->name[1] == '.') && (a_fs_file->name->name[2] == '\0')))) return 1; else return 0; } /** * Utility method to help determine if a file is a directory. * * @returns 1 if the file is a directory, 0 if not. */ uint8_t TskAuto::isDir(TSK_FS_FILE * a_fs_file) { if ((a_fs_file) && (a_fs_file->name)) { if (a_fs_file->name->type == TSK_FS_NAME_TYPE_DIR) { return 1; } else if (a_fs_file->name->type == TSK_FS_NAME_TYPE_UNDEF) { if ((a_fs_file->meta) && (a_fs_file->meta->type == TSK_FS_META_TYPE_DIR)) { return 1; } } } return 0; } /** * Utility method to help determine if a file is a file (and not a directory). * * @returns 1 if the file is a file, 0 if not. */ uint8_t TskAuto::isFile(TSK_FS_FILE * a_fs_file) { if ((a_fs_file) && (a_fs_file->name)) { if (a_fs_file->name->type == TSK_FS_NAME_TYPE_REG) { return 1; } else if (a_fs_file->name->type == TSK_FS_NAME_TYPE_UNDEF) { if ((a_fs_file->meta) && (a_fs_file->meta->type == TSK_FS_META_TYPE_REG)) { return 1; } } } return 0; } /** * Utility method to help determine if an attribute is the default type for the file/dir. * * @returns 1 if the attribute is a default type, 0 if not. */ uint8_t TskAuto::isDefaultType(TSK_FS_FILE * a_fs_file, const TSK_FS_ATTR * a_fs_attr) { if ((a_fs_file) && (a_fs_file->fs_info) && (a_fs_file->fs_info->get_default_attr_type(a_fs_file) == a_fs_attr->type)) return 1; else return 0; } /** * Utility method to help determine if an attribute is non-resident (meaning it uses blocks to store data) * * @returns 1 if the attribute is non-resident, 0 if not. */ uint8_t TskAuto::isNonResident(const TSK_FS_ATTR * a_fs_attr) { if ((a_fs_attr) && (a_fs_attr->flags & TSK_FS_ATTR_NONRES)) return 1; else return 0; } sleuthkit-3.2.3/tsk3/auto/auto_db.cpp000644 000765 000024 00000055032 11643647437 020326 0ustar00carrierstaff000000 000000 /* ** The Sleuth Kit ** ** Brian Carrier [carrier sleuthkit [dot] org] ** Copyright (c) 2010 Brian Carrier. All Rights reserved ** ** This software is distributed under the Common Public License 1.0 ** */ /** * \file auto_db.cpp * Contains code to populate SQLite database with volume and file system information. */ #include "tsk_auto_i.h" #include "sqlite3.h" #include #define TSK_SCHEMA_VER 1 TskAutoDb::TskAutoDb() { m_db = NULL; m_curFsId = 0; m_curVsId = 0; m_blkMapFlag = false; m_vsFound = false; m_volFound = false; } TskAutoDb::~TskAutoDb() { } void TskAutoDb::createBlockMap(bool flag) { m_blkMapFlag = flag; } /** * Open the image to be analyzed. Creates the database in the same * directory as the image (with .db appended to the name). * @param a_num Number of images * @param a_images Images to open * @param a_type Image file format * @param a_ssize Sector size in bytes * @return Resturns 1 on error */ uint8_t TskAutoDb::openImage(int a_num, const TSK_TCHAR * const a_images[], TSK_IMG_TYPE_ENUM a_type, unsigned int a_ssize) { return openImage(a_num, a_images, a_type, a_ssize, NULL); } /** * Open the image to be analyzed. Creates the database in the specified * directory (with .db appended to the name). * @param a_num Number of images * @param a_images Images to open * @param a_type Image file format * @param a_ssize Sector size in bytes * @param a_output_dir Output directory to place database into or NULL to place it in the same directory as the image. * @return Resturns 1 on error */ uint8_t TskAutoDb::openImage(int a_num, const TSK_TCHAR * const a_images[], TSK_IMG_TYPE_ENUM a_type, unsigned int a_ssize, TSK_TCHAR * a_output_dir) { TSK_TCHAR dbFile[1024]; char foo[1024]; if (m_db) { sqlite3_close(m_db); m_db = NULL; } m_curFsId = 0; m_curVsId = 0; uint8_t retval = TskAuto::openImage(a_num, a_images, a_type, a_ssize); // open the DB if (retval != 0) { return retval; } // make name of database #ifdef TSK_WIN32 if (a_output_dir != NULL){ wcsncpy(dbFile, a_output_dir, 1024); if(dbFile[wcslen(dbFile) - 1] != '/' && dbFile[wcslen(dbFile) - 1] != '\\') wcsncat(dbFile, L"\\", 1024-wcslen(dbFile)); // get the image name w/out the path size_t j; for (j = wcslen(a_images[0]) - 1; j > 0; j--) { if ((a_images[0][j] == '/') || (a_images[0][j] == '\\')) { j++; break; } } wcsncat(dbFile, &a_images[0][j], 1024-wcslen(dbFile)); wcsncat(dbFile, L".db", 1024-wcslen(dbFile)); } else{ wcsncpy(dbFile, a_images[0], 1024); wcsncat(dbFile, L".db", 1024-wcslen(dbFile)); } struct STAT_STR stat_buf; if (TSTAT(dbFile, &stat_buf) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Database %S already exists. Must be deleted first.", dbFile); return 1; } if (sqlite3_open16(dbFile, &m_db)) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Can't open database: %s\n", sqlite3_errmsg(m_db)); sqlite3_close(m_db); return 1; } #else if (a_output_dir != NULL){ strncpy(dbFile, a_output_dir, 1024); if(dbFile[strlen(dbFile) - 1] != '/') strncat(dbFile, "/", 1024-strlen(dbFile)); // get the image name size_t j; for (j = strlen(a_images[0]) - 1; j > 0; j--) { if ((a_images[0][j] == '/') || (a_images[0][j] == '\\')) { j++; break; } } strncat(dbFile, &a_images[0][j], 1024-strlen(dbFile)); strncat(dbFile, ".db", 1024-strlen(dbFile)); } else { snprintf(dbFile, 1024, "%s.db", a_images[0]); } struct STAT_STR stat_buf; if (TSTAT(dbFile, &stat_buf) == 0) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Database %s already exists. Must be deleted first.", dbFile); return 1; } if (sqlite3_open(dbFile, &m_db)) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Can't open database: %s\n", sqlite3_errmsg(m_db)); sqlite3_close(m_db); return 1; } #endif char *errmsg; // disable synchronous for loading the DB since we have no crash recovery anyway... if (sqlite3_exec(m_db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error setting PRAGMA synchronous: %s\n", errmsg); sqlite3_free(errmsg); return 1; } // We don't care about the return values of inserts etc. if (sqlite3_exec(m_db, "PRAGMA count_changes = false;", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error setting PRAGMA count changes: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (sqlite3_exec(m_db, "CREATE TABLE tsk_db_info (schema_ver INTEGER, tsk_ver INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_db_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } snprintf(foo, 1024, "INSERT INTO tsk_db_info (schema_ver, tsk_ver) VALUES (%d, %d);", TSK_SCHEMA_VER, TSK_VERSION_NUM); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_db_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (sqlite3_exec(m_db, "CREATE TABLE tsk_image_info (type INTEGER, ssize INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_image_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } snprintf(foo, 1024, "INSERT INTO tsk_image_info (type, ssize) VALUES (%d, %u);", (int) m_img_info->itype, m_img_info->sector_size); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_image_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } // Create the images table and add the image names if (sqlite3_exec(m_db, "CREATE TABLE tsk_image_names (name TEXT);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_image_names table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } for (int i = 0; i < a_num; i++) { int a; char *img_ptr = NULL; #ifdef TSK_WIN32 char img2[1024]; UTF8 *ptr8; UTF16 *ptr16; ptr8 = (UTF8 *) img2; ptr16 = (UTF16 *) a_images[i]; retval = tsk_UTF16toUTF8_lclorder((const UTF16 **) &ptr16, (UTF16 *) & ptr16[TSTRLEN(a_images[i]) + 1], &ptr8, (UTF8 *) ((uintptr_t) ptr8 + 1024), TSKlenientConversion); if (retval != TSKconversionOK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_UNICODE; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error converting image to UTF-8\n"); return 1; } img_ptr = img2; #else img_ptr = (char *) a_images[i]; #endif // get only the file name (ignore the directory name) for (a = strlen(img_ptr) - 1; a > 0; a--) { if ((img_ptr[a] == '/') || (img_ptr[a] == '\\')) { a++; break; } } snprintf(foo, 1024, "INSERT INTO tsk_image_names (name) VALUES ('%s')", &img_ptr[a]); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_image_names table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } } if (sqlite3_exec(m_db, "CREATE TABLE tsk_vs_info (vs_type INTEGER, img_offset INTEGER NOT NULL, block_size INTEGER NOT NULL);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_vs_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (sqlite3_exec(m_db, "CREATE TABLE tsk_vs_parts (vol_id INTEGER PRIMARY KEY, start INTEGER NOT NULL, length INTEGER NOT NULL, desc TEXT, flags INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_vs_parts table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (sqlite3_exec(m_db, "CREATE TABLE tsk_fs_info (fs_id INTEGER PRIMARY KEY, img_offset INTEGER, vol_id INTEGER NOT NULL, fs_type INTEGER, block_size INTEGER, block_count INTEGER, root_inum INTEGER, first_inum INTEGER, last_inum INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_fs_info table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (sqlite3_exec(m_db, "CREATE TABLE tsk_fs_files (fs_id INTEGER NOT NULL, file_id INTEGER NOT NULL, attr_type INTEGER, attr_id INTEGER, name TEXT NOT NULL, par_file_id INTEGER, dir_type INTEGER, meta_type INTEGER, dir_flags INTEGER, meta_flags INTEGER, size INTEGER, ctime INTEGER, crtime INTEGER, atime INTEGER, mtime INTEGER, mode INTEGER, uid INTEGER, gid INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_fs_files table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } if (m_blkMapFlag) { if (sqlite3_exec(m_db, "CREATE TABLE tsk_fs_blocks (fs_id INTEGER NOT NULL, blk_start INTEGER NOT NULL, blk_len INTEGER NOT NULL, file_id INTEGER NOT NULL, attr_type INTEGER, attr_id INTEGER);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_fs_blocks table: %s\n", errmsg); sqlite3_free(errmsg); return 1; } } return 0; } void TskAutoDb::closeImage() { TskAuto::closeImage(); if (m_db) { sqlite3_close(m_db); m_db = NULL; } } uint8_t TskAutoDb::createParentDirIndex() { char *errmsg; if (sqlite3_exec(m_db, "CREATE INDEX parentDir ON tsk_fs_files(par_file_id, fs_id);", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error creating tsk_fs_files index on par_file_id: %s\n", errmsg); sqlite3_free(errmsg); return 1; } return 0; } /** * Analyzes the open image and adds image info to a database. * @returns 1 on error */ uint8_t TskAutoDb::addFilesInImgToDB() { if (m_db == NULL) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "addFilesInImgToDB: m_db not open\n"); return 1; } setVolFilterFlags((TSK_VS_PART_FLAG_ENUM)(TSK_VS_PART_FLAG_ALLOC | TSK_VS_PART_FLAG_UNALLOC)); uint8_t retval = findFilesInImg(); if (retval) return retval; if (createParentDirIndex()) { tsk_error_print(stderr); return 1; } return 0; } TSK_FILTER_ENUM TskAutoDb::filterVs(const TSK_VS_INFO * vs_info) { char statement[1024]; char *errmsg; m_vsFound = true; snprintf(statement, 1024, "INSERT INTO tsk_vs_info (vs_type, img_offset, block_size) VALUES (%d,%" PRIuOFF ",%d)", vs_info->vstype, vs_info->offset, vs_info->block_size); if (sqlite3_exec(m_db, statement, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_vs_info table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_FILTER_STOP; } return TSK_FILTER_CONT; } TSK_FILTER_ENUM TskAutoDb::filterVol(const TSK_VS_PART_INFO * vs_part) { char foo[1024]; char *errmsg; m_volFound = true; snprintf(foo, 1024, "INSERT INTO tsk_vs_parts (vol_id, start, length, desc, flags) VALUES (%d,%" PRIuOFF ",%" PRIuOFF ",'%s',%d)", (int) vs_part->addr, vs_part->start, vs_part->len, vs_part->desc, vs_part->flags); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_vs_parts table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_FILTER_STOP; } m_curVsId = vs_part->addr; return TSK_FILTER_CONT; } TSK_FILTER_ENUM TskAutoDb::filterFs(TSK_FS_INFO * fs_info) { char foo[1024]; char *errmsg; TSK_FS_FILE *file_root; m_curFsId++; /* if we have a disk with no volume system, make a dummy entry. * we only do this so that we can have a dummy volume in vs_part so that * programs that use this can assume that there will be at least one * volume. */ if(!m_vsFound){ m_vsFound = true; snprintf(foo, 1024, "INSERT INTO tsk_vs_info (vs_type, img_offset, block_size) VALUES (%d,%" PRIuOFF ", 512)", TSK_VS_TYPE_DBFILLER, fs_info->offset); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_vs_info table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_FILTER_STOP; } } if(!m_volFound){ m_volFound = true; snprintf(foo, 1024, "INSERT INTO tsk_vs_parts (vol_id, start, length, desc, flags) VALUES (%d,%" PRIuOFF ",%" PRIuOFF ",'%s',%d)", 0, fs_info->offset, fs_info->block_count * fs_info->block_size, "", TSK_VS_PART_FLAG_ALLOC); m_curVsId = 0; if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_vs_parts table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_FILTER_STOP; } } snprintf(foo, 1024, "INSERT INTO tsk_fs_info (fs_id, img_offset, vol_id, fs_type, block_size, " "block_count, root_inum, first_inum, last_inum) VALUES (%d,%" PRIuOFF ",%d,'%d',%d,%" PRIuDADDR ",%" PRIuINUM ",%" PRIuINUM ",%" PRIuINUM ")", m_curFsId, fs_info->offset, m_curVsId, (int) fs_info->ftype, fs_info->block_size, fs_info->block_count, fs_info->root_inum, fs_info->first_inum, fs_info->last_inum); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_fs_info table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_FILTER_STOP; } // We won't hit the root directory on the walk, so open it now if ((file_root = tsk_fs_file_open(fs_info, NULL, "/")) != NULL) { processAttributes(file_root, ""); } // make sure that flags are set to get all files -- we need this to // find parent directory setFileFilterFlags((TSK_FS_DIR_WALK_FLAG_ENUM) (TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_UNALLOC)); return TSK_FILTER_CONT; } /* Insert the file data into the file table. * Returns 1 on error. */ TSK_RETVAL_ENUM TskAutoDb::insertFileData(TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr, const char *path) { char foo[1024]; char *errmsg; int mtime = 0; int crtime = 0; int ctime = 0; int atime = 0; TSK_OFF_T size = 0; int meta_type = 0; int meta_flags = 0; int meta_mode = 0; int gid = 0; int uid = 0; int type = 0; int idx = 0; if (fs_file->name == NULL) return TSK_OK; if (fs_file->meta) { mtime = fs_file->meta->mtime; atime = fs_file->meta->atime; ctime = fs_file->meta->ctime; crtime = fs_file->meta->crtime; size = fs_file->meta->size; meta_type = fs_file->meta->type; meta_flags = fs_file->meta->flags; meta_mode = fs_file->meta->mode; gid = fs_file->meta->gid; uid = fs_file->meta->uid; } size_t attr_nlen = 0; if (fs_attr) { type = fs_attr->type; idx = fs_attr->id; if (fs_attr->name) { if ((fs_attr->type != TSK_FS_ATTR_TYPE_NTFS_IDXROOT) || (strcmp(fs_attr->name, "$I30") != 0)) { attr_nlen = strlen(fs_attr->name); } } } // clean up special characters in name before we insert size_t len = strlen(fs_file->name->name); char *name; size_t nlen = 2 * (len + attr_nlen); if ((name = (char *) tsk_malloc(nlen + 1)) == NULL) { return TSK_ERR; } size_t j = 0; for (size_t i = 0; i < len && j < nlen; i++) { // ' is special in SQLite if (fs_file->name->name[i] == '\'') { name[j++] = '\''; name[j++] = '\''; } else { name[j++] = fs_file->name->name[i]; } } // Add the attribute name if (attr_nlen > 0) { name[j++] = ':'; for (unsigned i = 0; i < attr_nlen && j < nlen; i++) { // ' is special in SQLite if (fs_attr->name[i] == '\'') { name[j++] = '\''; name[j++] = '\''; } else { name[j++] = fs_attr->name[i]; } } } snprintf(foo, 1024, "INSERT INTO tsk_fs_files (fs_id, file_id, attr_type, attr_id, name, par_file_id, dir_type, meta_type, dir_flags, meta_flags, size, crtime, ctime, atime, mtime, mode, gid, uid) VALUES (%d,%" PRIuINUM ",%d,%d,'%s',%" PRIuINUM ",%d,%d,%d,%d,%" PRIuOFF ",%d,%d,%d,%d,%d,%d,%d)", m_curFsId, fs_file->name->meta_addr, type, idx, name, fs_file->name->par_addr, fs_file->name->type, meta_type, fs_file->name->flags, meta_flags, size, crtime, ctime, atime, mtime, meta_mode, gid, uid); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_fs_files table: %s\n", errmsg); sqlite3_free(errmsg); free(name); return TSK_ERR; } free(name); return TSK_OK; } TSK_RETVAL_ENUM TskAutoDb::processFile(TSK_FS_FILE * fs_file, const char *path) { char *errmsg; if (sqlite3_exec(m_db, "BEGIN", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error using BEGIN for insert transaction: %s\n", errmsg); sqlite3_free(errmsg); return TSK_ERR; } TSK_RETVAL_ENUM retval; // process the attributes if there are more than 1 if (tsk_fs_file_attr_getsize(fs_file) == 0) retval = insertFileData(fs_file, NULL, path); else retval = processAttributes(fs_file, path); if (sqlite3_exec(m_db, "COMMIT", NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error using COMMIT for insert transaction: %s\n", errmsg); sqlite3_free(errmsg); return TSK_ERR; } return retval; } TSK_RETVAL_ENUM TskAutoDb::processAttribute(TSK_FS_FILE * fs_file, const TSK_FS_ATTR * fs_attr, const char *path) { // add the file metadata for the default attribute type if (isDefaultType(fs_file, fs_attr)) { if (insertFileData(fs_attr->fs_file, fs_attr, path)) return TSK_ERR; } // add the block map, if requested and the file is non-resident if ((m_blkMapFlag) && (isNonResident(fs_attr)) && (isDotDir(fs_file, path) == 0)) { TSK_FS_ATTR_RUN *run; for (run = fs_attr->nrd.run; run != NULL; run = run->next) { char foo[1024]; char *errmsg; // ignore sparse blocks if (run->flags & TSK_FS_ATTR_RUN_FLAG_SPARSE) continue; snprintf(foo, 1024, "INSERT INTO tsk_fs_blocks (fs_id, blk_start, blk_len, file_id, attr_type, attr_id) VALUES (%d,%" PRIuDADDR ",%"PRIuDADDR ",%" PRIuINUM ",%d,%d)", m_curFsId, run->addr, run->len, fs_file->meta->addr, fs_attr->type, fs_attr->id); if (sqlite3_exec(m_db, foo, NULL, NULL, &errmsg) != SQLITE_OK) { tsk_error_reset(); tsk_errno = TSK_ERR_AUTO_DB; snprintf(tsk_errstr, TSK_ERRSTR_L, "Error adding data to tsk_fs_info table: %s\n", errmsg); sqlite3_free(errmsg); return TSK_ERR; } } } return TSK_OK; } sleuthkit-3.2.3/tsk3/auto/Makefile.am000644 000765 000024 00000000456 11643647437 020241 0ustar00carrierstaff000000 000000 AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskauto.la # Note that the .h files are in the top-level Makefile libtskauto_la_SOURCES = auto.cpp tsk_auto_i.h auto_db.cpp sqlite3.c sqlite3.h indent: indent *.cpp *.h clean-local: -rm -f *.cpp~ *.h~ sleuthkit-3.2.3/tsk3/auto/Makefile.in000644 000765 000024 00000035740 11643647517 020255 0ustar00carrierstaff000000 000000 # Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006 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@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@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 = tsk3/auto DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/tsk3/tsk_config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtskauto_la_LIBADD = am_libtskauto_la_OBJECTS = auto.lo auto_db.lo sqlite3.lo libtskauto_la_OBJECTS = $(am_libtskauto_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(top_builddir)/tsk3@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libtskauto_la_SOURCES) DIST_SOURCES = $(libtskauto_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ RANLIB = @RANLIB@ SED = @SED@ 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@ ac_ct_CXX = @ac_ct_CXX@ 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@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ 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_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I../.. -I$(srcdir)/../.. -Wall EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskauto.la # Note that the .h files are in the top-level Makefile libtskauto_la_SOURCES = auto.cpp tsk_auto_i.h auto_db.cpp sqlite3.c sqlite3.h all: all-am .SUFFIXES: .SUFFIXES: .c .cpp .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tsk3/auto/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tsk3/auto/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtskauto.la: $(libtskauto_la_OBJECTS) $(libtskauto_la_DEPENDENCIES) $(CXXLINK) $(libtskauto_la_OBJECTS) $(libtskauto_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auto.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auto_db.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlite3.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @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 $@ $< .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$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 $(LTLIBRARIES) installdirs: 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: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-local \ clean-noinstLTLIBRARIES 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 info: info-am info-am: install-data-am: install-dvi: install-dvi-am 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 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: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-local clean-noinstLTLIBRARIES 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-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 indent: indent *.cpp *.h clean-local: -rm -f *.cpp~ *.h~ # 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: sleuthkit-3.2.3/tsk3/auto/sqlite3.c000644 000765 000024 00020023002 11643647437 017727 0ustar00carrierstaff000000 000000 /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.7.2. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a one translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% are more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other ** programs, you need this file and the "sqlite3.h" header file that defines ** the programming interface to the SQLite library. (If you do not have ** the "sqlite3.h" header file at hand, you will find a copy embedded within ** the text of this file. Search for "Begin file sqlite3.h" to find the start ** of the embedded sqlite3.h header file.) Additional code files may be needed ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE # define SQLITE_PRIVATE static #endif #ifndef SQLITE_API # define SQLITE_API #endif /************** Begin file sqliteInt.h ***************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** These #defines should enable >2GB file support on POSIX if the ** underlying operating system supports it. If the OS lacks ** large file support, or if the OS is windows, these should be no-ops. ** ** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any ** system #includes. Hence, this block of code must be the very first ** code in all source files. ** ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch ** on the compiler command line. This is necessary if you are compiling ** on a recent machine (ex: Red Hat 7.2) but you want your code to work ** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2 ** without this option, LFS is enable. But LFS does not exist in the kernel ** in Red Hat 6.0, so the code won't work. Hence, for maximum binary ** portability you should omit LFS. ** ** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later. */ #ifndef SQLITE_DISABLE_LFS # define _LARGE_FILE 1 # ifndef _FILE_OFFSET_BITS # define _FILE_OFFSET_BITS 64 # endif # define _LARGEFILE_SOURCE 1 #endif /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build */ #ifdef _HAVE_SQLITE_CONFIG_H #include "config.h" #endif /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ /************** Begin file sqliteLimit.h *************************************/ /* ** 2007 May 7 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file defines various limits of what SQLite can process. */ /* ** The maximum length of a TEXT or BLOB in bytes. This also ** limits the size of a row in a table or index. ** ** The hard limit is the ability of a 32-bit signed integer ** to count the size: 2^31-1 or 2147483647. */ #ifndef SQLITE_MAX_LENGTH # define SQLITE_MAX_LENGTH 1000000000 #endif /* ** This is the maximum number of ** ** * Columns in a table ** * Columns in an index ** * Columns in a view ** * Terms in the SET clause of an UPDATE statement ** * Terms in the result set of a SELECT statement ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement. ** * Terms in the VALUES clause of an INSERT statement ** ** The hard upper limit here is 32676. Most database people will ** tell you that in a well-normalized database, you usually should ** not have more than a dozen or so columns in any table. And if ** that is the case, there is no point in having more than a few ** dozen values in any of the other situations described above. */ #ifndef SQLITE_MAX_COLUMN # define SQLITE_MAX_COLUMN 2000 #endif /* ** The maximum length of a single SQL statement in bytes. ** ** It used to be the case that setting this value to zero would ** turn the limit off. That is no longer true. It is not possible ** to turn this limit off. */ #ifndef SQLITE_MAX_SQL_LENGTH # define SQLITE_MAX_SQL_LENGTH 1000000000 #endif /* ** The maximum depth of an expression tree. This is limited to ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might ** want to place more severe limits on the complexity of an ** expression. ** ** A value of 0 used to mean that the limit was not enforced. ** But that is no longer true. The limit is now strictly enforced ** at all times. */ #ifndef SQLITE_MAX_EXPR_DEPTH # define SQLITE_MAX_EXPR_DEPTH 1000 #endif /* ** The maximum number of terms in a compound SELECT statement. ** The code generator for compound SELECT statements does one ** level of recursion for each term. A stack overflow can result ** if the number of terms is too large. In practice, most SQL ** never has more than 3 or 4 terms. Use a value of 0 to disable ** any limit on the number of terms in a compount SELECT. */ #ifndef SQLITE_MAX_COMPOUND_SELECT # define SQLITE_MAX_COMPOUND_SELECT 500 #endif /* ** The maximum number of opcodes in a VDBE program. ** Not currently enforced. */ #ifndef SQLITE_MAX_VDBE_OP # define SQLITE_MAX_VDBE_OP 25000 #endif /* ** The maximum number of arguments to an SQL function. */ #ifndef SQLITE_MAX_FUNCTION_ARG # define SQLITE_MAX_FUNCTION_ARG 127 #endif /* ** The maximum number of in-memory pages to use for the main database ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE */ #ifndef SQLITE_DEFAULT_CACHE_SIZE # define SQLITE_DEFAULT_CACHE_SIZE 2000 #endif #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE # define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500 #endif /* ** The default number of frames to accumulate in the log file before ** checkpointing the database in WAL mode. */ #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 #endif /* ** The maximum number of attached databases. This must be between 0 ** and 30. The upper bound on 30 is because a 32-bit integer bitmap ** is used internally to track attached databases. */ #ifndef SQLITE_MAX_ATTACHED # define SQLITE_MAX_ATTACHED 10 #endif /* ** The maximum value of a ?nnn wildcard that the parser will accept. */ #ifndef SQLITE_MAX_VARIABLE_NUMBER # define SQLITE_MAX_VARIABLE_NUMBER 999 #endif /* Maximum page size. The upper bound on this value is 65536. This a limit ** imposed by the use of 16-bit offsets within each page. ** ** Earlier versions of SQLite allowed the user to change this value at ** compile time. This is no longer permitted, on the grounds that it creates ** a library that is technically incompatible with an SQLite library ** compiled with a different limit. If a process operating on a database ** with a page-size of 65536 bytes crashes, then an instance of SQLite ** compiled with the default page-size limit will not be able to rollback ** the aborted transaction. This could lead to database corruption. */ #ifdef SQLITE_MAX_PAGE_SIZE # undef SQLITE_MAX_PAGE_SIZE #endif #define SQLITE_MAX_PAGE_SIZE 65536 /* ** The default size of a database page. */ #ifndef SQLITE_DEFAULT_PAGE_SIZE # define SQLITE_DEFAULT_PAGE_SIZE 1024 #endif #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE # undef SQLITE_DEFAULT_PAGE_SIZE # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE #endif /* ** Ordinarily, if no value is explicitly provided, SQLite creates databases ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain ** device characteristics (sector-size and atomic write() support), ** SQLite may choose a larger value. This constant is the maximum value ** SQLite will choose on its own. */ #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 #endif #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE # undef SQLITE_MAX_DEFAULT_PAGE_SIZE # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE #endif /* ** Maximum number of pages in one database file. ** ** This is really just the default value for the max_page_count pragma. ** This value can be lowered (or raised) at run-time using that the ** max_page_count macro. */ #ifndef SQLITE_MAX_PAGE_COUNT # define SQLITE_MAX_PAGE_COUNT 1073741823 #endif /* ** Maximum length (in bytes) of the pattern in a LIKE or GLOB ** operator. */ #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 #endif /* ** Maximum depth of recursion for triggers. ** ** A value of 1 means that a trigger program will not be able to itself ** fire any triggers. A value of 0 means that no trigger programs at all ** may be executed. */ #ifndef SQLITE_MAX_TRIGGER_DEPTH # define SQLITE_MAX_TRIGGER_DEPTH 1000 #endif /************** End of sqliteLimit.h *****************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /* Disable nuisance warnings on Borland compilers */ #if defined(__BORLANDC__) #pragma warn -rch /* unreachable code */ #pragma warn -ccc /* Condition is always true or false */ #pragma warn -aus /* Assigned value is never used */ #pragma warn -csu /* Comparing signed and unsigned */ #pragma warn -spa /* Suspicious pointer arithmetic */ #endif /* Needed for various definitions... */ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif /* ** Include standard header files as necessary */ #ifdef HAVE_STDINT_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif /* ** The number of samples of an index that SQLite takes in order to ** construct a histogram of the table content when running ANALYZE ** and with SQLITE_ENABLE_STAT2 */ #define SQLITE_INDEX_SAMPLES 10 /* ** The following macros are used to cast pointers to integers and ** integers to pointers. The way you do this varies from one compiler ** to the next, so we have developed the following set of #if statements ** to generate appropriate macros for a wide range of compilers. ** ** The correct "ANSI" way to do this is to use the intptr_t type. ** Unfortunately, that typedef is not available on all compilers, or ** if it is available, it requires an #include of specific headers ** that vary from one machine to the next. ** ** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on ** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)). ** So we have to define the macros in different ways depending on the ** compiler. */ #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */ # define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X)) #elif !defined(__GNUC__) /* Works for compilers other than LLVM */ # define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */ # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) #else /* Generates a warning - but it always works */ # define SQLITE_INT_TO_PTR(X) ((void*)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(X)) #endif /* ** The SQLITE_THREADSAFE macro must be defined as either 0 or 1. ** Older versions of SQLite used an optional THREADSAFE macro. ** We support that for legacy */ #if !defined(SQLITE_THREADSAFE) #if defined(THREADSAFE) # define SQLITE_THREADSAFE THREADSAFE #else # define SQLITE_THREADSAFE 1 #endif #endif /* ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1. ** It determines whether or not the features related to ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can ** be overridden at runtime using the sqlite3_config() API. */ #if !defined(SQLITE_DEFAULT_MEMSTATUS) # define SQLITE_DEFAULT_MEMSTATUS 1 #endif /* ** Exactly one of the following macros must be defined in order to ** specify which memory allocation subsystem to use. ** ** SQLITE_SYSTEM_MALLOC // Use normal system malloc() ** SQLITE_MEMDEBUG // Debugging version of system malloc() ** ** (Historical note: There used to be several other options, but we've ** pared it down to just these two.) ** ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as ** the default. */ #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)>1 # error "At most one of the following compile-time configuration options\ is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG" #endif #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)==0 # define SQLITE_SYSTEM_MALLOC 1 #endif /* ** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the ** sizes of memory allocations below this value where possible. */ #if !defined(SQLITE_MALLOC_SOFT_LIMIT) # define SQLITE_MALLOC_SOFT_LIMIT 1024 #endif /* ** We need to define _XOPEN_SOURCE as follows in order to enable ** recursive mutexes on most Unix systems. But Mac OS X is different. ** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, ** so it is omitted there. See ticket #2673. ** ** Later we learn that _XOPEN_SOURCE is poorly or incorrectly ** implemented on some systems. So we avoid defining it at all ** if it is already defined or if it is unneeded because we are ** not doing a threadsafe build. Ticket #2681. ** ** See also ticket #2741. */ #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE_THREADSAFE # define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ #endif /* ** The TCL headers are only needed when compiling the TCL bindings. */ #if defined(SQLITE_TCL) || defined(TCLSH) # include #endif /* ** Many people are failing to set -DNDEBUG=1 when compiling SQLite. ** Setting NDEBUG makes the code smaller and run faster. So the following ** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out ** feature. */ #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) # define NDEBUG 1 #endif /* ** The testcase() macro is used to aid in coverage testing. When ** doing coverage testing, the condition inside the argument to ** testcase() must be evaluated both true and false in order to ** get full branch coverage. The testcase() macro is inserted ** to help ensure adequate test coverage in places where simple ** condition/decision coverage is inadequate. For example, testcase() ** can be used to make sure boundary values are tested. For ** bitmask tests, testcase() can be used to make sure each bit ** is significant and used at least once. On switch statements ** where multiple cases go to the same block of code, testcase() ** can insure that all cases are evaluated. ** */ #ifdef SQLITE_COVERAGE_TEST SQLITE_PRIVATE void sqlite3Coverage(int); # define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } #else # define testcase(X) #endif /* ** The TESTONLY macro is used to enclose variable declarations or ** other bits of code that are needed to support the arguments ** within testcase() and assert() macros. */ #if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST) # define TESTONLY(X) X #else # define TESTONLY(X) #endif /* ** Sometimes we need a small amount of code such as a variable initialization ** to setup for a later assert() statement. We do not want this code to ** appear when assert() is disabled. The following macro is therefore ** used to contain that setup code. The "VVA" acronym stands for ** "Verification, Validation, and Accreditation". In other words, the ** code within VVA_ONLY() will only run during verification processes. */ #ifndef NDEBUG # define VVA_ONLY(X) X #else # define VVA_ONLY(X) #endif /* ** The ALWAYS and NEVER macros surround boolean expressions which ** are intended to always be true or false, respectively. Such ** expressions could be omitted from the code completely. But they ** are included in a few cases in order to enhance the resilience ** of SQLite to unexpected behavior - to make the code "self-healing" ** or "ductile" rather than being "brittle" and crashing at the first ** hint of unplanned behavior. ** ** In other words, ALWAYS and NEVER are added for defensive code. ** ** When doing coverage testing ALWAYS and NEVER are hard-coded to ** be true and false so that the unreachable code then specify will ** not be counted as untested code. */ #if defined(SQLITE_COVERAGE_TEST) # define ALWAYS(X) (1) # define NEVER(X) (0) #elif !defined(NDEBUG) # define ALWAYS(X) ((X)?1:(assert(0),0)) # define NEVER(X) ((X)?(assert(0),1):0) #else # define ALWAYS(X) (X) # define NEVER(X) (X) #endif /* ** Return true (non-zero) if the input is a integer that is too large ** to fit in 32-bits. This macro is used inside of various testcase() ** macros to verify that we have tested SQLite for large-file support. */ #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) /* ** The macro unlikely() is a hint that surrounds a boolean ** expression that is usually false. Macro likely() surrounds ** a boolean expression that is usually true. GCC is able to ** use these hints to generate better code, sometimes. */ #if defined(__GNUC__) && 0 # define likely(X) __builtin_expect((X),1) # define unlikely(X) __builtin_expect((X),0) #else # define likely(X) !!(X) # define unlikely(X) !!(X) #endif /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ /************** Begin file sqlite3.h *****************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. If a C-function, structure, datatype, ** or constant definition does not appear in this file, then it is ** not a published API of SQLite, is subject to change without ** notice, and should not be referenced by programs that use SQLite. ** ** Some of the definitions that are in this file are marked as ** "experimental". Experimental interfaces are normally new ** features recently added to SQLite. We do not anticipate changes ** to experimental interfaces but reserve the right to make minor changes ** if experience from use "in the wild" suggest such changes are prudent. ** ** The official C-language API documentation for SQLite is derived ** from comments in this file. This file is the authoritative source ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. */ #if 0 extern "C" { #endif /* ** Add the ability to override 'extern' */ #ifndef SQLITE_EXTERN # define SQLITE_EXTERN extern #endif #ifndef SQLITE_API # define SQLITE_API #endif /* ** These no-op macros are used in front of interfaces to mark those ** interfaces as either deprecated or experimental. New applications ** should not use deprecated interfaces - they are support for backwards ** compatibility only. Application writers should be aware that ** experimental interfaces are subject to change in point releases. ** ** These macros used to resolve to various kinds of compiler magic that ** would generate warning messages when they were used. But that ** compiler magic ended up generating such a flurry of bug reports ** that we have taken it all out and gone back to using simple ** noop macros. */ #define SQLITE_DEPRECATED #define SQLITE_EXPERIMENTAL /* ** Ensure these symbols were not defined by some previous header file. */ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* ** CAPI3REF: Compile-Time Library Version Numbers ** ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header ** evaluates to a string literal that is the SQLite version in the ** format "X.Y.Z" where X is the major version number (always 3 for ** SQLite3) and Y is the minor version number and Z is the release number.)^ ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same ** numbers used in [SQLITE_VERSION].)^ ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also ** be larger than the release from which it is derived. Either Y will ** be held constant and Z will be incremented or else Y will be incremented ** and Z will be reset to zero. ** ** Since version 3.6.18, SQLite source code has been stored in the ** Fossil configuration management ** system. ^The SQLITE_SOURCE_ID macro evaluates to ** a string which identifies a particular check-in of SQLite ** within its configuration management system. ^The SQLITE_SOURCE_ID ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.7.2" #define SQLITE_VERSION_NUMBER 3007002 #define SQLITE_SOURCE_ID "2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ** but are associated with the library instead of the header file. ^(Cautious ** programmers might include assert() statements in their application to ** verify that values returned by these interfaces match the macros in ** the header, and thus insure that the application is ** compiled with matching library and header files. ** **
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
** 
)^ ** ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] ** macro. ^The sqlite3_libversion() function returns a pointer to the ** to the sqlite3_version[] string constant. The sqlite3_libversion() ** function is provided for use in DLLs since DLL users usually do not have ** direct access to string constants within the DLL. ^The ** sqlite3_libversion_number() function returns an integer equal to ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns ** a pointer to a string constant whose value is the same as the ** [SQLITE_SOURCE_ID] C preprocessor macro. ** ** See also: [sqlite_version()] and [sqlite_source_id()]. */ SQLITE_API const char sqlite3_version[] = SQLITE_VERSION; SQLITE_API const char *sqlite3_libversion(void); SQLITE_API const char *sqlite3_sourceid(void); SQLITE_API int sqlite3_libversion_number(void); /* ** CAPI3REF: Run-Time Library Compilation Options Diagnostics ** ** ^The sqlite3_compileoption_used() function returns 0 or 1 ** indicating whether the specified option was defined at ** compile time. ^The SQLITE_ prefix may be omitted from the ** option name passed to sqlite3_compileoption_used(). ** ** ^The sqlite3_compileoption_get() function allows iterating ** over the list of options that were defined at compile time by ** returning the N-th compile time option string. ^If N is out of range, ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ ** prefix is omitted from any strings returned by ** sqlite3_compileoption_get(). ** ** ^Support for the diagnostic functions sqlite3_compileoption_used() ** and sqlite3_compileoption_get() may be omitted by specifying the ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled mutexing code omitted due to the ** [SQLITE_THREADSAFE] compile-time option being set to 0. ** ** SQLite can be compiled with or without mutexes. When ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes ** are enabled and SQLite is threadsafe. When the ** [SQLITE_THREADSAFE] macro is 0, ** the mutexes are omitted. Without the mutexes, it is not safe ** to use SQLite concurrently from more than one thread. ** ** Enabling mutexes incurs a measurable performance penalty. ** So if speed is of utmost importance, it makes sense to disable ** the mutexes. But for maximum safety, mutexes should be enabled. ** ^The default behavior is for mutexes to be enabled. ** ** This interface can be used by an application to make sure that the ** version of SQLite that it is linking against was compiled with ** the desired setting of the [SQLITE_THREADSAFE] macro. ** ** This interface only reports on the compile-time mutex setting ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but ** can be fully or partially disabled using a call to [sqlite3_config()] ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the ** sqlite3_threadsafe() function shows only the compile-time setting of ** thread safety, not any run-time changes to that setting made by ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() ** is unchanged by calls to sqlite3_config().)^ ** ** See the [threading mode] documentation for additional information. */ SQLITE_API int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by a pointer to an instance of ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] ** is its destructor. There are many other interfaces (such as ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_busy_timeout()] to name but three) that are methods on an ** sqlite3 object. */ typedef struct sqlite3 sqlite3; /* ** CAPI3REF: 64-Bit Integer Types ** KEYWORDS: sqlite_int64 sqlite_uint64 ** ** Because there is no cross-platform way to specify 64-bit integer types ** SQLite includes typedefs for 64-bit signed and unsigned integers. ** ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. ** The sqlite_int64 and sqlite_uint64 types are supported for backwards ** compatibility only. ** ** ^The sqlite3_int64 and sqlite_int64 types can store integer values ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The ** sqlite3_uint64 and sqlite_uint64 types can store integer values ** between 0 and +18446744073709551615 inclusive. */ #ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64; #else typedef long long int sqlite_int64; typedef unsigned long long int sqlite_uint64; #endif typedef sqlite_int64 sqlite3_int64; typedef sqlite_uint64 sqlite3_uint64; /* ** If compiling for a processor that lacks floating point support, ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* ** CAPI3REF: Closing A Database Connection ** ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is ** successfully destroyed and all associated resources are deallocated. ** ** Applications must [sqlite3_finalize | finalize] all [prepared statements] ** and [sqlite3_blob_close | close] all [BLOB handles] associated with ** the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close() is called on a [database connection] that still has ** outstanding [prepared statements] or [BLOB handles], then it returns ** SQLITE_BUSY. ** ** ^If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. ** ** The C parameter to [sqlite3_close(C)] must be either a NULL ** pointer or an [sqlite3] object pointer obtained ** from [sqlite3_open()], [sqlite3_open16()], or ** [sqlite3_open_v2()], and not previously closed. ** ^Calling sqlite3_close() with a NULL pointer argument is a ** harmless no-op. */ SQLITE_API int sqlite3_close(sqlite3 *); /* ** The type for a callback function. ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface ** ** The sqlite3_exec() interface is a convenience wrapper around ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], ** that allows an application to run multiple statements of SQL ** without having to use a lot of C code. ** ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, ** semicolon-separate SQL statements passed into its 2nd argument, ** in the context of the [database connection] passed in as its 1st ** argument. ^If the callback function of the 3rd argument to ** sqlite3_exec() is not NULL, then it is invoked for each result row ** coming out of the evaluated SQL statements. ^The 4th argument to ** to sqlite3_exec() is relayed through to the 1st argument of each ** callback invocation. ^If the callback pointer to sqlite3_exec() ** is NULL, then no callback is ever invoked and result rows are ** ignored. ** ** ^If an error occurs while evaluating the SQL statements passed into ** sqlite3_exec(), then execution of the current statement stops and ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() ** is not NULL then any error message is written into memory obtained ** from [sqlite3_malloc()] and passed back through the 5th parameter. ** To avoid memory leaks, the application should invoke [sqlite3_free()] ** on error message strings returned through the 5th parameter of ** of sqlite3_exec() after the error message string is no longer needed. ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to ** NULL before returning. ** ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() ** routine returns SQLITE_ABORT without invoking the callback again and ** without running any subsequent SQL statements. ** ** ^The 2nd argument to the sqlite3_exec() callback function is the ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() ** callback is an array of pointers to strings obtained as if from ** [sqlite3_column_text()], one for each column. ^If an element of a ** result row is NULL then the corresponding string pointer for the ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the ** sqlite3_exec() callback is an array of pointers to strings where each ** entry represents the name of corresponding result column as obtained ** from [sqlite3_column_name()]. ** ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer ** to an empty string, or a pointer that contains only whitespace and/or ** SQL comments, then no SQL statements are evaluated and the database ** is not changed. ** ** Restrictions: ** **
    **
  • The application must insure that the 1st parameter to sqlite3_exec() ** is a valid and open [database connection]. **
  • The application must not close [database connection] specified by ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. **
  • The application must not modify the SQL statement text passed into ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. **
*/ SQLITE_API int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* ** CAPI3REF: Result Codes ** KEYWORDS: SQLITE_OK {error code} {error codes} ** KEYWORDS: {result code} {result codes} ** ** Many SQLite functions return an integer result code from the set shown ** here in order to indicates success or failure. ** ** New error codes may be added in future versions of SQLite. ** ** See also: [SQLITE_IOERR_READ | extended result codes] */ #define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ #define SQLITE_ERROR 1 /* SQL error or missing database */ #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* The database file is locked */ #define SQLITE_LOCKED 6 /* A table in the database is locked */ #define SQLITE_NOMEM 7 /* A malloc() failed */ #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ #define SQLITE_FULL 13 /* Insertion failed because database is full */ #define SQLITE_CANTOPEN 14 /* Unable to open the database file */ #define SQLITE_PROTOCOL 15 /* Database lock protocol error */ #define SQLITE_EMPTY 16 /* Database is empty */ #define SQLITE_SCHEMA 17 /* The database schema changed */ #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ #define SQLITE_MISMATCH 20 /* Data type mismatch */ #define SQLITE_MISUSE 21 /* Library used incorrectly */ #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ #define SQLITE_AUTH 23 /* Authorization denied */ #define SQLITE_FORMAT 24 /* Auxiliary database format error */ #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* ** CAPI3REF: Extended Result Codes ** KEYWORDS: {extended error code} {extended error codes} ** KEYWORDS: {extended result code} {extended result codes} ** ** In its default configuration, SQLite API routines return one of 26 integer ** [SQLITE_OK | result codes]. However, experience has shown that many of ** these result codes are too coarse-grained. They do not provide as ** much information about problems as programmers might like. In an effort to ** address this, newer versions of SQLite (version 3.3.8 and later) include ** support for additional result codes that provide more detailed information ** about errors. The extended result codes are enabled or disabled ** on a per database connection basis using the ** [sqlite3_extended_result_codes()] API. ** ** Some of the available extended result codes are listed here. ** One may expect the number of extended result codes will be expand ** over time. Software that uses extended result codes should expect ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. */ #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the xOpen method of the ** [sqlite3_vfs] object. */ #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ #define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ /* ** CAPI3REF: Device Characteristics ** ** The xDeviceCharacteristics method of the [sqlite3_io_methods] ** object returns an integer which is a vector of the these ** bit values expressing I/O characteristics of the mass storage ** device that holds the file that the [sqlite3_io_methods] ** refers to. ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means ** that when data is appended to a file, the data is appended ** first then the size of the file is extended, never the other ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that ** information is written to disk in the same order as calls ** to xWrite(). */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. */ #define SQLITE_LOCK_NONE 0 #define SQLITE_LOCK_SHARED 1 #define SQLITE_LOCK_RESERVED 2 #define SQLITE_LOCK_PENDING 3 #define SQLITE_LOCK_EXCLUSIVE 4 /* ** CAPI3REF: Synchronization Type Flags ** ** When SQLite invokes the xSync() method of an ** [sqlite3_io_methods] object it uses a combination of ** these integer values as the second argument. ** ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the ** sync operation only needs to flush data to mass storage. Inode ** information need not be flushed. If the lower four bits of the flag ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. ** If the lower four bits equal SQLITE_SYNC_FULL, that means ** to use Mac OS X style fullsync instead of fsync(). */ #define SQLITE_SYNC_NORMAL 0x00002 #define SQLITE_SYNC_FULL 0x00003 #define SQLITE_SYNC_DATAONLY 0x00010 /* ** CAPI3REF: OS Interface Open File Handle ** ** An [sqlite3_file] object represents an open file in the ** [sqlite3_vfs | OS interface layer]. Individual OS interface ** implementations will ** want to subclass this object by appending additional fields ** for their own use. The pMethods entry is a pointer to an ** [sqlite3_io_methods] object that defines methods for performing ** I/O operations on the open file. */ typedef struct sqlite3_file sqlite3_file; struct sqlite3_file { const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ }; /* ** CAPI3REF: OS Interface File Virtual Methods Object ** ** Every file opened by the [sqlite3_vfs] xOpen method populates an ** [sqlite3_file] object (or, more commonly, a subclass of the ** [sqlite3_file] object) with a pointer to an instance of this object. ** This object defines the methods used to perform various operations ** against the open file represented by the [sqlite3_file] object. ** ** If the xOpen method sets the sqlite3_file.pMethods element ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method ** may be invoked even if the xOpen reported that it failed. The ** only way to prevent a call to xClose following a failed xOpen ** is for the xOpen to set the sqlite3_file.pMethods element to NULL. ** ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). ** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] ** flag may be ORed in to indicate that only the data of the file ** and not its inode needs to be synced. ** ** The integer values to xLock() and xUnlock() are one of **
    **
  • [SQLITE_LOCK_NONE], **
  • [SQLITE_LOCK_SHARED], **
  • [SQLITE_LOCK_RESERVED], **
  • [SQLITE_LOCK_PENDING], or **
  • [SQLITE_LOCK_EXCLUSIVE]. **
** xLock() increases the lock. xUnlock() decreases the lock. ** The xCheckReservedLock() method checks whether any database connection, ** either in this process or in some other process, is holding a RESERVED, ** PENDING, or EXCLUSIVE lock on the file. It returns true ** if such a lock exists and false otherwise. ** ** The xFileControl() method is a generic interface that allows custom ** VFS implementations to directly control an open file using the ** [sqlite3_file_control()] interface. The second "op" argument is an ** integer opcode. The third argument is a generic pointer intended to ** point to a structure that may contain arguments or space in which to ** write return values. Potential uses for xFileControl() might be ** functions to enable blocking locks with timeouts, to change the ** locking strategy (for example to use dot-file locks), to inquire ** about the status of a lock, or to break stale locks. The SQLite ** core reserves all opcodes less than 100 for its own use. ** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. ** Applications that define a custom xFileControl method should use opcodes ** greater than 100 to avoid conflicts. ** ** The xSectorSize() method returns the sector size of the ** device that underlies the file. The sector size is the ** minimum write that can be performed without disturbing ** other bytes in the file. The xDeviceCharacteristics() ** method returns a bit vector describing behaviors of the ** underlying device: ** **
    **
  • [SQLITE_IOCAP_ATOMIC] **
  • [SQLITE_IOCAP_ATOMIC512] **
  • [SQLITE_IOCAP_ATOMIC1K] **
  • [SQLITE_IOCAP_ATOMIC2K] **
  • [SQLITE_IOCAP_ATOMIC4K] **
  • [SQLITE_IOCAP_ATOMIC8K] **
  • [SQLITE_IOCAP_ATOMIC16K] **
  • [SQLITE_IOCAP_ATOMIC32K] **
  • [SQLITE_IOCAP_ATOMIC64K] **
  • [SQLITE_IOCAP_SAFE_APPEND] **
  • [SQLITE_IOCAP_SEQUENTIAL] **
** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means ** that when data is appended to a file, the data is appended ** first then the size of the file is extended, never the other ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that ** information is written to disk in the same order as calls ** to xWrite(). ** ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill ** in the unread portions of the buffer with zeros. A VFS that ** fails to zero-fill short reads might seem to work. However, ** failure to zero-fill short reads will eventually lead to ** database corruption. */ typedef struct sqlite3_io_methods sqlite3_io_methods; struct sqlite3_io_methods { int iVersion; int (*xClose)(sqlite3_file*); int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); int (*xSync)(sqlite3_file*, int flags); int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); int (*xLock)(sqlite3_file*, int); int (*xUnlock)(sqlite3_file*, int); int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Methods above are valid for version 1 */ int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); void (*xShmBarrier)(sqlite3_file*); int (*xShmUnmap)(sqlite3_file*, int deleteFlag); /* Methods above are valid for version 2 */ /* Additional methods may be added in future releases */ }; /* ** CAPI3REF: Standard File Control Opcodes ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] ** interface. ** ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This ** opcode causes the xFileControl method to write the current state of ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) ** into an integer that the pArg argument points to. This capability ** is used during testing and only needs to be supported when SQLITE_TEST ** is defined. ** ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS ** layer a hint of how large the database file will grow to be during the ** current transaction. This hint is not guaranteed to be accurate but it ** is often close. The underlying VFS might choose to preallocate database ** file space based on this hint in order to help writes to the database ** file run faster. ** ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS ** extends and truncates the database file in chunks of a size specified ** by the user. The fourth argument to [sqlite3_file_control()] should ** point to an integer (type int) containing the new chunk-size to use ** for the nominated database. Allocating database file space in large ** chunks (say 1MB at a time), may reduce file-system fragmentation and ** improve performance on some systems. */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 #define SQLITE_SET_LOCKPROXYFILE 3 #define SQLITE_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 #define SQLITE_FCNTL_CHUNK_SIZE 6 /* ** CAPI3REF: Mutex Handle ** ** The mutex module within SQLite defines [sqlite3_mutex] to be an ** abstract type for a mutex object. The SQLite core never looks ** at the internal representation of an [sqlite3_mutex]. It only ** deals with pointers to the [sqlite3_mutex] object. ** ** Mutexes are created using [sqlite3_mutex_alloc()]. */ typedef struct sqlite3_mutex sqlite3_mutex; /* ** CAPI3REF: OS Interface Object ** ** An instance of the sqlite3_vfs object defines the interface between ** the SQLite core and the underlying operating system. The "vfs" ** in the name of the object stands for "virtual file system". ** ** The value of the iVersion field is initially 1 but may be larger in ** future versions of SQLite. Additional fields may be appended to this ** object when the iVersion value is increased. Note that the structure ** of the sqlite3_vfs object changes in the transaction between ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not ** modified. ** ** The szOsFile field is the size of the subclassed [sqlite3_file] ** structure used by this VFS. mxPathname is the maximum length of ** a pathname in this VFS. ** ** Registered sqlite3_vfs objects are kept on a linked list formed by ** the pNext pointer. The [sqlite3_vfs_register()] ** and [sqlite3_vfs_unregister()] interfaces manage this list ** in a thread-safe way. The [sqlite3_vfs_find()] interface ** searches the list. Neither the application code nor the VFS ** implementation should use the pNext pointer. ** ** The pNext field is the only field in the sqlite3_vfs ** structure that SQLite will ever modify. SQLite will only access ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** ** SQLite will guarantee that the zFilename parameter to xOpen ** is either a NULL pointer or string obtained ** from xFullPathname(). SQLite further guarantees that ** the string will be valid and unchanged until xClose() is ** called. Because of the previous sentence, ** the [sqlite3_file] can safely store a pointer to the ** filename if it needs to remember the filename for some reason. ** If the zFilename parameter is xOpen is a NULL pointer then xOpen ** must invent its own temporary name for the file. Whenever the ** xFilename parameter is NULL it will also be the case that the ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. ** ** The flags argument to xOpen() includes all bits set in ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] ** or [sqlite3_open16()] is used, then flags includes at least ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. ** If xOpen() opens a file read-only then it sets *pOutFlags to ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. ** ** SQLite will also add one of the following flags to the xOpen() ** call, depending on the object being opened: ** **
    **
  • [SQLITE_OPEN_MAIN_DB] **
  • [SQLITE_OPEN_MAIN_JOURNAL] **
  • [SQLITE_OPEN_TEMP_DB] **
  • [SQLITE_OPEN_TEMP_JOURNAL] **
  • [SQLITE_OPEN_TRANSIENT_DB] **
  • [SQLITE_OPEN_SUBJOURNAL] **
  • [SQLITE_OPEN_MASTER_JOURNAL] **
** ** The file I/O implementation can use the object type flags to ** change the way it deals with files. For example, an application ** that does not care about crash recovery or rollback might make ** the open of a journal file a no-op. Writes to this journal would ** also be no-ops, and any attempt to read the journal would return ** SQLITE_IOERR. Or the implementation might recognize that a database ** file will be doing page-aligned sector reads and writes in a random ** order and set up its I/O subsystem accordingly. ** ** SQLite might also add one of the following flags to the xOpen method: ** **
    **
  • [SQLITE_OPEN_DELETEONCLOSE] **
  • [SQLITE_OPEN_EXCLUSIVE] **
** ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be ** deleted when it is closed. The [SQLITE_OPEN_DELETEONCLOSE] ** will be set for TEMP databases, journals and for subjournals. ** ** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction ** with the [SQLITE_OPEN_CREATE] flag, which are both directly ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the ** SQLITE_OPEN_CREATE, is used to indicate that file should always ** be created, and that it is an error if it already exists. ** It is not used to indicate the file should be opened ** for exclusive access. ** ** At least szOsFile bytes of memory are allocated by SQLite ** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. The xOpen method does not have to ** allocate the structure; it should just fill it in. Note that ** the xOpen method must set the sqlite3_file.pMethods to either ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods ** element will be valid after xOpen returns regardless of the success ** or failure of the xOpen call. ** ** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] ** to test whether a file is at least readable. The file can be a ** directory. ** ** SQLite will always allocate at least mxPathname+1 bytes for the ** output buffer xFullPathname. The exact size of the output buffer ** is also passed as a parameter to both methods. If the output buffer ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is ** handled as a fatal error by SQLite, vfs implementations should endeavor ** to prevent this by setting mxPathname to a sufficiently large value. ** ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() ** interfaces are not strictly a part of the filesystem, but they are ** included in the VFS structure for completeness. ** The xRandomness() function attempts to return nBytes bytes ** of good-quality randomness into zOut. The return value is ** the actual number of bytes of randomness obtained. ** The xSleep() method causes the calling thread to sleep for at ** least the number of microseconds given. The xCurrentTime() ** method returns a Julian Day Number for the current date and time as ** a floating point value. ** The xCurrentTimeInt64() method returns, as an integer, the Julian ** Day Number multipled by 86400000 (the number of milliseconds in ** a 24-hour day). ** ^SQLite will use the xCurrentTimeInt64() method to get the current ** date and time if that method is available (if iVersion is 2 or ** greater and the function pointer is not NULL) and will fall back ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. */ typedef struct sqlite3_vfs sqlite3_vfs; struct sqlite3_vfs { int iVersion; /* Structure version number (currently 2) */ int szOsFile; /* Size of subclassed sqlite3_file */ int mxPathname; /* Maximum file pathname length */ sqlite3_vfs *pNext; /* Next registered VFS */ const char *zName; /* Name of this virtual file system */ void *pAppData; /* Pointer to application-specific data */ int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, int flags, int *pOutFlags); int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); void (*xDlClose)(sqlite3_vfs*, void*); int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); int (*xSleep)(sqlite3_vfs*, int microseconds); int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* ** The methods above are in version 1 of the sqlite_vfs object ** definition. Those that follow are added in version 2 or later */ int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); /* ** The methods above are in versions 1 and 2 of the sqlite_vfs object. ** New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* ** CAPI3REF: Flags for the xAccess VFS method ** ** These integer constants can be used as the third parameter to ** the xAccess method of an [sqlite3_vfs] object. They determine ** what kind of permissions the xAccess method is looking for. ** With SQLITE_ACCESS_EXISTS, the xAccess method ** simply checks whether the file exists. ** With SQLITE_ACCESS_READWRITE, the xAccess method ** checks whether the named directory is both readable and writable ** (in other words, if files can be added, removed, and renamed within ** the directory). ** The SQLITE_ACCESS_READWRITE constant is currently used only by the ** [temp_store_directory pragma], though this could change in a future ** release of SQLite. ** With SQLITE_ACCESS_READ, the xAccess method ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is ** currently unused, though it might be used in a future release of ** SQLite. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ #define SQLITE_ACCESS_READ 2 /* Unused */ /* ** CAPI3REF: Flags for the xShmLock VFS method ** ** These integer constants define the various locking operations ** allowed by the xShmLock method of [sqlite3_io_methods]. The ** following are the only legal combinations of flags to the ** xShmLock method: ** **
    **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE **
** ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as ** was given no the corresponding lock. ** ** The xShmLock method can transition between unlocked and SHARED or ** between unlocked and EXCLUSIVE. It cannot transition between SHARED ** and EXCLUSIVE. */ #define SQLITE_SHM_UNLOCK 1 #define SQLITE_SHM_LOCK 2 #define SQLITE_SHM_SHARED 4 #define SQLITE_SHM_EXCLUSIVE 8 /* ** CAPI3REF: Maximum xShmLock index ** ** The xShmLock method on [sqlite3_io_methods] may use values ** between 0 and this upper bound as its "offset" argument. ** The SQLite core will never attempt to acquire or release a ** lock outside of this range */ #define SQLITE_SHM_NLOCK 8 /* ** CAPI3REF: Initialize The SQLite Library ** ** ^The sqlite3_initialize() routine initializes the ** SQLite library. ^The sqlite3_shutdown() routine ** deallocates any resources that were allocated by sqlite3_initialize(). ** These routines are designed to aid in process initialization and ** shutdown on embedded systems. Workstation applications using ** SQLite normally do not need to invoke either of these routines. ** ** A call to sqlite3_initialize() is an "effective" call if it is ** the first time sqlite3_initialize() is invoked during the lifetime of ** the process, or if it is the first time sqlite3_initialize() is invoked ** following a call to sqlite3_shutdown(). ^(Only an effective call ** of sqlite3_initialize() does any initialization. All other calls ** are harmless no-ops.)^ ** ** A call to sqlite3_shutdown() is an "effective" call if it is the first ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only ** an effective call to sqlite3_shutdown() does any deinitialization. ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ ** ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() ** is not. The sqlite3_shutdown() interface must only be called from a ** single thread. All open [database connections] must be closed and all ** other SQLite resources must be deallocated prior to invoking ** sqlite3_shutdown(). ** ** Among other things, ^sqlite3_initialize() will invoke ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() ** will invoke sqlite3_os_end(). ** ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. ** ^If for some reason, sqlite3_initialize() is unable to initialize ** the library (perhaps it is unable to allocate a needed resource such ** as a mutex) it returns an [error code] other than [SQLITE_OK]. ** ** ^The sqlite3_initialize() routine is called internally by many other ** SQLite interfaces so that an application usually does not need to ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] ** calls sqlite3_initialize() so the SQLite library will be automatically ** initialized when [sqlite3_open()] is called if it has not be initialized ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] ** compile-time option, then the automatic calls to sqlite3_initialize() ** are omitted and the application must call sqlite3_initialize() directly ** prior to using any other SQLite interface. For maximum portability, ** it is recommended that applications always invoke sqlite3_initialize() ** directly prior to using any other SQLite interface. Future releases ** of SQLite may require this. In other words, the behavior exhibited ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the ** default behavior in some future release of SQLite. ** ** The sqlite3_os_init() routine does operating-system specific ** initialization of the SQLite library. The sqlite3_os_end() ** routine undoes the effect of sqlite3_os_init(). Typical tasks ** performed by these routines include allocation or deallocation ** of static resources, initialization of global variables, ** setting up a default [sqlite3_vfs] module, or setting up ** a default configuration using [sqlite3_config()]. ** ** The application should never invoke either sqlite3_os_init() ** or sqlite3_os_end() directly. The application should only invoke ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() ** interface is called automatically by sqlite3_initialize() and ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate ** implementations for sqlite3_os_init() and sqlite3_os_end() ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. ** When [custom builds | built for other platforms] ** (using the [SQLITE_OS_OTHER=1] compile-time ** option) the application must supply a suitable implementation for ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied ** implementation of sqlite3_os_init() or sqlite3_os_end() ** must return [SQLITE_OK] on success and some other [error code] upon ** failure. */ SQLITE_API int sqlite3_initialize(void); SQLITE_API int sqlite3_shutdown(void); SQLITE_API int sqlite3_os_init(void); SQLITE_API int sqlite3_os_end(void); /* ** CAPI3REF: Configuring The SQLite Library ** ** The sqlite3_config() interface is used to make global configuration ** changes to SQLite in order to tune SQLite to the specific needs of ** the application. The default configuration is recommended for most ** applications and so this routine is usually not necessary. It is ** provided to support rare applications with unusual needs. ** ** The sqlite3_config() interface is not threadsafe. The application ** must insure that no other SQLite interfaces are invoked by other ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() ** may only be invoked prior to library initialization using ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. ** Note, however, that ^sqlite3_config() can be called as part of the ** implementation of an application-defined [sqlite3_os_init()]. ** ** The first argument to sqlite3_config() is an integer ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] ** in the first argument. ** ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. ** ^If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. */ SQLITE_API int sqlite3_config(int, ...); /* ** CAPI3REF: Configure database connections ** ** The sqlite3_db_config() interface is used to make configuration ** changes to a [database connection]. The interface is similar to ** [sqlite3_config()] except that the changes apply to a single ** [database connection] (specified in the first argument). The ** sqlite3_db_config() interface should only be used immediately after ** the database connection is created using [sqlite3_open()], ** [sqlite3_open16()], or [sqlite3_open_v2()]. ** ** The second argument to sqlite3_db_config(D,V,...) is the ** configuration verb - an integer code that indicates what ** aspect of the [database connection] is being configured. ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. ** New verbs are likely to be added in future releases of SQLite. ** Additional arguments depend on the verb. ** ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if ** the call is considered successful. */ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); /* ** CAPI3REF: Memory Allocation Routines ** ** An instance of this object defines the interface between SQLite ** and low-level memory allocation routines. ** ** This object is used in only one place in the SQLite interface. ** A pointer to an instance of this object is the argument to ** [sqlite3_config()] when the configuration option is ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. ** By creating an instance of this object ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) ** during configuration, an application can specify an alternative ** memory allocation subsystem for SQLite to use for all of its ** dynamic memory needs. ** ** Note that SQLite comes with several [built-in memory allocators] ** that are perfectly adequate for the overwhelming majority of applications ** and that this object is only useful to a tiny minority of applications ** with specialized memory allocation requirements. This object is ** also used during testing of SQLite in order to specify an alternative ** memory allocator that simulates memory out-of-memory conditions in ** order to verify that SQLite recovers gracefully from such ** conditions. ** ** The xMalloc and xFree methods must work like the ** malloc() and free() functions from the standard C library. ** The xRealloc method must work like realloc() from the standard C library ** with the exception that if the second argument to xRealloc is zero, ** xRealloc must be a no-op - it must not perform any allocation or ** deallocation. ^SQLite guarantees that the second argument to ** xRealloc is always a value returned by a prior call to xRoundup. ** And so in cases where xRoundup always returns a positive number, ** xRealloc can perform exactly as the standard library realloc() and ** still be in compliance with this specification. ** ** xSize should return the allocated size of a memory allocation ** previously obtained from xMalloc or xRealloc. The allocated size ** is always at least as big as the requested size but may be larger. ** ** The xRoundup method returns what would be the allocated size of ** a memory allocation given a particular requested size. Most memory ** allocators round up memory allocations at least to the next multiple ** of 8. Some allocators round up to a larger multiple or to a power of 2. ** Every memory allocation request coming in through [sqlite3_malloc()] ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, ** that causes the corresponding memory allocation to fail. ** ** The xInit method initializes the memory allocator. (For example, ** it might allocate any require mutexes or initialize internal data ** structures. The xShutdown method is invoked (indirectly) by ** [sqlite3_shutdown()] and should deallocate any resources acquired ** by xInit. The pAppData pointer is used as the only parameter to ** xInit and xShutdown. ** ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes ** the xInit method, so the xInit method need not be threadsafe. The ** xShutdown method is only called from [sqlite3_shutdown()] so it does ** not need to be threadsafe either. For all other methods, SQLite ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which ** it is by default) and so the methods are automatically serialized. ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other ** methods must be threadsafe or else make their own arrangements for ** serialization. ** ** SQLite will never invoke xInit() more than once without an intervening ** call to xShutdown(). */ typedef struct sqlite3_mem_methods sqlite3_mem_methods; struct sqlite3_mem_methods { void *(*xMalloc)(int); /* Memory allocation function */ void (*xFree)(void*); /* Free a prior allocation */ void *(*xRealloc)(void*,int); /* Resize an allocation */ int (*xSize)(void*); /* Return the size of an allocation */ int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* ** CAPI3REF: Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the first argument to the [sqlite3_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_config()] to make sure that ** the call worked. The [sqlite3_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** **
**
SQLITE_CONFIG_SINGLETHREAD
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Single-thread. In other words, it disables ** all mutexing and puts SQLite into a mode where it can only be used ** by a single thread. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to change the [threading mode] from its default ** value of Single-thread and so [sqlite3_config()] will return ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD ** configuration option.
** **
SQLITE_CONFIG_MULTITHREAD
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Multi-thread. In other words, it disables ** mutexing on [database connection] and [prepared statement] objects. ** The application is responsible for serializing access to ** [database connections] and [prepared statements]. But other mutexes ** are enabled so that SQLite will be safe to use in a multi-threaded ** environment as long as no two threads attempt to use the same ** [database connection] at the same time. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to set the Multi-thread [threading mode] and ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_MULTITHREAD configuration option.
** **
SQLITE_CONFIG_SERIALIZED
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Serialized. In other words, this option enables ** all mutexes including the recursive ** mutexes on [database connection] and [prepared statement] objects. ** In this mode (which is the default when SQLite is compiled with ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access ** to [database connections] and [prepared statements] so that the ** application is free to use the same [database connection] or the ** same [prepared statement] in different threads at the same time. ** ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to set the Serialized [threading mode] and ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_SERIALIZED configuration option.
** **
SQLITE_CONFIG_MALLOC
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The argument specifies ** alternative low-level memory allocation routines to be used in place of ** the memory allocation routines built into SQLite.)^ ^SQLite makes ** its own private copy of the content of the [sqlite3_mem_methods] structure ** before the [sqlite3_config()] call returns.
** **
SQLITE_CONFIG_GETMALLOC
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines.)^ ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.
** **
SQLITE_CONFIG_MEMSTATUS
**
^This option takes single argument of type int, interpreted as a ** boolean, which enables or disables the collection of memory allocation ** statistics. ^(When memory allocation statistics are disabled, the ** following SQLite interfaces become non-operational: **
    **
  • [sqlite3_memory_used()] **
  • [sqlite3_memory_highwater()] **
  • [sqlite3_soft_heap_limit()] **
  • [sqlite3_status()] **
)^ ** ^Memory allocation statistics are enabled by default unless SQLite is ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory ** allocation statistics are disabled by default. **
** **
SQLITE_CONFIG_SCRATCH
**
^This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer an 8-byte ** aligned memory buffer from which the scrach allocations will be ** drawn, the size of each scratch allocation (sz), ** and the maximum number of scratch allocations (N). The sz ** argument must be a multiple of 16. The sz parameter should be a few bytes ** larger than the actual scratch space required due to internal overhead. ** The first argument must be a pointer to an 8-byte aligned buffer ** of at least sz*N bytes of memory. ** ^SQLite will use no more than one scratch buffer per thread. So ** N should be set to the expected maximum number of threads. ^SQLite will ** never require a scratch buffer that is more than 6 times the database ** page size. ^If SQLite needs needs additional scratch memory beyond ** what is provided by this configuration option, then ** [sqlite3_malloc()] will be used to obtain the memory needed.
** **
SQLITE_CONFIG_PAGECACHE
**
^This option specifies a static memory buffer that SQLite can use for ** the database page cache with the default page cache implemenation. ** This configuration should not be used if an application-define page ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. ** There are three arguments to this option: A pointer to 8-byte aligned ** memory, the size of each page buffer (sz), and the number of pages (N). ** The sz argument should be the size of the largest database page ** (a power of two between 512 and 32768) plus a little extra for each ** page header. ^The page header size is 20 to 40 bytes depending on ** the host architecture. ^It is harmless, apart from the wasted memory, ** to make sz a little too large. The first ** argument should point to an allocation of at least sz*N bytes of memory. ** ^SQLite will use the memory provided by the first argument to satisfy its ** memory needs for the first N pages that it adds to cache. ^If additional ** page cache memory is needed beyond what is provided by this option, then ** SQLite goes to [sqlite3_malloc()] for the additional storage space. ** ^The implementation might use one or more of the N buffers to hold ** memory accounting information. The pointer in the first argument must ** be aligned to an 8-byte boundary or subsequent behavior of SQLite ** will be undefined.
** **
SQLITE_CONFIG_HEAP
**
^This option specifies a static memory buffer that SQLite will use ** for all of its dynamic memory allocation needs beyond those provided ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. ** There are three arguments: An 8-byte aligned pointer to the memory, ** the number of bytes in the memory buffer, and the minimum allocation size. ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts ** to using its default memory allocator (the system malloc() implementation), ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory ** allocator is engaged to handle all of SQLites memory allocation needs. ** The first pointer (the memory pointer) must be aligned to an 8-byte ** boundary or subsequent behavior of SQLite will be undefined.
** **
SQLITE_CONFIG_MUTEX
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The argument specifies ** alternative low-level mutex routines to be used in place ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the ** content of the [sqlite3_mutex_methods] structure before the call to ** [sqlite3_config()] returns. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** the entire mutexing subsystem is omitted from the build and hence calls to ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will ** return [SQLITE_ERROR].
** **
SQLITE_CONFIG_GETMUTEX
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines.)^ ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** the entire mutexing subsystem is omitted from the build and hence calls to ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will ** return [SQLITE_ERROR].
** **
SQLITE_CONFIG_LOOKASIDE
**
^(This option takes two arguments that determine the default ** memory allocation for the lookaside memory allocator on each ** [database connection]. The first argument is the ** size of each lookaside buffer slot and the second is the number of ** slots allocated to each database connection.)^ ^(This option sets the ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] ** verb to [sqlite3_db_config()] can be used to change the lookaside ** configuration on individual connections.)^
** **
SQLITE_CONFIG_PCACHE
**
^(This option takes a single argument which is a pointer to ** an [sqlite3_pcache_methods] object. This object specifies the interface ** to a custom page cache implementation.)^ ^SQLite makes a copy of the ** object and uses it for page cache memory allocations.
** **
SQLITE_CONFIG_GETPCACHE
**
^(This option takes a single argument which is a pointer to an ** [sqlite3_pcache_methods] object. SQLite copies of the current ** page cache implementation into that object.)^
** **
SQLITE_CONFIG_LOG
**
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a ** function with a call signature of void(*)(void*,int,const char*), ** and a pointer to void. ^If the function pointer is not NULL, it is ** invoked by [sqlite3_log()] to process each logging event. ^If the ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is ** passed through as the first parameter to the application-defined logger ** function whenever that function is invoked. ^The second parameter to ** the logger function is a copy of the first parameter to the corresponding ** [sqlite3_log()] call and is intended to be a [result code] or an ** [extended result code]. ^The third parameter passed to the logger is ** log message after formatting via [sqlite3_snprintf()]. ** The SQLite logging interface is not reentrant; the logger function ** supplied by the application must not invoke any SQLite interface. ** In a multi-threaded application, the application-defined logger ** function must be threadsafe.
** **
*/ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_db_config()] to make sure that ** the call worked. ^The [sqlite3_db_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** **
**
SQLITE_DBCONFIG_LOOKASIDE
**
^This option takes three additional arguments that determine the ** [lookaside memory allocator] configuration for the [database connection]. ** ^The first argument (the third parameter to [sqlite3_db_config()] is a ** pointer to an memory buffer to use for lookaside memory. ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb ** may be NULL in which case SQLite will allocate the ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the ** size of each lookaside buffer slot. ^The third argument is the number of ** slots. The size of the buffer in the first argument must be greater than ** or equal to the product of the second and third arguments. The buffer ** must be aligned to an 8-byte boundary. ^If the second argument to ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally ** rounded down to the next smaller ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]
** **
*/ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** ** ^The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. ^The extended result ** codes are disabled by default for historical compatibility. */ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); /* ** CAPI3REF: Last Insert Rowid ** ** ^Each entry in an SQLite table has a unique 64-bit signed ** integer key called the [ROWID | "rowid"]. ^The rowid is always available ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those ** names are not also used by explicitly declared columns. ^If ** the table has a column of type [INTEGER PRIMARY KEY] then that column ** is another alias for the rowid. ** ** ^This routine returns the [rowid] of the most recent ** successful [INSERT] into the database from the [database connection] ** in the first argument. ^If no successful [INSERT]s ** have ever occurred on that database connection, zero is returned. ** ** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted ** row is returned by this routine as long as the trigger is running. ** But once the trigger terminates, the value returned by this routine ** reverts to the last value inserted before the trigger fired.)^ ** ** ^An [INSERT] that fails due to a constraint violation is not a ** successful [INSERT] and does not change the value returned by this ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, ** and INSERT OR ABORT make no changes to the return value of this ** routine when their insertion fails. ^(When INSERT OR REPLACE ** encounters a constraint violation, it does not fail. The ** INSERT continues to completion after deleting rows that caused ** the constraint problem so INSERT OR REPLACE will always change ** the return value of this interface.)^ ** ** ^For the purposes of this routine, an [INSERT] is considered to ** be successful even if it is subsequently rolled back. ** ** This function is accessible to SQL statements via the ** [last_insert_rowid() SQL function]. ** ** If a separate thread performs a new [INSERT] on the same ** database connection while the [sqlite3_last_insert_rowid()] ** function is running and thus changes the last insert [rowid], ** then the value returned by [sqlite3_last_insert_rowid()] is ** unpredictable and might not equal either the old or the new ** last insert [rowid]. */ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); /* ** CAPI3REF: Count The Number Of Rows Modified ** ** ^This function returns the number of database rows that were changed ** or inserted or deleted by the most recently completed SQL statement ** on the [database connection] specified by the first parameter. ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], ** or [DELETE] statement are counted. Auxiliary changes caused by ** triggers or [foreign key actions] are not counted.)^ Use the ** [sqlite3_total_changes()] function to find the total number of changes ** including changes caused by triggers and foreign key actions. ** ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] ** are not counted. Only real table changes are counted. ** ** ^(A "row change" is a change to a single row of a single table ** caused by an INSERT, DELETE, or UPDATE statement. Rows that ** are changed as side effects of [REPLACE] constraint resolution, ** rollback, ABORT processing, [DROP TABLE], or by any other ** mechanisms do not count as direct row changes.)^ ** ** A "trigger context" is a scope of execution that begins and ** ends with the script of a [CREATE TRIGGER | trigger]. ** Most SQL statements are ** evaluated outside of any trigger. This is the "top level" ** trigger context. If a trigger fires from the top level, a ** new trigger context is entered for the duration of that one ** trigger. Subtriggers create subcontexts for their duration. ** ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does ** not create a new trigger context. ** ** ^This function returns the number of direct row changes in the ** most recent INSERT, UPDATE, or DELETE statement within the same ** trigger context. ** ** ^Thus, when called from the top level, this function returns the ** number of changes in the most recent INSERT, UPDATE, or DELETE ** that also occurred at the top level. ^(Within the body of a trigger, ** the sqlite3_changes() interface can be called to find the number of ** changes in the most recently completed INSERT, UPDATE, or DELETE ** statement within the body of the same trigger. ** However, the number returned does not include changes ** caused by subtriggers since those have their own context.)^ ** ** See also the [sqlite3_total_changes()] interface, the ** [count_changes pragma], and the [changes() SQL function]. ** ** If a separate thread makes changes on the same database connection ** while [sqlite3_changes()] is running then the value returned ** is unpredictable and not meaningful. */ SQLITE_API int sqlite3_changes(sqlite3*); /* ** CAPI3REF: Total Number Of Rows Modified ** ** ^This function returns the number of row changes caused by [INSERT], ** [UPDATE] or [DELETE] statements since the [database connection] was opened. ** ^(The count returned by sqlite3_total_changes() includes all changes ** from all [CREATE TRIGGER | trigger] contexts and changes made by ** [foreign key actions]. However, ** the count does not include changes used to implement [REPLACE] constraints, ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The ** count does not include rows of views that fire an [INSTEAD OF trigger], ** though if the INSTEAD OF trigger makes changes of its own, those changes ** are counted.)^ ** ^The sqlite3_total_changes() function counts the changes as soon as ** the statement that makes them is completed (when the statement handle ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). ** ** See also the [sqlite3_changes()] interface, the ** [count_changes pragma], and the [total_changes() SQL function]. ** ** If a separate thread makes changes on the same database connection ** while [sqlite3_total_changes()] is running then the value ** returned is unpredictable and not meaningful. */ SQLITE_API int sqlite3_total_changes(sqlite3*); /* ** CAPI3REF: Interrupt A Long-Running Query ** ** ^This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically ** called in response to a user action such as pressing "Cancel" ** or Ctrl-C where the user wants a long query operation to halt ** immediately. ** ** ^It is safe to call this routine from a thread different from the ** thread that is currently running the database operation. But it ** is not safe to call this routine with a [database connection] that ** is closed or might close before sqlite3_interrupt() returns. ** ** ^If an SQL operation is very nearly finished at the time when ** sqlite3_interrupt() is called, then it might not have an opportunity ** to be interrupted and might continue to completion. ** ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE ** that is inside an explicit transaction, then the entire transaction ** will be rolled back automatically. ** ** ^The sqlite3_interrupt(D) call is in effect until all currently running ** SQL statements on [database connection] D complete. ^Any new SQL statements ** that are started after the sqlite3_interrupt() call and before the ** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). ** ^A call to sqlite3_interrupt(D) that occurs when there are no running ** SQL statements is a no-op and has no effect on SQL statements ** that are started after the sqlite3_interrupt() call returns. ** ** If the database connection closes while [sqlite3_interrupt()] ** is running then bad things will likely happen. */ SQLITE_API void sqlite3_interrupt(sqlite3*); /* ** CAPI3REF: Determine If An SQL Statement Is Complete ** ** These routines are useful during command-line input to determine if the ** currently entered text seems to form a complete SQL statement or ** if additional input is needed before sending the text into ** SQLite for parsing. ^These routines return 1 if the input string ** appears to be a complete SQL statement. ^A statement is judged to be ** complete if it ends with a semicolon token and is not a prefix of a ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within ** string literals or quoted identifier names or comments are not ** independent tokens (they are part of the token in which they are ** embedded) and thus do not count as a statement terminator. ^Whitespace ** and comments that follow the final semicolon are ignored. ** ** ^These routines return 0 if the statement is incomplete. ^If a ** memory allocation fails, then SQLITE_NOMEM is returned. ** ** ^These routines do not parse the SQL statements thus ** will not detect syntactically incorrect SQL. ** ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked ** automatically by sqlite3_complete16(). If that initialization fails, ** then the return value from sqlite3_complete16() will be non-zero ** regardless of whether or not the input SQL is complete.)^ ** ** The input to [sqlite3_complete()] must be a zero-terminated ** UTF-8 string. ** ** The input to [sqlite3_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ SQLITE_API int sqlite3_complete(const char *sql); SQLITE_API int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors ** ** ^This routine sets a callback function that might be invoked whenever ** an attempt is made to open a database table that another thread ** or process has locked. ** ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] ** is returned immediately upon encountering the lock. ^If the busy callback ** is not NULL, then the callback might be invoked with two arguments. ** ** ^The first argument to the busy handler is a copy of the void* pointer which ** is the third argument to sqlite3_busy_handler(). ^The second argument to ** the busy handler callback is the number of times that the busy handler has ** been invoked for this locking event. ^If the ** busy callback returns 0, then no additional attempts are made to ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. ** ^If the callback returns non-zero, then another attempt ** is made to open the database for reading and the cycle repeats. ** ** The presence of a busy handler does not guarantee that it will be invoked ** when there is lock contention. ^If SQLite determines that invoking the busy ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. ** Consider a scenario where one process is holding a read lock that ** it is trying to promote to a reserved lock and ** a second process is holding a reserved lock that it is trying ** to promote to an exclusive lock. The first process cannot proceed ** because it is blocked by the second and the second process cannot ** proceed because it is blocked by the first. If both processes ** invoke the busy handlers, neither will make any progress. Therefore, ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this ** will induce the first process to release its read lock and allow ** the second process to proceed. ** ** ^The default busy callback is NULL. ** ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] ** when SQLite is in the middle of a large transaction where all the ** changes will not fit into the in-memory cache. SQLite will ** already hold a RESERVED lock on the database file, but it needs ** to promote this lock to EXCLUSIVE so that it can spill cache ** pages into the database file without harm to concurrent ** readers. ^If it is unable to promote the lock, then the in-memory ** cache will be left in an inconsistent state and so the error ** code is promoted from the relatively benign [SQLITE_BUSY] to ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion ** forces an automatic rollback of the changes. See the ** ** CorruptionFollowingBusyError wiki page for a discussion of why ** this is important. ** ** ^(There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** The busy callback should not take any actions which modify the ** database connection that invoked the busy handler. Any such actions ** result in undefined behavior. ** ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout ** ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. ^The handler ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. ^After at least "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. ** ** ^Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. ** ** ^(There can only be a single busy handler for a particular ** [database connection] any any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared.)^ */ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries ** ** Definition: A result table is memory data structure created by the ** [sqlite3_get_table()] interface. A result table records the ** complete query results from one or more queries. ** ** The table conceptually has a number of rows and columns. But ** these numbers are not part of the result table itself. These ** numbers are obtained separately. Let N be the number of rows ** and M be the number of columns. ** ** A result table is an array of pointers to zero-terminated UTF-8 strings. ** There are (N+1)*M elements in the array. The first M pointers point ** to zero-terminated strings that contain the names of the columns. ** The remaining entries all point to query results. NULL values result ** in NULL pointers. All other values are in their UTF-8 zero-terminated ** string representation as returned by [sqlite3_column_text()]. ** ** A result table might consist of one or more memory allocations. ** It is not safe to pass a result table directly to [sqlite3_free()]. ** A result table should be deallocated using [sqlite3_free_table()]. ** ** As an example of the result table format, suppose a query result ** is as follows: ** **
**        Name        | Age
**        -----------------------
**        Alice       | 43
**        Bob         | 28
**        Cindy       | 21
** 
** ** There are two column (M==2) and three rows (N==3). Thus the ** result table has 8 entries. Suppose the result table is stored ** in an array names azResult. Then azResult holds this content: ** **
**        azResult[0] = "Name";
**        azResult[1] = "Age";
**        azResult[2] = "Alice";
**        azResult[3] = "43";
**        azResult[4] = "Bob";
**        azResult[5] = "28";
**        azResult[6] = "Cindy";
**        azResult[7] = "21";
** 
** ** ^The sqlite3_get_table() function evaluates one or more ** semicolon-separated SQL statements in the zero-terminated UTF-8 ** string of its 2nd parameter and returns a result table to the ** pointer given in its 3rd parameter. ** ** After the application has finished with the result from sqlite3_get_table(), ** it should pass the result table pointer to sqlite3_free_table() in order to ** release the memory that was malloced. Because of the way the ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling ** function must not try to call [sqlite3_free()] directly. Only ** [sqlite3_free_table()] is able to release the memory properly and safely. ** ** ^(The sqlite3_get_table() interface is implemented as a wrapper around ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or ** [sqlite3_errmsg()].)^ */ SQLITE_API int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ ); SQLITE_API void sqlite3_free_table(char **result); /* ** CAPI3REF: Formatted String Printing Functions ** ** These routines are work-alikes of the "printf()" family of functions ** from the standard C library. ** ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their ** results into memory obtained from [sqlite3_malloc()]. ** The strings returned by these two routines should be ** released by [sqlite3_free()]. ^Both routines return a ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough ** memory to hold the resulting string. ** ** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from ** the standard C library. The result is written into the ** buffer supplied as the second parameter whose size is given by ** the first parameter. Note that the order of the ** first two parameters is reversed from snprintf().)^ This is an ** historical accident that cannot be fixed without breaking ** backwards compatibility. ^(Note also that sqlite3_snprintf() ** returns a pointer to its buffer instead of the number of ** characters actually written into the buffer.)^ We admit that ** the number of characters written would be a more useful return ** value but we cannot change the implementation of sqlite3_snprintf() ** now without breaking compatibility. ** ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() ** guarantees that the buffer is always zero-terminated. ^The first ** parameter "n" is the total size of the buffer, including space for ** the zero terminator. So the longest string that can be completely ** written will be n-1 characters. ** ** These routines all implement some additional formatting ** options that are useful for constructing SQL statements. ** All of the usual printf() formatting options apply. In addition, there ** is are "%q", "%Q", and "%z" options. ** ** ^(The %q option works like %s in that it substitutes a null-terminated ** string from the argument list. But %q also doubles every '\'' character. ** %q is designed for use inside a string literal.)^ By doubling each '\'' ** character it escapes that character and allows it to be inserted into ** the string. ** ** For example, assume the string variable zText contains text as follows: ** **
**  char *zText = "It's a happy day!";
** 
** ** One can use this text in an SQL statement as follows: ** **
**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
**  sqlite3_exec(db, zSQL, 0, 0, 0);
**  sqlite3_free(zSQL);
** 
** ** Because the %q format string is used, the '\'' character in zText ** is escaped and the SQL generated is as follows: ** **
**  INSERT INTO table1 VALUES('It''s a happy day!')
** 
** ** This is correct. Had we used %s instead of %q, the generated SQL ** would have looked like this: ** **
**  INSERT INTO table1 VALUES('It's a happy day!');
** 
** ** This second example is an SQL syntax error. As a general rule you should ** always use %q instead of %s when inserting text into a string literal. ** ** ^(The %Q option works like %q except it also adds single quotes around ** the outside of the total string. Additionally, if the parameter in the ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without ** single quotes).)^ So, for example, one could say: ** **
**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
**  sqlite3_exec(db, zSQL, 0, 0, 0);
**  sqlite3_free(zSQL);
** 
** ** The code above will render a correct SQL statement in the zSQL ** variable even if the zText variable is a NULL pointer. ** ** ^(The "%z" formatting option works like "%s" but with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string.)^ */ SQLITE_API char *sqlite3_mprintf(const char*,...); SQLITE_API char *sqlite3_vmprintf(const char*, va_list); SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); /* ** CAPI3REF: Memory Allocation Subsystem ** ** The SQLite core uses these three routines for all of its own ** internal memory allocation needs. "Core" in the previous sentence ** does not include operating-system specific VFS implementation. The ** Windows VFS uses native malloc() and free() for some operations. ** ** ^The sqlite3_malloc() routine returns a pointer to a block ** of memory at least N bytes in length, where N is the parameter. ** ^If sqlite3_malloc() is unable to obtain sufficient free ** memory, it returns a NULL pointer. ^If the parameter N to ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns ** a NULL pointer. ** ** ^Calling sqlite3_free() with a pointer previously returned ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so ** that it might be reused. ^The sqlite3_free() routine is ** a no-op if is called with a NULL pointer. Passing a NULL pointer ** to sqlite3_free() is harmless. After being freed, memory ** should neither be read nor written. Even reading previously freed ** memory might result in a segmentation fault or other severe error. ** Memory corruption, a segmentation fault, or other severe error ** might result if sqlite3_free() is called with a non-NULL pointer that ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). ** ** ^(The sqlite3_realloc() interface attempts to resize a ** prior memory allocation to be at least N bytes, where N is the ** second parameter. The memory allocation to be resized is the first ** parameter.)^ ^ If the first parameter to sqlite3_realloc() ** is a NULL pointer then its behavior is identical to calling ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). ** ^If the second parameter to sqlite3_realloc() is zero or ** negative then the behavior is exactly the same as calling ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). ** ^sqlite3_realloc() returns a pointer to a memory allocation ** of at least N bytes in size or NULL if sufficient memory is unavailable. ** ^If M is the size of the prior allocation, then min(N,M) bytes ** of the prior allocation are copied into the beginning of buffer returned ** by sqlite3_realloc() and the prior allocation is freed. ** ^If sqlite3_realloc() returns NULL, then the prior allocation ** is not freed. ** ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary. ** ** In SQLite version 3.5.0 and 3.5.1, it was possible to define ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in ** implementation of these routines to be omitted. That capability ** is no longer provided. Only built-in memory allocators can be used. ** ** The Windows OS interface layer calls ** the system malloc() and free() directly when converting ** filenames between the UTF-8 encoding used by SQLite ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors are detected, but ** they are reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] ** must be either NULL or else pointers obtained from a prior ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have ** not yet been released. ** ** The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ SQLITE_API void *sqlite3_malloc(int); SQLITE_API void *sqlite3_realloc(void*, int); SQLITE_API void sqlite3_free(void*); /* ** CAPI3REF: Memory Allocator Statistics ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. ** ** ^The [sqlite3_memory_used()] routine returns the number of bytes ** of memory currently outstanding (malloced but not freed). ** ^The [sqlite3_memory_highwater()] routine returns the maximum ** value of [sqlite3_memory_used()] since the high-water mark ** was last reset. ^The values returned by [sqlite3_memory_used()] and ** [sqlite3_memory_highwater()] include any overhead ** added by SQLite in its implementation of [sqlite3_malloc()], ** but not overhead added by the any underlying system library ** routines that [sqlite3_malloc()] may call. ** ** ^The memory high-water mark is reset to the current value of ** [sqlite3_memory_used()] if and only if the parameter to ** [sqlite3_memory_highwater()] is true. ^The value returned ** by [sqlite3_memory_highwater(1)] is the high-water mark ** prior to the reset. */ SQLITE_API sqlite3_int64 sqlite3_memory_used(void); SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); /* ** CAPI3REF: Pseudo-Random Number Generator ** ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to ** select random [ROWID | ROWIDs] when inserting new records into a table that ** already uses the largest possible [ROWID]. The PRNG is also used for ** the build-in random() and randomblob() SQL functions. This interface allows ** applications to access the same PRNG for other purposes. ** ** ^A call to this routine stores N bytes of randomness into buffer P. ** ** ^The first time this routine is invoked (either internally or by ** the application) the PRNG is seeded using randomness obtained ** from the xRandomness method of the default [sqlite3_vfs] object. ** ^On all subsequent invocations, the pseudo-randomness is generated ** internally and without recourse to the [sqlite3_vfs] xRandomness ** method. */ SQLITE_API void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks ** ** ^This routine registers a authorizer callback with a particular ** [database connection], supplied in the first argument. ** ^The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various ** points during the compilation process, as logic is being created ** to perform various actions, the authorizer callback is invoked to ** see if those actions are allowed. ^The authorizer callback should ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the ** specific action but allow the SQL statement to continue to be ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be ** rejected with an error. ^If the authorizer callback returns ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] ** then the [sqlite3_prepare_v2()] or equivalent call that triggered ** the authorizer will fail with an error message. ** ** When the callback returns [SQLITE_OK], that means the operation ** requested is ok. ^When the callback returns [SQLITE_DENY], the ** [sqlite3_prepare_v2()] or equivalent call that triggered the ** authorizer will fail with an error message explaining that ** access is denied. ** ** ^The first parameter to the authorizer callback is a copy of the third ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter ** to the callback is an integer [SQLITE_COPY | action code] that specifies ** the particular action to be authorized. ^The third through sixth parameters ** to the callback are zero-terminated strings that contain additional ** details about the action to be authorized. ** ** ^If the action code is [SQLITE_READ] ** and the callback returns [SQLITE_IGNORE] then the ** [prepared statement] statement is constructed to substitute ** a NULL value in place of the table column that would have ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] ** return can be used to deny an untrusted user access to individual ** columns of a table. ** ^If the action code is [SQLITE_DELETE] and the callback returns ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the ** [truncate optimization] is disabled and all rows are deleted individually. ** ** An authorizer is used when [sqlite3_prepare | preparing] ** SQL statements from an untrusted source, to ensure that the SQL statements ** do not try to access data they are not allowed to see, or that they do not ** try to execute malicious statements that damage the database. For ** example, an application may allow a user to enter arbitrary ** SQL queries for evaluation by a database. But the application does ** not want the user to be able to make arbitrary changes to the ** database. An authorizer could then be put in place while the ** user-entered SQL is being [sqlite3_prepare | prepared] that ** disallows everything except [SELECT] statements. ** ** Applications that need to process SQL from untrusted sources ** might also consider lowering resource limits using [sqlite3_limit()] ** and limiting database size using the [max_page_count] [PRAGMA] ** in addition to using an authorizer. ** ** ^(Only a single authorizer can be in place on a database connection ** at a time. Each call to sqlite3_set_authorizer overrides the ** previous call.)^ ^Disable the authorizer by installing a NULL callback. ** The authorizer is disabled by default. ** ** The authorizer callback must not do anything that will modify ** the database connection that invoked the authorizer callback. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the ** statement might be re-prepared during [sqlite3_step()] due to a ** schema change. Hence, the application should ensure that the ** correct authorizer callback remains in place during the [sqlite3_step()]. ** ** ^Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()], unless ** as stated in the previous paragraph, sqlite3_step() invokes ** sqlite3_prepare_v2() to reprepare a statement after a schema change. */ SQLITE_API int sqlite3_set_authorizer( sqlite3*, int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData ); /* ** CAPI3REF: Authorizer Return Codes ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ /* ** CAPI3REF: Authorizer Action Codes ** ** The [sqlite3_set_authorizer()] interface registers a callback function ** that is invoked to authorize certain SQL statement actions. The ** second parameter to the callback is an integer code that specifies ** what action is being authorized. These are the integer action codes that ** the authorizer callback may be passed. ** ** These action code values signify what kind of operation is to be ** authorized. The 3rd and 4th parameters to the authorization ** callback function will be parameters or NULL depending on which of these ** codes is used as the second parameter. ^(The 5th parameter to the ** authorizer callback is the name of the database ("main", "temp", ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback ** is the name of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. */ /******************************************* 3rd ************ 4th ***********/ #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ #define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ #define SQLITE_CREATE_VIEW 8 /* View Name NULL */ #define SQLITE_DELETE 9 /* Table Name NULL */ #define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ #define SQLITE_DROP_TABLE 11 /* Table Name NULL */ #define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ #define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ #define SQLITE_DROP_VIEW 17 /* View Name NULL */ #define SQLITE_INSERT 18 /* Table Name NULL */ #define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ #define SQLITE_READ 20 /* Table Name Column Name */ #define SQLITE_SELECT 21 /* NULL NULL */ #define SQLITE_TRANSACTION 22 /* Operation NULL */ #define SQLITE_UPDATE 23 /* Table Name Column Name */ #define SQLITE_ATTACH 24 /* Filename NULL */ #define SQLITE_DETACH 25 /* Database Name NULL */ #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** ** ^The callback function registered by sqlite3_trace() is invoked at ** various times when an SQL statement is being run by [sqlite3_step()]. ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the ** SQL statement text as the statement first begins executing. ** ^(Additional sqlite3_trace() callbacks might occur ** as each triggered subprogram is entered. The callbacks for triggers ** contain a UTF-8 SQL comment that identifies the trigger.)^ ** ** ^The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. ^The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ^The profile callback ** time is in units of nanoseconds, however the current implementation ** is only capable of millisecond resolution so the six least significant ** digits in the time are meaningless. Future versions of SQLite ** might provide greater resolution on the profiler callback. The ** sqlite3_profile() function is considered experimental and is ** subject to change in future versions of SQLite. */ SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: Query Progress Callbacks ** ** ^This routine configures a callback function - the ** progress callback - that is invoked periodically during long ** running calls to [sqlite3_exec()], [sqlite3_step()] and ** [sqlite3_get_table()]. An example use for this ** interface is to keep a GUI updated during a large query. ** ** ^If the progress callback returns non-zero, the operation is ** interrupted. This feature can be used to implement a ** "Cancel" button on a GUI progress dialog box. ** ** The progress handler must not do anything that will modify ** the database connection that invoked the progress handler. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** */ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection ** ** ^These routines open an SQLite database file whose name is given by the ** filename argument. ^The filename argument is interpreted as UTF-8 for ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte ** order for sqlite3_open16(). ^(A [database connection] handle is usually ** returned in *ppDb, even if an error occurs. The only exception is that ** if SQLite is unable to allocate memory to hold the [sqlite3] object, ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] ** object.)^ ^(If the database is opened (and/or created) successfully, then ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain ** an English language description of the error following a failure of any ** of the sqlite3_open() routines. ** ** ^The default encoding for the database will be UTF-8 if ** sqlite3_open() or sqlite3_open_v2() is called and ** UTF-16 in the native byte order if sqlite3_open16() is used. ** ** Whether or not an error occurs when it is opened, resources ** associated with the [database connection] handle should be released by ** passing it to [sqlite3_close()] when it is no longer required. ** ** The sqlite3_open_v2() interface works like sqlite3_open() ** except that it accepts two additional parameters for additional control ** over the new database connection. ^(The flags parameter to ** sqlite3_open_v2() can take one of ** the following three values, optionally combined with the ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ ** **
** ^(
[SQLITE_OPEN_READONLY]
**
The database is opened in read-only mode. If the database does not ** already exist, an error is returned.
)^ ** ** ^(
[SQLITE_OPEN_READWRITE]
**
The database is opened for reading and writing if possible, or reading ** only if the file is write protected by the operating system. In either ** case the database must already exist, otherwise an error is returned.
)^ ** ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
**
The database is opened for reading and writing, and is creates it if ** it does not already exist. This is the behavior that is always used for ** sqlite3_open() and sqlite3_open16().
)^ **
** ** If the 3rd parameter to sqlite3_open_v2() is not one of the ** combinations shown above or one of the combinations shown above combined ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, ** then the behavior is undefined. ** ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection ** opens in the multi-thread [threading mode] as long as the single-thread ** mode has not been set at compile-time or start-time. ^If the ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens ** in the serialized [threading mode] unless single-thread was ** previously selected at compile-time or start-time. ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be ** eligible to use [shared cache mode], regardless of whether or not shared ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not ** participate in [shared cache mode] even if it is enabled. ** ** ^If the filename is ":memory:", then a private, temporary in-memory database ** is created for the connection. ^This in-memory database will vanish when ** the database connection is closed. Future versions of SQLite might ** make use of additional special filenames that begin with the ":" character. ** It is recommended that when a database filename actually does begin with ** a ":" character you should prefix the filename with a pathname such as ** "./" to avoid ambiguity. ** ** ^If the filename is an empty string, then a private, temporary ** on-disk database will be created. ^This private database will be ** automatically deleted as soon as the database connection is closed. ** ** ^The fourth parameter to sqlite3_open_v2() is the name of the ** [sqlite3_vfs] object that defines the operating system interface that ** the new database connection should use. ^If the fourth parameter is ** a NULL pointer then the default [sqlite3_vfs] object is used. ** ** Note to Windows users: The encoding used for the filename argument ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). */ SQLITE_API int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open_v2( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb, /* OUT: SQLite db handle */ int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ); /* ** CAPI3REF: Error Codes And Messages ** ** ^The sqlite3_errcode() interface returns the numeric [result code] or ** [extended result code] for the most recent failed sqlite3_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() ** interface is the same except that it always returns the ** [extended result code] even when extended result codes are ** disabled. ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ ** ** When the serialized [threading mode] is in use, it might be the ** case that a second error occurs on a separate thread in between ** the time of the first error and the call to these interfaces. ** When that happens, the second error will be reported since these ** interfaces always report the most recent result. To avoid ** this, each thread can obtain exclusive use of the [database connection] D ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after ** all calls to the interfaces listed here are completed. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. */ SQLITE_API int sqlite3_errcode(sqlite3 *db); SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); SQLITE_API const char *sqlite3_errmsg(sqlite3*); SQLITE_API const void *sqlite3_errmsg16(sqlite3*); /* ** CAPI3REF: SQL Statement Object ** KEYWORDS: {prepared statement} {prepared statements} ** ** An instance of this object represents a single SQL statement. ** This object is variously known as a "prepared statement" or a ** "compiled SQL statement" or simply as a "statement". ** ** The life of a statement object goes something like this: ** **
    **
  1. Create the object using [sqlite3_prepare_v2()] or a related ** function. **
  2. Bind values to [host parameters] using the sqlite3_bind_*() ** interfaces. **
  3. Run the SQL by calling [sqlite3_step()] one or more times. **
  4. Reset the statement using [sqlite3_reset()] then go back ** to step 2. Do this zero or more times. **
  5. Destroy the object using [sqlite3_finalize()]. **
** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* ** CAPI3REF: Run-time Limits ** ** ^(This interface allows the size of various constructs to be limited ** on a connection by connection basis. The first parameter is the ** [database connection] whose limit is to be set or queried. The ** second parameter is one of the [limit categories] that define a ** class of constructs to be size limited. The third parameter is the ** new limit for that construct. The function returns the old limit.)^ ** ** ^If the new limit is a negative number, the limit is unchanged. ** ^(For the limit category of SQLITE_LIMIT_XYZ there is a ** [limits | hard upper bound] ** set by a compile-time C preprocessor macro named ** [limits | SQLITE_MAX_XYZ]. ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ ** ^Attempts to increase a limit above its hard upper bound are ** silently truncated to the hard upper bound. ** ** Run-time limits are intended for use in applications that manage ** both their own internal database and also databases that are controlled ** by untrusted external sources. An example application might be a ** web browser that has its own databases for storing history and ** separate databases controlled by JavaScript applications downloaded ** off the Internet. The internal databases can be given the ** large, default limits. Databases managed by external sources can ** be given much smaller limits designed to prevent a denial of service ** attack. Developers might also want to use the [sqlite3_set_authorizer()] ** interface to further control untrusted SQL. The size of the database ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. */ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); /* ** CAPI3REF: Run-Time Limit Categories ** KEYWORDS: {limit category} {*limit categories} ** ** These constants define various performance limits ** that can be lowered at run-time using [sqlite3_limit()]. ** The synopsis of the meanings of the various limits is shown below. ** Additional information is available at [limits | Limits in SQLite]. ** **
** ^(
SQLITE_LIMIT_LENGTH
**
The maximum size of any string or BLOB or table row.
)^ ** ** ^(
SQLITE_LIMIT_SQL_LENGTH
**
The maximum length of an SQL statement, in bytes.
)^ ** ** ^(
SQLITE_LIMIT_COLUMN
**
The maximum number of columns in a table definition or in the ** result set of a [SELECT] or the maximum number of columns in an index ** or in an ORDER BY or GROUP BY clause.
)^ ** ** ^(
SQLITE_LIMIT_EXPR_DEPTH
**
The maximum depth of the parse tree on any expression.
)^ ** ** ^(
SQLITE_LIMIT_COMPOUND_SELECT
**
The maximum number of terms in a compound SELECT statement.
)^ ** ** ^(
SQLITE_LIMIT_VDBE_OP
**
The maximum number of instructions in a virtual machine program ** used to implement an SQL statement.
)^ ** ** ^(
SQLITE_LIMIT_FUNCTION_ARG
**
The maximum number of arguments on a function.
)^ ** ** ^(
SQLITE_LIMIT_ATTACHED
**
The maximum number of [ATTACH | attached databases].)^
** ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
**
The maximum length of the pattern argument to the [LIKE] or ** [GLOB] operators.
)^ ** ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
**
The maximum number of variables in an SQL statement that can ** be bound.
)^ ** ** ^(
SQLITE_LIMIT_TRIGGER_DEPTH
**
The maximum depth of recursion for triggers.
)^ **
*/ #define SQLITE_LIMIT_LENGTH 0 #define SQLITE_LIMIT_SQL_LENGTH 1 #define SQLITE_LIMIT_COLUMN 2 #define SQLITE_LIMIT_EXPR_DEPTH 3 #define SQLITE_LIMIT_COMPOUND_SELECT 4 #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 #define SQLITE_LIMIT_TRIGGER_DEPTH 10 /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} ** ** To execute an SQL query, it must first be compiled into a byte-code ** program using one of these routines. ** ** The first argument, "db", is a [database connection] obtained from a ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or ** [sqlite3_open16()]. The database connection must not have been closed. ** ** The second argument, "zSql", is the statement to be compiled, encoded ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() ** use UTF-16. ** ** ^If the nByte argument is less than zero, then zSql is read up to the ** first zero terminator. ^If nByte is non-negative, then it is the maximum ** number of bytes read from zSql. ^When nByte is non-negative, the ** zSql string ends at either the first '\000' or '\u0000' character or ** the nByte-th byte, whichever comes first. If the caller knows ** that the supplied string is nul-terminated, then there is a small ** performance advantage to be gained by passing an nByte parameter that ** is equal to the number of bytes in the input string including ** the nul-terminator bytes. ** ** ^If pzTail is not NULL then *pzTail is made to point to the first byte ** past the end of the first SQL statement in zSql. These routines only ** compile the first statement in zSql, so *pzTail is left pointing to ** what remains uncompiled. ** ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set ** to NULL. ^If the input text contains no SQL (if the input is an empty ** string or a comment) then *ppStmt is set to NULL. ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite3_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. ** ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are ** recommended for all new programs. The two older interfaces are retained ** for backwards compatibility, but their use is discouraged. ** ^In the "v2" interfaces, the prepared statement ** that is returned (the [sqlite3_stmt] object) contains a copy of the ** original SQL text. This causes the [sqlite3_step()] interface to ** behave differently in three ways: ** **
    **
  1. ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it ** always used to do, [sqlite3_step()] will automatically recompile the SQL ** statement and try to run it again. ^If the schema has changed in ** a way that makes the statement no longer valid, [sqlite3_step()] will still ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the ** error go away. Note: use [sqlite3_errmsg()] to find the text ** of the parsing error that results in an [SQLITE_SCHEMA] return. **
  2. ** **
  3. ** ^When an error occurs, [sqlite3_step()] will return one of the detailed ** [error codes] or [extended error codes]. ^The legacy behavior was that ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code ** and the application would have to make a second call to [sqlite3_reset()] ** in order to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. **
  4. ** **
  5. ** ^If the value of a [parameter | host parameter] in the WHERE clause might ** change the query plan for a statement, then the statement may be ** automatically recompiled (as if there had been a schema change) on the first ** [sqlite3_step()] call following any change to the ** [sqlite3_bind_text | bindings] of the [parameter]. **
  6. **
*/ SQLITE_API int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare_v2( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPI3REF: Retrieving Statement SQL ** ** ^This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. */ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Dynamically Typed Value Object ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} ** ** SQLite uses the sqlite3_value object to represent all values ** that can be stored in a database table. SQLite uses dynamic typing ** for the values it stores. ^Values stored in sqlite3_value objects ** can be integers, floating point values, strings, BLOBs, or NULL. ** ** An sqlite3_value object may be either "protected" or "unprotected". ** Some interfaces require a protected sqlite3_value. Other interfaces ** will accept either a protected or an unprotected sqlite3_value. ** Every interface that accepts sqlite3_value arguments specifies ** whether or not it requires a protected sqlite3_value. ** ** The terms "protected" and "unprotected" refer to whether or not ** a mutex is held. A internal mutex is held for a protected ** sqlite3_value object but no mutex is held for an unprotected ** sqlite3_value object. If SQLite is compiled to be single-threaded ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) ** or if SQLite is run in one of reduced mutex modes ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] ** then there is no distinction between protected and unprotected ** sqlite3_value objects and they can be used interchangeably. However, ** for maximum code portability it is recommended that applications ** still make the distinction between between protected and unprotected ** sqlite3_value objects even when not strictly required. ** ** ^The sqlite3_value objects that are passed as parameters into the ** implementation of [application-defined SQL functions] are protected. ** ^The sqlite3_value object returned by ** [sqlite3_column_value()] is unprotected. ** Unprotected sqlite3_value objects may only be used with ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* ** CAPI3REF: SQL Function Context Object ** ** The context in which an SQL function executes is stored in an ** sqlite3_context object. ^A pointer to an sqlite3_context object ** is always first parameter to [application-defined SQL functions]. ** The application-defined SQL function implementation will pass this ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], ** [sqlite3_aggregate_context()], [sqlite3_user_data()], ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], ** and/or [sqlite3_set_auxdata()]. */ typedef struct sqlite3_context sqlite3_context; /* ** CAPI3REF: Binding Values To Prepared Statements ** KEYWORDS: {host parameter} {host parameters} {host parameter name} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} ** ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, ** literals may be replaced by a [parameter] that matches one of following ** templates: ** **
    **
  • ? **
  • ?NNN **
  • :VVV **
  • @VVV **
  • $VVV **
** ** In the templates above, NNN represents an integer literal, ** and VVV represents an alphanumeric identifier.)^ ^The values of these ** parameters (also called "host parameter names" or "SQL parameters") ** can be set using the sqlite3_bind_*() routines defined here. ** ** ^The first argument to the sqlite3_bind_*() routines is always ** a pointer to the [sqlite3_stmt] object returned from ** [sqlite3_prepare_v2()] or its variants. ** ** ^The second argument is the index of the SQL parameter to be set. ** ^The leftmost SQL parameter has an index of 1. ^When the same named ** SQL parameter is used more than once, second and subsequent ** occurrences have the same index as the first occurrence. ** ^The index for named parameters can be looked up using the ** [sqlite3_bind_parameter_index()] API if desired. ^The index ** for "?NNN" parameters is the value of NNN. ** ^The NNN value must be between 1 and the [sqlite3_limit()] ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). ** ** ^The third argument is the value to bind to the parameter. ** ** ^(In those routines that have a fourth argument, its value is the ** number of bytes in the parameter. To be clear: the value is the ** number of bytes in the value, not the number of characters.)^ ** ^If the fourth parameter is negative, the length of the string is ** the number of bytes up to the first zero terminator. ** ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or ** string after SQLite has finished with it. ^If the fifth argument is ** the special value [SQLITE_STATIC], then SQLite assumes that the ** information is in static, unmanaged space and does not need to be freed. ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then ** SQLite makes its own private copy of the data immediately, before ** the sqlite3_bind_*() routine returns. ** ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory ** (just an integer to hold its size) while it is being processed. ** Zeroblobs are intended to serve as placeholders for BLOBs whose ** content is later written using ** [sqlite3_blob_open | incremental BLOB I/O] routines. ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. ** ** ^Bindings are not cleared by the [sqlite3_reset()] routine. ** ^Unbound parameters are interpreted as NULL. ** ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an ** [error code] if anything goes wrong. ** ^[SQLITE_RANGE] is returned if the parameter ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); /* ** CAPI3REF: Number Of SQL Parameters ** ** ^This routine can be used to find the number of [SQL parameters] ** in a [prepared statement]. SQL parameters are tokens of the ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as ** placeholders for values that are [sqlite3_bind_blob | bound] ** to the parameters at a later time. ** ** ^(This routine actually returns the index of the largest (rightmost) ** parameter. For all forms except ?NNN, this will correspond to the ** number of unique parameters. If parameters of the ?NNN form are used, ** there may be gaps in the list.)^ ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_name()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); /* ** CAPI3REF: Name Of A Host Parameter ** ** ^The sqlite3_bind_parameter_name(P,N) interface returns ** the name of the N-th [SQL parameter] in the [prepared statement] P. ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" ** respectively. ** In other words, the initial ":" or "$" or "@" or "?" ** is included as part of the name.)^ ** ^Parameters of the form "?" without a following integer have no name ** and are referred to as "nameless" or "anonymous parameters". ** ** ^The first host parameter has an index of 1, not 0. ** ** ^If the value N is out of range or if the N-th parameter is ** nameless, then NULL is returned. ^The returned string is ** always in UTF-8 encoding even if the named parameter was ** originally specified as UTF-16 in [sqlite3_prepare16()] or ** [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name ** ** ^Return the index of an SQL parameter given its name. ^The ** index value returned is suitable for use as the second ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero ** is returned if no matching parameter is found. ^The parameter ** name must be given in UTF-8 even if the original statement ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); /* ** CAPI3REF: Reset All Bindings On A Prepared Statement ** ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. ** ^Use this routine to reset all host parameters to NULL. */ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); /* ** CAPI3REF: Number Of Columns In A Result Set ** ** ^Return the number of columns in the result set returned by the ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL ** statement that does not return data (for example an [UPDATE]). */ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Column Names In A Result Set ** ** ^These routines return the name assigned to a particular column ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() ** interface returns a pointer to a zero-terminated UTF-8 string ** and sqlite3_column_name16() returns a pointer to a zero-terminated ** UTF-16 string. ^The first parameter is the [prepared statement] ** that implements the [SELECT] statement. ^The second parameter is the ** column number. ^The leftmost column is number 0. ** ** ^The returned string pointer is valid until either the [prepared statement] ** is destroyed by [sqlite3_finalize()] or until the next call to ** sqlite3_column_name() or sqlite3_column_name16() on the same column. ** ** ^If sqlite3_malloc() fails during the processing of either routine ** (for example during a conversion from UTF-8 to UTF-16) then a ** NULL pointer is returned. ** ** ^The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. */ SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); /* ** CAPI3REF: Source Of Data In A Query Result ** ** ^These routines provide a means to determine the database, table, and ** table column that is the origin of a particular result column in ** [SELECT] statement. ** ^The name of the database or table or column can be returned as ** either a UTF-8 or UTF-16 string. ^The _database_ routines return ** the database name, the _table_ routines return the table name, and ** the origin_ routines return the column name. ** ^The returned string is valid until the [prepared statement] is destroyed ** using [sqlite3_finalize()] or until the same information is requested ** again in a different encoding. ** ** ^The names returned are the original un-aliased names of the ** database, table, and column. ** ** ^The first argument to these interfaces is a [prepared statement]. ** ^These functions return information about the Nth result column returned by ** the statement, where N is the second function argument. ** ^The left-most column is column 0 for these routines. ** ** ^If the Nth column returned by the statement is an expression or ** subquery and is not a column value, then all of these functions return ** NULL. ^These routine might also return NULL if a memory allocation error ** occurs. ^Otherwise, they return the name of the attached database, table, ** or column that query result column was extracted from. ** ** ^As with all other SQLite APIs, those whose names end with "16" return ** UTF-16 encoded strings and the other functions return UTF-8. ** ** ^These APIs are only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. ** ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column ** at the same time then the results are undefined. */ SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); /* ** CAPI3REF: Declared Datatype Of A Query Result ** ** ^(The first parameter is a [prepared statement]. ** If this statement is a [SELECT] statement and the Nth column of the ** returned result set of that [SELECT] is a table column (not an ** expression or subquery) then the declared type of the table ** column is returned.)^ ^If the Nth column of the result set is an ** expression or subquery, then a NULL pointer is returned. ** ^The returned string is always UTF-8 encoded. ** ** ^(For example, given the database schema: ** ** CREATE TABLE t1(c1 VARIANT); ** ** and the following statement to be compiled: ** ** SELECT c1 + 1, c1 FROM t1; ** ** this routine would return the string "VARIANT" for the second result ** column (i==1), and a NULL pointer for the first result column (i==0).)^ ** ** ^SQLite uses dynamic run-time typing. ^So just because a column ** is declared to contain a particular type does not mean that the ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. ^Type ** is associated with individual values, not with the containers ** used to hold those values. */ SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement ** ** After a [prepared statement] has been prepared using either ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** must be called one or more times to evaluate the statement. ** ** The details of the behavior of the sqlite3_step() interface depend ** on whether the statement was prepared using the newer "v2" interface ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the ** new "v2" interface is recommended for new applications but the legacy ** interface will continue to be supported. ** ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. ** ^With the "v2" interface, any of the other [result codes] or ** [extended result codes] might be returned as well. ** ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the ** database locks it needs to do its job. ^If the statement is a [COMMIT] ** or occurs outside of an explicit transaction, then you can retry the ** statement. If the statement is not a [COMMIT] and occurs within a ** explicit transaction then you should rollback the transaction before ** continuing. ** ** ^[SQLITE_DONE] means that the statement has finished executing ** successfully. sqlite3_step() should not be called again on this virtual ** machine without first calling [sqlite3_reset()] to reset the virtual ** machine back to its initial state. ** ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] ** is returned each time a new row of data is ready for processing by the ** caller. The values may be accessed using the [column access functions]. ** sqlite3_step() is called again to retrieve the next row of data. ** ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint ** violation) has occurred. sqlite3_step() should not be called again on ** the VM. More information may be found by calling [sqlite3_errmsg()]. ** ^With the legacy interface, a more specific error code (for example, ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) ** can be obtained by calling [sqlite3_reset()] on the ** [prepared statement]. ^In the "v2" interface, ** the more specific error code is returned directly by sqlite3_step(). ** ** [SQLITE_MISUSE] means that the this routine was called inappropriately. ** Perhaps it was called on a [prepared statement] that has ** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could ** be the case that the same database connection is being used by two or ** more threads at the same moment in time. ** ** For all versions of SQLite up to and including 3.6.23.1, it was required ** after sqlite3_step() returned anything other than [SQLITE_ROW] that ** [sqlite3_reset()] be called before any subsequent invocation of ** sqlite3_step(). Failure to invoke [sqlite3_reset()] in this way would ** result in an [SQLITE_MISUSE] return from sqlite3_step(). But after ** version 3.6.23.1, sqlite3_step() began calling [sqlite3_reset()] ** automatically in this circumstance rather than returning [SQLITE_MISUSE]. ** ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. */ SQLITE_API int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set ** ** ^The sqlite3_data_count(P) the number of columns in the ** of the result set of [prepared statement] P. */ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Fundamental Datatypes ** KEYWORDS: SQLITE_TEXT ** ** ^(Every value in SQLite has one of five fundamental datatypes: ** **
    **
  • 64-bit signed integer **
  • 64-bit IEEE floating point number **
  • string **
  • BLOB **
  • NULL **
)^ ** ** These constants are codes for each of those types. ** ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 ** for a completely different meaning. Software that links against both ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not ** SQLITE_TEXT. */ #define SQLITE_INTEGER 1 #define SQLITE_FLOAT 2 #define SQLITE_BLOB 4 #define SQLITE_NULL 5 #ifdef SQLITE_TEXT # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* ** CAPI3REF: Result Values From A Query ** KEYWORDS: {column access functions} ** ** These routines form the "result set" interface. ** ** ^These routines return information about a single column of the current ** result row of a query. ^In every case the first argument is a pointer ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] ** that was returned from [sqlite3_prepare_v2()] or one of its variants) ** and the second argument is the index of the column for which information ** should be returned. ^The leftmost column of the result set has the index 0. ** ^The number of columns in the result can be determined using ** [sqlite3_column_count()]. ** ** If the SQL statement does not currently point to a valid row, or if the ** column index is out of range, the result is undefined. ** These routines may only be called when the most recent call to ** [sqlite3_step()] has returned [SQLITE_ROW] and neither ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. ** If any of these routines are called after [sqlite3_reset()] or ** [sqlite3_finalize()] or after [sqlite3_step()] has returned ** something other than [SQLITE_ROW], the results are undefined. ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] ** are called from a different thread while any of these routines ** are pending, then the results are undefined. ** ** ^The sqlite3_column_type() routine returns the ** [SQLITE_INTEGER | datatype code] for the initial data type ** of the result column. ^The returned value is one of [SQLITE_INTEGER], ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value ** returned by sqlite3_column_type() is only meaningful if no type ** conversions have occurred as described below. After a type conversion, ** the value returned by sqlite3_column_type() is undefined. Future ** versions of SQLite may change the behavior of sqlite3_column_type() ** following a type conversion. ** ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() ** routine returns the number of bytes in that BLOB or string. ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts ** the string to UTF-8 and then returns the number of bytes. ** ^If the result is a numeric value then sqlite3_column_bytes() uses ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns ** the number of bytes in that string. ** ^The value returned does not include the zero terminator at the end ** of the string. ^For clarity: the value returned is the number of ** bytes in the string, not the number of characters. ** ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), ** even empty strings, are always zero terminated. ^The return ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary ** pointer, possibly even a NULL pointer. ** ** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() ** but leaves the result in UTF-16 in native byte order instead of UTF-8. ** ^The zero terminator is not included in this count. ** ** ^The object returned by [sqlite3_column_value()] is an ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], ** or [sqlite3_value_bytes()], then the behavior is undefined. ** ** These routines attempt to convert the value where appropriate. ^For ** example, if the internal representation is FLOAT and a text result ** is requested, [sqlite3_snprintf()] is used internally to perform the ** conversion automatically. ^(The following table details the conversions ** that are applied: ** **
** **
Internal
Type
Requested
Type
Conversion ** **
NULL INTEGER Result is 0 **
NULL FLOAT Result is 0.0 **
NULL TEXT Result is NULL pointer **
NULL BLOB Result is NULL pointer **
INTEGER FLOAT Convert from integer to float **
INTEGER TEXT ASCII rendering of the integer **
INTEGER BLOB Same as INTEGER->TEXT **
FLOAT INTEGER Convert from float to integer **
FLOAT TEXT ASCII rendering of the float **
FLOAT BLOB Same as FLOAT->TEXT **
TEXT INTEGER Use atoi() **
TEXT FLOAT Use atof() **
TEXT BLOB No change **
BLOB INTEGER Convert to TEXT then use atoi() **
BLOB FLOAT Convert to TEXT then use atof() **
BLOB TEXT Add a zero terminator if needed **
**
)^ ** ** The table above makes reference to standard C library functions atoi() ** and atof(). SQLite does not really use these functions. It has its ** own equivalent internal routines. The atoi() and atof() names are ** used in the table for brevity and because they are familiar to most ** C programmers. ** ** ^Note that when type conversions occur, pointers returned by prior ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or ** sqlite3_column_text16() may be invalidated. ** ^(Type conversions and pointer invalidations might occur ** in the following cases: ** **
    **
  • The initial content is a BLOB and sqlite3_column_text() or ** sqlite3_column_text16() is called. A zero-terminator might ** need to be added to the string.
  • **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or ** sqlite3_column_text16() is called. The content must be converted ** to UTF-16.
  • **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or ** sqlite3_column_text() is called. The content must be converted ** to UTF-8.
  • **
)^ ** ** ^Conversions between UTF-16be and UTF-16le are always done in place and do ** not invalidate a prior pointer, though of course the content of the buffer ** that the prior pointer points to will have been modified. Other kinds ** of conversion are done in place when it is possible, but sometimes they ** are not possible and in those cases prior pointers are invalidated. ** ** ^(The safest and easiest to remember policy is to invoke these routines ** in one of the following ways: ** **
    **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • **
)^ ** ** In other words, you should call sqlite3_column_text(), ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result ** into the desired format, then invoke sqlite3_column_bytes() or ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls ** to sqlite3_column_text() or sqlite3_column_blob() with calls to ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() ** with calls to sqlite3_column_bytes(). ** ** ^The pointers returned are valid until a type conversion occurs as ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or ** [sqlite3_finalize()] is called. ^The memory space used to hold strings ** and BLOBs is freed automatically. Do not pass the pointers returned ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into ** [sqlite3_free()]. ** ** ^(If a memory allocation error occurs during the evaluation of any ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM].)^ */ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object ** ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. ** ^If the statement was executed successfully or not executed at all, then ** SQLITE_OK is returned. ^If execution of the statement failed then an ** [error code] or [extended error code] is returned. ** ** ^This routine can be called at any point during the execution of the ** [prepared statement]. ^If the virtual machine has not ** completed execution when this routine is called, that is like ** encountering an error or an [sqlite3_interrupt | interrupt]. ** ^Incomplete updates may be rolled back and transactions canceled, ** depending on the circumstances, and the ** [error code] returned will be [SQLITE_ABORT]. */ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object ** ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state, ready to be re-executed. ** ^Any SQL statement variables that had values bound to them using ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. ** Use [sqlite3_clear_bindings()] to reset the bindings. ** ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], ** or if [sqlite3_step(S)] has never before been called on S, ** then [sqlite3_reset(S)] returns [SQLITE_OK]. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. ** ** ^The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} ** KEYWORDS: {application-defined SQL function} ** KEYWORDS: {application-defined SQL functions} ** ** ^These two functions (collectively known as "function creation routines") ** are used to add SQL functions or aggregates or to redefine the behavior ** of existing SQL functions or aggregates. The only difference between the ** two is that the second parameter, the name of the (scalar) function or ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16 ** for sqlite3_create_function16(). ** ** ^The first parameter is the [database connection] to which the SQL ** function is to be added. ^If an application uses more than one database ** connection then application-defined SQL functions must be added ** to each database connection separately. ** ** The second parameter is the name of the SQL function to be created or ** redefined. ^The length of the name is limited to 255 bytes, exclusive of ** the zero-terminator. Note that the name length limit is in bytes, not ** characters. ^Any attempt to create a function with a longer name ** will result in [SQLITE_ERROR] being returned. ** ** ^The third parameter (nArg) ** is the number of arguments that the SQL function or ** aggregate takes. ^If this parameter is -1, then the SQL function or ** aggregate may take any number of arguments between 0 and the limit ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third ** parameter is less than -1 or greater than 127 then the behavior is ** undefined. ** ** The fourth parameter, eTextRep, specifies what ** [SQLITE_UTF8 | text encoding] this SQL function prefers for ** its parameters. Any SQL function implementation should be able to work ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be ** more efficient with one encoding than another. ^An application may ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple ** times with the same function but with different values of eTextRep. ** ^When multiple implementations of the same function are available, SQLite ** will pick the one that involves the least amount of data conversion. ** If there is only a single implementation which does not care what text ** encoding is used, then the fourth argument should be [SQLITE_ANY]. ** ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ ** ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are ** pointers to C-language functions that implement the SQL function or ** aggregate. ^A scalar SQL function requires an implementation of the xFunc ** callback only; NULL pointers should be passed as the xStep and xFinal ** parameters. ^An aggregate SQL function requires an implementation of xStep ** and xFinal and NULL should be passed for xFunc. ^To delete an existing ** SQL function or aggregate, pass NULL for all three function callbacks. ** ** ^It is permitted to register multiple implementations of the same ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. ^SQLite will use ** the implementation that most closely matches the way in which the ** SQL function is used. ^A function implementation with a non-negative ** nArg parameter is a better match than a function implementation with ** a negative nArg. ^A function where the preferred text encoding ** matches the database encoding is a better ** match than a function where the encoding is different. ** ^A function where the encoding difference is between UTF16le and UTF16be ** is a closer match than a function where the encoding difference is ** between UTF8 and UTF16. ** ** ^Built-in functions may be overloaded by new application-defined functions. ** ^The first application-defined function with a given name overrides all ** built-in functions in the same [database connection] with the same name. ** ^Subsequent application-defined functions of the same name only override ** prior application-defined functions that are an exact match for the ** number of parameters and preferred encoding. ** ** ^An application-defined function is permitted to call other ** SQLite interfaces. However, such calls must not ** close the database connection nor finalize or reset the prepared ** statement in which the function is running. */ SQLITE_API int sqlite3_create_function( sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); SQLITE_API int sqlite3_create_function16( sqlite3 *db, const void *zFunctionName, int nArg, int eTextRep, void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); /* ** CAPI3REF: Text Encodings ** ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** CAPI3REF: Deprecated Functions ** DEPRECATED ** ** These functions are [deprecated]. In order to maintain ** backwards compatibility with older code, these functions continue ** to be supported. However, new applications should avoid ** the use of these functions. To help encourage people to avoid ** using these functions, we are not going to tell you what they do. */ #ifndef SQLITE_OMIT_DEPRECATED SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); #endif /* ** CAPI3REF: Obtaining SQL Function Parameter Values ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on ** the function or aggregate. ** ** The xFunc (for scalar functions) or xStep (for aggregates) parameters ** to [sqlite3_create_function()] and [sqlite3_create_function16()] ** define callbacks that implement the SQL functions and aggregates. ** The 4th parameter to these callbacks is an array of pointers to ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for ** each parameter to the SQL function. These routines are used to ** extract values from the [sqlite3_value] objects. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] ** object results in undefined behavior. ** ** ^These routines work just like the corresponding [column access functions] ** except that these routines take a single [protected sqlite3_value] object ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. ** ** ^The sqlite3_value_text16() interface extracts a UTF-16 string ** in the native byte-order of the host machine. ^The ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces ** extract UTF-16 strings as big-endian and little-endian respectively. ** ** ^(The sqlite3_value_numeric_type() interface attempts to apply ** numeric affinity to the value. This means that an attempt is ** made to convert the value to an integer or floating point. If ** such a conversion is possible without loss of information (in other ** words, if the value is a string that looks like a number) ** then the conversion is performed. Otherwise no conversion occurs. ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. */ SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API double sqlite3_value_double(sqlite3_value*); SQLITE_API int sqlite3_value_int(sqlite3_value*); SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context ** ** Implementations of aggregate SQL functions use this ** routine to allocate memory for storing their state. ** ** ^The first time the sqlite3_aggregate_context(C,N) routine is called ** for a particular aggregate function, SQLite ** allocates N of memory, zeroes out that memory, and returns a pointer ** to the new memory. ^On second and subsequent calls to ** sqlite3_aggregate_context() for the same aggregate function instance, ** the same buffer is returned. Sqlite3_aggregate_context() is normally ** called once for each invocation of the xStep callback and then one ** last time when the xFinal callback is invoked. ^(When no rows match ** an aggregate query, the xStep() callback of the aggregate function ** implementation is never called and xFinal() is called exactly once. ** In those cases, sqlite3_aggregate_context() might be called for the ** first time from within xFinal().)^ ** ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is ** less than or equal to zero or if a memory allocate error occurs. ** ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is ** determined by the N parameter on first successful call. Changing the ** value of N in subsequent call to sqlite3_aggregate_context() within ** the same aggregate function instance will not resize the memory ** allocation.)^ ** ** ^SQLite automatically frees the memory allocated by ** sqlite3_aggregate_context() when the aggregate query concludes. ** ** The first parameter must be a copy of the ** [sqlite3_context | SQL function context] that is the first parameter ** to the xStep or xFinal callback routine that implements the aggregate ** function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. */ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); /* ** CAPI3REF: User Data For Functions ** ** ^The sqlite3_user_data() interface returns a copy of ** the pointer that was the pUserData parameter (the 5th parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. ** ** This routine must be called from the same thread in which ** the application-defined function is running. */ SQLITE_API void *sqlite3_user_data(sqlite3_context*); /* ** CAPI3REF: Database Connection For Functions ** ** ^The sqlite3_context_db_handle() interface returns a copy of ** the pointer to the [database connection] (the 1st parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. */ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); /* ** CAPI3REF: Function Auxiliary Data ** ** The following two functions may be used by scalar SQL functions to ** associate metadata with argument values. If the same value is passed to ** multiple invocations of the same SQL function during query execution, under ** some circumstances the associated metadata may be preserved. This may ** be used, for example, to add a regular-expression matching scalar ** function. The compiled version of the regular expression is stored as ** metadata associated with the SQL value passed as the regular expression ** pattern. The compiled regular expression can be reused on multiple ** invocations of the same function so that the original pattern string ** does not need to be recompiled on each invocation. ** ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata ** associated by the sqlite3_set_auxdata() function with the Nth argument ** value to the application-defined function. ^If no metadata has been ever ** been set for the Nth argument of the function, or if the corresponding ** function parameter has changed since the meta-data was set, ** then sqlite3_get_auxdata() returns a NULL pointer. ** ** ^The sqlite3_set_auxdata() interface saves the metadata ** pointed to by its 3rd parameter as the metadata for the N-th ** argument of the application-defined function. Subsequent ** calls to sqlite3_get_auxdata() might return this data, if it has ** not been destroyed. ** ^If it is not NULL, SQLite will invoke the destructor ** function given by the 4th parameter to sqlite3_set_auxdata() on ** the metadata when the corresponding function parameter changes ** or when the SQL statement completes, whichever comes first. ** ** SQLite is free to call the destructor and drop metadata on any ** parameter of any function at any time. ^The only guarantee is that ** the destructor will be called before the metadata is dropped. ** ** ^(In practice, metadata is preserved between function calls for ** expressions that are constant at compile time. This includes literal ** values and [parameters].)^ ** ** These routines must be called from the same thread in which ** the SQL function is running. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior ** ** These are special values for the destructor that is passed in as the ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor ** argument is SQLITE_STATIC, it means that the content pointer is constant ** and will never change. It does not need to be destroyed. ^The ** SQLITE_TRANSIENT value means that the content will likely change in ** the near future and that SQLite should make its own private copy of ** the content before returning. ** ** The typedef is necessary to work around problems in certain ** C++ compilers. See ticket #2191. */ typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** CAPI3REF: Setting The Result Of An SQL Function ** ** These routines are used by the xFunc or xFinal callbacks that ** implement SQL functions and aggregates. See ** [sqlite3_create_function()] and [sqlite3_create_function16()] ** for additional information. ** ** These functions work very much like the [parameter binding] family of ** functions used to bind values to host parameters in prepared statements. ** Refer to the [SQL parameter] documentation for additional information. ** ** ^The sqlite3_result_blob() interface sets the result from ** an application-defined function to be the BLOB whose content is pointed ** to by the second parameter and which is N bytes long where N is the ** third parameter. ** ** ^The sqlite3_result_zeroblob() interfaces set the result of ** the application-defined function to be a BLOB containing all zero ** bytes and N bytes in size, where N is the value of the 2nd parameter. ** ** ^The sqlite3_result_double() interface sets the result from ** an application-defined function to be a floating point value specified ** by its 2nd argument. ** ** ^The sqlite3_result_error() and sqlite3_result_error16() functions ** cause the implemented SQL function to throw an exception. ** ^SQLite uses the string pointed to by the ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() ** as the text of an error message. ^SQLite interprets the error ** message string from sqlite3_result_error() as UTF-8. ^SQLite ** interprets the string from sqlite3_result_error16() as UTF-16 in native ** byte order. ^If the third parameter to sqlite3_result_error() ** or sqlite3_result_error16() is negative then SQLite takes as the error ** message all text up through the first zero character. ** ^If the third parameter to sqlite3_result_error() or ** sqlite3_result_error16() is non-negative then SQLite takes that many ** bytes (not characters) from the 2nd parameter as the error message. ** ^The sqlite3_result_error() and sqlite3_result_error16() ** routines make a private copy of the error message text before ** they return. Hence, the calling function can deallocate or ** modify the text after they return without harm. ** ^The sqlite3_result_error_code() function changes the error code ** returned by SQLite as a result of an error in a function. ^By default, ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. ** ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error ** indicating that a string or BLOB is too long to represent. ** ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error ** indicating that a memory allocation failed. ** ** ^The sqlite3_result_int() interface sets the return value ** of the application-defined function to be the 32-bit signed integer ** value given in the 2nd argument. ** ^The sqlite3_result_int64() interface sets the return value ** of the application-defined function to be the 64-bit signed integer ** value given in the 2nd argument. ** ** ^The sqlite3_result_null() interface sets the return value ** of the application-defined function to be NULL. ** ** ^The sqlite3_result_text(), sqlite3_result_text16(), ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces ** set the return value of the application-defined function to be ** a text string which is represented as UTF-8, UTF-16 native byte order, ** UTF-16 little endian, or UTF-16 big endian, respectively. ** ^SQLite takes the text result from the application from ** the 2nd parameter of the sqlite3_result_text* interfaces. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is negative, then SQLite takes result text from the 2nd parameter ** through the first zero character. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is non-negative, then as many bytes (not characters) of the text ** pointed to by the 2nd parameter are taken as the application-defined ** function result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that ** function as the destructor on the text or BLOB result when it has ** finished using that result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite ** assumes that the text or BLOB result is in constant space and does not ** copy the content of the parameter nor call a destructor on the content ** when it has finished using that result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT ** then SQLite makes a copy of the result into space obtained from ** from [sqlite3_malloc()] before it returns. ** ** ^The sqlite3_result_value() interface sets the result of ** the application-defined function to be a copy the ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] ** so that the [sqlite3_value] specified in the parameter may change or ** be deallocated after sqlite3_result_value() returns without harm. ** ^A [protected sqlite3_value] object may always be used where an ** [unprotected sqlite3_value] object is required, so either ** kind of [sqlite3_value] object can be used with this interface. ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_double(sqlite3_context*, double); SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); SQLITE_API void sqlite3_result_int(sqlite3_context*, int); SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); SQLITE_API void sqlite3_result_null(sqlite3_context*); SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); /* ** CAPI3REF: Define New Collating Sequences ** ** These functions are used to add new collation sequences to the ** [database connection] specified as the first argument. ** ** ^The name of the new collation sequence is specified as a UTF-8 string ** for sqlite3_create_collation() and sqlite3_create_collation_v2() ** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases ** the name is passed as the second function argument. ** ** ^The third argument may be one of the constants [SQLITE_UTF8], ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied ** routine expects to be passed pointers to strings encoded using UTF-8, ** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The ** third argument might also be [SQLITE_UTF16] to indicate that the routine ** expects pointers to be UTF-16 strings in the native byte order, or the ** argument can be [SQLITE_UTF16_ALIGNED] if the ** the routine expects pointers to 16-bit word aligned strings ** of UTF-16 in the native byte order. ** ** A pointer to the user supplied routine must be passed as the fifth ** argument. ^If it is NULL, this is the same as deleting the collation ** sequence (so that SQLite cannot call it any more). ** ^Each time the application supplied function is invoked, it is passed ** as its first parameter a copy of the void* passed as the fourth argument ** to sqlite3_create_collation() or sqlite3_create_collation16(). ** ** ^The remaining arguments to the application-supplied routine are two strings, ** each represented by a (length, data) pair and encoded in the encoding ** that was passed as the third argument when the collation sequence was ** registered. The application defined collation routine should ** return negative, zero or positive if the first string is less than, ** equal to, or greater than the second string. i.e. (STRING1 - STRING2). ** ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() ** except that it takes an extra argument which is a destructor for ** the collation. ^The destructor is called when the collation is ** destroyed and is passed a copy of the fourth parameter void* pointer ** of the sqlite3_create_collation_v2(). ** ^Collations are destroyed when they are overridden by later calls to the ** collation creation functions or when the [database connection] is closed ** using [sqlite3_close()]. ** ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. */ SQLITE_API int sqlite3_create_collation( sqlite3*, const char *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); SQLITE_API int sqlite3_create_collation_v2( sqlite3*, const char *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*), void(*xDestroy)(void*) ); SQLITE_API int sqlite3_create_collation16( sqlite3*, const void *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); /* ** CAPI3REF: Collation Needed Callbacks ** ** ^To avoid having to register all collation sequences before a database ** can be used, a single callback function may be registered with the ** [database connection] to be invoked whenever an undefined collation ** sequence is required. ** ** ^If the function is registered using the sqlite3_collation_needed() API, ** then it is passed the names of undefined collation sequences as strings ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, ** the names are passed as UTF-16 in machine native byte order. ** ^A call to either function replaces the existing collation-needed callback. ** ** ^(When the callback is invoked, the first argument passed is a copy ** of the second argument to sqlite3_collation_needed() or ** sqlite3_collation_needed16(). The second argument is the database ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation ** sequence function required. The fourth parameter is the name of the ** required collation sequence.)^ ** ** The callback function should register the desired collation using ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or ** [sqlite3_create_collation_v2()]. */ SQLITE_API int sqlite3_collation_needed( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const char*) ); SQLITE_API int sqlite3_collation_needed16( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const void*) ); #ifdef SQLITE_HAS_CODEC /* ** Specify the key for an encrypted database. This routine should be ** called right after sqlite3_open(). ** ** The code to implement this API is not available in the public release ** of SQLite. */ SQLITE_API int sqlite3_key( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The key */ ); /* ** Change the key on an open database. If the current database is not ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the ** database is decrypted. ** ** The code to implement this API is not available in the public release ** of SQLite. */ SQLITE_API int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* ** Specify the activation key for a SEE database. Unless ** activated, none of the SEE routines will work. */ SQLITE_API void sqlite3_activate_see( const char *zPassPhrase /* Activation phrase */ ); #endif #ifdef SQLITE_ENABLE_CEROD /* ** Specify the activation key for a CEROD database. Unless ** activated, none of the CEROD routines will work. */ SQLITE_API void sqlite3_activate_cerod( const char *zPassPhrase /* Activation phrase */ ); #endif /* ** CAPI3REF: Suspend Execution For A Short Time ** ** ^The sqlite3_sleep() function causes the current thread to suspend execution ** for at least a number of milliseconds specified in its parameter. ** ** ^If the operating system does not support sleep requests with ** millisecond time resolution, then the time will be rounded up to ** the nearest second. ^The number of milliseconds of sleep actually ** requested from the operating system is returned. ** ** ^SQLite implements this interface by calling the xSleep() ** method of the default [sqlite3_vfs] object. */ SQLITE_API int sqlite3_sleep(int); /* ** CAPI3REF: Name Of The Folder Holding Temporary Files ** ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite when using a built-in [sqlite3_vfs | VFS] ** will be placed in that directory.)^ ^If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been called and that this variable remain unchanged ** thereafter. ** ** ^The [temp_store_directory pragma] may modify this variable and cause ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, ** the [temp_store_directory pragma] always assumes that any string ** that this variable points to is held in memory obtained from ** [sqlite3_malloc] and the pragma may attempt to free that memory ** using [sqlite3_free]. ** Hence, if this variable is modified directly, either it should be ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [temp_store_directory pragma] should be avoided. */ SQLITE_API char *sqlite3_temp_directory; /* ** CAPI3REF: Test For Auto-Commit Mode ** KEYWORDS: {autocommit mode} ** ** ^The sqlite3_get_autocommit() interface returns non-zero or ** zero if the given database connection is or is not in autocommit mode, ** respectively. ^Autocommit mode is on by default. ** ^Autocommit mode is disabled by a [BEGIN] statement. ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. ** ** If certain kinds of errors occur on a statement within a multi-statement ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the ** transaction might be rolled back automatically. The only way to ** find out whether SQLite automatically rolled back the transaction after ** an error is to use this function. ** ** If another thread changes the autocommit status of the database ** connection while this routine is running, then the return value ** is undefined. */ SQLITE_API int sqlite3_get_autocommit(sqlite3*); /* ** CAPI3REF: Find The Database Handle Of A Prepared Statement ** ** ^The sqlite3_db_handle interface returns the [database connection] handle ** to which a [prepared statement] belongs. ^The [database connection] ** returned by sqlite3_db_handle is the same [database connection] ** that was the first argument ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** create the statement in the first place. */ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); /* ** CAPI3REF: Find the next prepared statement ** ** ^This interface returns a pointer to the next [prepared statement] after ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL ** then this interface returns a pointer to the first prepared statement ** associated with the database connection pDb. ^If no prepared statement ** satisfies the conditions of this routine, it returns NULL. ** ** The [database connection] pointer D in a call to ** [sqlite3_next_stmt(D,S)] must refer to an open database ** connection and in particular must not be a NULL pointer. */ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); /* ** CAPI3REF: Commit And Rollback Notification Callbacks ** ** ^The sqlite3_commit_hook() interface registers a callback ** function to be invoked whenever a transaction is [COMMIT | committed]. ** ^Any callback set by a previous call to sqlite3_commit_hook() ** for the same database connection is overridden. ** ^The sqlite3_rollback_hook() interface registers a callback ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. ** ^Any callback set by a previous call to sqlite3_rollback_hook() ** for the same database connection is overridden. ** ^The pArg argument is passed through to the callback. ** ^If the callback on a commit hook function returns non-zero, ** then the commit is converted into a rollback. ** ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions ** return the P argument from the previous call of the same function ** on the same [database connection] D, or NULL for ** the first call for each function on D. ** ** The callback implementation must not do anything that will modify ** the database connection that invoked the callback. Any actions ** to modify the database connection must be deferred until after the ** completion of the [sqlite3_step()] call that triggered the commit ** or rollback hook in the first place. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** ** ^Registering a NULL function disables the callback. ** ** ^When the commit hook callback routine returns zero, the [COMMIT] ** operation is allowed to continue normally. ^If the commit hook ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. ** ^The rollback hook is invoked on a rollback that results from a commit ** hook returning non-zero, just as it would be with any other rollback. ** ** ^For the purposes of this API, a transaction is said to have been ** rolled back if an explicit "ROLLBACK" statement is executed, or ** an error or constraint causes an implicit rollback to occur. ** ^The rollback callback is not invoked if a transaction is ** automatically rolled back because the database connection is closed. ** ** See also the [sqlite3_update_hook()] interface. */ SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks ** ** ^The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument ** to be invoked whenever a row is updated, inserted or deleted. ** ^Any callback set by a previous call to this function ** for the same database connection is overridden. ** ** ^The second argument is a pointer to the function to invoke when a ** row is updated, inserted or deleted. ** ^The first argument to the callback is a copy of the third argument ** to sqlite3_update_hook(). ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], ** or [SQLITE_UPDATE], depending on the operation that caused the callback ** to be invoked. ** ^The third and fourth arguments to the callback contain pointers to the ** database and table name containing the affected row. ** ^The final callback parameter is the [rowid] of the row. ** ^In the case of an update, this is the [rowid] after the update takes place. ** ** ^(The update hook is not invoked when internal system tables are ** modified (i.e. sqlite_master and sqlite_sequence).)^ ** ** ^In the current implementation, the update hook ** is not invoked when duplication rows are deleted because of an ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook ** invoked when rows are deleted using the [truncate optimization]. ** The exceptions defined in this paragraph might change in a future ** release of SQLite. ** ** The update hook implementation must not do anything that will modify ** the database connection that invoked the update hook. Any actions ** to modify the database connection must be deferred until after the ** completion of the [sqlite3_step()] call that triggered the update hook. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** ** ^The sqlite3_update_hook(D,C,P) function ** returns the P argument from the previous call ** on the same [database connection] D, or NULL for ** the first call on D. ** ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] ** interfaces. */ SQLITE_API void *sqlite3_update_hook( sqlite3*, void(*)(void *,int ,char const *,char const *,sqlite3_int64), void* ); /* ** CAPI3REF: Enable Or Disable Shared Pager Cache ** KEYWORDS: {shared cache} ** ** ^(This routine enables or disables the sharing of the database cache ** and schema data structures between [database connection | connections] ** to the same database. Sharing is enabled if the argument is true ** and disabled if the argument is false.)^ ** ** ^Cache sharing is enabled and disabled for an entire process. ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, ** sharing was enabled or disabled for each thread separately. ** ** ^(The cache sharing mode set by this interface effects all subsequent ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. ** Existing database connections continue use the sharing mode ** that was in effect at the time they were opened.)^ ** ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled ** successfully. An [error code] is returned otherwise.)^ ** ** ^Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** See Also: [SQLite Shared-Cache Mode] */ SQLITE_API int sqlite3_enable_shared_cache(int); /* ** CAPI3REF: Attempt To Free Heap Memory ** ** ^The sqlite3_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations ** held by the database library. Memory used to cache database ** pages to improve performance is an example of non-essential memory. ** ^sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. */ SQLITE_API int sqlite3_release_memory(int); /* ** CAPI3REF: Impose A Limit On Heap Size ** ** ^The sqlite3_soft_heap_limit() interface places a "soft" limit ** on the amount of heap memory that may be allocated by SQLite. ** ^If an internal allocation is requested that would exceed the ** soft heap limit, [sqlite3_release_memory()] is invoked one or ** more times to free up some space before the allocation is performed. ** ** ^The limit is called "soft" because if [sqlite3_release_memory()] ** cannot free sufficient memory to prevent the limit from being exceeded, ** the memory is allocated anyway and the current operation proceeds. ** ** ^A negative or zero value for N means that there is no soft heap limit and ** [sqlite3_release_memory()] will only be called when memory is exhausted. ** ^The default value for the soft heap limit is zero. ** ** ^(SQLite makes a best effort to honor the soft heap limit. ** But if the soft heap limit cannot be honored, execution will ** continue without error or notification.)^ This is why the limit is ** called a "soft" limit. It is advisory only. ** ** Prior to SQLite version 3.5.0, this routine only constrained the memory ** allocated by a single thread - the same thread in which this routine ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is ** applied to all threads. The value specified for the soft heap limit ** is an upper bound on the total memory allocation for all threads. In ** version 3.5.0 there is no mechanism for limiting the heap usage for ** individual threads. */ SQLITE_API void sqlite3_soft_heap_limit(int); /* ** CAPI3REF: Extract Metadata About A Column Of A Table ** ** ^This routine returns metadata about a specific column of a specific ** database table accessible using the [database connection] handle ** passed as the first function argument. ** ** ^The column is identified by the second, third and fourth parameters to ** this function. ^The second parameter is either the name of the database ** (i.e. "main", "temp", or an attached database) containing the specified ** table or NULL. ^If it is NULL, then all attached databases are searched ** for the table using the same algorithm used by the database engine to ** resolve unqualified table references. ** ** ^The third and fourth parameters to this function are the table and column ** name of the desired column, respectively. Neither of these parameters ** may be NULL. ** ** ^Metadata is returned by writing to the memory locations passed as the 5th ** and subsequent parameters to this function. ^Any of these arguments may be ** NULL, in which case the corresponding element of metadata is omitted. ** ** ^(
** **
Parameter Output
Type
Description ** **
5th const char* Data type **
6th const char* Name of default collation sequence **
7th int True if column has a NOT NULL constraint **
8th int True if column is part of the PRIMARY KEY **
9th int True if column is [AUTOINCREMENT] **
**
)^ ** ** ^The memory pointed to by the character pointers returned for the ** declaration type and collation sequence is valid only until the next ** call to any SQLite API function. ** ** ^If the specified table is actually a view, an [error code] is returned. ** ** ^If the specified column is "rowid", "oid" or "_rowid_" and an ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output ** parameters are set for the explicitly declared column. ^(If there is no ** explicitly declared [INTEGER PRIMARY KEY] column, then the output ** parameters are set as follows: ** **
**     data type: "INTEGER"
**     collation sequence: "BINARY"
**     not null: 0
**     primary key: 1
**     auto increment: 0
** 
)^ ** ** ^(This function may load one or more schemas from database files. If an ** error occurs during this process, or if the requested table or column ** cannot be found, an [error code] is returned and an error message left ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ ** ** ^This API is only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. */ SQLITE_API int sqlite3_table_column_metadata( sqlite3 *db, /* Connection handle */ const char *zDbName, /* Database name or NULL */ const char *zTableName, /* Table name */ const char *zColumnName, /* Column name */ char const **pzDataType, /* OUTPUT: Declared data type */ char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* ** CAPI3REF: Load An Extension ** ** ^This interface loads an SQLite extension library from the named file. ** ** ^The sqlite3_load_extension() interface attempts to load an ** SQLite extension library contained in the file zFile. ** ** ^The entry point is zProc. ** ^zProc may be 0, in which case the name of the entry point ** defaults to "sqlite3_extension_init". ** ^The sqlite3_load_extension() interface returns ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. ** ^If an error occurs and pzErrMsg is not 0, then the ** [sqlite3_load_extension()] interface shall attempt to ** fill *pzErrMsg with error message text stored in memory ** obtained from [sqlite3_malloc()]. The calling function ** should free this memory by calling [sqlite3_free()]. ** ** ^Extension loading must be enabled using ** [sqlite3_enable_load_extension()] prior to calling this API, ** otherwise an error will be returned. ** ** See also the [load_extension() SQL function]. */ SQLITE_API int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Derived from zFile if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ); /* ** CAPI3REF: Enable Or Disable Extension Loading ** ** ^So as not to open security holes in older applications that are ** unprepared to deal with extension loading, and as a means of disabling ** extension loading while evaluating user-entered SQL, the following API ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. ** ** ^Extension loading is off by default. See ticket #1863. ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 ** to turn extension loading on and call it with onoff==0 to turn ** it back off again. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); /* ** CAPI3REF: Automatically Load An Extensions ** ** ^This API can be invoked at program startup in order to register ** one or more statically linked extensions that will be available ** to all new [database connections]. ** ** ^(This routine stores a pointer to the extension entry point ** in an array that is obtained from [sqlite3_malloc()]. That memory ** is deallocated by [sqlite3_reset_auto_extension()].)^ ** ** ^This function registers an extension entry point that is ** automatically invoked whenever a new [database connection] ** is opened using [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()]. ** ^Duplicate extensions are detected so calling this routine ** multiple times with the same extension is harmless. ** ^Automatic extensions apply across all threads. */ SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Reset Automatic Extension Loading ** ** ^(This function disables all previously registered automatic ** extensions. It undoes the effect of all prior ** [sqlite3_auto_extension()] calls.)^ ** ** ^This function disables automatic extensions in all threads. */ SQLITE_API void sqlite3_reset_auto_extension(void); /* ** The interface to the virtual-table mechanism is currently considered ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ /* ** Structures used by the virtual table interface */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* ** CAPI3REF: Virtual Table Object ** KEYWORDS: sqlite3_module {virtual table module} ** ** This structure, sometimes called a a "virtual table module", ** defines the implementation of a [virtual tables]. ** This structure consists mostly of methods for the module. ** ** ^A virtual table module is created by filling in a persistent ** instance of this structure and passing a pointer to that instance ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. ** ^The registration remains valid until it is replaced by a different ** module or until the [database connection] closes. The content ** of this structure must not change while it is registered with ** any database connection. */ struct sqlite3_module { int iVersion; int (*xCreate)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); int (*xConnect)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); int (*xDisconnect)(sqlite3_vtab *pVTab); int (*xDestroy)(sqlite3_vtab *pVTab); int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); int (*xClose)(sqlite3_vtab_cursor*); int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, int argc, sqlite3_value **argv); int (*xNext)(sqlite3_vtab_cursor*); int (*xEof)(sqlite3_vtab_cursor*); int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); }; /* ** CAPI3REF: Virtual Table Indexing Information ** KEYWORDS: sqlite3_index_info ** ** The sqlite3_index_info structure and its substructures is used as part ** of the [virtual table] interface to ** pass information into and receive the reply from the [xBestIndex] ** method of a [virtual table module]. The fields under **Inputs** are the ** inputs to xBestIndex and are read-only. xBestIndex inserts its ** results into the **Outputs** fields. ** ** ^(The aConstraint[] array records WHERE clause constraints of the form: ** **
column OP expr
** ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is ** stored in aConstraint[].op using one of the ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ ** ^(The index of the column is stored in ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the ** expr on the right-hand side can be evaluated (and thus the constraint ** is usable) and false if it cannot.)^ ** ** ^The optimizer automatically inverts terms of the form "expr OP column" ** and makes other simplifications to the WHERE clause in an attempt to ** get as many WHERE clause terms into the form shown above as possible. ** ^The aConstraint[] array only reports WHERE clause terms that are ** relevant to the particular virtual table being queried. ** ** ^Information about the ORDER BY clause is stored in aOrderBy[]. ** ^Each term of aOrderBy records a column of the ORDER BY clause. ** ** The [xBestIndex] method must fill aConstraintUsage[] with information ** about what parameters to pass to xFilter. ^If argvIndex>0 then ** the right-hand side of the corresponding aConstraint[] is evaluated ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit ** is true, then the constraint is assumed to be fully handled by the ** virtual table and is not checked again by SQLite.)^ ** ** ^The idxNum and idxPtr values are recorded and passed into the ** [xFilter] method. ** ^[sqlite3_free()] is used to free idxPtr if and only if ** needToFreeIdxPtr is true. ** ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in ** the correct order to satisfy the ORDER BY clause so that no separate ** sorting step is required. ** ** ^The estimatedCost value is an estimate of the cost of doing the ** particular lookup. A full scan of a table with N entries should have ** a cost of N. A binary search of a table of N entries should have a ** cost of approximately log(N). */ struct sqlite3_index_info { /* Inputs */ int nConstraint; /* Number of entries in aConstraint */ struct sqlite3_index_constraint { int iColumn; /* Column on left-hand side of constraint */ unsigned char op; /* Constraint operator */ unsigned char usable; /* True if this constraint is usable */ int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ /* Outputs */ struct sqlite3_index_constraint_usage { int argvIndex; /* if >0, constraint is part of argv to xFilter */ unsigned char omit; /* Do not code a test for this constraint */ } *aConstraintUsage; int idxNum; /* Number used to identify the index */ char *idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ int orderByConsumed; /* True if output is already ordered */ double estimatedCost; /* Estimated cost of using this index */ }; /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** ** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. */ #define SQLITE_INDEX_CONSTRAINT_EQ 2 #define SQLITE_INDEX_CONSTRAINT_GT 4 #define SQLITE_INDEX_CONSTRAINT_LE 8 #define SQLITE_INDEX_CONSTRAINT_LT 16 #define SQLITE_INDEX_CONSTRAINT_GE 32 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 /* ** CAPI3REF: Register A Virtual Table Implementation ** ** ^These routines are used to register a new [virtual table module] name. ** ^Module names must be registered before ** creating a new [virtual table] using the module and before using a ** preexisting [virtual table] for the module. ** ** ^The module name is registered on the [database connection] specified ** by the first parameter. ^The name of the module is given by the ** second parameter. ^The third parameter is a pointer to ** the implementation of the [virtual table module]. ^The fourth ** parameter is an arbitrary client data pointer that is passed through ** into the [xCreate] and [xConnect] methods of the virtual table module ** when a new virtual table is be being created or reinitialized. ** ** ^The sqlite3_create_module_v2() interface has a fifth parameter which ** is a pointer to a destructor for the pClientData. ^SQLite will ** invoke the destructor function (if it is not NULL) when SQLite ** no longer needs the pClientData pointer. ^The sqlite3_create_module() ** interface is equivalent to sqlite3_create_module_v2() with a NULL ** destructor. */ SQLITE_API int sqlite3_create_module( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData /* Client data for xCreate/xConnect */ ); SQLITE_API int sqlite3_create_module_v2( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); /* ** CAPI3REF: Virtual Table Instance Object ** KEYWORDS: sqlite3_vtab ** ** Every [virtual table module] implementation uses a subclass ** of this object to describe a particular instance ** of the [virtual table]. Each subclass will ** be tailored to the specific needs of the module implementation. ** The purpose of this superclass is to define certain fields that are ** common to all module implementations. ** ** ^Virtual tables methods can set an error message by assigning a ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should ** take care that any prior string is freed by a call to [sqlite3_free()] ** prior to assigning a new string to zErrMsg. ^After the error message ** is delivered up to the client application, the string will be automatically ** freed by sqlite3_free() and the zErrMsg field will be zeroed. */ struct sqlite3_vtab { const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* NO LONGER USED */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Virtual Table Cursor Object ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} ** ** Every [virtual table module] implementation uses a subclass of the ** following structure to describe cursors that point into the ** [virtual table] and are used ** to loop through the virtual table. Cursors are created using the ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed ** by the [sqlite3_module.xClose | xClose] method. Cursors are used ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods ** of the module. Each module implementation will define ** the content of a cursor structure to suit its own needs. ** ** This superclass exists in order to define fields of the cursor that ** are common to all implementations. */ struct sqlite3_vtab_cursor { sqlite3_vtab *pVtab; /* Virtual table of this cursor */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Declare The Schema Of A Virtual Table ** ** ^The [xCreate] and [xConnect] methods of a ** [virtual table module] call this interface ** to declare the format (the names and datatypes of the columns) of ** the virtual tables they implement. */ SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL); /* ** CAPI3REF: Overload A Function For A Virtual Table ** ** ^(Virtual tables can provide alternative implementations of functions ** using the [xFindFunction] method of the [virtual table module]. ** But global versions of those functions ** must exist in order to be overloaded.)^ ** ** ^(This API makes sure a global version of a function with a particular ** name and number of parameters exists. If no such function exists ** before this API is called, a new function is created.)^ ^The implementation ** of the new function always causes an exception to be thrown. So ** the new function is not good for anything by itself. Its only ** purpose is to be a placeholder function that can be overloaded ** by a [virtual table]. */ SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); /* ** The interface to the virtual-table mechanism defined above (back up ** to a comment remarkably similar to this one) is currently considered ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ /* ** CAPI3REF: A Handle To An Open BLOB ** KEYWORDS: {BLOB handle} {BLOB handles} ** ** An instance of this object represents an open BLOB on which ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. ** ^Objects of this type are created by [sqlite3_blob_open()] ** and destroyed by [sqlite3_blob_close()]. ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces ** can be used to read or write small subsections of the BLOB. ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. */ typedef struct sqlite3_blob sqlite3_blob; /* ** CAPI3REF: Open A BLOB For Incremental I/O ** ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located ** in row iRow, column zColumn, table zTable in database zDb; ** in other words, the same BLOB that would be selected by: ** **
**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
** 
)^ ** ** ^If the flags parameter is non-zero, then the BLOB is opened for read ** and write access. ^If it is zero, the BLOB is opened for read access. ** ^It is not possible to open a column that is part of an index or primary ** key for writing. ^If [foreign key constraints] are enabled, it is ** not possible to open a column that is part of a [child key] for writing. ** ** ^Note that the database name is not the filename that contains ** the database but rather the symbolic name of the database that ** appears after the AS keyword when the database is connected using [ATTACH]. ** ^For the main database file, the database name is "main". ** ^For TEMP tables, the database name is "temp". ** ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set ** to be a null pointer.)^ ** ^This function sets the [database connection] error code and message ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related ** functions. ^Note that the *ppBlob variable is always initialized in a ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob ** regardless of the success or failure of this routine. ** ** ^(If the row that a BLOB handle points to is modified by an ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects ** then the BLOB handle is marked as "expired". ** This is true if any column of the row is changed, even a column ** other than the one the BLOB handle is open on.)^ ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for ** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. ** ^(Changes written into a BLOB prior to the BLOB expiring are not ** rolled back by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion.)^ ** ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of ** the opened blob. ^The size of a blob may not be changed by this ** interface. Use the [UPDATE] SQL command to change the size of a ** blob. ** ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces ** and the built-in [zeroblob] SQL function can be used, if desired, ** to create an empty, zero-filled blob in which to read or write using ** this interface. ** ** To avoid a resource leak, every open [BLOB handle] should eventually ** be released by a call to [sqlite3_blob_close()]. */ SQLITE_API int sqlite3_blob_open( sqlite3*, const char *zDb, const char *zTable, const char *zColumn, sqlite3_int64 iRow, int flags, sqlite3_blob **ppBlob ); /* ** CAPI3REF: Close A BLOB Handle ** ** ^Closes an open [BLOB handle]. ** ** ^Closing a BLOB shall cause the current transaction to commit ** if there are no other BLOBs, no pending prepared statements, and the ** database connection is in [autocommit mode]. ** ^If any writes were made to the BLOB, they might be held in cache ** until the close operation if they will fit. ** ** ^(Closing the BLOB often forces the changes ** out to disk and so if any I/O errors occur, they will likely occur ** at the time when the BLOB is closed. Any errors that occur during ** closing are reported as a non-zero return value.)^ ** ** ^(The BLOB is closed unconditionally. Even if this routine returns ** an error code, the BLOB is still closed.)^ ** ** ^Calling this routine with a null pointer (such as would be returned ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. */ SQLITE_API int sqlite3_blob_close(sqlite3_blob *); /* ** CAPI3REF: Return The Size Of An Open BLOB ** ** ^Returns the size in bytes of the BLOB accessible via the ** successfully opened [BLOB handle] in its only argument. ^The ** incremental blob I/O routines can only read or overwriting existing ** blob content; they cannot change the size of a blob. ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. */ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); /* ** CAPI3REF: Read Data From A BLOB Incrementally ** ** ^(This function is used to read data from an open [BLOB handle] into a ** caller-supplied buffer. N bytes of data are copied into buffer Z ** from the open BLOB, starting at offset iOffset.)^ ** ** ^If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is ** less than zero, [SQLITE_ERROR] is returned and no data is read. ** ^The size of the blob (and hence the maximum value of N+iOffset) ** can be determined using the [sqlite3_blob_bytes()] interface. ** ** ^An attempt to read from an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ** ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. ** Otherwise, an [error code] or an [extended error code] is returned.)^ ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. ** ** See also: [sqlite3_blob_write()]. */ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* ** CAPI3REF: Write Data Into A BLOB Incrementally ** ** ^This function is used to write data into an open [BLOB handle] from a ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z ** into the open BLOB, starting at offset iOffset. ** ** ^If the [BLOB handle] passed as the first argument was not opened for ** writing (the flags parameter to [sqlite3_blob_open()] was zero), ** this function returns [SQLITE_READONLY]. ** ** ^This function may only modify the contents of the BLOB; it is ** not possible to increase the size of a BLOB using this API. ** ^If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is written. ^If N is ** less than zero [SQLITE_ERROR] is returned and no data is written. ** The size of the BLOB (and hence the maximum value of N+iOffset) ** can be determined using the [sqlite3_blob_bytes()] interface. ** ** ^An attempt to write to an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred ** before the [BLOB handle] expired are not rolled back by the ** expiration of the handle, though of course those changes might ** have been overwritten by the statement that expired the BLOB handle ** or by other independent statements. ** ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. ** Otherwise, an [error code] or an [extended error code] is returned.)^ ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. ** ** See also: [sqlite3_blob_read()]. */ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); /* ** CAPI3REF: Virtual File System Objects ** ** A virtual filesystem (VFS) is an [sqlite3_vfs] object ** that SQLite uses to interact ** with the underlying operating system. Most SQLite builds come with a ** single default VFS that is appropriate for the host computer. ** New VFSes can be registered and existing VFSes can be unregistered. ** The following interfaces are provided. ** ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. ** ^Names are case sensitive. ** ^Names are zero-terminated UTF-8 strings. ** ^If there is no match, a NULL pointer is returned. ** ^If zVfsName is NULL then the default VFS is returned. ** ** ^New VFSes are registered with sqlite3_vfs_register(). ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. ** ^The same VFS can be registered multiple times without injury. ** ^To make an existing VFS into the default VFS, register it again ** with the makeDflt flag set. If two different VFSes with the ** same name are registered, the behavior is undefined. If a ** VFS is registered with a name that is NULL or an empty string, ** then the behavior is undefined. ** ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. ** ^(If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary.)^ */ SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); /* ** CAPI3REF: Mutexes ** ** The SQLite core uses these routines for thread ** synchronization. Though they are intended for internal ** use by SQLite, code that links against SQLite is ** permitted to use any of these routines. ** ** The SQLite source code contains multiple implementations ** of these mutex routines. An appropriate implementation ** is selected automatically at compile-time. ^(The following ** implementations are available in the SQLite core: ** **
    **
  • SQLITE_MUTEX_OS2 **
  • SQLITE_MUTEX_PTHREAD **
  • SQLITE_MUTEX_W32 **
  • SQLITE_MUTEX_NOOP **
)^ ** ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines ** that does no real locking and is appropriate for use in ** a single-threaded application. ^The SQLITE_MUTEX_OS2, ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations ** are appropriate for use on OS/2, Unix, and Windows. ** ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize().)^ ** ** ^The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. ^If it returns NULL ** that means that a mutex could not be allocated. ^SQLite ** will unwind its stack and return an error. ^(The argument ** to sqlite3_mutex_alloc() is one of these integer constants: ** **
    **
  • SQLITE_MUTEX_FAST **
  • SQLITE_MUTEX_RECURSIVE **
  • SQLITE_MUTEX_STATIC_MASTER **
  • SQLITE_MUTEX_STATIC_MEM **
  • SQLITE_MUTEX_STATIC_MEM2 **
  • SQLITE_MUTEX_STATIC_PRNG **
  • SQLITE_MUTEX_STATIC_LRU **
  • SQLITE_MUTEX_STATIC_LRU2 **
)^ ** ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) ** cause sqlite3_mutex_alloc() to create ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. ** The mutex implementation does not need to make a distinction ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does ** not want to. ^SQLite will only request a recursive mutex in ** cases where it really needs one. ^If a faster non-recursive mutex ** implementation is available on the host platform, the mutex subsystem ** might return such a mutex in response to SQLITE_MUTEX_FAST. ** ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return ** a pointer to a static preexisting mutex. ^Six static mutexes are ** used by the current version of SQLite. Future versions of SQLite ** may add additional static mutexes. Static mutexes are for internal ** use by SQLite only. Applications that use SQLite mutexes should ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or ** SQLITE_MUTEX_RECURSIVE. ** ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. ^But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. ** ** ^The sqlite3_mutex_free() routine deallocates a previously ** allocated dynamic mutex. ^SQLite is careful to deallocate every ** dynamic mutex that it allocates. The dynamic mutexes must not be in ** use when they are deallocated. Attempting to deallocate a static ** mutex results in undefined behavior. ^SQLite never deallocates ** a static mutex. ** ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt ** to enter a mutex. ^If another thread is already within the mutex, ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] ** upon successful entry. ^(Mutexes created using ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. ** In such cases the, ** mutex must be exited an equal number of times before another thread ** can enter.)^ ^(If the same thread tries to enter any other ** kind of mutex more than once, the behavior is undefined. ** SQLite will never exhibit ** such behavior in its own use of mutexes.)^ ** ** ^(Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() ** will always return SQLITE_BUSY. The SQLite core only ever uses ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ ** ** ^The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. ^(The behavior ** is undefined if the mutex is not currently entered by the ** calling thread or is not currently allocated. SQLite will ** never do either.)^ ** ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or ** sqlite3_mutex_leave() is a NULL pointer, then all three routines ** behave as no-ops. ** ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. */ SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); /* ** CAPI3REF: Mutex Methods Object ** ** An instance of this structure defines the low-level routines ** used to allocate and use mutexes. ** ** Usually, the default mutex implementations provided by SQLite are ** sufficient, however the user has the option of substituting a custom ** implementation for specialized deployments or systems for which SQLite ** does not provide a suitable implementation. In this case, the user ** creates and populates an instance of this structure to pass ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. ** Additionally, an instance of this structure can be used as an ** output variable when querying the system for the current mutex ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. ** ** ^The xMutexInit method defined by this structure is invoked as ** part of system initialization by the sqlite3_initialize() function. ** ^The xMutexInit routine is calle by SQLite exactly once for each ** effective call to [sqlite3_initialize()]. ** ** ^The xMutexEnd method defined by this structure is invoked as ** part of system shutdown by the sqlite3_shutdown() function. The ** implementation of this method is expected to release all outstanding ** resources obtained by the mutex methods implementation, especially ** those obtained by the xMutexInit method. ^The xMutexEnd() ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. ** ** ^(The remaining seven methods defined by this structure (xMutexAlloc, ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and ** xMutexNotheld) implement the following interfaces (respectively): ** **
    **
  • [sqlite3_mutex_alloc()]
  • **
  • [sqlite3_mutex_free()]
  • **
  • [sqlite3_mutex_enter()]
  • **
  • [sqlite3_mutex_try()]
  • **
  • [sqlite3_mutex_leave()]
  • **
  • [sqlite3_mutex_held()]
  • **
  • [sqlite3_mutex_notheld()]
  • **
)^ ** ** The only difference is that the public sqlite3_XXX functions enumerated ** above silently ignore any invocations that pass a NULL pointer instead ** of a valid mutex handle. The implementations of the methods defined ** by this structure are not required to handle this case, the results ** of passing a NULL pointer instead of a valid mutex handle are undefined ** (i.e. it is acceptable to provide an implementation that segfaults if ** it is passed a NULL pointer). ** ** The xMutexInit() method must be threadsafe. ^It must be harmless to ** invoke xMutexInit() multiple times within the same process and without ** intervening calls to xMutexEnd(). Second and subsequent calls to ** xMutexInit() must be no-ops. ** ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite ** memory allocation for a fast or recursive mutex. ** ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is ** called, but only if the prior call to xMutexInit returned SQLITE_OK. ** If xMutexInit fails in any way, it is expected to clean up after itself ** prior to returning. */ typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; struct sqlite3_mutex_methods { int (*xMutexInit)(void); int (*xMutexEnd)(void); sqlite3_mutex *(*xMutexAlloc)(int); void (*xMutexFree)(sqlite3_mutex *); void (*xMutexEnter)(sqlite3_mutex *); int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* ** CAPI3REF: Mutex Verification Routines ** ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines ** are intended for use inside assert() statements. ^The SQLite core ** never uses these routines except inside an assert() and applications ** are advised to follow the lead of the core. ^The SQLite core only ** provides implementations for these routines when it is compiled ** with the SQLITE_DEBUG flag. ^External mutex implementations ** are only required to provide these routines if SQLITE_DEBUG is ** defined and if NDEBUG is not defined. ** ** ^These routines should return true if the mutex in their argument ** is held or not held, respectively, by the calling thread. ** ** ^The implementation is not required to provided versions of these ** routines that actually work. If the implementation does not provide working ** versions of these routines, it should at least provide stubs that always ** return true so that one does not get spurious assertion failures. ** ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then ** the routine should return 1. This seems counter-intuitive since ** clearly the mutex cannot be held if it does not exist. But the ** the reason the mutex does not exist is because the build is not ** using mutexes. And we do not want the assert() containing the ** call to sqlite3_mutex_held() to fail, so a non-zero return is ** the appropriate thing to do. ^The sqlite3_mutex_notheld() ** interface should also return 1 when given a NULL pointer. */ #ifndef NDEBUG SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); #endif /* ** CAPI3REF: Mutex Types ** ** The [sqlite3_mutex_alloc()] interface takes a single argument ** which is one of these integer constants. ** ** The set of static mutexes may change from one SQLite release to the ** next. Applications that override the built-in mutex logic must be ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ /* ** CAPI3REF: Retrieve the mutex for a database connection ** ** ^This interface returns a pointer the [sqlite3_mutex] object that ** serializes access to the [database connection] given in the argument ** when the [threading mode] is Serialized. ** ^If the [threading mode] is Single-thread or Multi-thread then this ** routine returns a NULL pointer. */ SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); /* ** CAPI3REF: Low-Level Control Of Database Files ** ** ^The [sqlite3_file_control()] interface makes a direct call to the ** xFileControl method for the [sqlite3_io_methods] object associated ** with a particular database identified by the second argument. ^The ** name of the database "main" for the main database or "temp" for the ** TEMP database, or the name that appears after the AS keyword for ** databases that are added using the [ATTACH] SQL command. ** ^A NULL pointer can be used in place of "main" to refer to the ** main database file. ** ^The third and fourth parameters to this routine ** are passed directly through to the second and third parameters of ** the xFileControl method. ^The return value of the xFileControl ** method becomes the return value of this routine. ** ** ^If the second parameter (zDbName) does not match the name of any ** open database file, then SQLITE_ERROR is returned. ^This error ** code is not remembered and will not be recalled by [sqlite3_errcode()] ** or [sqlite3_errmsg()]. The underlying xFileControl method might ** also return SQLITE_ERROR. There is no way to distinguish between ** an incorrect zDbName and an SQLITE_ERROR return from the underlying ** xFileControl method. ** ** See also: [SQLITE_FCNTL_LOCKSTATE] */ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); /* ** CAPI3REF: Testing Interface ** ** ^The sqlite3_test_control() interface is used to read out internal ** state of SQLite and to inject faults into SQLite for testing ** purposes. ^The first parameter is an operation code that determines ** the number, meaning, and operation of all subsequent parameters. ** ** This interface is not for use by applications. It exists solely ** for verifying the correct operation of the SQLite library. Depending ** on how the SQLite library is compiled, this interface might not exist. ** ** The details of the operation codes, their meanings, the parameters ** they take, and what they do are all subject to change without notice. ** Unlike most of the SQLite API, this function is not guaranteed to ** operate consistently from one release to the next. */ SQLITE_API int sqlite3_test_control(int op, ...); /* ** CAPI3REF: Testing Interface Operation Codes ** ** These constants are the valid operation code parameters used ** as the first argument to [sqlite3_test_control()]. ** ** These parameters and their meanings are subject to change ** without notice. These values are for testing purposes only. ** Applications should not use any of these parameters or the ** [sqlite3_test_control()] interface. */ #define SQLITE_TESTCTRL_FIRST 5 #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 #define SQLITE_TESTCTRL_PENDING_BYTE 11 #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 #define SQLITE_TESTCTRL_PGHDRSZ 17 #define SQLITE_TESTCTRL_LAST 17 /* ** CAPI3REF: SQLite Runtime Status ** ** ^This interface is used to retrieve runtime status information ** about the performance of SQLite, and optionally to reset various ** highwater marks. ^The first argument is an integer code for ** the specific parameter to measure. ^(Recognized integer codes ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^ ** ^The current value of the parameter is returned into *pCurrent. ** ^The highest recorded value is returned in *pHighwater. ^If the ** resetFlag is true, then the highest record value is reset after ** *pHighwater is written. ^(Some parameters do not record the highest ** value. For those parameters ** nothing is written into *pHighwater and the resetFlag is ignored.)^ ** ^(Other parameters record only the highwater mark and not the current ** value. For these latter parameters nothing is written into *pCurrent.)^ ** ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a ** non-zero [error code] on failure. ** ** This routine is threadsafe but is not atomic. This routine can be ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** ** See also: [sqlite3_db_status()] */ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); /* ** CAPI3REF: Status Parameters ** ** These integer constants designate various run-time status parameters ** that can be returned by [sqlite3_status()]. ** **
** ^(
SQLITE_STATUS_MEMORY_USED
**
This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application ** and internal memory usage by the SQLite library. Scratch memory ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ ** ** ^(
SQLITE_STATUS_MALLOC_SIZE
**
This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their ** internal equivalents). Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** ^(
SQLITE_STATUS_MALLOC_COUNT
**
This parameter records the number of separate memory allocations.
)^ ** ** ^(
SQLITE_STATUS_PAGECACHE_USED
**
This parameter returns the number of pages used out of the ** [pagecache memory allocator] that was configured using ** [SQLITE_CONFIG_PAGECACHE]. The ** value returned is in pages, not in bytes.
)^ ** ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
**
This parameter returns the number of bytes of page cache ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] ** buffer and where forced to overflow to [sqlite3_malloc()]. The ** returned value includes allocations that overflowed because they ** where too large (they were larger than the "sz" parameter to ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because ** no space was left in the page cache.
)^ ** ** ^(
SQLITE_STATUS_PAGECACHE_SIZE
**
This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** ^(
SQLITE_STATUS_SCRATCH_USED
**
This parameter returns the number of allocations used out of the ** [scratch memory allocator] configured using ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not ** in bytes. Since a single thread may only have one scratch allocation ** outstanding at time, this parameter also reports the number of threads ** using scratch memory at the same time.
)^ ** ** ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
**
This parameter returns the number of bytes of scratch memory ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] ** buffer and where forced to overflow to [sqlite3_malloc()]. The values ** returned include overflows because the requested allocation was too ** larger (that is, because the requested allocation was larger than the ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer ** slots were available. **
)^ ** ** ^(
SQLITE_STATUS_SCRATCH_SIZE
**
This parameter records the largest memory allocation request ** handed to [scratch memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** ^(
SQLITE_STATUS_PARSER_STACK
**
This parameter records the deepest parser stack. It is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ **
** ** New status parameters may be added from time to time. */ #define SQLITE_STATUS_MEMORY_USED 0 #define SQLITE_STATUS_PAGECACHE_USED 1 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 #define SQLITE_STATUS_SCRATCH_USED 3 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 #define SQLITE_STATUS_MALLOC_SIZE 5 #define SQLITE_STATUS_PARSER_STACK 6 #define SQLITE_STATUS_PAGECACHE_SIZE 7 #define SQLITE_STATUS_SCRATCH_SIZE 8 #define SQLITE_STATUS_MALLOC_COUNT 9 /* ** CAPI3REF: Database Connection Status ** ** ^This interface is used to retrieve runtime status information ** about a single [database connection]. ^The first argument is the ** database connection object to be interrogated. ^The second argument ** is an integer constant, taken from the set of ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that ** determines the parameter to interrogate. The set of ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely ** to grow in future releases of SQLite. ** ** ^The current value of the requested parameter is written into *pCur ** and the highest instantaneous value is written into *pHiwtr. ^If ** the resetFlg is true, then the highest instantaneous value is ** reset back down to the current value. ** ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. */ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Status Parameters for database connections ** ** These constants are the available integer "verbs" that can be passed as ** the second argument to the [sqlite3_db_status()] interface. ** ** New verbs may be added in future releases of SQLite. Existing verbs ** might be discontinued. Applications should check the return code from ** [sqlite3_db_status()] to make sure that the call worked. ** The [sqlite3_db_status()] interface will return a non-zero error code ** if a discontinued or unsupported verb is invoked. ** **
** ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
**
This parameter returns the number of lookaside memory slots currently ** checked out.
)^ ** ** ^(
SQLITE_DBSTATUS_CACHE_USED
**
This parameter returns the approximate number of of bytes of heap ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** ** ^(
SQLITE_DBSTATUS_SCHEMA_USED
**
This parameter returns the approximate number of of bytes of heap ** memory used to store the schema for all databases associated ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ ** ^The full amount of memory used by the schemas is reported, even if the ** schema memory is shared with other database connections due to ** [shared cache mode] being enabled. ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. ** ** ^(
SQLITE_DBSTATUS_STMT_USED
**
This parameter returns the approximate number of of bytes of heap ** and lookaside memory used by all prepared statements associated with ** the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. **
**
*/ #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 #define SQLITE_DBSTATUS_CACHE_USED 1 #define SQLITE_DBSTATUS_SCHEMA_USED 2 #define SQLITE_DBSTATUS_STMT_USED 3 #define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ /* ** CAPI3REF: Prepared Statement Status ** ** ^(Each prepared statement maintains various ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number ** of times it has performed specific operations.)^ These counters can ** be used to monitor the performance characteristics of the prepared ** statements. For example, if the number of table steps greatly exceeds ** the number of table searches or result rows, that would tend to indicate ** that the prepared statement is using a full table scan rather than ** an index. ** ** ^(This interface is used to retrieve and reset counter values from ** a [prepared statement]. The first argument is the prepared statement ** object to be interrogated. The second argument ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] ** to be interrogated.)^ ** ^The current value of the requested counter is returned. ** ^If the resetFlg is true, then the counter is reset to zero after this ** interface call returns. ** ** See also: [sqlite3_status()] and [sqlite3_db_status()]. */ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); /* ** CAPI3REF: Status Parameters for prepared statements ** ** These preprocessor macros define integer codes that name counter ** values associated with the [sqlite3_stmt_status()] interface. ** The meanings of the various counters are as follows: ** **
**
SQLITE_STMTSTATUS_FULLSCAN_STEP
**
^This is the number of times that SQLite has stepped forward in ** a table as part of a full table scan. Large numbers for this counter ** may indicate opportunities for performance improvement through ** careful use of indices.
** **
SQLITE_STMTSTATUS_SORT
**
^This is the number of sort operations that have occurred. ** A non-zero value in this counter may indicate an opportunity to ** improvement performance through careful use of indices.
** **
SQLITE_STMTSTATUS_AUTOINDEX
**
^This is the number of rows inserted into transient indices that ** were created automatically in order to help joins run faster. ** A non-zero value in this counter may indicate an opportunity to ** improvement performance by adding permanent indices that do not ** need to be reinitialized each time the statement is run.
** **
*/ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of ** its size or internal structure and never deals with the ** sqlite3_pcache object except by holding and passing pointers ** to the object. ** ** See [sqlite3_pcache_methods] for additional information. */ typedef struct sqlite3_pcache sqlite3_pcache; /* ** CAPI3REF: Application Defined Page Cache. ** KEYWORDS: {page cache} ** ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can ** register an alternative page cache implementation by passing in an ** instance of the sqlite3_pcache_methods structure.)^ The majority of the ** heap memory used by SQLite is used by the page cache to cache data read ** from, or ready to be written to, the database file. By implementing a ** custom page cache using this API, an application can control more ** precisely the amount of memory consumed by SQLite, the way in which ** that memory is allocated and released, and the policies used to ** determine exactly which parts of a database file are cached and for ** how long. ** ** ^(The contents of the sqlite3_pcache_methods structure are copied to an ** internal buffer by SQLite within the call to [sqlite3_config]. Hence ** the application may discard the parameter after the call to ** [sqlite3_config()] returns.)^ ** ** ^The xInit() method is called once for each call to [sqlite3_initialize()] ** (usually only once during the lifetime of the process). ^(The xInit() ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ ** ^The xInit() method can set up up global structures and/or any mutexes ** required by the custom page cache implementation. ** ** ^The xShutdown() method is called from within [sqlite3_shutdown()], ** if the application invokes this API. It can be used to clean up ** any outstanding resources before process shutdown, if required. ** ** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes ** the xInit method, so the xInit method need not be threadsafe. ^The ** xShutdown method is only called from [sqlite3_shutdown()] so it does ** not need to be threadsafe either. All other methods must be threadsafe ** in multithreaded applications. ** ** ^SQLite will never invoke xInit() more than once without an intervening ** call to xShutdown(). ** ** ^The xCreate() method is used to construct a new cache instance. SQLite ** will typically create one cache instance for each open database file, ** though this is not guaranteed. ^The ** first parameter, szPage, is the size in bytes of the pages that must ** be allocated by the cache. ^szPage will not be a power of two. ^szPage ** will the page size of the database file that is to be cached plus an ** increment (here called "R") of about 100 or 200. ^SQLite will use the ** extra R bytes on each page to store metadata about the underlying ** database page on disk. The value of R depends ** on the SQLite version, the target platform, and how SQLite was compiled. ** ^R is constant for a particular build of SQLite. ^The second argument to ** xCreate(), bPurgeable, is true if the cache being created will ** be used to cache database pages of a file stored on disk, or ** false if it is used for an in-memory database. ^The cache implementation ** does not have to do anything special based with the value of bPurgeable; ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will ** never invoke xUnpin() except to deliberately delete a page. ** ^In other words, a cache created with bPurgeable set to false will ** never contain any unpinned pages. ** ** ^(The xCachesize() method may be called at any time by SQLite to set the ** suggested maximum cache-size (number of pages stored by) the cache ** instance passed as the first argument. This is the value configured using ** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable ** parameter, the implementation is not required to do anything with this ** value; it is advisory only. ** ** ^The xPagecount() method should return the number of pages currently ** stored in the cache. ** ** ^The xFetch() method is used to fetch a page and return a pointer to it. ** ^A 'page', in this context, is a buffer of szPage bytes aligned at an ** 8-byte boundary. ^The page to be fetched is determined by the key. ^The ** mimimum key value is 1. After it has been retrieved using xFetch, the page ** is considered to be "pinned". ** ** ^If the requested page is already in the page cache, then the page cache ** implementation must return a pointer to the page buffer with its content ** intact. ^(If the requested page is not already in the cache, then the ** behavior of the cache implementation is determined by the value of the ** createFlag parameter passed to xFetch, according to the following table: ** ** **
createFlag Behaviour when page is not already in cache **
0 Do not allocate a new page. Return NULL. **
1 Allocate a new page if it easy and convenient to do so. ** Otherwise return NULL. **
2 Make every effort to allocate a new page. Only return ** NULL if allocating a new page is effectively impossible. **
)^ ** ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will ** attempt to unpin one or more cache pages by spilling the content of ** pinned pages to disk and synching the operating system disk cache. After ** attempting to unpin pages, the xFetch() method will be invoked again with ** a createFlag of 2. ** ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page ** as its second argument. ^(If the third parameter, discard, is non-zero, ** then the page should be evicted from the cache. In this case SQLite ** assumes that the next time the page is retrieved from the cache using ** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is ** zero, then the page is considered to be unpinned. ^The cache implementation ** may choose to evict unpinned pages at any time. ** ** ^(The cache is not required to perform any reference counting. A single ** call to xUnpin() unpins the page regardless of the number of prior calls ** to xFetch().)^ ** ** ^The xRekey() method is used to change the key value associated with the ** page passed as the second argument from oldKey to newKey. ^If the cache ** previously contains an entry associated with newKey, it should be ** discarded. ^Any prior cache entry associated with newKey is guaranteed not ** to be pinned. ** ** ^When SQLite calls the xTruncate() method, the cache must discard all ** existing cache entries with page numbers (keys) greater than or equal ** to the value of the iLimit parameter passed to xTruncate(). ^If any ** of these pages are pinned, they are implicitly unpinned, meaning that ** they can be safely discarded. ** ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). ** All resources associated with the specified cache should be freed. ^After ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] ** handle invalid, and will not use it with any other sqlite3_pcache_methods ** functions. */ typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; struct sqlite3_pcache_methods { void *pArg; int (*xInit)(void*); void (*xShutdown)(void*); sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); void (*xCachesize)(sqlite3_pcache*, int nCachesize); int (*xPagecount)(sqlite3_pcache*); void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); void (*xUnpin)(sqlite3_pcache*, void*, int discard); void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); void (*xDestroy)(sqlite3_pcache*); }; /* ** CAPI3REF: Online Backup Object ** ** The sqlite3_backup object records state information about an ongoing ** online backup operation. ^The sqlite3_backup object is created by ** a call to [sqlite3_backup_init()] and is destroyed by a call to ** [sqlite3_backup_finish()]. ** ** See Also: [Using the SQLite Online Backup API] */ typedef struct sqlite3_backup sqlite3_backup; /* ** CAPI3REF: Online Backup API. ** ** The backup API copies the content of one database into another. ** It is useful either for creating backups of databases or ** for copying in-memory databases to or from persistent files. ** ** See Also: [Using the SQLite Online Backup API] ** ** ^Exclusive access is required to the destination database for the ** duration of the operation. ^However the source database is only ** read-locked while it is actually being read; it is not locked ** continuously for the entire backup operation. ^Thus, the backup may be ** performed on a live source database without preventing other users from ** reading or writing to the source database while the backup is underway. ** ** ^(To perform a backup operation: **
    **
  1. sqlite3_backup_init() is called once to initialize the ** backup, **
  2. sqlite3_backup_step() is called one or more times to transfer ** the data between the two databases, and finally **
  3. sqlite3_backup_finish() is called to release all resources ** associated with the backup operation. **
)^ ** There should be exactly one call to sqlite3_backup_finish() for each ** successful call to sqlite3_backup_init(). ** ** sqlite3_backup_init() ** ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the ** [database connection] associated with the destination database ** and the database name, respectively. ** ^The database name is "main" for the main database, "temp" for the ** temporary database, or the name specified after the AS keyword in ** an [ATTACH] statement for an attached database. ** ^The S and M arguments passed to ** sqlite3_backup_init(D,N,S,M) identify the [database connection] ** and database name of the source database, respectively. ** ^The source and destination [database connections] (parameters S and D) ** must be different or else sqlite3_backup_init(D,N,S,M) will file with ** an error. ** ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is ** returned and an error code and error message are store3d in the ** destination [database connection] D. ** ^The error code and message for the failed call to sqlite3_backup_init() ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or ** [sqlite3_errmsg16()] functions. ** ^A successful call to sqlite3_backup_init() returns a pointer to an ** [sqlite3_backup] object. ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and ** sqlite3_backup_finish() functions to perform the specified backup ** operation. ** ** sqlite3_backup_step() ** ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between ** the source and destination databases specified by [sqlite3_backup] object B. ** ^If N is negative, all remaining source pages are copied. ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there ** are still more pages to be copied, then the function resturns [SQLITE_OK]. ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages ** from source to destination, then it returns [SQLITE_DONE]. ** ^If an error occurs while running sqlite3_backup_step(B,N), ** then an [error code] is returned. ^As well as [SQLITE_OK] and ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. ** ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if **
    **
  1. the destination database was opened read-only, or **
  2. the destination database is using write-ahead-log journaling ** and the destination and source page sizes differ, or **
  3. The destination database is an in-memory database and the ** destination and source page sizes differ. **
)^ ** ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then ** the [sqlite3_busy_handler | busy-handler function] ** is invoked (if one is specified). ^If the ** busy-handler returns non-zero before the lock is available, then ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to ** sqlite3_backup_step() can be retried later. ^If the source ** [database connection] ** is being used to write to the source database when sqlite3_backup_step() ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this ** case the call to sqlite3_backup_step() can be retried later on. ^(If ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or ** [SQLITE_READONLY] is returned, then ** there is no point in retrying the call to sqlite3_backup_step(). These ** errors are considered fatal.)^ The application must accept ** that the backup operation has failed and pass the backup operation handle ** to the sqlite3_backup_finish() to release associated resources. ** ** ^The first call to sqlite3_backup_step() obtains an exclusive lock ** on the destination file. ^The exclusive lock is not released until either ** sqlite3_backup_finish() is called or the backup operation is complete ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to ** sqlite3_backup_step() obtains a [shared lock] on the source database that ** lasts for the duration of the sqlite3_backup_step() call. ** ^Because the source database is not locked between calls to ** sqlite3_backup_step(), the source database may be modified mid-way ** through the backup process. ^If the source database is modified by an ** external process or via a database connection other than the one being ** used by the backup operation, then the backup will be automatically ** restarted by the next call to sqlite3_backup_step(). ^If the source ** database is modified by the using the same database connection as is used ** by the backup operation, then the backup database is automatically ** updated at the same time. ** ** sqlite3_backup_finish() ** ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the ** application wishes to abandon the backup operation, the application ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). ** ^The sqlite3_backup_finish() interfaces releases all ** resources associated with the [sqlite3_backup] object. ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any ** active write-transaction on the destination database is rolled back. ** The [sqlite3_backup] object is invalid ** and may not be used following a call to sqlite3_backup_finish(). ** ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no ** sqlite3_backup_step() errors occurred, regardless or whether or not ** sqlite3_backup_step() completed. ** ^If an out-of-memory condition or IO error occurred during any prior ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then ** sqlite3_backup_finish() returns the corresponding [error code]. ** ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() ** is not a permanent error and does not affect the return value of ** sqlite3_backup_finish(). ** ** sqlite3_backup_remaining(), sqlite3_backup_pagecount() ** ** ^Each call to sqlite3_backup_step() sets two values inside ** the [sqlite3_backup] object: the number of pages still to be backed ** up and the total number of pages in the source database file. ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces ** retrieve these two values, respectively. ** ** ^The values returned by these functions are only updated by ** sqlite3_backup_step(). ^If the source database is modified during a backup ** operation, then the values are not updated to account for any extra ** pages that need to be updated or the size of the source database file ** changing. ** ** Concurrent Usage of Database Handles ** ** ^The source [database connection] may be used by the application for other ** purposes while a backup operation is underway or being initialized. ** ^If SQLite is compiled and configured to support threadsafe database ** connections, then the source database connection may be used concurrently ** from within other threads. ** ** However, the application must guarantee that the destination ** [database connection] is not passed to any other API (by any thread) after ** sqlite3_backup_init() is called and before the corresponding call to ** sqlite3_backup_finish(). SQLite does not currently check to see ** if the application incorrectly accesses the destination [database connection] ** and so no error code is reported, but the operations may malfunction ** nevertheless. Use of the destination database connection while a ** backup is in progress might also also cause a mutex deadlock. ** ** If running in [shared cache mode], the application must ** guarantee that the shared cache used by the destination database ** is not accessed while the backup is running. In practice this means ** that the application must guarantee that the disk file being ** backed up to is not accessed by any connection within the process, ** not just the specific connection that was passed to sqlite3_backup_init(). ** ** The [sqlite3_backup] object itself is partially threadsafe. Multiple ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() ** APIs are not strictly speaking threadsafe. If they are invoked at the ** same time as another thread is invoking sqlite3_backup_step() it is ** possible that they return invalid values. */ SQLITE_API sqlite3_backup *sqlite3_backup_init( sqlite3 *pDest, /* Destination database handle */ const char *zDestName, /* Destination database name */ sqlite3 *pSource, /* Source database handle */ const char *zSourceName /* Source database name */ ); SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); /* ** CAPI3REF: Unlock Notification ** ** ^When running in shared-cache mode, a database operation may fail with ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or ** individual tables within the shared-cache cannot be obtained. See ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. ** ^This API may be used to register a callback that SQLite will invoke ** when the connection currently holding the required lock relinquishes it. ** ^This API is only available if the library was compiled with the ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. ** ** See Also: [Using the SQLite Unlock Notification Feature]. ** ** ^Shared-cache locks are released when a database connection concludes ** its current transaction, either by committing it or rolling it back. ** ** ^When a connection (known as the blocked connection) fails to obtain a ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the ** identity of the database connection (the blocking connection) that ** has locked the required resource is stored internally. ^After an ** application receives an SQLITE_LOCKED error, it may call the ** sqlite3_unlock_notify() method with the blocked connection handle as ** the first argument to register for a callback that will be invoked ** when the blocking connections current transaction is concluded. ^The ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] ** call that concludes the blocking connections transaction. ** ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, ** there is a chance that the blocking connection will have already ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. ** If this happens, then the specified callback is invoked immediately, ** from within the call to sqlite3_unlock_notify().)^ ** ** ^If the blocked connection is attempting to obtain a write-lock on a ** shared-cache table, and more than one other connection currently holds ** a read-lock on the same table, then SQLite arbitrarily selects one of ** the other connections to use as the blocking connection. ** ** ^(There may be at most one unlock-notify callback registered by a ** blocked connection. If sqlite3_unlock_notify() is called when the ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing ** unlock-notify callback is canceled. ^The blocked connections ** unlock-notify callback may also be canceled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes ** any sqlite3_xxx API functions from within an unlock-notify callback, a ** crash or deadlock may be the result. ** ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always ** returns SQLITE_OK. ** ** Callback Invocation Details ** ** When an unlock-notify callback is registered, the application provides a ** single void* pointer that is passed to the callback when it is invoked. ** However, the signature of the callback function allows SQLite to pass ** it an array of void* context pointers. The first argument passed to ** an unlock-notify callback is a pointer to an array of void* pointers, ** and the second is the number of entries in the array. ** ** When a blocking connections transaction is concluded, there may be ** more than one blocked connection that has registered for an unlock-notify ** callback. ^If two or more such blocked connections have specified the ** same callback function, then instead of invoking the callback function ** multiple times, it is invoked once with the set of void* context pointers ** specified by the blocked connections bundled together into an array. ** This gives the application an opportunity to prioritize any actions ** related to the set of unblocked database connections. ** ** Deadlock Detection ** ** Assuming that after registering for an unlock-notify callback a ** database waits for the callback to be issued before taking any further ** action (a reasonable assumption), then using this API may cause the ** application to deadlock. For example, if connection X is waiting for ** connection Y's transaction to be concluded, and similarly connection ** Y is waiting on connection X's transaction, then neither connection ** will proceed and the system may remain deadlocked indefinitely. ** ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock ** detection. ^If a given call to sqlite3_unlock_notify() would put the ** system in a deadlocked state, then SQLITE_LOCKED is returned and no ** unlock-notify callback is registered. The system is said to be in ** a deadlocked state if connection A has registered for an unlock-notify ** callback on the conclusion of connection B's transaction, and connection ** B has itself registered for an unlock-notify callback when connection ** A's transaction is concluded. ^Indirect deadlock is also detected, so ** the system is also considered to be deadlocked if connection B has ** registered for an unlock-notify callback on the conclusion of connection ** C's transaction, where connection C is waiting on connection A. ^Any ** number of levels of indirection are allowed. ** ** The "DROP TABLE" Exception ** ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost ** always appropriate to call sqlite3_unlock_notify(). There is however, ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, ** SQLite checks if there are any currently executing SELECT statements ** that belong to the same connection. If there are, SQLITE_LOCKED is ** returned. In this case there is no "blocking connection", so invoking ** sqlite3_unlock_notify() results in the unlock-notify callback being ** invoked immediately. If the application then re-attempts the "DROP TABLE" ** or "DROP INDEX" query, an infinite loop might be the result. ** ** One way around this problem is to check the extended error code returned ** by an sqlite3_step() call. ^(If there is a blocking connection, then the ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in ** the special "DROP TABLE/INDEX" case, the extended error code is just ** SQLITE_LOCKED.)^ */ SQLITE_API int sqlite3_unlock_notify( sqlite3 *pBlocked, /* Waiting connection */ void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ void *pNotifyArg /* Argument to pass to xNotify */ ); /* ** CAPI3REF: String Comparison ** ** ^The [sqlite3_strnicmp()] API allows applications and extensions to ** compare the contents of two buffers containing UTF-8 strings in a ** case-independent fashion, using the same definition of case independence ** that SQLite uses internally when comparing identifiers. */ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); /* ** CAPI3REF: Error Logging Interface ** ** ^The [sqlite3_log()] interface writes a message into the error log ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. ** ^If logging is enabled, the zFormat string and subsequent arguments are ** used with [sqlite3_snprintf()] to generate the final output string. ** ** The sqlite3_log() interface is intended for use by extensions such as ** virtual tables, collating functions, and SQL functions. While there is ** nothing to prevent an application from calling sqlite3_log(), doing so ** is considered bad form. ** ** The zFormat string must not be NULL. ** ** To avoid deadlocks and other threading problems, the sqlite3_log() routine ** will not use dynamically allocated memory. The log message is stored in ** a fixed-length buffer on the stack. If the log message is longer than ** a few hundred characters, it will be truncated to the length of the ** buffer. */ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); /* ** CAPI3REF: Write-Ahead Log Commit Hook ** ** ^The [sqlite3_wal_hook()] function is used to register a callback that ** will be invoked each time a database connection commits data to a ** [write-ahead log] (i.e. whenever a transaction is committed in ** [journal_mode | journal_mode=WAL mode]). ** ** ^The callback is invoked by SQLite after the commit has taken place and ** the associated write-lock on the database released, so the implementation ** may read, write or [checkpoint] the database as required. ** ** ^The first parameter passed to the callback function when it is invoked ** is a copy of the third parameter passed to sqlite3_wal_hook() when ** registering the callback. ^The second is a copy of the database handle. ** ^The third parameter is the name of the database that was written to - ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter ** is the number of pages currently in the write-ahead log file, ** including those that were just committed. ** ** The callback function should normally return [SQLITE_OK]. ^If an error ** code is returned, that error will propagate back up through the ** SQLite code base to cause the statement that provoked the callback ** to report an error, though the commit will have still occurred. If the ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value ** that does not correspond to any valid SQLite error code, the results ** are undefined. ** ** A single database handle may have at most a single write-ahead log callback ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any ** previously registered write-ahead log callback. ^Note that the ** [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will ** those overwrite any prior [sqlite3_wal_hook()] settings. */ SQLITE_API void *sqlite3_wal_hook( sqlite3*, int(*)(void *,sqlite3*,const char*,int), void* ); /* ** CAPI3REF: Configure an auto-checkpoint ** ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around ** [sqlite3_wal_hook()] that causes any database on [database connection] D ** to automatically [checkpoint] ** after committing a transaction if there are N or ** more frames in the [write-ahead log] file. ^Passing zero or ** a negative value as the nFrame parameter disables automatic ** checkpoints entirely. ** ** ^The callback registered by this function replaces any existing callback ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism ** configured by this function. ** ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface ** from SQL. ** ** ^Every new [database connection] defaults to having the auto-checkpoint ** enabled with a threshold of 1000 pages. The use of this interface ** is only necessary if the default setting is found to be suboptimal ** for a particular application. */ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); /* ** CAPI3REF: Checkpoint a database ** ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X ** on [database connection] D to be [checkpointed]. ^If X is NULL or an ** empty string, then a checkpoint is run on all databases of ** connection D. ^If the database connection D is not in ** [WAL | write-ahead log mode] then this interface is a harmless no-op. ** ** ^The [wal_checkpoint pragma] can be used to invoke this interface ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] can be used to cause this interface to be ** run whenever the WAL reaches a certain size threshold. */ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double #endif #if 0 } /* End of the 'extern "C"' block */ #endif #endif /************** End of sqlite3.h *********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include hash.h in the middle of sqliteInt.h ******************/ /************** Begin file hash.h ********************************************/ /* ** 2001 September 22 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; /* A complete hash table is an instance of the following structure. ** The internals of this structure are intended to be opaque -- client ** code should not attempt to access or modify the fields of this structure ** directly. Change this structure only by using the routines below. ** However, some of the "procedures" and "functions" for modifying and ** accessing this structure are really macros, so we can't really make ** this structure opaque. ** ** All elements of the hash table are on a single doubly-linked list. ** Hash.first points to the head of this list. ** ** There are Hash.htsize buckets. Each bucket points to a spot in ** the global doubly-linked list. The contents of the bucket are the ** element pointed to plus the next _ht.count-1 elements in the list. ** ** Hash.htsize and Hash.ht may be zero. In that case lookup is done ** by a linear search of the global list. For small tables, the ** Hash.ht table is never allocated because if there are few elements ** in the table, it is faster to do a linear search than to manage ** the hash table. */ struct Hash { unsigned int htsize; /* Number of buckets in the hash table */ unsigned int count; /* Number of entries in this table */ HashElem *first; /* The first element of the array */ struct _ht { /* the hash table */ int count; /* Number of entries with this hash */ HashElem *chain; /* Pointer to first entry with this hash */ } *ht; }; /* Each element in the hash table is an instance of the following ** structure. All elements are stored on a single doubly-linked list. ** ** Again, this structure is intended to be opaque, but it can't really ** be opaque because it is used by macros. */ struct HashElem { HashElem *next, *prev; /* Next and previous elements in the table */ void *data; /* Data associated with this element */ const char *pKey; int nKey; /* Key associated with this element */ }; /* ** Access routines. To delete, insert a NULL pointer. */ SQLITE_PRIVATE void sqlite3HashInit(Hash*); SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData); SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey, int nKey); SQLITE_PRIVATE void sqlite3HashClear(Hash*); /* ** Macros for looping over all elements of a hash table. The idiom is ** like this: ** ** Hash h; ** HashElem *p; ** ... ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ ** SomeStructure *pData = sqliteHashData(p); ** // do something with pData ** } */ #define sqliteHashFirst(H) ((H)->first) #define sqliteHashNext(E) ((E)->next) #define sqliteHashData(E) ((E)->data) /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ /* ** Number of entries in a hash table */ /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ #endif /* _SQLITE_HASH_H_ */ /************** End of hash.h ************************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include parse.h in the middle of sqliteInt.h *****************/ /************** Begin file parse.h *******************************************/ #define TK_SEMI 1 #define TK_EXPLAIN 2 #define TK_QUERY 3 #define TK_PLAN 4 #define TK_BEGIN 5 #define TK_TRANSACTION 6 #define TK_DEFERRED 7 #define TK_IMMEDIATE 8 #define TK_EXCLUSIVE 9 #define TK_COMMIT 10 #define TK_END 11 #define TK_ROLLBACK 12 #define TK_SAVEPOINT 13 #define TK_RELEASE 14 #define TK_TO 15 #define TK_TABLE 16 #define TK_CREATE 17 #define TK_IF 18 #define TK_NOT 19 #define TK_EXISTS 20 #define TK_TEMP 21 #define TK_LP 22 #define TK_RP 23 #define TK_AS 24 #define TK_COMMA 25 #define TK_ID 26 #define TK_INDEXED 27 #define TK_ABORT 28 #define TK_ACTION 29 #define TK_AFTER 30 #define TK_ANALYZE 31 #define TK_ASC 32 #define TK_ATTACH 33 #define TK_BEFORE 34 #define TK_BY 35 #define TK_CASCADE 36 #define TK_CAST 37 #define TK_COLUMNKW 38 #define TK_CONFLICT 39 #define TK_DATABASE 40 #define TK_DESC 41 #define TK_DETACH 42 #define TK_EACH 43 #define TK_FAIL 44 #define TK_FOR 45 #define TK_IGNORE 46 #define TK_INITIALLY 47 #define TK_INSTEAD 48 #define TK_LIKE_KW 49 #define TK_MATCH 50 #define TK_NO 51 #define TK_KEY 52 #define TK_OF 53 #define TK_OFFSET 54 #define TK_PRAGMA 55 #define TK_RAISE 56 #define TK_REPLACE 57 #define TK_RESTRICT 58 #define TK_ROW 59 #define TK_TRIGGER 60 #define TK_VACUUM 61 #define TK_VIEW 62 #define TK_VIRTUAL 63 #define TK_REINDEX 64 #define TK_RENAME 65 #define TK_CTIME_KW 66 #define TK_ANY 67 #define TK_OR 68 #define TK_AND 69 #define TK_IS 70 #define TK_BETWEEN 71 #define TK_IN 72 #define TK_ISNULL 73 #define TK_NOTNULL 74 #define TK_NE 75 #define TK_EQ 76 #define TK_GT 77 #define TK_LE 78 #define TK_LT 79 #define TK_GE 80 #define TK_ESCAPE 81 #define TK_BITAND 82 #define TK_BITOR 83 #define TK_LSHIFT 84 #define TK_RSHIFT 85 #define TK_PLUS 86 #define TK_MINUS 87 #define TK_STAR 88 #define TK_SLASH 89 #define TK_REM 90 #define TK_CONCAT 91 #define TK_COLLATE 92 #define TK_BITNOT 93 #define TK_STRING 94 #define TK_JOIN_KW 95 #define TK_CONSTRAINT 96 #define TK_DEFAULT 97 #define TK_NULL 98 #define TK_PRIMARY 99 #define TK_UNIQUE 100 #define TK_CHECK 101 #define TK_REFERENCES 102 #define TK_AUTOINCR 103 #define TK_ON 104 #define TK_INSERT 105 #define TK_DELETE 106 #define TK_UPDATE 107 #define TK_SET 108 #define TK_DEFERRABLE 109 #define TK_FOREIGN 110 #define TK_DROP 111 #define TK_UNION 112 #define TK_ALL 113 #define TK_EXCEPT 114 #define TK_INTERSECT 115 #define TK_SELECT 116 #define TK_DISTINCT 117 #define TK_DOT 118 #define TK_FROM 119 #define TK_JOIN 120 #define TK_USING 121 #define TK_ORDER 122 #define TK_GROUP 123 #define TK_HAVING 124 #define TK_LIMIT 125 #define TK_WHERE 126 #define TK_INTO 127 #define TK_VALUES 128 #define TK_INTEGER 129 #define TK_FLOAT 130 #define TK_BLOB 131 #define TK_REGISTER 132 #define TK_VARIABLE 133 #define TK_CASE 134 #define TK_WHEN 135 #define TK_THEN 136 #define TK_ELSE 137 #define TK_INDEX 138 #define TK_ALTER 139 #define TK_ADD 140 #define TK_TO_TEXT 141 #define TK_TO_BLOB 142 #define TK_TO_NUMERIC 143 #define TK_TO_INT 144 #define TK_TO_REAL 145 #define TK_ISNOT 146 #define TK_END_OF_FILE 147 #define TK_ILLEGAL 148 #define TK_SPACE 149 #define TK_UNCLOSED_STRING 150 #define TK_FUNCTION 151 #define TK_COLUMN 152 #define TK_AGG_FUNCTION 153 #define TK_AGG_COLUMN 154 #define TK_CONST_FUNC 155 #define TK_UMINUS 156 #define TK_UPLUS 157 /************** End of parse.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ #include #include #include #include #include /* ** If compiling for a processor that lacks floating point support, ** substitute integer for floating-point */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite_int64 # define float sqlite_int64 # define LONGDOUBLE_TYPE sqlite_int64 # ifndef SQLITE_BIG_DBL # define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50) # endif # define SQLITE_OMIT_DATETIME_FUNCS 1 # define SQLITE_OMIT_TRACE 1 # undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT # undef SQLITE_HAVE_ISNAN #endif #ifndef SQLITE_BIG_DBL # define SQLITE_BIG_DBL (1e99) #endif /* ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 ** afterward. Having this macro allows us to cause the C compiler ** to omit code used by TEMP tables without messy #ifndef statements. */ #ifdef SQLITE_OMIT_TEMPDB #define OMIT_TEMPDB 1 #else #define OMIT_TEMPDB 0 #endif /* ** The "file format" number is an integer that is incremented whenever ** the VDBE-level file format changes. The following macros define the ** the default file format for new databases and the maximum file format ** that the library can read. */ #define SQLITE_MAX_FILE_FORMAT 4 #ifndef SQLITE_DEFAULT_FILE_FORMAT # define SQLITE_DEFAULT_FILE_FORMAT 1 #endif /* ** Determine whether triggers are recursive by default. This can be ** changed at run-time using a pragma. */ #ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS # define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 #endif /* ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified ** on the command-line */ #ifndef SQLITE_TEMP_STORE # define SQLITE_TEMP_STORE 1 #endif /* ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves. */ #ifndef offsetof #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) #endif /* ** Check to see if this machine uses EBCDIC. (Yes, believe it or ** not, there are still machines out there that use EBCDIC.) */ #if 'A' == '\301' # define SQLITE_EBCDIC 1 #else # define SQLITE_ASCII 1 #endif /* ** Integers of known sizes. These typedefs might change for architectures ** where the sizes very. Preprocessor macros are available so that the ** types can be conveniently redefined at compile-type. Like this: ** ** cc '-DUINTPTR_TYPE=long long int' ... */ #ifndef UINT32_TYPE # ifdef HAVE_UINT32_T # define UINT32_TYPE uint32_t # else # define UINT32_TYPE unsigned int # endif #endif #ifndef UINT16_TYPE # ifdef HAVE_UINT16_T # define UINT16_TYPE uint16_t # else # define UINT16_TYPE unsigned short int # endif #endif #ifndef INT16_TYPE # ifdef HAVE_INT16_T # define INT16_TYPE int16_t # else # define INT16_TYPE short int # endif #endif #ifndef UINT8_TYPE # ifdef HAVE_UINT8_T # define UINT8_TYPE uint8_t # else # define UINT8_TYPE unsigned char # endif #endif #ifndef INT8_TYPE # ifdef HAVE_INT8_T # define INT8_TYPE int8_t # else # define INT8_TYPE signed char # endif #endif #ifndef LONGDOUBLE_TYPE # define LONGDOUBLE_TYPE long double #endif typedef sqlite_int64 i64; /* 8-byte signed integer */ typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef INT8_TYPE i8; /* 1-byte signed integer */ /* ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value ** that can be stored in a u32 without loss of data. The value ** is 0x00000000ffffffff. But because of quirks of some compilers, we ** have to specify the value in the less intuitive manner shown: */ #define SQLITE_MAX_U32 ((((u64)1)<<32)-1) /* ** Macros to determine whether the machine is big or little endian, ** evaluated at runtime. */ #ifdef SQLITE_AMALGAMATION SQLITE_PRIVATE const int sqlite3one = 1; #else SQLITE_PRIVATE const int sqlite3one; #endif #if defined(i386) || defined(__i386__) || defined(_M_IX86)\ || defined(__x86_64) || defined(__x86_64__) # define SQLITE_BIGENDIAN 0 # define SQLITE_LITTLEENDIAN 1 # define SQLITE_UTF16NATIVE SQLITE_UTF16LE #else # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) # define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) #endif /* ** Constants for the largest and smallest possible 64-bit signed integers. ** These macros are designed to work correctly on both 32-bit and 64-bit ** compilers. */ #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) /* ** Round up a number to the next larger multiple of 8. This is used ** to force 8-byte alignment on 64-bit architectures. */ #define ROUND8(x) (((x)+7)&~7) /* ** Round down to the nearest multiple of 8 */ #define ROUNDDOWN8(x) ((x)&~7) /* ** Assert that the pointer X is aligned to an 8-byte boundary. This ** macro is used only within assert() to verify that the code gets ** all alignment restrictions correct. ** ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the ** underlying malloc() implemention might return us 4-byte aligned ** pointers. In that case, only verify 4-byte alignment. */ #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0) #else # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0) #endif /* ** An instance of the following structure is used to store the busy-handler ** callback for a given sqlite handle. ** ** The sqlite.busyHandler member of the sqlite struct contains the busy ** callback for the database handle. Each pager opened via the sqlite ** handle is passed a pointer to sqlite.busyHandler. The busy-handler ** callback is currently invoked only from within pager.c. */ typedef struct BusyHandler BusyHandler; struct BusyHandler { int (*xFunc)(void *,int); /* The busy callback */ void *pArg; /* First arg to busy callback */ int nBusy; /* Incremented with each busy call */ }; /* ** Name of the master database table. The master database table ** is a special table that holds the names and attributes of all ** user tables and indices. */ #define MASTER_NAME "sqlite_master" #define TEMP_MASTER_NAME "sqlite_temp_master" /* ** The root-page of the master database table. */ #define MASTER_ROOT 1 /* ** The name of the schema table. */ #define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) /* ** A convenience macro that returns the number of elements in ** an array. */ #define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) /* ** The following value as a destructor means to use sqlite3DbFree(). ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. */ #define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) /* ** When SQLITE_OMIT_WSD is defined, it means that the target platform does ** not support Writable Static Data (WSD) such as global and static variables. ** All variables must either be on the stack or dynamically allocated from ** the heap. When WSD is unsupported, the variable declarations scattered ** throughout the SQLite code must become constants instead. The SQLITE_WSD ** macro is used for this purpose. And instead of referencing the variable ** directly, we use its constant as a key to lookup the run-time allocated ** buffer that holds real variable. The constant is also the initializer ** for the run-time allocated buffer. ** ** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL ** macros become no-ops and have zero performance impact. */ #ifdef SQLITE_OMIT_WSD #define SQLITE_WSD const #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v))) #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config) SQLITE_API int sqlite3_wsd_init(int N, int J); SQLITE_API void *sqlite3_wsd_find(void *K, int L); #else #define SQLITE_WSD #define GLOBAL(t,v) v #define sqlite3GlobalConfig sqlite3Config #endif /* ** The following macros are used to suppress compiler warnings and to ** make it clear to human readers when a function parameter is deliberately ** left unused within the body of a function. This usually happens when ** a function is called via a function pointer. For example the ** implementation of an SQL aggregate step callback may not use the ** parameter indicating the number of arguments passed to the aggregate, ** if it knows that this is enforced elsewhere. ** ** When a function parameter is not used at all within the body of a function, ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. ** However, these macros may also be used to suppress warnings related to ** parameters that may or may not be used depending on compilation options. ** For example those parameters only used in assert() statements. In these ** cases the parameters are named as per the usual conventions. */ #define UNUSED_PARAMETER(x) (void)(x) #define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) /* ** Forward references to structures */ typedef struct AggInfo AggInfo; typedef struct AuthContext AuthContext; typedef struct AutoincInfo AutoincInfo; typedef struct Bitvec Bitvec; typedef struct CollSeq CollSeq; typedef struct Column Column; typedef struct Db Db; typedef struct Schema Schema; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct ExprSpan ExprSpan; typedef struct FKey FKey; typedef struct FuncDef FuncDef; typedef struct FuncDefHash FuncDefHash; typedef struct IdList IdList; typedef struct Index Index; typedef struct IndexSample IndexSample; typedef struct KeyClass KeyClass; typedef struct KeyInfo KeyInfo; typedef struct Lookaside Lookaside; typedef struct LookasideSlot LookasideSlot; typedef struct Module Module; typedef struct NameContext NameContext; typedef struct Parse Parse; typedef struct RowSet RowSet; typedef struct Savepoint Savepoint; typedef struct Select Select; typedef struct SrcList SrcList; typedef struct StrAccum StrAccum; typedef struct Table Table; typedef struct TableLock TableLock; typedef struct Token Token; typedef struct Trigger Trigger; typedef struct TriggerPrg TriggerPrg; typedef struct TriggerStep TriggerStep; typedef struct UnpackedRecord UnpackedRecord; typedef struct VTable VTable; typedef struct Walker Walker; typedef struct WherePlan WherePlan; typedef struct WhereInfo WhereInfo; typedef struct WhereLevel WhereLevel; /* ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque ** pointer types (i.e. FuncDef) defined above. */ /************** Include btree.h in the middle of sqliteInt.h *****************/ /************** Begin file btree.h *******************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite B-Tree file ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. */ #ifndef _BTREE_H_ #define _BTREE_H_ /* TODO: This definition is just included so other modules compile. It ** needs to be revisited. */ #define SQLITE_N_BTREE_META 10 /* ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". */ #ifndef SQLITE_DEFAULT_AUTOVACUUM #define SQLITE_DEFAULT_AUTOVACUUM 0 #endif #define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */ #define BTREE_AUTOVACUUM_FULL 1 /* Do full auto-vacuum */ #define BTREE_AUTOVACUUM_INCR 2 /* Incremental vacuum */ /* ** Forward declarations of structure */ typedef struct Btree Btree; typedef struct BtCursor BtCursor; typedef struct BtShared BtShared; typedef struct BtreeMutexArray BtreeMutexArray; /* ** This structure records all of the Btrees that need to hold ** a mutex before we enter sqlite3VdbeExec(). The Btrees are ** are placed in aBtree[] in order of aBtree[]->pBt. That way, ** we can always lock and unlock them all quickly. */ struct BtreeMutexArray { int nMutex; Btree *aBtree[SQLITE_MAX_ATTACHED+1]; }; SQLITE_PRIVATE int sqlite3BtreeOpen( const char *zFilename, /* Name of database file to open */ sqlite3 *db, /* Associated database connection */ Btree **ppBtree, /* Return open Btree* here */ int flags, /* Flags */ int vfsFlags /* Flags passed through to VFS open */ ); /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the ** following values. ** ** NOTE: These values must match the corresponding PAGER_ values in ** pager.h. */ #define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */ #define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ #define BTREE_MEMORY 4 /* In-memory DB. No argument */ #define BTREE_READONLY 8 /* Open the database in read-only mode */ #define BTREE_READWRITE 16 /* Open for both reading and writing */ #define BTREE_CREATE 32 /* Create the database if it does not exist */ SQLITE_PRIVATE int sqlite3BtreeClose(Btree*); SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int); SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int); SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*); SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*); SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int); SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*); SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int); SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*); SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int); SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *); SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int); SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster); SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*); SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*); SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*); SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int); SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags); SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*); SQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree*); SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*); SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *)); SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree); SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock); SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int); SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *); SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *); SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *); SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *); /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR ** of the following flags: */ #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ #define BTREE_ZERODATA 2 /* Table has keys only - no data */ #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */ SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*); SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*); SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int); SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); /* ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta ** should be one of the following values. The integer values are assigned ** to constants so that the offset of the corresponding field in an ** SQLite database header may be found using the following formula: ** ** offset = 36 + (idx * 4) ** ** For example, the free-page-count field is located at byte offset 36 of ** the database file header. The incr-vacuum-flag field is located at ** byte offset 64 (== 36+4*7). */ #define BTREE_FREE_PAGE_COUNT 0 #define BTREE_SCHEMA_VERSION 1 #define BTREE_FILE_FORMAT 2 #define BTREE_DEFAULT_CACHE_SIZE 3 #define BTREE_LARGEST_ROOT_PAGE 4 #define BTREE_TEXT_ENCODING 5 #define BTREE_USER_VERSION 6 #define BTREE_INCR_VACUUM 7 SQLITE_PRIVATE int sqlite3BtreeCursor( Btree*, /* BTree containing table to open */ int iTable, /* Index of root page */ int wrFlag, /* 1 for writing. 0 for read-only */ struct KeyInfo*, /* First argument to compare function */ BtCursor *pCursor /* Space to write cursor structure */ ); SQLITE_PRIVATE int sqlite3BtreeCursorSize(void); SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*); SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*); SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( BtCursor*, UnpackedRecord *pUnKey, i64 intKey, int bias, int *pRes ); SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*, int*); SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*); SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, const void *pData, int nData, int nZero, int bias, int seekResult); SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt); SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt); SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor*); SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *); SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *); SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); #ifndef NDEBUG SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*); #endif #ifndef SQLITE_OMIT_BTREECOUNT SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *); #endif #ifdef SQLITE_TEST SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int); SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*); #endif #ifndef SQLITE_OMIT_WAL SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*); #endif /* ** If we are not using shared cache, then there is no need to ** use mutexes to access the BtShared structures. So make the ** Enter and Leave procedures no-ops. */ #ifndef SQLITE_OMIT_SHARED_CACHE SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*); SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*); #else # define sqlite3BtreeEnter(X) # define sqlite3BtreeEnterAll(X) #endif #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*); SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*); SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*); SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3*); SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*); SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*); SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*); #ifndef NDEBUG /* These routines are used inside assert() statements only. */ SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*); SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*); #endif #else # define sqlite3BtreeLeave(X) # define sqlite3BtreeEnterCursor(X) # define sqlite3BtreeLeaveCursor(X) # define sqlite3BtreeLeaveAll(X) # define sqlite3BtreeMutexArrayEnter(X) # define sqlite3BtreeMutexArrayLeave(X) # define sqlite3BtreeMutexArrayInsert(X,Y) # define sqlite3BtreeHoldsMutex(X) 1 # define sqlite3BtreeHoldsAllMutexes(X) 1 #endif #endif /* _BTREE_H_ */ /************** End of btree.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include vdbe.h in the middle of sqliteInt.h ******************/ /************** Begin file vdbe.h ********************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ /* ** A single VDBE is an opaque structure named "Vdbe". Only routines ** in the source file sqliteVdbe.c are allowed to see the insides ** of this structure. */ typedef struct Vdbe Vdbe; /* ** The names of the following types declared in vdbeInt.h are required ** for the VdbeOp definition. */ typedef struct VdbeFunc VdbeFunc; typedef struct Mem Mem; typedef struct SubProgram SubProgram; /* ** A single instruction of the virtual machine has an opcode ** and as many as three operands. The instruction is recorded ** as an instance of the following structure: */ struct VdbeOp { u8 opcode; /* What operation to perform */ signed char p4type; /* One of the P4_xxx constants for p4 */ u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ u8 p5; /* Fifth parameter is an unsigned character */ int p1; /* First operand */ int p2; /* Second parameter (often the jump destination) */ int p3; /* The third parameter */ union { /* fourth parameter */ int i; /* Integer value if p4type==P4_INT32 */ void *p; /* Generic pointer */ char *z; /* Pointer to data for string (char array) types */ i64 *pI64; /* Used when p4type is P4_INT64 */ double *pReal; /* Used when p4type is P4_REAL */ FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */ VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ Mem *pMem; /* Used when p4type is P4_MEM */ VTable *pVtab; /* Used when p4type is P4_VTAB */ KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ int *ai; /* Used when p4type is P4_INTARRAY */ SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ } p4; #ifdef SQLITE_DEBUG char *zComment; /* Comment to improve readability */ #endif #ifdef VDBE_PROFILE int cnt; /* Number of times this instruction was executed */ u64 cycles; /* Total time spent executing this instruction */ #endif }; typedef struct VdbeOp VdbeOp; /* ** A sub-routine used to implement a trigger program. */ struct SubProgram { VdbeOp *aOp; /* Array of opcodes for sub-program */ int nOp; /* Elements in aOp[] */ int nMem; /* Number of memory cells required */ int nCsr; /* Number of cursors required */ void *token; /* id that may be used to recursive triggers */ SubProgram *pNext; /* Next sub-program already visited */ }; /* ** A smaller version of VdbeOp used for the VdbeAddOpList() function because ** it takes up less space. */ struct VdbeOpList { u8 opcode; /* What operation to perform */ signed char p1; /* First operand */ signed char p2; /* Second parameter (often the jump destination) */ signed char p3; /* Third parameter */ }; typedef struct VdbeOpList VdbeOpList; /* ** Allowed values of VdbeOp.p4type */ #define P4_NOTUSED 0 /* The P4 parameter is not used */ #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */ #define P4_STATIC (-2) /* Pointer to a static string */ #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */ #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */ #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */ #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */ #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */ #define P4_TRANSIENT (-9) /* P4 is a pointer to a transient string */ #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */ #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */ #define P4_REAL (-12) /* P4 is a 64-bit floating point value */ #define P4_INT64 (-13) /* P4 is a 64-bit signed integer */ #define P4_INT32 (-14) /* P4 is a 32-bit signed integer */ #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ /* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure ** is made. That copy is freed when the Vdbe is finalized. But if the ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still ** gets freed when the Vdbe is finalized so it still should be obtained ** from a single sqliteMalloc(). But no copy is made and the calling ** function should *not* try to free the KeyInfo. */ #define P4_KEYINFO_HANDOFF (-16) #define P4_KEYINFO_STATIC (-17) /* ** The Vdbe.aColName array contains 5n Mem structures, where n is the ** number of columns of data returned by the statement. */ #define COLNAME_NAME 0 #define COLNAME_DECLTYPE 1 #define COLNAME_DATABASE 2 #define COLNAME_TABLE 3 #define COLNAME_COLUMN 4 #ifdef SQLITE_ENABLE_COLUMN_METADATA # define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ #else # ifdef SQLITE_OMIT_DECLTYPE # define COLNAME_N 1 /* Store only the name */ # else # define COLNAME_N 2 /* Store the name and decltype */ # endif #endif /* ** The following macro converts a relative address in the p2 field ** of a VdbeOp structure into a negative number so that ** sqlite3VdbeAddOpList() knows that the address is relative. Calling ** the macro again restores the address. */ #define ADDR(X) (-1-(X)) /* ** The makefile scans the vdbe.c source file and creates the "opcodes.h" ** header file that defines a number for each opcode used by the VDBE. */ /************** Include opcodes.h in the middle of vdbe.h ********************/ /************** Begin file opcodes.h *****************************************/ /* Automatically generated. Do not edit */ /* See the mkopcodeh.awk script for details */ #define OP_Goto 1 #define OP_Gosub 2 #define OP_Return 3 #define OP_Yield 4 #define OP_HaltIfNull 5 #define OP_Halt 6 #define OP_Integer 7 #define OP_Int64 8 #define OP_Real 130 /* same as TK_FLOAT */ #define OP_String8 94 /* same as TK_STRING */ #define OP_String 9 #define OP_Null 10 #define OP_Blob 11 #define OP_Variable 12 #define OP_Move 13 #define OP_Copy 14 #define OP_SCopy 15 #define OP_ResultRow 16 #define OP_Concat 91 /* same as TK_CONCAT */ #define OP_Add 86 /* same as TK_PLUS */ #define OP_Subtract 87 /* same as TK_MINUS */ #define OP_Multiply 88 /* same as TK_STAR */ #define OP_Divide 89 /* same as TK_SLASH */ #define OP_Remainder 90 /* same as TK_REM */ #define OP_CollSeq 17 #define OP_Function 18 #define OP_BitAnd 82 /* same as TK_BITAND */ #define OP_BitOr 83 /* same as TK_BITOR */ #define OP_ShiftLeft 84 /* same as TK_LSHIFT */ #define OP_ShiftRight 85 /* same as TK_RSHIFT */ #define OP_AddImm 20 #define OP_MustBeInt 21 #define OP_RealAffinity 22 #define OP_ToText 141 /* same as TK_TO_TEXT */ #define OP_ToBlob 142 /* same as TK_TO_BLOB */ #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ #define OP_ToInt 144 /* same as TK_TO_INT */ #define OP_ToReal 145 /* same as TK_TO_REAL */ #define OP_Eq 76 /* same as TK_EQ */ #define OP_Ne 75 /* same as TK_NE */ #define OP_Lt 79 /* same as TK_LT */ #define OP_Le 78 /* same as TK_LE */ #define OP_Gt 77 /* same as TK_GT */ #define OP_Ge 80 /* same as TK_GE */ #define OP_Permutation 23 #define OP_Compare 24 #define OP_Jump 25 #define OP_And 69 /* same as TK_AND */ #define OP_Or 68 /* same as TK_OR */ #define OP_Not 19 /* same as TK_NOT */ #define OP_BitNot 93 /* same as TK_BITNOT */ #define OP_If 26 #define OP_IfNot 27 #define OP_IsNull 73 /* same as TK_ISNULL */ #define OP_NotNull 74 /* same as TK_NOTNULL */ #define OP_Column 28 #define OP_Affinity 29 #define OP_MakeRecord 30 #define OP_Count 31 #define OP_Savepoint 32 #define OP_AutoCommit 33 #define OP_Transaction 34 #define OP_ReadCookie 35 #define OP_SetCookie 36 #define OP_VerifyCookie 37 #define OP_OpenRead 38 #define OP_OpenWrite 39 #define OP_OpenAutoindex 40 #define OP_OpenEphemeral 41 #define OP_OpenPseudo 42 #define OP_Close 43 #define OP_SeekLt 44 #define OP_SeekLe 45 #define OP_SeekGe 46 #define OP_SeekGt 47 #define OP_Seek 48 #define OP_NotFound 49 #define OP_Found 50 #define OP_IsUnique 51 #define OP_NotExists 52 #define OP_Sequence 53 #define OP_NewRowid 54 #define OP_Insert 55 #define OP_InsertInt 56 #define OP_Delete 57 #define OP_ResetCount 58 #define OP_RowKey 59 #define OP_RowData 60 #define OP_Rowid 61 #define OP_NullRow 62 #define OP_Last 63 #define OP_Sort 64 #define OP_Rewind 65 #define OP_Prev 66 #define OP_Next 67 #define OP_IdxInsert 70 #define OP_IdxDelete 71 #define OP_IdxRowid 72 #define OP_IdxLT 81 #define OP_IdxGE 92 #define OP_Destroy 95 #define OP_Clear 96 #define OP_CreateIndex 97 #define OP_CreateTable 98 #define OP_ParseSchema 99 #define OP_LoadAnalysis 100 #define OP_DropTable 101 #define OP_DropIndex 102 #define OP_DropTrigger 103 #define OP_IntegrityCk 104 #define OP_RowSetAdd 105 #define OP_RowSetRead 106 #define OP_RowSetTest 107 #define OP_Program 108 #define OP_Param 109 #define OP_FkCounter 110 #define OP_FkIfZero 111 #define OP_MemMax 112 #define OP_IfPos 113 #define OP_IfNeg 114 #define OP_IfZero 115 #define OP_AggStep 116 #define OP_AggFinal 117 #define OP_Checkpoint 118 #define OP_JournalMode 119 #define OP_Vacuum 120 #define OP_IncrVacuum 121 #define OP_Expire 122 #define OP_TableLock 123 #define OP_VBegin 124 #define OP_VCreate 125 #define OP_VDestroy 126 #define OP_VOpen 127 #define OP_VFilter 128 #define OP_VColumn 129 #define OP_VNext 131 #define OP_VRename 132 #define OP_VUpdate 133 #define OP_Pagecount 134 #define OP_Trace 135 #define OP_Noop 136 #define OP_Explain 137 /* The following opcode values are never used */ #define OP_NotUsed_138 138 #define OP_NotUsed_139 139 #define OP_NotUsed_140 140 /* Properties such as "out2" or "jump" that are specified in ** comments following the "case" for each opcode in the vdbe.c ** are encoded into bitvectors as follows: */ #define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ #define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ #define OPFLG_IN1 0x0004 /* in1: P1 is an input */ #define OPFLG_IN2 0x0008 /* in2: P2 is an input */ #define OPFLG_IN3 0x0010 /* in3: P3 is an input */ #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ #define OPFLG_INITIALIZER {\ /* 0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02,\ /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x24, 0x24,\ /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\ /* 24 */ 0x00, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\ /* 32 */ 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00,\ /* 40 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\ /* 48 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00,\ /* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\ /* 64 */ 0x01, 0x01, 0x01, 0x01, 0x4c, 0x4c, 0x08, 0x00,\ /* 72 */ 0x02, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\ /* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x02,\ /* 96 */ 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 104 */ 0x00, 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01,\ /* 112 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\ /* 120 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 128 */ 0x01, 0x00, 0x02, 0x01, 0x00, 0x00, 0x02, 0x00,\ /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\ /* 144 */ 0x04, 0x04,} /************** End of opcodes.h *********************************************/ /************** Continuing where we left off in vdbe.h ***********************/ /* ** Prototypes for the VDBE interface. See comments on the implementation ** for a description of what each of these routines does. */ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(sqlite3*); SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int); SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*); SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int); SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int); SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*); #endif SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int); SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*); SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*); SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int); #ifndef SQLITE_OMIT_TRACE SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*); #endif SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); #ifndef SQLITE_OMIT_TRIGGER SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); #endif #ifndef NDEBUG SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe*, const char*, ...); # define VdbeComment(X) sqlite3VdbeComment X SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); # define VdbeNoopComment(X) sqlite3VdbeNoopComment X #else # define VdbeComment(X) # define VdbeNoopComment(X) #endif #endif /************** End of vdbe.h ************************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include pager.h in the middle of sqliteInt.h *****************/ /************** Begin file pager.h *******************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. */ #ifndef _PAGER_H_ #define _PAGER_H_ /* ** Default maximum size for persistent journal files. A negative ** value means no limit. This value may be overridden using the ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". */ #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 #endif /* ** The type used to represent a page number. The first page in a file ** is called page 1. 0 is used to represent "not a page". */ typedef u32 Pgno; /* ** Each open file is managed by a separate instance of the "Pager" structure. */ typedef struct Pager Pager; /* ** Handle type for pages. */ typedef struct PgHdr DbPage; /* ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is ** reserved for working around a windows/posix incompatibility). It is ** used in the journal to signify that the remainder of the journal file ** is devoted to storing a master journal name - there are no more pages to ** roll back. See comments for function writeMasterJournal() in pager.c ** for details. */ #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) /* ** Allowed values for the flags parameter to sqlite3PagerOpen(). ** ** NOTE: These values must match the corresponding BTREE_ values in btree.h. */ #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ /* ** Valid values for the second argument to sqlite3PagerLockingMode(). */ #define PAGER_LOCKINGMODE_QUERY -1 #define PAGER_LOCKINGMODE_NORMAL 0 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 /* ** Numeric constants that encode the journalmode. */ #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ /* ** The remainder of this file contains the declarations of the functions ** that make up the Pager sub-system API. See source code comments for ** a detailed description of each routine. */ /* Open and close a Pager connection. */ SQLITE_PRIVATE int sqlite3PagerOpen( sqlite3_vfs*, Pager **ppPager, const char*, int, int, int, void(*)(DbPage*) ); SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); /* Functions used to configure a Pager object. */ SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int); SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int); SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int); SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int); SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int); SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int); SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*); SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*); SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64); SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*); /* Functions used to obtain and release page references. */ SQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); SQLITE_PRIVATE void sqlite3PagerRef(DbPage*); SQLITE_PRIVATE void sqlite3PagerUnref(DbPage*); /* Operations on page references. */ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage*); SQLITE_PRIVATE void sqlite3PagerDontWrite(DbPage*); SQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); SQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage*); SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); SQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); /* Functions used to manage pager transactions and savepoints. */ SQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*); SQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int); SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*); SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*); SQLITE_PRIVATE int sqlite3PagerRollback(Pager*); SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n); SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager); SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager); /* Functions used to query pager state and configuration. */ SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*); SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*); SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*); SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*); SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); /* Functions used to truncate the database file. */ SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *); #endif /* Functions to support testing and debugging. */ #if !defined(NDEBUG) || defined(SQLITE_TEST) SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage*); SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage*); #endif #ifdef SQLITE_TEST SQLITE_PRIVATE int *sqlite3PagerStats(Pager*); SQLITE_PRIVATE void sqlite3PagerRefdump(Pager*); void disable_simulated_io_errors(void); void enable_simulated_io_errors(void); #else # define disable_simulated_io_errors() # define enable_simulated_io_errors() #endif #endif /* _PAGER_H_ */ /************** End of pager.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include pcache.h in the middle of sqliteInt.h ****************/ /************** Begin file pcache.h ******************************************/ /* ** 2008 August 05 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. */ #ifndef _PCACHE_H_ typedef struct PgHdr PgHdr; typedef struct PCache PCache; /* ** Every page in the cache is controlled by an instance of the following ** structure. */ struct PgHdr { void *pData; /* Content of this page */ void *pExtra; /* Extra content */ PgHdr *pDirty; /* Transient list of dirty pages */ Pgno pgno; /* Page number for this page */ Pager *pPager; /* The pager this page is part of */ #ifdef SQLITE_CHECK_PAGES u32 pageHash; /* Hash of page content */ #endif u16 flags; /* PGHDR flags defined below */ /********************************************************************** ** Elements above are public. All that follows is private to pcache.c ** and should not be accessed by other modules. */ i16 nRef; /* Number of users of this page */ PCache *pCache; /* Cache that owns this page */ PgHdr *pDirtyNext; /* Next element in list of dirty pages */ PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */ }; /* Bit values for PgHdr.flags */ #define PGHDR_DIRTY 0x002 /* Page has changed */ #define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before ** writing this page to the database */ #define PGHDR_NEED_READ 0x008 /* Content is unread */ #define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ #define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ /* Initialize and shutdown the page cache subsystem */ SQLITE_PRIVATE int sqlite3PcacheInitialize(void); SQLITE_PRIVATE void sqlite3PcacheShutdown(void); /* Page cache buffer management: ** These routines implement SQLITE_CONFIG_PAGECACHE. */ SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *, int sz, int n); /* Create a new pager cache. ** Under memory stress, invoke xStress to try to make pages clean. ** Only clean and unpinned pages can be reclaimed. */ SQLITE_PRIVATE void sqlite3PcacheOpen( int szPage, /* Size of every page */ int szExtra, /* Extra space associated with each page */ int bPurgeable, /* True if pages are on backing store */ int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ void *pStress, /* Argument to xStress */ PCache *pToInit /* Preallocated space for the PCache */ ); /* Modify the page-size after the cache has been created. */ SQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *, int); /* Return the size in bytes of a PCache object. Used to preallocate ** storage space. */ SQLITE_PRIVATE int sqlite3PcacheSize(void); /* One release per successful fetch. Page is pinned until released. ** Reference counted. */ SQLITE_PRIVATE int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); SQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*); SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ SQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ SQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ /* Change a page number. Used by incr-vacuum. */ SQLITE_PRIVATE void sqlite3PcacheMove(PgHdr*, Pgno); /* Remove all pages with pgno>x. Reset the cache if x==0 */ SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache*, Pgno x); /* Get a list of all dirty pages in the cache, sorted by page number */ SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache*); /* Reset and close the cache object */ SQLITE_PRIVATE void sqlite3PcacheClose(PCache*); /* Clear flags from pages of the page cache */ SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *); /* Discard the contents of the cache */ SQLITE_PRIVATE void sqlite3PcacheClear(PCache*); /* Return the total number of outstanding page references */ SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*); /* Increment the reference count of an existing page */ SQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*); SQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*); /* Return the total number of pages stored in the cache */ SQLITE_PRIVATE int sqlite3PcachePagecount(PCache*); #if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG) /* Iterate through all dirty pages currently stored in the cache. This ** interface is only available if SQLITE_CHECK_PAGES is defined when the ** library is built. */ SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)); #endif /* Set and get the suggested cache-size for the specified pager-cache. ** ** If no global maximum is configured, then the system attempts to limit ** the total number of pages cached by purgeable pager-caches to the sum ** of the suggested cache-sizes. */ SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int); #ifdef SQLITE_TEST SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *); #endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT /* Try to return memory used by the pcache module to the main memory heap */ SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int); #endif #ifdef SQLITE_TEST SQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*); #endif SQLITE_PRIVATE void sqlite3PCacheSetDefault(void); #endif /* _PCACHE_H_ */ /************** End of pcache.h **********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include os.h in the middle of sqliteInt.h ********************/ /************** Begin file os.h **********************************************/ /* ** 2001 September 16 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This header file (together with is companion C source-code file ** "os.c") attempt to abstract the underlying operating system so that ** the SQLite library will work on both POSIX and windows systems. ** ** This header file is #include-ed by sqliteInt.h and thus ends up ** being included by every source file. */ #ifndef _SQLITE_OS_H_ #define _SQLITE_OS_H_ /* ** Figure out if we are dealing with Unix, Windows, or some other ** operating system. After the following block of preprocess macros, ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER ** will defined to either 1 or 0. One of the four will be 1. The other ** three will be 0. */ #if defined(SQLITE_OS_OTHER) # if SQLITE_OS_OTHER==1 # undef SQLITE_OS_UNIX # define SQLITE_OS_UNIX 0 # undef SQLITE_OS_WIN # define SQLITE_OS_WIN 0 # undef SQLITE_OS_OS2 # define SQLITE_OS_OS2 0 # else # undef SQLITE_OS_OTHER # endif #endif #if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER) # define SQLITE_OS_OTHER 0 # ifndef SQLITE_OS_WIN # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) # define SQLITE_OS_WIN 1 # define SQLITE_OS_UNIX 0 # define SQLITE_OS_OS2 0 # elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) # define SQLITE_OS_WIN 0 # define SQLITE_OS_UNIX 0 # define SQLITE_OS_OS2 1 # else # define SQLITE_OS_WIN 0 # define SQLITE_OS_UNIX 1 # define SQLITE_OS_OS2 0 # endif # else # define SQLITE_OS_UNIX 0 # define SQLITE_OS_OS2 0 # endif #else # ifndef SQLITE_OS_WIN # define SQLITE_OS_WIN 0 # endif #endif /* ** Determine if we are dealing with WindowsCE - which has a much ** reduced API. */ #if defined(_WIN32_WCE) # define SQLITE_OS_WINCE 1 #else # define SQLITE_OS_WINCE 0 #endif /* ** Define the maximum size of a temporary filename */ #if SQLITE_OS_WIN # include # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) #elif SQLITE_OS_OS2 # if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) # include /* has to be included before os2.h for linking to work */ # endif # define INCL_DOSDATETIME # define INCL_DOSFILEMGR # define INCL_DOSERRORS # define INCL_DOSMISC # define INCL_DOSPROCESS # define INCL_DOSMODULEMGR # define INCL_DOSSEMAPHORES # include # include # define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) #else # define SQLITE_TEMPNAME_SIZE 200 #endif /* If the SET_FULLSYNC macro is not defined above, then make it ** a no-op */ #ifndef SET_FULLSYNC # define SET_FULLSYNC(x,y) #endif /* ** The default size of a disk sector */ #ifndef SQLITE_DEFAULT_SECTOR_SIZE # define SQLITE_DEFAULT_SECTOR_SIZE 512 #endif /* ** Temporary files are named starting with this prefix followed by 16 random ** alphanumeric characters, and no file extension. They are stored in the ** OS's standard temporary file directory, and are deleted prior to exit. ** If sqlite is being embedded in another program, you may wish to change the ** prefix to reflect your program's name, so that if your program exits ** prematurely, old temporary files can be easily identified. This can be done ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. ** ** 2006-10-31: The default prefix used to be "sqlite_". But then ** Mcafee started using SQLite in their anti-virus product and it ** started putting files with the "sqlite" name in the c:/temp folder. ** This annoyed many windows users. Those users would then do a ** Google search for "sqlite", find the telephone numbers of the ** developers and call to wake them up at night and complain. ** For this reason, the default name prefix is changed to be "sqlite" ** spelled backwards. So the temp files are still identified, but ** anybody smart enough to figure out the code is also likely smart ** enough to know that calling the developer will not help get rid ** of the file. */ #ifndef SQLITE_TEMP_FILE_PREFIX # define SQLITE_TEMP_FILE_PREFIX "etilqs_" #endif /* ** The following values may be passed as the second argument to ** sqlite3OsLock(). The various locks exhibit the following semantics: ** ** SHARED: Any number of processes may hold a SHARED lock simultaneously. ** RESERVED: A single process may hold a RESERVED lock on a file at ** any time. Other processes may hold and obtain new SHARED locks. ** PENDING: A single process may hold a PENDING lock on a file at ** any one time. Existing SHARED locks may persist, but no new ** SHARED locks may be obtained by other processes. ** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. ** ** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a ** process that requests an EXCLUSIVE lock may actually obtain a PENDING ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to ** sqlite3OsLock(). */ #define NO_LOCK 0 #define SHARED_LOCK 1 #define RESERVED_LOCK 2 #define PENDING_LOCK 3 #define EXCLUSIVE_LOCK 4 /* ** File Locking Notes: (Mostly about windows but also some info for Unix) ** ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because ** those functions are not available. So we use only LockFile() and ** UnlockFile(). ** ** LockFile() prevents not just writing but also reading by other processes. ** A SHARED_LOCK is obtained by locking a single randomly-chosen ** byte out of a specific range of bytes. The lock byte is obtained at ** random so two separate readers can probably access the file at the ** same time, unless they are unlucky and choose the same lock byte. ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. ** There can only be one writer. A RESERVED_LOCK is obtained by locking ** a single byte of the file that is designated as the reserved lock byte. ** A PENDING_LOCK is obtained by locking a designated byte different from ** the RESERVED_LOCK byte. ** ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, ** which means we can use reader/writer locks. When reader/writer locks ** are used, the lock is placed on the same range of bytes that is used ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme ** will support two or more Win95 readers or two or more WinNT readers. ** But a single Win95 reader will lock out all WinNT readers and a single ** WinNT reader will lock out all other Win95 readers. ** ** The following #defines specify the range of bytes used for locking. ** SHARED_SIZE is the number of bytes available in the pool from which ** a random byte is selected for a shared lock. The pool of bytes for ** shared locks begins at SHARED_FIRST. ** ** The same locking strategy and ** byte ranges are used for Unix. This leaves open the possiblity of having ** clients on win95, winNT, and unix all talking to the same shared file ** and all locking correctly. To do so would require that samba (or whatever ** tool is being used for file sharing) implements locks correctly between ** windows and unix. I'm guessing that isn't likely to happen, but by ** using the same locking range we are at least open to the possibility. ** ** Locking in windows is manditory. For this reason, we cannot store ** actual data in the bytes used for locking. The pager never allocates ** the pages involved in locking therefore. SHARED_SIZE is selected so ** that all locks will fit on a single page even at the minimum page size. ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE ** is set high so that we don't have to allocate an unused page except ** for very large databases. But one should test the page skipping logic ** by setting PENDING_BYTE low and running the entire regression suite. ** ** Changing the value of PENDING_BYTE results in a subtly incompatible ** file format. Depending on how it is changed, you might not notice ** the incompatibility right away, even running a full regression test. ** The default location of PENDING_BYTE is the first byte past the ** 1GB boundary. ** */ #ifdef SQLITE_OMIT_WSD # define PENDING_BYTE (0x40000000) #else # define PENDING_BYTE sqlite3PendingByte #endif #define RESERVED_BYTE (PENDING_BYTE+1) #define SHARED_FIRST (PENDING_BYTE+2) #define SHARED_SIZE 510 /* ** Wrapper around OS specific sqlite3_os_init() function. */ SQLITE_PRIVATE int sqlite3OsInit(void); /* ** Functions for accessing sqlite3_file methods */ SQLITE_PRIVATE int sqlite3OsClose(sqlite3_file*); SQLITE_PRIVATE int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); SQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); SQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file*, i64 size); SQLITE_PRIVATE int sqlite3OsSync(sqlite3_file*, int); SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize); SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int); SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int); SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut); SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*); #define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id); SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id); SQLITE_PRIVATE int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **); SQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int, int, int); SQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id); SQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int); /* ** Functions for accessing sqlite3_vfs methods */ SQLITE_PRIVATE int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *, const char *, int); SQLITE_PRIVATE int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); SQLITE_PRIVATE int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *); #ifndef SQLITE_OMIT_LOAD_EXTENSION SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *, int, char *); SQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *); #endif /* SQLITE_OMIT_LOAD_EXTENSION */ SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *); SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int); SQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*); /* ** Convenience functions for opening and closing files using ** sqlite3_malloc() to obtain space for the file-handle structure. */ SQLITE_PRIVATE int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*); SQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *); #endif /* _SQLITE_OS_H_ */ /************** End of os.h **************************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include mutex.h in the middle of sqliteInt.h *****************/ /************** Begin file mutex.h *******************************************/ /* ** 2007 August 28 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains the common header for all mutex implementations. ** The sqliteInt.h header #includes this file so that it is available ** to all source files. We break it out in an effort to keep the code ** better organized. ** ** NOTE: source files should *not* #include this header file directly. ** Source files should #include the sqliteInt.h file and let that file ** include this one indirectly. */ /* ** Figure out what version of the code to use. The choices are ** ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The ** mutexes implemention cannot be overridden ** at start-time. ** ** SQLITE_MUTEX_NOOP For single-threaded applications. No ** mutual exclusion is provided. But this ** implementation can be overridden at ** start-time. ** ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. ** ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. ** ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. */ #if !SQLITE_THREADSAFE # define SQLITE_MUTEX_OMIT #endif #if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) # if SQLITE_OS_UNIX # define SQLITE_MUTEX_PTHREADS # elif SQLITE_OS_WIN # define SQLITE_MUTEX_W32 # elif SQLITE_OS_OS2 # define SQLITE_MUTEX_OS2 # else # define SQLITE_MUTEX_NOOP # endif #endif #ifdef SQLITE_MUTEX_OMIT /* ** If this is a no-op implementation, implement everything as macros. */ #define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) #define sqlite3_mutex_free(X) #define sqlite3_mutex_enter(X) #define sqlite3_mutex_try(X) SQLITE_OK #define sqlite3_mutex_leave(X) #define sqlite3_mutex_held(X) 1 #define sqlite3_mutex_notheld(X) 1 #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) #define sqlite3MutexInit() SQLITE_OK #define sqlite3MutexEnd() #endif /* defined(SQLITE_MUTEX_OMIT) */ /************** End of mutex.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /* ** Each database file to be accessed by the system is an instance ** of the following structure. There are normally two of these structures ** in the sqlite.aDb[] array. aDb[0] is the main database file and ** aDb[1] is the database file used to hold temporary tables. Additional ** databases may be attached. */ struct Db { char *zName; /* Name of this database */ Btree *pBt; /* The B*Tree structure for this database file */ u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ u8 safety_level; /* How aggressive at syncing data to disk */ Schema *pSchema; /* Pointer to database schema (possibly shared) */ }; /* ** An instance of the following structure stores a database schema. */ struct Schema { int schema_cookie; /* Database schema version number for this file */ Hash tblHash; /* All tables indexed by name */ Hash idxHash; /* All (named) indices indexed by name */ Hash trigHash; /* All triggers indexed by name */ Hash fkeyHash; /* All foreign keys by referenced table name */ Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ u8 file_format; /* Schema format version for this file */ u8 enc; /* Text encoding used by this database */ u16 flags; /* Flags associated with this schema */ int cache_size; /* Number of pages to use in the cache */ }; /* ** These macros can be used to test, set, or clear bits in the ** Db.pSchema->flags field. */ #define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) #define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) #define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) #define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) /* ** Allowed values for the DB.pSchema->flags field. ** ** The DB_SchemaLoaded flag is set after the database schema has been ** read into internal hash tables. ** ** DB_UnresetViews means that one or more views have column names that ** have been filled out. If the schema changes, these column names might ** changes and so the view will need to be reset. */ #define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ #define DB_UnresetViews 0x0002 /* Some views have defined column names */ #define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ /* ** The number of different kinds of things that can be limited ** using the sqlite3_limit() interface. */ #define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) /* ** Lookaside malloc is a set of fixed-size buffers that can be used ** to satisfy small transient memory allocation requests for objects ** associated with a particular database connection. The use of ** lookaside malloc provides a significant performance enhancement ** (approx 10%) by avoiding numerous malloc/free requests while parsing ** SQL statements. ** ** The Lookaside structure holds configuration information about the ** lookaside malloc subsystem. Each available memory allocation in ** the lookaside subsystem is stored on a linked list of LookasideSlot ** objects. ** ** Lookaside allocations are only allowed for objects that are associated ** with a particular database connection. Hence, schema information cannot ** be stored in lookaside because in shared cache mode the schema information ** is shared by multiple database connections. Therefore, while parsing ** schema information, the Lookaside.bEnabled flag is cleared so that ** lookaside allocations are not used to construct the schema objects. */ struct Lookaside { u16 sz; /* Size of each buffer in bytes */ u8 bEnabled; /* False to disable new lookaside allocations */ u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ int nOut; /* Number of buffers currently checked out */ int mxOut; /* Highwater mark for nOut */ LookasideSlot *pFree; /* List of available buffers */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */ }; struct LookasideSlot { LookasideSlot *pNext; /* Next buffer in the list of free buffers */ }; /* ** A hash table for function definitions. ** ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. ** Collisions are on the FuncDef.pHash chain. */ struct FuncDefHash { FuncDef *a[23]; /* Hash table for functions */ }; /* ** Each database connection is an instance of the following structure. ** ** The sqlite.lastRowid records the last insert rowid generated by an ** insert statement. Inserts on views do not affect its value. Each ** trigger has its own context, so that lastRowid can be updated inside ** triggers as usual. The previous value will be restored once the trigger ** exits. Upon entering a before or instead of trigger, lastRowid is no ** longer (since after version 2.8.12) reset to -1. ** ** The sqlite.nChange does not count changes within triggers and keeps no ** context. It is reset at start of sqlite3_exec. ** The sqlite.lsChange represents the number of changes made by the last ** insert, update, or delete statement. It remains constant throughout the ** length of a statement and is then updated by OP_SetCounts. It keeps a ** context stack just like lastRowid so that the count of changes ** within a trigger is not seen outside the trigger. Changes to views do not ** affect the value of lsChange. ** The sqlite.csChange keeps track of the number of current changes (since ** the last statement) and is used to update sqlite_lsChange. ** ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 ** store the most recent error code and, if applicable, string. The ** internal function sqlite3Error() is used to set these variables ** consistently. */ struct sqlite3 { sqlite3_vfs *pVfs; /* OS Interface */ int nDb; /* Number of backends currently in use */ Db *aDb; /* All backends */ int flags; /* Miscellaneous flags. See below */ int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ int errMask; /* & result codes with this before returning */ u8 autoCommit; /* The auto-commit flag. */ u8 temp_store; /* 1: file 2: memory 0: default */ u8 mallocFailed; /* True if we have seen a malloc failure */ u8 dfltLockMode; /* Default locking-mode for attached dbs */ signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ u8 suppressErr; /* Do not issue error messages if true */ int nextPagesize; /* Pagesize after VACUUM if >0 */ int nTable; /* Number of tables in the database */ CollSeq *pDfltColl; /* The default collating sequence (BINARY) */ i64 lastRowid; /* ROWID of most recent insert (see above) */ u32 magic; /* Magic number for detect library misuse */ int nChange; /* Value returned by sqlite3_changes() */ int nTotalChange; /* Value returned by sqlite3_total_changes() */ sqlite3_mutex *mutex; /* Connection mutex */ int aLimit[SQLITE_N_LIMIT]; /* Limits */ struct sqlite3InitInfo { /* Information used during initialization */ int iDb; /* When back is being initialized */ int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ } init; int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of VDBEs currently executing */ int writeVdbeCnt; /* Number of active VDBEs that are writing */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ void (*xRollbackCallback)(void*); /* Invoked at every commit. */ void *pUpdateArg; void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); #ifndef SQLITE_OMIT_WAL int (*xWalCallback)(void *, sqlite3 *, const char *, int); void *pWalArg; #endif void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*); void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*); void *pCollNeededArg; sqlite3_value *pErr; /* Most recent error message */ char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { volatile int isInterrupted; /* True if sqlite3_interrupt has been called */ double notUsed1; /* Spacer */ } u1; Lookaside lookaside; /* Lookaside malloc configuration */ #ifndef SQLITE_OMIT_AUTHORIZATION int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); /* Access authorization function */ void *pAuthArg; /* 1st argument to the access auth function */ #endif #ifndef SQLITE_OMIT_PROGRESS_CALLBACK int (*xProgress)(void *); /* The progress callback */ void *pProgressArg; /* Argument to the progress callback */ int nProgressOps; /* Number of opcodes for progress callback */ #endif #ifndef SQLITE_OMIT_VIRTUALTABLE Hash aModule; /* populated by sqlite3_create_module() */ Table *pVTab; /* vtab with active Connect/Create method */ VTable **aVTrans; /* Virtual tables with open transactions */ int nVTrans; /* Allocated size of aVTrans */ VTable *pDisconnect; /* Disconnect these in next sqlite3_prepare() */ #endif FuncDefHash aFunc; /* Hash table of connection functions */ Hash aCollSeq; /* All collating sequences */ BusyHandler busyHandler; /* Busy callback */ int busyTimeout; /* Busy handler timeout, in msec */ Db aDbStatic[2]; /* Static space for the 2 default backends */ Savepoint *pSavepoint; /* List of active savepoints */ int nSavepoint; /* Number of non-transaction savepoints */ int nStatement; /* Number of nested statement-transactions */ u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ i64 nDeferredCons; /* Net deferred constraints this transaction. */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY /* The following variables are all protected by the STATIC_MASTER ** mutex, not by sqlite3.mutex. They are used by code in notify.c. ** ** When X.pUnlockConnection==Y, that means that X is waiting for Y to ** unlock so that it can proceed. ** ** When X.pBlockingConnection==Y, that means that something that X tried ** tried to do recently failed with an SQLITE_LOCKED error due to locks ** held by Y. */ sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */ sqlite3 *pUnlockConnection; /* Connection to watch for unlock */ void *pUnlockArg; /* Argument to xUnlockNotify */ void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ #endif }; /* ** A macro to discover the encoding of a database. */ #define ENC(db) ((db)->aDb[0].pSchema->enc) /* ** Possible values for the sqlite3.flags. */ #define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ #define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ #define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ #define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ #define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ /* DELETE, or UPDATE and return */ /* the count using a callback. */ #define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ /* result set is empty */ #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ #define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ #define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ #define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when ** accessing read-only databases */ #define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ #define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ #define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ #define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ #define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ #define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ #define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ #define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ #define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ #define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ /* ** Bits of the sqlite3.flags field that are used by the ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. ** These must be the low-order bits of the flags field. */ #define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ #define SQLITE_ColumnCache 0x02 /* Disable the column cache */ #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ #define SQLITE_IndexCover 0x10 /* Disable index covering table */ #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ /* ** Possible values for the sqlite.magic field. ** The numbers are obtained at random and have no special meaning, other ** than being distinct from one another. */ #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ #define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ #define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ #define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ /* ** Each SQL function is defined by an instance of the following ** structure. A pointer to this structure is stored in the sqlite.aFunc ** hash table. When multiple functions have the same name, the hash table ** points to a linked list of these structures. */ struct FuncDef { i16 nArg; /* Number of arguments. -1 means unlimited */ u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ u8 flags; /* Some combination of SQLITE_FUNC_* */ void *pUserData; /* User data parameter */ FuncDef *pNext; /* Next function with same name */ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */ void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */ void (*xFinalize)(sqlite3_context*); /* Aggregate finalizer */ char *zName; /* SQL name of the function. */ FuncDef *pHash; /* Next with a different name but the same hash */ }; /* ** Possible values for FuncDef.flags */ #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ #define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ #define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */ #define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ /* ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are ** used to create the initializers for the FuncDef structures. ** ** FUNCTION(zName, nArg, iArg, bNC, xFunc) ** Used to create a scalar function definition of a function zName ** implemented by C function xFunc that accepts nArg arguments. The ** value passed as iArg is cast to a (void*) and made available ** as the user-data (sqlite3_user_data()) for the function. If ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. ** ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) ** Used to create an aggregate function definition implemented by ** the C functions xStep and xFinal. The first four parameters ** are interpreted in the same way as the first 4 parameters to ** FUNCTION(). ** ** LIKEFUNC(zName, nArg, pArg, flags) ** Used to create a scalar function definition of a function zName ** that accepts nArg arguments and is implemented by a call to C ** function likeFunc. Argument pArg is cast to a (void *) and made ** available as the function user-data (sqlite3_user_data()). The ** FuncDef.flags variable is set to the value passed as the flags ** parameter. */ #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0} #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ pArg, 0, xFunc, 0, 0, #zName, 0} #define LIKEFUNC(zName, nArg, arg, flags) \ {nArg, SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0} #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0} /* ** All current savepoints are stored in a linked list starting at ** sqlite3.pSavepoint. The first element in the list is the most recently ** opened savepoint. Savepoints are added to the list by the vdbe ** OP_Savepoint instruction. */ struct Savepoint { char *zName; /* Savepoint name (nul-terminated) */ i64 nDeferredCons; /* Number of deferred fk violations */ Savepoint *pNext; /* Parent savepoint (if any) */ }; /* ** The following are used as the second parameter to sqlite3Savepoint(), ** and as the P1 argument to the OP_Savepoint instruction. */ #define SAVEPOINT_BEGIN 0 #define SAVEPOINT_RELEASE 1 #define SAVEPOINT_ROLLBACK 2 /* ** Each SQLite module (virtual table definition) is defined by an ** instance of the following structure, stored in the sqlite3.aModule ** hash table. */ struct Module { const sqlite3_module *pModule; /* Callback pointers */ const char *zName; /* Name passed to create_module() */ void *pAux; /* pAux passed to create_module() */ void (*xDestroy)(void *); /* Module destructor function */ }; /* ** information about each column of an SQL table is held in an instance ** of this structure. */ struct Column { char *zName; /* Name of this column */ Expr *pDflt; /* Default value of this column */ char *zDflt; /* Original text of the default value */ char *zType; /* Data type for this column */ char *zColl; /* Collating sequence. If NULL, use the default */ u8 notNull; /* True if there is a NOT NULL constraint */ u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ char affinity; /* One of the SQLITE_AFF_... values */ #ifndef SQLITE_OMIT_VIRTUALTABLE u8 isHidden; /* True if this column is 'hidden' */ #endif }; /* ** A "Collating Sequence" is defined by an instance of the following ** structure. Conceptually, a collating sequence consists of a name and ** a comparison routine that defines the order of that sequence. ** ** There may two separate implementations of the collation function, one ** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that ** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine ** native byte order. When a collation sequence is invoked, SQLite selects ** the version that will require the least expensive encoding ** translations, if any. ** ** The CollSeq.pUser member variable is an extra parameter that passed in ** as the first argument to the UTF-8 comparison function, xCmp. ** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, ** xCmp16. ** ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the ** collating sequence is undefined. Indices built on an undefined ** collating sequence may not be read or written. */ struct CollSeq { char *zName; /* Name of the collating sequence, UTF-8 encoded */ u8 enc; /* Text encoding handled by xCmp() */ u8 type; /* One of the SQLITE_COLL_... values below */ void *pUser; /* First argument to xCmp() */ int (*xCmp)(void*,int, const void*, int, const void*); void (*xDel)(void*); /* Destructor for pUser */ }; /* ** Allowed values of CollSeq.type: */ #define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ #define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ #define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ #define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ /* ** A sort order can be either ASC or DESC. */ #define SQLITE_SO_ASC 0 /* Sort in ascending order */ #define SQLITE_SO_DESC 1 /* Sort in ascending order */ /* ** Column affinity types. ** ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and ** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve ** the speed a little by numbering the values consecutively. ** ** But rather than start with 0 or 1, we begin with 'a'. That way, ** when multiple affinity types are concatenated into a string and ** used as the P4 operand, they will be more readable. ** ** Note also that the numeric types are grouped together so that testing ** for a numeric type is a single comparison. */ #define SQLITE_AFF_TEXT 'a' #define SQLITE_AFF_NONE 'b' #define SQLITE_AFF_NUMERIC 'c' #define SQLITE_AFF_INTEGER 'd' #define SQLITE_AFF_REAL 'e' #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) /* ** The SQLITE_AFF_MASK values masks off the significant bits of an ** affinity value. */ #define SQLITE_AFF_MASK 0x67 /* ** Additional bit values that can be ORed with an affinity without ** changing the affinity. */ #define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ #define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ #define SQLITE_NULLEQ 0x80 /* NULL=NULL */ /* ** An object of this type is created for each virtual table present in ** the database schema. ** ** If the database schema is shared, then there is one instance of this ** structure for each database connection (sqlite3*) that uses the shared ** schema. This is because each database connection requires its own unique ** instance of the sqlite3_vtab* handle used to access the virtual table ** implementation. sqlite3_vtab* handles can not be shared between ** database connections, even when the rest of the in-memory database ** schema is shared, as the implementation often stores the database ** connection handle passed to it via the xConnect() or xCreate() method ** during initialization internally. This database connection handle may ** then used by the virtual table implementation to access real tables ** within the database. So that they appear as part of the callers ** transaction, these accesses need to be made via the same database ** connection as that used to execute SQL operations on the virtual table. ** ** All VTable objects that correspond to a single table in a shared ** database schema are initially stored in a linked-list pointed to by ** the Table.pVTable member variable of the corresponding Table object. ** When an sqlite3_prepare() operation is required to access the virtual ** table, it searches the list for the VTable that corresponds to the ** database connection doing the preparing so as to use the correct ** sqlite3_vtab* handle in the compiled query. ** ** When an in-memory Table object is deleted (for example when the ** schema is being reloaded for some reason), the VTable objects are not ** deleted and the sqlite3_vtab* handles are not xDisconnect()ed ** immediately. Instead, they are moved from the Table.pVTable list to ** another linked list headed by the sqlite3.pDisconnect member of the ** corresponding sqlite3 structure. They are then deleted/xDisconnected ** next time a statement is prepared using said sqlite3*. This is done ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. ** Refer to comments above function sqlite3VtabUnlockList() for an ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect ** list without holding the corresponding sqlite3.mutex mutex. ** ** The memory for objects of this type is always allocated by ** sqlite3DbMalloc(), using the connection handle stored in VTable.db as ** the first argument. */ struct VTable { sqlite3 *db; /* Database connection associated with this table */ Module *pMod; /* Pointer to module implementation */ sqlite3_vtab *pVtab; /* Pointer to vtab instance */ int nRef; /* Number of pointers to this structure */ VTable *pNext; /* Next in linked list (see above) */ }; /* ** Each SQL table is represented in memory by an instance of the ** following structure. ** ** Table.zName is the name of the table. The case of the original ** CREATE TABLE statement is stored, but case is not significant for ** comparisons. ** ** Table.nCol is the number of columns in this table. Table.aCol is a ** pointer to an array of Column structures, one for each column. ** ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of ** the column that is that key. Otherwise Table.iPKey is negative. Note ** that the datatype of the PRIMARY KEY must be INTEGER for this field to ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid ** is generated for each row of the table. TF_HasPrimaryKey is set if ** the table has any PRIMARY KEY, INTEGER or otherwise. ** ** Table.tnum is the page number for the root BTree page of the table in the ** database file. If Table.iDb is the index of the database table backend ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that ** holds temporary tables and indices. If TF_Ephemeral is set ** then the table is stored in a file that is automatically deleted ** when the VDBE cursor to the table is closed. In this case Table.tnum ** refers VDBE cursor number that holds the table open, not to the root ** page number. Transient tables are used to hold the results of a ** sub-query that appears instead of a real table name in the FROM clause ** of a SELECT statement. */ struct Table { char *zName; /* Name of the table or view */ int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ int nCol; /* Number of columns in this table */ Column *aCol; /* Information about each column */ Index *pIndex; /* List of SQL indexes on this table. */ int tnum; /* Root BTree node for this table (see note above) */ Select *pSelect; /* NULL for tables. Points to definition if a view. */ u16 nRef; /* Number of pointers to this Table */ u8 tabFlags; /* Mask of TF_* values */ u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ FKey *pFKey; /* Linked list of all foreign keys in this table */ char *zColAff; /* String defining the affinity of each column */ #ifndef SQLITE_OMIT_CHECK Expr *pCheck; /* The AND of all CHECK constraints */ #endif #ifndef SQLITE_OMIT_ALTERTABLE int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ #endif #ifndef SQLITE_OMIT_VIRTUALTABLE VTable *pVTable; /* List of VTable objects. */ int nModuleArg; /* Number of arguments to the module */ char **azModuleArg; /* Text of all module args. [0] is module name */ #endif Trigger *pTrigger; /* List of triggers stored in pSchema */ Schema *pSchema; /* Schema that contains this table */ Table *pNextZombie; /* Next on the Parse.pZombieTab list */ }; /* ** Allowed values for Tabe.tabFlags. */ #define TF_Readonly 0x01 /* Read-only system table */ #define TF_Ephemeral 0x02 /* An ephemeral table */ #define TF_HasPrimaryKey 0x04 /* Table has a primary key */ #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ #define TF_Virtual 0x10 /* Is a virtual table */ #define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ /* ** Test to see whether or not a table is a virtual table. This is ** done as a macro so that it will be optimized out when virtual ** table support is omitted from the build. */ #ifndef SQLITE_OMIT_VIRTUALTABLE # define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) # define IsHiddenColumn(X) ((X)->isHidden) #else # define IsVirtual(X) 0 # define IsHiddenColumn(X) 0 #endif /* ** Each foreign key constraint is an instance of the following structure. ** ** A foreign key is associated with two tables. The "from" table is ** the table that contains the REFERENCES clause that creates the foreign ** key. The "to" table is the table that is named in the REFERENCES clause. ** Consider this example: ** ** CREATE TABLE ex1( ** a INTEGER PRIMARY KEY, ** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) ** ); ** ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". ** ** Each REFERENCES clause generates an instance of the following structure ** which is attached to the from-table. The to-table need not exist when ** the from-table is created. The existence of the to-table is not checked. */ struct FKey { Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */ FKey *pNextFrom; /* Next foreign key in pFrom */ char *zTo; /* Name of table that the key points to (aka: Parent) */ FKey *pNextTo; /* Next foreign key on table named zTo */ FKey *pPrevTo; /* Previous foreign key on table named zTo */ int nCol; /* Number of columns in this key */ /* EV: R-30323-21917 */ u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */ Trigger *apTrigger[2]; /* Triggers for aAction[] actions */ struct sColMap { /* Mapping of columns in pFrom to columns in zTo */ int iFrom; /* Index of column in pFrom */ char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ } aCol[1]; /* One entry for each of nCol column s */ }; /* ** SQLite supports many different ways to resolve a constraint ** error. ROLLBACK processing means that a constraint violation ** causes the operation in process to fail and for the current transaction ** to be rolled back. ABORT processing means the operation in process ** fails and any prior changes from that one operation are backed out, ** but the transaction is not rolled back. FAIL processing means that ** the operation in progress stops and returns an error code. But prior ** changes due to the same operation are not backed out and no rollback ** occurs. IGNORE means that the particular row that caused the constraint ** error is not inserted or updated. Processing continues and no error ** is returned. REPLACE means that preexisting database rows that caused ** a UNIQUE constraint violation are removed so that the new insert or ** update can proceed. Processing continues and no error is reported. ** ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the ** referenced table row is propagated into the row that holds the ** foreign key. ** ** The following symbolic values are used to record which type ** of action to take. */ #define OE_None 0 /* There is no constraint to check */ #define OE_Rollback 1 /* Fail the operation and rollback the transaction */ #define OE_Abort 2 /* Back out changes but do no rollback transaction */ #define OE_Fail 3 /* Stop the operation but leave all prior changes */ #define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ #define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ #define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ #define OE_SetNull 7 /* Set the foreign key value to NULL */ #define OE_SetDflt 8 /* Set the foreign key value to its default */ #define OE_Cascade 9 /* Cascade the changes */ #define OE_Default 99 /* Do whatever the default action is */ /* ** An instance of the following structure is passed as the first ** argument to sqlite3VdbeKeyCompare and is used to control the ** comparison of the two index keys. */ struct KeyInfo { sqlite3 *db; /* The database connection */ u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ u16 nField; /* Number of entries in aColl[] */ u8 *aSortOrder; /* Sort order for each column. May be NULL */ CollSeq *aColl[1]; /* Collating sequence for each term of the key */ }; /* ** An instance of the following structure holds information about a ** single index record that has already been parsed out into individual ** values. ** ** A record is an object that contains one or more fields of data. ** Records are used to store the content of a table row and to store ** the key of an index. A blob encoding of a record is created by ** the OP_MakeRecord opcode of the VDBE and is disassembled by the ** OP_Column opcode. ** ** This structure holds a record that has already been disassembled ** into its constituent fields. */ struct UnpackedRecord { KeyInfo *pKeyInfo; /* Collation and sort-order information */ u16 nField; /* Number of entries in apMem[] */ u16 flags; /* Boolean settings. UNPACKED_... below */ i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ Mem *aMem; /* Values */ }; /* ** Allowed values of UnpackedRecord.flags */ #define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ #define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ #define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ #define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ #define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ #define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ /* ** Each SQL index is represented in memory by an ** instance of the following structure. ** ** The columns of the table that are to be indexed are described ** by the aiColumn[] field of this structure. For example, suppose ** we have the following table and index: ** ** CREATE TABLE Ex1(c1 int, c2 int, c3 text); ** CREATE INDEX Ex2 ON Ex1(c3,c1); ** ** In the Table structure describing Ex1, nCol==3 because there are ** three columns in the table. In the Index structure describing ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. ** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. ** The second column to be indexed (c1) has an index of 0 in ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. ** ** The Index.onError field determines whether or not the indexed columns ** must be unique and what to do if they are not. When Index.onError=OE_None, ** it means this is not a unique index. Otherwise it is a unique index ** and the value of Index.onError indicate the which conflict resolution ** algorithm to employ whenever an attempt is made to insert a non-unique ** element. */ struct Index { char *zName; /* Name of this index */ int nColumn; /* Number of columns in the table used by this index */ int *aiColumn; /* Which columns are used by this index. 1st is 0 */ unsigned *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ Table *pTable; /* The SQL table being indexed */ int tnum; /* Page containing root of this index in database file */ u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ char *zColAff; /* String defining the affinity of each column */ Index *pNext; /* The next index associated with the same table */ Schema *pSchema; /* Schema containing this index */ u8 *aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ char **azColl; /* Array of collation sequence names for index */ IndexSample *aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ }; /* ** Each sample stored in the sqlite_stat2 table is represented in memory ** using a structure of this type. */ struct IndexSample { union { char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */ double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ } u; u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ u8 nByte; /* Size in byte of text or blob. */ }; /* ** Each token coming out of the lexer is an instance of ** this structure. Tokens are also used as part of an expression. ** ** Note if Token.z==0 then Token.dyn and Token.n are undefined and ** may contain random values. Do not make any assumptions about Token.dyn ** and Token.n when Token.z==0. */ struct Token { const char *z; /* Text of the token. Not NULL-terminated! */ unsigned int n; /* Number of characters in this token */ }; /* ** An instance of this structure contains information needed to generate ** code for a SELECT that contains aggregate functions. ** ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a ** pointer to this structure. The Expr.iColumn field is the index in ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate ** code for that node. ** ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the ** original Select structure that describes the SELECT statement. These ** fields do not need to be freed when deallocating the AggInfo structure. */ struct AggInfo { u8 directMode; /* Direct rendering mode means take data directly ** from source tables rather than from accumulators */ u8 useSortingIdx; /* In direct mode, reference the sorting index rather ** than the source table */ int sortingIdx; /* Cursor number of the sorting index */ ExprList *pGroupBy; /* The group by clause */ int nSortingColumn; /* Number of columns in the sorting index */ struct AggInfo_col { /* For each column used in source tables */ Table *pTab; /* Source table */ int iTable; /* Cursor number of the source table */ int iColumn; /* Column number within the source table */ int iSorterColumn; /* Column number in the sorting index */ int iMem; /* Memory location that acts as accumulator */ Expr *pExpr; /* The original expression */ } *aCol; int nColumn; /* Number of used entries in aCol[] */ int nColumnAlloc; /* Number of slots allocated for aCol[] */ int nAccumulator; /* Number of columns that show through to the output. ** Additional columns are used only as parameters to ** aggregate functions */ struct AggInfo_func { /* For each aggregate function */ Expr *pExpr; /* Expression encoding the function */ FuncDef *pFunc; /* The aggregate function implementation */ int iMem; /* Memory location that acts as accumulator */ int iDistinct; /* Ephemeral table used to enforce DISTINCT */ } *aFunc; int nFunc; /* Number of entries in aFunc[] */ int nFuncAlloc; /* Number of slots allocated for aFunc[] */ }; /* ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater ** than 32767 we have to make it 32-bit. 16-bit is preferred because ** it uses less memory in the Expr object, which is a big memory user ** in systems with lots of prepared statements. And few applications ** need more than about 10 or 20 variables. But some extreme users want ** to have prepared statements with over 32767 variables, and for them ** the option is available (at compile-time). */ #if SQLITE_MAX_VARIABLE_NUMBER<=32767 typedef i16 ynVar; #else typedef int ynVar; #endif /* ** Each node of an expression in the parse tree is an instance ** of this structure. ** ** Expr.op is the opcode. The integer parser token codes are reused ** as opcodes here. For example, the parser defines TK_GE to be an integer ** code representing the ">=" operator. This same integer code is reused ** to represent the greater-than-or-equal-to operator in the expression ** tree. ** ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, ** or TK_STRING), then Expr.token contains the text of the SQL literal. If ** the expression is a variable (TK_VARIABLE), then Expr.token contains the ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), ** then Expr.token contains the name of the function. ** ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a ** binary operator. Either or both may be NULL. ** ** Expr.x.pList is a list of arguments if the expression is an SQL function, ** a CASE expression or an IN expression of the form " IN (, ...)". ** Expr.x.pSelect is used if the expression is a sub-select or an expression of ** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the ** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is ** valid. ** ** An expression of the form ID or ID.ID refers to a column in a table. ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is ** the integer cursor number of a VDBE cursor pointing to that table and ** Expr.iColumn is the column number for the specific column. If the ** expression is used as a result in an aggregate SELECT, then the ** value is also stored in the Expr.iAgg column in the aggregate so that ** it can be accessed after all aggregates are computed. ** ** If the expression is an unbound variable marker (a question mark ** character '?' in the original SQL) then the Expr.iTable holds the index ** number for that variable. ** ** If the expression is a subquery then Expr.iColumn holds an integer ** register number containing the result of the subquery. If the ** subquery gives a constant result, then iTable is -1. If the subquery ** gives a different answer at different times during statement processing ** then iTable is the address of a subroutine that computes the subquery. ** ** If the Expr is of type OP_Column, and the table it is selecting from ** is a disk table or the "old.*" pseudo-table, then pTab points to the ** corresponding table definition. ** ** ALLOCATION NOTES: ** ** Expr objects can use a lot of memory space in database schema. To ** help reduce memory requirements, sometimes an Expr object will be ** truncated. And to reduce the number of memory allocations, sometimes ** two or more Expr objects will be stored in a single memory allocation, ** together with Expr.zToken strings. ** ** If the EP_Reduced and EP_TokenOnly flags are set when ** an Expr object is truncated. When EP_Reduced is set, then all ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees ** are contained within the same memory allocation. Note, however, that ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately ** allocated, regardless of whether or not EP_Reduced is set. */ struct Expr { u8 op; /* Operation performed by this node */ char affinity; /* The affinity of the column or 0 if not a column */ u16 flags; /* Various flags. EP_* See below */ union { char *zToken; /* Token value. Zero terminated and dequoted */ int iValue; /* Integer value if EP_IntValue */ } u; /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no ** space is allocated for the fields below this point. An attempt to ** access them will result in a segfault or malfunction. *********************************************************************/ Expr *pLeft; /* Left subnode */ Expr *pRight; /* Right subnode */ union { ExprList *pList; /* Function arguments or in " IN ( IN (