summaryrefslogtreecommitdiffstats
path: root/src/vfs/cpio
diff options
context:
space:
mode:
Diffstat (limited to 'src/vfs/cpio')
-rw-r--r--src/vfs/cpio/Makefile.am7
-rw-r--r--src/vfs/cpio/Makefile.in734
-rw-r--r--src/vfs/cpio/cpio.c906
-rw-r--r--src/vfs/cpio/cpio.h18
4 files changed, 1665 insertions, 0 deletions
diff --git a/src/vfs/cpio/Makefile.am b/src/vfs/cpio/Makefile.am
new file mode 100644
index 0000000..a7806f8
--- /dev/null
+++ b/src/vfs/cpio/Makefile.am
@@ -0,0 +1,7 @@
+
+AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
+
+noinst_LTLIBRARIES = libvfs-cpio.la
+
+libvfs_cpio_la_SOURCES = \
+ cpio.c cpio.h
diff --git a/src/vfs/cpio/Makefile.in b/src/vfs/cpio/Makefile.in
new file mode 100644
index 0000000..df1622b
--- /dev/null
+++ b/src/vfs/cpio/Makefile.in
@@ -0,0 +1,734 @@
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2021 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@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/vfs/cpio
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/m4.include/gnulib/mode_t.m4 \
+ $(top_srcdir)/m4.include/gnulib/stat-size.m4 \
+ $(top_srcdir)/m4.include/gnulib/fstypename.m4 \
+ $(top_srcdir)/m4.include/gnulib/fsusage.m4 \
+ $(top_srcdir)/m4.include/gnulib/mountlist.m4 \
+ $(top_srcdir)/m4.include/gnulib/windows-stat-inodes.m4 \
+ $(top_srcdir)/m4.include/gnulib/sys_types_h.m4 \
+ $(top_srcdir)/m4.include/ax_path_lib_pcre.m4 \
+ $(top_srcdir)/m4.include/dx_doxygen.m4 \
+ $(top_srcdir)/m4.include/ax_require_defined.m4 \
+ $(top_srcdir)/m4.include/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4.include/ax_append_flag.m4 \
+ $(top_srcdir)/m4.include/ax_append_compile_flags.m4 \
+ $(top_srcdir)/m4.include/mc-cflags.m4 \
+ $(top_srcdir)/m4.include/ax_gcc_func_attribute.m4 \
+ $(top_srcdir)/m4.include/mc-check-search-type.m4 \
+ $(top_srcdir)/m4.include/mc-get-fs-info.m4 \
+ $(top_srcdir)/m4.include/mc-with-x.m4 \
+ $(top_srcdir)/m4.include/mc-use-termcap.m4 \
+ $(top_srcdir)/m4.include/mc-with-screen.m4 \
+ $(top_srcdir)/m4.include/mc-with-screen-ncurses.m4 \
+ $(top_srcdir)/m4.include/mc-with-screen-slang.m4 \
+ $(top_srcdir)/m4.include/mc-with-internal-edit.m4 \
+ $(top_srcdir)/m4.include/mc-subshell.m4 \
+ $(top_srcdir)/m4.include/mc-background.m4 \
+ $(top_srcdir)/m4.include/mc-ext2fs-attr.m4 \
+ $(top_srcdir)/m4.include/mc-glib.m4 \
+ $(top_srcdir)/m4.include/mc-vfs.m4 \
+ $(top_srcdir)/m4.include/vfs/rpc.m4 \
+ $(top_srcdir)/m4.include/vfs/socket.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-extfs.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-sfs.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-ftp.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-sftp.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-fish.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-undelfs.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-tarfs.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-cpiofs.m4 \
+ $(top_srcdir)/m4.include/mc-version.m4 \
+ $(top_srcdir)/m4.include/mc-tests.m4 \
+ $(top_srcdir)/m4.include/mc-i18n.m4 \
+ $(top_srcdir)/m4.include/mc-assert.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libvfs_cpio_la_LIBADD =
+am_libvfs_cpio_la_OBJECTS = cpio.lo
+libvfs_cpio_la_OBJECTS = $(am_libvfs_cpio_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/cpio.Plo
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libvfs_cpio_la_SOURCES)
+DIST_SOURCES = $(libvfs_cpio_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHECK_CFLAGS = @CHECK_CFLAGS@
+CHECK_LIBS = @CHECK_LIBS@
+COM_ERR_CFLAGS = @COM_ERR_CFLAGS@
+COM_ERR_LIBS = @COM_ERR_LIBS@
+CP1251 = @CP1251@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DOC_LINGUAS = @DOC_LINGUAS@
+DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DX_CONFIG = @DX_CONFIG@
+DX_DOCDIR = @DX_DOCDIR@
+DX_DOT = @DX_DOT@
+DX_DOXYGEN = @DX_DOXYGEN@
+DX_DVIPS = @DX_DVIPS@
+DX_EGREP = @DX_EGREP@
+DX_ENV = @DX_ENV@
+DX_FLAG_chi = @DX_FLAG_chi@
+DX_FLAG_chm = @DX_FLAG_chm@
+DX_FLAG_doc = @DX_FLAG_doc@
+DX_FLAG_dot = @DX_FLAG_dot@
+DX_FLAG_html = @DX_FLAG_html@
+DX_FLAG_man = @DX_FLAG_man@
+DX_FLAG_pdf = @DX_FLAG_pdf@
+DX_FLAG_ps = @DX_FLAG_ps@
+DX_FLAG_rtf = @DX_FLAG_rtf@
+DX_FLAG_xml = @DX_FLAG_xml@
+DX_HHC = @DX_HHC@
+DX_LATEX = @DX_LATEX@
+DX_MAKEINDEX = @DX_MAKEINDEX@
+DX_PDFLATEX = @DX_PDFLATEX@
+DX_PERL = @DX_PERL@
+DX_PROJECT = @DX_PROJECT@
+E2P_CFLAGS = @E2P_CFLAGS@
+E2P_LIBS = @E2P_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ETAGS = @ETAGS@
+EXEEXT = @EXEEXT@
+EXT2FS_CFLAGS = @EXT2FS_CFLAGS@
+EXT2FS_LIBS = @EXT2FS_LIBS@
+EXTHELPERSDIR = @EXTHELPERSDIR@
+FGREP = @FGREP@
+FILECMD = @FILECMD@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GMODULE_CFLAGS = @GMODULE_CFLAGS@
+GMODULE_LIBS = @GMODULE_LIBS@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+HAVE_FILECMD = @HAVE_FILECMD@
+HAVE_ZIPINFO = @HAVE_ZIPINFO@
+HAVE_nroff = @HAVE_nroff@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBMC_RELEASE = @LIBMC_RELEASE@
+LIBMC_VERSION = @LIBMC_VERSION@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBSSH_CFLAGS = @LIBSSH_CFLAGS@
+LIBSSH_LIBS = @LIBSSH_LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANDOC = @MANDOC@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MAN_DATE = @MAN_DATE@
+MAN_FLAGS = @MAN_FLAGS@
+MAN_VERSION = @MAN_VERSION@
+MCLIBS = @MCLIBS@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCRE_CPPFLAGS = @PCRE_CPPFLAGS@
+PCRE_LIBS = @PCRE_LIBS@
+PERL = @PERL@
+PERL_FOR_BUILD = @PERL_FOR_BUILD@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POSUB = @POSUB@
+PYTHON = @PYTHON@
+RANLIB = @RANLIB@
+RUBY = @RUBY@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLANG_CFLAGS = @SLANG_CFLAGS@
+SLANG_LIBS = @SLANG_LIBS@
+STRIP = @STRIP@
+TESTS_LDFLAGS = @TESTS_LDFLAGS@
+UNZIP = @UNZIP@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+X11_WWW = @X11_WWW@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+XMKMF = @XMKMF@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
+noinst_LTLIBRARIES = libvfs-cpio.la
+libvfs_cpio_la_SOURCES = \
+ cpio.c cpio.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 ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/vfs/cpio/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/vfs/cpio/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__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+libvfs-cpio.la: $(libvfs_cpio_la_OBJECTS) $(libvfs_cpio_la_DEPENDENCIES) $(EXTRA_libvfs_cpio_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(libvfs_cpio_la_OBJECTS) $(libvfs_cpio_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpio.Plo@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(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:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+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-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/cpio.Plo
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/cpio.Plo
+ -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 TAGS all all-am am--depfiles check check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ cscopelist-am ctags ctags-am distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/vfs/cpio/cpio.c b/src/vfs/cpio/cpio.c
new file mode 100644
index 0000000..f46766f
--- /dev/null
+++ b/src/vfs/cpio/cpio.c
@@ -0,0 +1,906 @@
+/*
+ Virtual File System: GNU Tar file system.
+
+ Copyright (C) 2000-2022
+ Free Software Foundation, Inc.
+
+ Written by:
+ Jan Hudec, 2000
+ Slava Zanko <slavazanko@gmail.com>, 2013
+
+ This file is part of the Midnight Commander.
+
+ The Midnight Commander is free software: you can redistribute it
+ and/or modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ The Midnight Commander is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * \brief Source: Virtual File System: GNU Tar file system.
+ * \author Jan Hudec
+ * \date 2000
+ */
+
+#include <config.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "lib/global.h"
+#include "lib/unixcompat.h"
+#include "lib/util.h"
+#include "lib/widget.h" /* message() */
+
+#include "lib/vfs/vfs.h"
+#include "lib/vfs/utilvfs.h"
+#include "lib/vfs/xdirentry.h"
+#include "lib/vfs/gc.h" /* vfs_rmstamp */
+
+#include "cpio.h"
+
+/*** global variables ****************************************************************************/
+
+/*** file scope macro definitions ****************************************************************/
+
+#define CPIO_SUPER(super) ((cpio_super_t *) (super))
+
+#define CPIO_POS(super) cpio_position
+/* If some time reentrancy should be needed change it to */
+/* #define CPIO_POS(super) (super)->u.arch.fd */
+
+#define CPIO_SEEK_SET(super, where) mc_lseek (CPIO_SUPER(super)->fd, CPIO_POS(super) = (where), SEEK_SET)
+#define CPIO_SEEK_CUR(super, where) mc_lseek (CPIO_SUPER(super)->fd, CPIO_POS(super) += (where), SEEK_SET)
+
+#define MAGIC_LENGTH (6) /* How many bytes we have to read ahead */
+#define SEEKBACK CPIO_SEEK_CUR(super, ptr - top)
+#define RETURN(x) return (CPIO_SUPER(super)->type = (x))
+#define TYPEIS(x) ((CPIO_SUPER(super)->type == CPIO_UNKNOWN) || (CPIO_SUPER(super)->type == (x)))
+
+#define HEAD_LENGTH (26)
+
+/*** file scope type declarations ****************************************************************/
+
+enum
+{
+ STATUS_START,
+ STATUS_OK,
+ STATUS_TRAIL,
+ STATUS_FAIL,
+ STATUS_EOF
+};
+
+enum
+{
+ CPIO_UNKNOWN = 0, /* Not determined yet */
+ CPIO_BIN, /* Binary format */
+ CPIO_BINRE, /* Binary format, reverse endianity */
+ CPIO_OLDC, /* Old ASCII format */
+ CPIO_NEWC, /* New ASCII format */
+ CPIO_CRC /* New ASCII format + CRC */
+};
+
+struct old_cpio_header
+{
+ unsigned short c_magic;
+ short c_dev;
+ unsigned short c_ino;
+ unsigned short c_mode;
+ unsigned short c_uid;
+ unsigned short c_gid;
+ unsigned short c_nlink;
+ short c_rdev;
+ unsigned short c_mtimes[2];
+ unsigned short c_namesize;
+ unsigned short c_filesizes[2];
+};
+
+struct new_cpio_header
+{
+ unsigned short c_magic;
+ unsigned long c_ino;
+ unsigned long c_mode;
+ unsigned long c_uid;
+ unsigned long c_gid;
+ unsigned long c_nlink;
+ unsigned long c_mtime;
+ unsigned long c_filesize;
+ long c_dev;
+ long c_devmin;
+ long c_rdev;
+ long c_rdevmin;
+ unsigned long c_namesize;
+ unsigned long c_chksum;
+};
+
+typedef struct
+{
+ unsigned long inumber;
+ dev_t device;
+ struct vfs_s_inode *inode;
+} defer_inode;
+
+typedef struct
+{
+ struct vfs_s_super base; /* base class */
+
+ int fd;
+ struct stat st;
+ int type; /* Type of the archive */
+ GSList *deferred; /* List of inodes for which another entries may appear */
+} cpio_super_t;
+
+/*** file scope variables ************************************************************************/
+
+static struct vfs_s_subclass cpio_subclass;
+static struct vfs_class *vfs_cpiofs_ops = VFS_CLASS (&cpio_subclass);
+
+static off_t cpio_position;
+
+/* --------------------------------------------------------------------------------------------- */
+/*** file scope functions ************************************************************************/
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t cpio_find_head (struct vfs_class *me, struct vfs_s_super *super);
+static ssize_t cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super);
+static ssize_t cpio_read_oldc_head (struct vfs_class *me, struct vfs_s_super *super);
+static ssize_t cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super);
+static ssize_t cpio_read (void *fh, char *buffer, size_t count);
+
+/* --------------------------------------------------------------------------------------------- */
+
+static int
+cpio_defer_find (const void *a, const void *b)
+{
+ const defer_inode *a1 = (const defer_inode *) a;
+ const defer_inode *b1 = (const defer_inode *) b;
+
+ return (a1->inumber == b1->inumber && a1->device == b1->device) ? 0 : 1;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t
+cpio_skip_padding (struct vfs_s_super *super)
+{
+ switch (CPIO_SUPER (super)->type)
+ {
+ case CPIO_BIN:
+ case CPIO_BINRE:
+ return CPIO_SEEK_CUR (super, (2 - (CPIO_POS (super) % 2)) % 2);
+ case CPIO_NEWC:
+ case CPIO_CRC:
+ return CPIO_SEEK_CUR (super, (4 - (CPIO_POS (super) % 4)) % 4);
+ case CPIO_OLDC:
+ return CPIO_POS (super);
+ default:
+ g_assert_not_reached ();
+ return 42; /* & the compiler is happy :-) */
+ }
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static struct vfs_s_super *
+cpio_new_archive (struct vfs_class *me)
+{
+ cpio_super_t *arch;
+
+ arch = g_new0 (cpio_super_t, 1);
+ arch->base.me = me;
+ arch->fd = -1; /* for now */
+ arch->type = CPIO_UNKNOWN;
+
+ return VFS_SUPER (arch);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static void
+cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super)
+{
+ cpio_super_t *arch = CPIO_SUPER (super);
+
+ (void) me;
+
+ if (arch->fd != -1)
+ {
+ mc_close (arch->fd);
+ arch->fd = -1;
+ }
+
+ g_clear_slist (&arch->deferred, g_free);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static int
+cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const vfs_path_t * vpath)
+{
+ int fd, type;
+ cpio_super_t *arch;
+ mode_t mode;
+ struct vfs_s_inode *root;
+
+ fd = mc_open (vpath, O_RDONLY);
+ if (fd == -1)
+ {
+ message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), vfs_path_as_str (vpath));
+ return -1;
+ }
+
+ super->name = g_strdup (vfs_path_as_str (vpath));
+ arch = CPIO_SUPER (super);
+ mc_stat (vpath, &arch->st);
+
+ type = get_compression_type (fd, super->name);
+ if (type == COMPRESSION_NONE)
+ mc_lseek (fd, 0, SEEK_SET);
+ else
+ {
+ char *s;
+ vfs_path_t *tmp_vpath;
+
+ mc_close (fd);
+ s = g_strconcat (super->name, decompress_extension (type), (char *) NULL);
+ tmp_vpath = vfs_path_from_str_flags (s, VPF_NO_CANON);
+ fd = mc_open (tmp_vpath, O_RDONLY);
+ vfs_path_free (tmp_vpath, TRUE);
+ if (fd == -1)
+ {
+ message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
+ g_free (s);
+ MC_PTR_FREE (super->name);
+ return -1;
+ }
+ g_free (s);
+ }
+
+ arch->fd = fd;
+ mode = arch->st.st_mode & 07777;
+ mode |= (mode & 0444) >> 2; /* set eXec where Read is */
+ mode |= S_IFDIR;
+
+ root = vfs_s_new_inode (me, super, &arch->st);
+ root->st.st_mode = mode;
+ root->data_offset = -1;
+ root->st.st_nlink++;
+ root->st.st_dev = VFS_SUBCLASS (me)->rdev++;
+
+ super->root = root;
+
+ CPIO_SEEK_SET (super, 0);
+
+ return fd;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t
+cpio_read_head (struct vfs_class *me, struct vfs_s_super *super)
+{
+ switch (cpio_find_head (me, super))
+ {
+ case CPIO_UNKNOWN:
+ return -1;
+ case CPIO_BIN:
+ case CPIO_BINRE:
+ return cpio_read_bin_head (me, super);
+ case CPIO_OLDC:
+ return cpio_read_oldc_head (me, super);
+ case CPIO_NEWC:
+ case CPIO_CRC:
+ return cpio_read_crc_head (me, super);
+ default:
+ g_assert_not_reached ();
+ return 42; /* & the compiler is happy :-) */
+ }
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t
+cpio_find_head (struct vfs_class *me, struct vfs_s_super *super)
+{
+ cpio_super_t *arch = CPIO_SUPER (super);
+ char buf[BUF_SMALL * 2];
+ ssize_t ptr = 0;
+ ssize_t top;
+ ssize_t tmp;
+
+ top = mc_read (arch->fd, buf, sizeof (buf));
+ if (top > 0)
+ CPIO_POS (super) += top;
+
+ while (TRUE)
+ {
+ if (ptr + MAGIC_LENGTH >= top)
+ {
+ if (top > (ssize_t) (sizeof (buf) / 2))
+ {
+ memmove (buf, buf + top - sizeof (buf) / 2, sizeof (buf) / 2);
+ ptr -= top - sizeof (buf) / 2;
+ top = sizeof (buf) / 2;
+ }
+ tmp = mc_read (arch->fd, buf, top);
+ if (tmp == 0 || tmp == -1)
+ {
+ message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name);
+ cpio_free_archive (me, super);
+ return CPIO_UNKNOWN;
+ }
+ top += tmp;
+ }
+ if (TYPEIS (CPIO_BIN) && ((*(unsigned short *) (buf + ptr)) == 070707))
+ {
+ SEEKBACK;
+ RETURN (CPIO_BIN);
+ }
+ else if (TYPEIS (CPIO_BINRE)
+ && ((*(unsigned short *) (buf + ptr)) == GUINT16_SWAP_LE_BE_CONSTANT (070707)))
+ {
+ SEEKBACK;
+ RETURN (CPIO_BINRE);
+ }
+ else if (TYPEIS (CPIO_OLDC) && (strncmp (buf + ptr, "070707", 6) == 0))
+ {
+ SEEKBACK;
+ RETURN (CPIO_OLDC);
+ }
+ else if (TYPEIS (CPIO_NEWC) && (strncmp (buf + ptr, "070701", 6) == 0))
+ {
+ SEEKBACK;
+ RETURN (CPIO_NEWC);
+ }
+ else if (TYPEIS (CPIO_CRC) && (strncmp (buf + ptr, "070702", 6) == 0))
+ {
+ SEEKBACK;
+ RETURN (CPIO_CRC);
+ };
+ ptr++;
+ }
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static int
+cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat *st, char *name)
+{
+ cpio_super_t *arch = CPIO_SUPER (super);
+ struct vfs_s_inode *inode = NULL;
+ struct vfs_s_inode *root = super->root;
+ struct vfs_s_entry *entry = NULL;
+ char *tn;
+
+ switch (st->st_mode & S_IFMT)
+ { /* For case of HP/UX archives */
+ case S_IFCHR:
+ case S_IFBLK:
+#ifdef S_IFSOCK
+ /* cppcheck-suppress syntaxError */
+ case S_IFSOCK:
+#endif
+#ifdef S_IFIFO
+ /* cppcheck-suppress syntaxError */
+ case S_IFIFO:
+#endif
+#ifdef S_IFNAM
+ /* cppcheck-suppress syntaxError */
+ case S_IFNAM:
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ if ((st->st_size != 0) && (st->st_rdev == 0x0001))
+ {
+ /* FIXME: representation of major/minor differs between */
+ /* different operating systems. */
+ st->st_rdev = (unsigned) st->st_size;
+ st->st_size = 0;
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+
+ if ((st->st_nlink > 1) && ((arch->type == CPIO_NEWC) || (arch->type == CPIO_CRC)))
+ { /* For case of hardlinked files */
+ defer_inode i = { st->st_ino, st->st_dev, NULL };
+ GSList *l;
+
+ l = g_slist_find_custom (arch->deferred, &i, cpio_defer_find);
+ if (l != NULL)
+ {
+ inode = ((defer_inode *) l->data)->inode;
+ if (inode->st.st_size != 0 && st->st_size != 0 && (inode->st.st_size != st->st_size))
+ {
+ message (D_ERROR, MSG_ERROR,
+ _("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
+ name, super->name);
+ inode = NULL;
+ }
+ else if (inode->st.st_size == 0)
+ inode->st.st_size = st->st_size;
+ }
+ }
+
+ /* remove trailing slashes */
+ for (tn = name + strlen (name) - 1; tn >= name && IS_PATH_SEP (*tn); tn--)
+ *tn = '\0';
+
+ tn = strrchr (name, PATH_SEP);
+ if (tn == NULL)
+ tn = name;
+ else if (tn == name + 1)
+ {
+ /* started with "./" -- directory in the root of archive */
+ tn++;
+ }
+ else
+ {
+ *tn = '\0';
+ root = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_MKDIR);
+ *tn = PATH_SEP;
+ tn++;
+ }
+
+ entry = VFS_SUBCLASS (me)->find_entry (me, root, tn, LINK_FOLLOW, FL_NONE); /* In case entry is already there */
+
+ if (entry != NULL)
+ {
+ /* This shouldn't happen! (well, it can happen if there is a record for a
+ file and than a record for a directory it is in; cpio would die with
+ 'No such file or directory' is such case) */
+
+ if (!S_ISDIR (entry->ino->st.st_mode))
+ {
+ /* This can be considered archive inconsistency */
+ message (D_ERROR, MSG_ERROR,
+ _("%s contains duplicate entries! Skipping!"), super->name);
+ }
+ else
+ {
+ entry->ino->st.st_mode = st->st_mode;
+ entry->ino->st.st_uid = st->st_uid;
+ entry->ino->st.st_gid = st->st_gid;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ entry->ino->st.st_atim = st->st_atim;
+ entry->ino->st.st_mtim = st->st_mtim;
+ entry->ino->st.st_ctim = st->st_ctim;
+#else
+ entry->ino->st.st_atime = st->st_atime;
+ entry->ino->st.st_mtime = st->st_mtime;
+ entry->ino->st.st_ctime = st->st_ctime;
+#endif
+ }
+
+ g_free (name);
+ }
+ else
+ { /* !entry */
+ /* root == NULL can be in the following case:
+ * a/b/c -> d
+ * where 'a/b' is the stale link and therefore root of 'c' cannot be found in the archive
+ */
+ if (root != NULL)
+ {
+ if (inode == NULL)
+ {
+ inode = vfs_s_new_inode (me, super, st);
+ if ((st->st_nlink > 0) && ((arch->type == CPIO_NEWC) || (arch->type == CPIO_CRC)))
+ {
+ /* For case of hardlinked files */
+ defer_inode *i;
+
+ i = g_new (defer_inode, 1);
+ i->inumber = st->st_ino;
+ i->device = st->st_dev;
+ i->inode = inode;
+
+ arch->deferred = g_slist_prepend (arch->deferred, i);
+ }
+ }
+
+ if (st->st_size != 0)
+ inode->data_offset = CPIO_POS (super);
+
+ entry = vfs_s_new_entry (me, tn, inode);
+ vfs_s_insert_entry (me, root, entry);
+ }
+
+ g_free (name);
+
+ if (!S_ISLNK (st->st_mode))
+ CPIO_SEEK_CUR (super, st->st_size);
+ else
+ {
+ if (inode != NULL)
+ {
+ /* FIXME: do we must read from arch->fd in case of inode != NULL only or in any case? */
+
+ inode->linkname = g_malloc (st->st_size + 1);
+
+ if (mc_read (arch->fd, inode->linkname, st->st_size) < st->st_size)
+ {
+ inode->linkname[0] = '\0';
+ return STATUS_EOF;
+ }
+
+ inode->linkname[st->st_size] = '\0'; /* Linkname stored without terminating \0 !!! */
+ }
+
+ CPIO_POS (super) += st->st_size;
+ cpio_skip_padding (super);
+ }
+ } /* !entry */
+
+ return STATUS_OK;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t
+cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super)
+{
+ union
+ {
+ struct old_cpio_header buf;
+ short shorts[HEAD_LENGTH >> 1];
+ } u;
+
+ cpio_super_t *arch = CPIO_SUPER (super);
+ ssize_t len;
+ char *name;
+ struct stat st;
+
+ len = mc_read (arch->fd, (char *) &u.buf, HEAD_LENGTH);
+ if (len < HEAD_LENGTH)
+ return STATUS_EOF;
+ CPIO_POS (super) += len;
+ if (arch->type == CPIO_BINRE)
+ {
+ int i;
+ for (i = 0; i < (HEAD_LENGTH >> 1); i++)
+ u.shorts[i] = GUINT16_SWAP_LE_BE_CONSTANT (u.shorts[i]);
+ }
+
+ if (u.buf.c_magic != 070707 || u.buf.c_namesize == 0 || u.buf.c_namesize > MC_MAXPATHLEN)
+ {
+ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
+ return STATUS_FAIL;
+ }
+ name = g_malloc (u.buf.c_namesize);
+ len = mc_read (arch->fd, name, u.buf.c_namesize);
+ if (len < u.buf.c_namesize)
+ {
+ g_free (name);
+ return STATUS_EOF;
+ }
+ name[u.buf.c_namesize - 1] = '\0';
+ CPIO_POS (super) += len;
+ cpio_skip_padding (super);
+
+ if (!strcmp ("TRAILER!!!", name))
+ { /* We got to the last record */
+ g_free (name);
+ return STATUS_TRAIL;
+ }
+
+ st.st_dev = u.buf.c_dev;
+ st.st_ino = u.buf.c_ino;
+ st.st_mode = u.buf.c_mode;
+ st.st_nlink = u.buf.c_nlink;
+ st.st_uid = u.buf.c_uid;
+ st.st_gid = u.buf.c_gid;
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ st.st_rdev = u.buf.c_rdev;
+#endif
+ st.st_size = ((off_t) u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ st.st_atim.tv_nsec = st.st_mtim.tv_nsec = st.st_ctim.tv_nsec = 0;
+#endif
+ st.st_atime = st.st_mtime = st.st_ctime =
+ ((time_t) u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
+
+ return cpio_create_entry (me, super, &st, name);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+#undef HEAD_LENGTH
+#define HEAD_LENGTH (76)
+
+static ssize_t
+cpio_read_oldc_head (struct vfs_class *me, struct vfs_s_super *super)
+{
+ cpio_super_t *arch = CPIO_SUPER (super);
+ struct new_cpio_header hd;
+ union
+ {
+ struct stat st;
+ char buf[HEAD_LENGTH + 1];
+ } u;
+ ssize_t len;
+ char *name;
+
+ if (mc_read (arch->fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
+ return STATUS_EOF;
+ CPIO_POS (super) += HEAD_LENGTH;
+ u.buf[HEAD_LENGTH] = 0;
+
+ if (sscanf (u.buf, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo",
+ (unsigned long *) &hd.c_dev, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
+ &hd.c_nlink, (unsigned long *) &hd.c_rdev, &hd.c_mtime,
+ &hd.c_namesize, &hd.c_filesize) < 10)
+ {
+ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
+ return STATUS_FAIL;
+ }
+
+ if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN)
+ {
+ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
+ return STATUS_FAIL;
+ }
+ name = g_malloc (hd.c_namesize);
+ len = mc_read (arch->fd, name, hd.c_namesize);
+ if ((len == -1) || ((unsigned long) len < hd.c_namesize))
+ {
+ g_free (name);
+ return STATUS_EOF;
+ }
+ name[hd.c_namesize - 1] = '\0';
+ CPIO_POS (super) += len;
+ cpio_skip_padding (super);
+
+ if (!strcmp ("TRAILER!!!", name))
+ { /* We got to the last record */
+ g_free (name);
+ return STATUS_TRAIL;
+ }
+
+ u.st.st_dev = hd.c_dev;
+ u.st.st_ino = hd.c_ino;
+ u.st.st_mode = hd.c_mode;
+ u.st.st_nlink = hd.c_nlink;
+ u.st.st_uid = hd.c_uid;
+ u.st.st_gid = hd.c_gid;
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ u.st.st_rdev = hd.c_rdev;
+#endif
+ u.st.st_size = hd.c_filesize;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ u.st.st_atim.tv_nsec = u.st.st_mtim.tv_nsec = u.st.st_ctim.tv_nsec = 0;
+#endif
+ u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
+
+ return cpio_create_entry (me, super, &u.st, name);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+#undef HEAD_LENGTH
+#define HEAD_LENGTH (110)
+
+static ssize_t
+cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super)
+{
+ cpio_super_t *arch = CPIO_SUPER (super);
+ struct new_cpio_header hd;
+ union
+ {
+ struct stat st;
+ char buf[HEAD_LENGTH + 1];
+ } u;
+ ssize_t len;
+ char *name;
+
+ if (mc_read (arch->fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
+ return STATUS_EOF;
+
+ CPIO_POS (super) += HEAD_LENGTH;
+ u.buf[HEAD_LENGTH] = '\0';
+
+ if (sscanf (u.buf, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx",
+ &hd.c_magic, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
+ &hd.c_nlink, &hd.c_mtime, &hd.c_filesize,
+ (unsigned long *) &hd.c_dev, (unsigned long *) &hd.c_devmin,
+ (unsigned long *) &hd.c_rdev, (unsigned long *) &hd.c_rdevmin,
+ &hd.c_namesize, &hd.c_chksum) < 14)
+ {
+ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
+ return STATUS_FAIL;
+ }
+
+ if ((arch->type == CPIO_NEWC && hd.c_magic != 070701) ||
+ (arch->type == CPIO_CRC && hd.c_magic != 070702))
+ return STATUS_FAIL;
+
+ if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN)
+ {
+ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
+ return STATUS_FAIL;
+ }
+
+ name = g_malloc (hd.c_namesize);
+ len = mc_read (arch->fd, name, hd.c_namesize);
+
+ if ((len == -1) || ((unsigned long) len < hd.c_namesize))
+ {
+ g_free (name);
+ return STATUS_EOF;
+ }
+ name[hd.c_namesize - 1] = '\0';
+ CPIO_POS (super) += len;
+ cpio_skip_padding (super);
+
+ if (strcmp ("TRAILER!!!", name) == 0)
+ { /* We got to the last record */
+ g_free (name);
+ return STATUS_TRAIL;
+ }
+
+ u.st.st_dev = makedev (hd.c_dev, hd.c_devmin);
+ u.st.st_ino = hd.c_ino;
+ u.st.st_mode = hd.c_mode;
+ u.st.st_nlink = hd.c_nlink;
+ u.st.st_uid = hd.c_uid;
+ u.st.st_gid = hd.c_gid;
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin);
+#endif
+ u.st.st_size = hd.c_filesize;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ u.st.st_atim.tv_nsec = u.st.st_mtim.tv_nsec = u.st.st_ctim.tv_nsec = 0;
+#endif
+ u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
+
+ return cpio_create_entry (me, super, &u.st, name);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+/** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
+
+static int
+cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
+ const vfs_path_element_t * vpath_element)
+{
+ (void) vpath_element;
+
+ if (cpio_open_cpio_file (vpath_element->class, super, vpath) == -1)
+ return -1;
+
+ while (TRUE)
+ {
+ ssize_t status;
+
+ status = cpio_read_head (vpath_element->class, super);
+ if (status < 0)
+ return (-1);
+
+ switch (status)
+ {
+ case STATUS_EOF:
+ {
+ message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"),
+ vfs_path_as_str (vpath));
+ return 0;
+ }
+ case STATUS_OK:
+ continue;
+ case STATUS_TRAIL:
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+/** Remaining functions are exactly same as for tarfs (and were in fact just copied) */
+
+static void *
+cpio_super_check (const vfs_path_t * vpath)
+{
+ static struct stat sb;
+ int stat_result;
+
+ stat_result = mc_stat (vpath, &sb);
+ return (stat_result == 0 ? &sb : NULL);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static int
+cpio_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *parc,
+ const vfs_path_t * vpath, void *cookie)
+{
+ struct stat *archive_stat = cookie; /* stat of main archive */
+
+ (void) vpath_element;
+
+ if (strcmp (parc->name, vfs_path_as_str (vpath)))
+ return 0;
+
+ /* Has the cached archive been changed on the disk? */
+ if (parc != NULL && CPIO_SUPER (parc)->st.st_mtime < archive_stat->st_mtime)
+ {
+ /* Yes, reload! */
+ vfs_cpiofs_ops->free ((vfsid) parc);
+ vfs_rmstamp (vfs_cpiofs_ops, (vfsid) parc);
+ return 2;
+ }
+ /* Hasn't been modified, give it a new timeout */
+ vfs_stamp (vfs_cpiofs_ops, (vfsid) parc);
+ return 1;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static ssize_t
+cpio_read (void *fh, char *buffer, size_t count)
+{
+ vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
+ struct vfs_class *me = VFS_FILE_HANDLER_SUPER (fh)->me;
+ int fd = CPIO_SUPER (VFS_FILE_HANDLER_SUPER (fh))->fd;
+ off_t begin = file->ino->data_offset;
+ ssize_t res;
+
+ if (mc_lseek (fd, begin + file->pos, SEEK_SET) != begin + file->pos)
+ ERRNOR (EIO, -1);
+
+ count = MIN (count, (size_t) (file->ino->st.st_size - file->pos));
+
+ res = mc_read (fd, buffer, count);
+ if (res == -1)
+ ERRNOR (errno, -1);
+
+ file->pos += res;
+ return res;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+static int
+cpio_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t mode)
+{
+ (void) fh;
+ (void) mode;
+
+ if ((flags & O_ACCMODE) != O_RDONLY)
+ ERRNOR (EROFS, -1);
+ return 0;
+}
+
+/* --------------------------------------------------------------------------------------------- */
+/*** public functions ****************************************************************************/
+/* --------------------------------------------------------------------------------------------- */
+
+void
+vfs_init_cpiofs (void)
+{
+ /* FIXME: cpiofs used own temp files */
+ vfs_init_subclass (&cpio_subclass, "cpiofs", VFSF_READONLY, "ucpio");
+ vfs_cpiofs_ops->read = cpio_read;
+ vfs_cpiofs_ops->setctl = NULL;
+ cpio_subclass.archive_check = cpio_super_check;
+ cpio_subclass.archive_same = cpio_super_same;
+ cpio_subclass.new_archive = cpio_new_archive;
+ cpio_subclass.open_archive = cpio_open_archive;
+ cpio_subclass.free_archive = cpio_free_archive;
+ cpio_subclass.fh_open = cpio_fh_open;
+ vfs_register_class (vfs_cpiofs_ops);
+}
+
+/* --------------------------------------------------------------------------------------------- */
diff --git a/src/vfs/cpio/cpio.h b/src/vfs/cpio/cpio.h
new file mode 100644
index 0000000..a00756a
--- /dev/null
+++ b/src/vfs/cpio/cpio.h
@@ -0,0 +1,18 @@
+#ifndef MC__VFS_CPIO_H
+#define MC__VFS_CPIO_H
+
+/*** typedefs(not structures) and defined constants **********************************************/
+
+/*** enums ***************************************************************************************/
+
+/*** structures declarations (and typedefs of structures)*****************************************/
+
+/*** global variables defined in .c file *********************************************************/
+
+/*** declarations of public functions ************************************************************/
+
+void vfs_init_cpiofs (void);
+
+/*** inline functions ****************************************************************************/
+
+#endif /* MC__VFS_CPIO_H */