Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package avfs for openSUSE:Factory checked in at 2021-06-01 10:36:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/avfs (Old) and /work/SRC/openSUSE:Factory/.avfs.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "avfs" Tue Jun 1 10:36:58 2021 rev:9 rq:895508 version:1.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/avfs/avfs.changes 2020-08-17 12:10:41.390871796 +0200 +++ /work/SRC/openSUSE:Factory/.avfs.new.1898/avfs.changes 2021-06-01 10:37:58.468865422 +0200 @@ -1,0 +2,6 @@ +Wed May 26 08:52:40 UTC 2021 - Ferdinand Thiessen <[email protected]> + +- Update to version 1.1.4: + * add support for lzip (ulzip module for .lz files) + +------------------------------------------------------------------- Old: ---- avfs-1.1.3.tar.bz2 avfs-1.1.3.tar.bz2.asc New: ---- avfs-1.1.4.tar.bz2 avfs-1.1.4.tar.bz2.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ avfs.spec ++++++ --- /var/tmp/diff_new_pack.iMZsxd/_old 2021-06-01 10:37:59.016866356 +0200 +++ /var/tmp/diff_new_pack.iMZsxd/_new 2021-06-01 10:37:59.020866362 +0200 @@ -1,7 +1,7 @@ # # spec file for package avfs # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: avfs -Version: 1.1.3 +Version: 1.1.4 Release: 0 Summary: AVFS - an archive look-inside filesystem License: GPL-2.0-or-later AND LGPL-2.1-or-later @@ -27,6 +27,7 @@ Source2: %{name}.keyring BuildRequires: emacs-nox BuildRequires: help2man +BuildRequires: lzlib-devel BuildRequires: pkgconfig BuildRequires: pkgconfig(bzip2) BuildRequires: pkgconfig(e2p) @@ -76,6 +77,7 @@ --enable-shared \ --with-system-zlib \ --with-system-bzlib \ + --with-lzip \ --with-lzma \ --with-xz %make_build ++++++ avfs-1.1.3.tar.bz2 -> avfs-1.1.4.tar.bz2 ++++++ ++++ 8908 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/ChangeLog new/avfs-1.1.4/ChangeLog --- old/avfs-1.1.3/ChangeLog 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/ChangeLog 2021-04-04 15:41:21.000000000 +0200 @@ -1,3 +1,8 @@ +2021-04-04 Ralf Hoffmann <[email protected]> + + * add support for lzip (ulzip module for .lz files) + * bump version to 1.1.4 + 2020-08-12 Ralf Hoffmann <[email protected]> * bump version to 1.1.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/NEWS new/avfs-1.1.4/NEWS --- old/avfs-1.1.3/NEWS 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/NEWS 2021-04-04 15:41:21.000000000 +0200 @@ -1,3 +1,6 @@ +Changes from 1.1.3 to 1.1.4 (2021-04-04) + - add support for lzip + Changes from 1.1.2 to 1.1.3 (2020-08-12) - fix compilation problem on MacOS - fix encoding problem in ulha extfs module diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/README new/avfs-1.1.4/README --- old/avfs-1.1.3/README 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/README 2021-04-04 15:41:21.000000000 +0200 @@ -159,6 +159,7 @@ #ucftp_ctl control ftp sessions #ugz gunzip builtin (1) #ugzip gunzip uses gzip + #ulzip unlzip builtin #urar unrar builtin list + uses rar to extract #utar untar builtin #uxz unxz/unlzma builtin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/compile new/avfs-1.1.4/compile --- old/avfs-1.1.3/compile 2020-08-12 22:18:32.000000000 +0200 +++ new/avfs-1.1.4/compile 2021-04-04 15:41:31.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # Written by Tom Tromey <[email protected]>. # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -53,7 +53,7 @@ MINGW*) file_conv=mingw ;; - CYGWIN*) + CYGWIN* | MSYS*) file_conv=cygwin ;; *) @@ -67,7 +67,7 @@ mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin/*) + cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) @@ -340,7 +340,7 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/config.h.in new/avfs-1.1.4/config.h.in --- old/avfs-1.1.3/config.h.in 2020-08-12 22:18:31.000000000 +0200 +++ new/avfs-1.1.4/config.h.in 2021-04-04 15:41:30.000000000 +0200 @@ -33,6 +33,9 @@ /* Define to 1 if your system has libfuse installed */ #undef HAVE_LIBFUSE +/* Define to 1 if your system has liblzip installed */ +#undef HAVE_LIBLZIP + /* Define to 1 if your system has liblzma installed */ #undef HAVE_LIBLZMA @@ -45,6 +48,9 @@ /* Define to 1 if your system has libzstd installed */ #undef HAVE_LIBZSTD +/* Define to 1 if you have the <lzlib.h> header file. */ +#undef HAVE_LZLIB_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/configure.ac new/avfs-1.1.4/configure.ac --- old/avfs-1.1.3/configure.ac 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/configure.ac 2021-04-04 15:41:21.000000000 +0200 @@ -2,7 +2,7 @@ define(AVFS_MAJOR,[1]) define(AVFS_MINOR,[1]) -define(AVFS_PATCH,[3]) +define(AVFS_PATCH,[4]) define(AVFS_COMMENT,[]) define(AVFS_VERSION,AVFS_MAJOR[.]AVFS_MINOR[.]AVFS_PATCH[]AVFS_COMMENT) @@ -373,9 +373,23 @@ dnl AC_MSG_RESULT($have_libzstd) fi +dnl ================================================================ +dnl == check for liblzip == +dnl ================================================================ + +use_liblzip=no +AC_ARG_WITH(lzip,AC_HELP_STRING([--with-lzip],[use lzip (default is YES)]), + ac_cv_use_lzip=$withval, ac_cv_use_lzip=yes) +if test "$ac_cv_use_lzip" = "yes"; then + AC_CHECK_HEADERS(lzlib.h, [AC_CHECK_LIB(lz, LZ_decompress_open, + [LIBS="$LIBS -llz" + AC_DEFINE(HAVE_LIBLZIP, 1, [Define to 1 if your system has liblzip installed]) + use_liblzip=yes])]) +fi AM_CONDITIONAL(USE_LIBLZMA, test x$use_liblzma = xyes) AM_CONDITIONAL(USE_LIBZSTD, test x$use_libzstd = xyes) +AM_CONDITIONAL(USE_LIBLZIP, test x$use_liblzip = xyes) AM_CONDITIONAL(INSTALL_FUSE, test x$install_fuse = xyes) dnl ================================================================ @@ -484,6 +498,11 @@ else echo " WebDAV support : no" fi +if test "x$use_liblzip" = "xyes"; then + echo " Use liblzip : yes" +else + echo " Use liblzip : no" +fi echo "" echo " Installation prefix : $prefix" echo "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/include/Makefile.am new/avfs-1.1.4/include/Makefile.am --- old/avfs-1.1.3/include/Makefile.am 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/include/Makefile.am 2021-04-04 15:41:21.000000000 +0200 @@ -43,4 +43,8 @@ noinst_HEADERS += zstdfile.h endif +if USE_LIBLZIP +noinst_HEADERS += lzipfile.h +endif + BUILT_SOURCES = version.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/include/lzipfile.h new/avfs-1.1.4/include/lzipfile.h --- old/avfs-1.1.3/include/lzipfile.h 1970-01-01 01:00:00.000000000 +0100 +++ new/avfs-1.1.4/include/lzipfile.h 2021-04-04 15:41:21.000000000 +0200 @@ -0,0 +1,27 @@ +/* + AVFS: A Virtual File System Library + Copyright (C) 2021 Ralf Hoffmann <[email protected]> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. + + based on zstdfile.h +*/ + +#ifndef LZIPFILE_H +#define LZIPFILE_H + +#include "avfs.h" + +struct lzipfile; +struct lzipcache; + +avssize_t av_lzipfile_pread(struct lzipfile *fil, struct lzipcache *zc, char *buf, + avsize_t nbyte, avoff_t offset); + +struct lzipfile *av_lzipfile_new(vfile *vf); +int av_lzipfile_size(struct lzipfile *fil, struct lzipcache *zc, avoff_t *sizep); +struct lzipcache *av_lzipcache_new(); +avoff_t av_lzipcache_size(struct lzipcache *zc); + +#endif /* LZIPFILE_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/missing new/avfs-1.1.4/missing --- old/avfs-1.1.3/missing 2020-08-12 22:18:32.000000000 +0200 +++ new/avfs-1.1.4/missing 2021-04-04 15:41:31.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -101,9 +101,9 @@ exit $st fi -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software +perl_URL=https://www.perl.org/ +flex_URL=https://github.com/westes/flex +gnu_software_URL=https://www.gnu.org/software program_details () { @@ -207,7 +207,7 @@ exit $st # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/modules/Makefile.am new/avfs-1.1.4/modules/Makefile.am --- old/avfs-1.1.3/modules/Makefile.am 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/modules/Makefile.am 2021-04-04 15:41:21.000000000 +0200 @@ -35,6 +35,10 @@ modules += uzstd.c endif +if USE_LIBLZIP + modules += ulzip.c +endif + libmodules_la_SOURCES = \ $(modules) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/modules/ulzip.c new/avfs-1.1.4/modules/ulzip.c --- old/avfs-1.1.3/modules/ulzip.c 1970-01-01 01:00:00.000000000 +0100 +++ new/avfs-1.1.4/modules/ulzip.c 2021-04-04 15:41:21.000000000 +0200 @@ -0,0 +1,327 @@ +/* + AVFS: A Virtual File System Library + Copyright (C) 2021 Ralf Hoffmann <[email protected]> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. + + ULZIP module (based on UZSTD module) +*/ + +#include "version.h" + +#include "lzipfile.h" +#include "filecache.h" +#include "cache.h" +#include "oper.h" +#include "version.h" + +struct lzipnode { + avmutex lock; + struct avstat sig; + struct cacheobj *cache; + avino_t ino; +}; + +struct lziphandle { + struct lzipfile *zfil; + vfile *base; + struct lzipnode *node; +}; + + +static void lzipnode_destroy(struct lzipnode *nod) +{ + av_unref_obj(nod->cache); + AV_FREELOCK(nod->lock); +} + +static struct lzipnode *lzip_new_node(ventry *ve, struct avstat *stbuf) +{ + struct lzipnode *nod; + + AV_NEW_OBJ(nod, lzipnode_destroy); + AV_INITLOCK(nod->lock); + nod->sig = *stbuf; + nod->cache = NULL; + nod->ino = av_new_ino(ve->mnt->avfs); + + return nod; +} + +static int lzip_same(struct lzipnode *nod, struct avstat *stbuf) +{ + if(nod->sig.ino == stbuf->ino && + nod->sig.dev == stbuf->dev && + nod->sig.size == stbuf->size && + AV_TIME_EQ(nod->sig.mtime, stbuf->mtime)) + return 1; + else + return 0; +} + +static struct lzipnode *lzip_do_get_node(ventry *ve, const char *key, + struct avstat *stbuf) +{ + static AV_LOCK_DECL(lock); + struct lzipnode *nod; + + AV_LOCK(lock); + nod = (struct lzipnode *) av_filecache_get(key); + if(nod != NULL) { + if(!lzip_same(nod, stbuf)) { + av_unref_obj(nod); + nod = NULL; + } + } + + if(nod == NULL) { + nod = lzip_new_node(ve, stbuf); + av_filecache_set(key, nod); + } + AV_UNLOCK(lock); + + return nod; +} + +static int lzip_getnode(ventry *ve, vfile *base, struct lzipnode **resp) +{ + int res; + struct avstat stbuf; + const int attrmask = AVA_INO | AVA_DEV | AVA_SIZE | AVA_MTIME; + struct lzipnode *nod; + char *key; + + res = av_fgetattr(base, &stbuf, attrmask); + if(res < 0) + return res; + + res = av_filecache_getkey(ve, &key); + if(res < 0) + return res; + + nod = lzip_do_get_node(ve, key, &stbuf); + + av_free(key); + + *resp = nod; + return 0; +} + +static struct lzipcache *lzip_getcache(ventry *base, struct lzipnode *nod) +{ + struct lzipcache *cache; + + cache = (struct lzipcache *) av_cacheobj_get(nod->cache); + if(cache == NULL) { + int res; + char *name; + + res = av_generate_path(base, &name); + if(res < 0) + name = NULL; + else + name = av_stradd(name, "(index)", NULL); + + cache = av_lzipcache_new(); + av_unref_obj(nod->cache); + + /* FIXME: the cacheobj should only be created when the lzipcache + is nonempty */ + nod->cache = av_cacheobj_new(cache, name); + av_free(name); + } + + return cache; +} + +static int lzip_lookup(ventry *ve, const char *name, void **newp) +{ + char *path = (char *) ve->data; + + if(path == NULL) { + if(name[0] != '\0') + return -ENOENT; + if(ve->mnt->opts[0] != '\0') + return -ENOENT; + path = av_strdup(name); + } + else if(name == NULL) { + av_free(path); + path = NULL; + } + else + return -ENOENT; + + *newp = path; + return 0; +} + +static int lzip_access(ventry *ve, int amode) +{ + return av_access(ve->mnt->base, amode); +} + +static int lzip_open(ventry *ve, int flags, avmode_t mode, void **resp) +{ + int res; + vfile *base; + struct lzipnode *nod; + struct lziphandle *fil; + + if(flags & AVO_DIRECTORY) + return -ENOTDIR; + + if(AV_ISWRITE(flags)) + return -EROFS; + + res = av_open(ve->mnt->base, AVO_RDONLY, 0, &base); + if(res < 0) + return res; + + res = lzip_getnode(ve, base, &nod); + if(res < 0) { + av_close(base); + return res; + } + + AV_NEW(fil); + if((flags & AVO_ACCMODE) != AVO_NOPERM) + fil->zfil = av_lzipfile_new(base); + else + fil->zfil = NULL; + + fil->base = base; + fil->node = nod; + + *resp = fil; + return 0; +} + +static int lzip_close(vfile *vf) +{ + struct lziphandle *fil = (struct lziphandle *) vf->data; + + av_unref_obj(fil->zfil); + av_unref_obj(fil->node); + av_close(fil->base); + av_free(fil); + + return 0; +} + +static avssize_t lzip_read(vfile *vf, char *buf, avsize_t nbyte) +{ + avssize_t res; + struct lziphandle *fil = (struct lziphandle *) vf->data; + struct lzipcache *zc; + struct cacheobj *cobj; + avoff_t prev_cachesize; + + AV_LOCK(fil->node->lock); + zc = lzip_getcache(vf->mnt->base, fil->node); + cobj = fil->node->cache; + av_ref_obj(cobj); + AV_UNLOCK(fil->node->lock); + + prev_cachesize = av_lzipcache_size(zc); + + res = av_lzipfile_pread(fil->zfil, zc, buf, nbyte, vf->ptr); + if(res > 0) { + avoff_t new_cachesize; + + vf->ptr += res; + + new_cachesize = av_lzipcache_size(zc); + if (new_cachesize != prev_cachesize) { + av_cacheobj_setsize(cobj, new_cachesize); + } + } else { + AV_LOCK(fil->node->lock); + av_unref_obj(fil->node->cache); + fil->node->cache = NULL; + AV_UNLOCK(fil->node->lock); + } + + av_unref_obj(zc); + av_unref_obj(cobj); + + return res; +} + +static int lzip_getattr(vfile *vf, struct avstat *buf, int attrmask) +{ + int res; + struct lziphandle *fil = (struct lziphandle *) vf->data; + struct lzipnode *nod = fil->node; + avoff_t size; + const int basemask = AVA_MODE | AVA_UID | AVA_GID | AVA_MTIME | AVA_ATIME | AVA_CTIME; + struct lzipcache *zc; + struct cacheobj *cobj; + + res = av_fgetattr(fil->base, buf, basemask); + if(res < 0) + return res; + + AV_LOCK(fil->node->lock); + zc = lzip_getcache(vf->mnt->base, fil->node); + cobj = fil->node->cache; + av_ref_obj(cobj); + AV_UNLOCK(fil->node->lock); + + if((attrmask & (AVA_SIZE | AVA_BLKCNT)) != 0) { + res = av_lzipfile_size(fil->zfil, zc, &size); + if(res == 0 && size == -1) { + fil->zfil = av_lzipfile_new(fil->base); + res = av_lzipfile_size(fil->zfil, zc, &size); + } + if(res < 0) { + av_unref_obj(zc); + av_unref_obj(cobj); + + return res; + } + + buf->size = size; + buf->blocks = AV_BLOCKS(buf->size); + } + + buf->mode &= ~(07000); + buf->blksize = 4096; + buf->dev = vf->mnt->avfs->dev; + buf->ino = nod->ino; + buf->nlink = 1; + + av_unref_obj(zc); + av_unref_obj(cobj); + + return 0; +} + +extern int av_init_module_ulzip(struct vmodule *module); + +int av_init_module_ulzip(struct vmodule *module) +{ + int res; + struct avfs *avfs; + struct ext_info ulzip_exts[3]; + + ulzip_exts[0].from = ".tar.lz", ulzip_exts[0].to = ".tar"; + ulzip_exts[1].from = ".lz", ulzip_exts[1].to = NULL; + ulzip_exts[2].from = NULL; + + res = av_new_avfs("ulzip", ulzip_exts, AV_VER, AVF_NOLOCK, module, &avfs); + if(res < 0) + return res; + + avfs->lookup = lzip_lookup; + avfs->access = lzip_access; + avfs->open = lzip_open; + avfs->close = lzip_close; + avfs->read = lzip_read; + avfs->getattr = lzip_getattr; + + av_add_avfs(avfs); + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/src/Makefile.am new/avfs-1.1.4/src/Makefile.am --- old/avfs-1.1.3/src/Makefile.am 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/src/Makefile.am 2021-04-04 15:41:21.000000000 +0200 @@ -46,6 +46,10 @@ libavfscore_la_SOURCES += zstdread.c endif +if USE_LIBLZIP +libavfscore_la_SOURCES += lzipread.c +endif + noinst_HEADERS = \ archint.h \ filtprog.h \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/src/lzipread.c new/avfs-1.1.4/src/lzipread.c --- old/avfs-1.1.3/src/lzipread.c 1970-01-01 01:00:00.000000000 +0100 +++ new/avfs-1.1.4/src/lzipread.c 2021-04-04 15:41:21.000000000 +0200 @@ -0,0 +1,437 @@ +/* + AVFS: A Virtual File System Library + Copyright (C) 2021 Ralf Hoffmann <[email protected]> + + This program can be distributed under the terms of the GNU GPL. + See the file COPYING. + + based on zstdread.c +*/ + +#include "config.h" +#include "lzipfile.h" +#include "oper.h" +#include "exit.h" + +#include <stdlib.h> +#include <inttypes.h> +#include <fcntl.h> +#include <lzlib.h> + +#define INDEXDISTANCE 1048576 +#define LOOKUP_COST_DISTANCE (16 * 1024) // cost for searching for + // cached member post instead + // of just seeking forward + +#define INBUFSIZE 16384 +#define OUTBUFSIZE 32768 + +static AV_LOCK_DECL(lzipread_lock); + +struct lzipindex { + avoff_t o_offset; /* The number of output bytes */ + avoff_t i_offset; /* The offset within the input file where the member begins */ + struct lzipindex *next; +}; + +struct lzipcache { + avoff_t cachesize; // size of cache used to decide for cleanup + avoff_t nextindex; // min position when next index should happen + avoff_t size; // output file size + struct lzipindex *indexes; +}; + +struct lzipfile { + struct LZ_Decoder *decoder; + int iseof; + int iserror; + + vfile *infile; + + avoff_t total_in; + avoff_t total_out; + avoff_t last_member_pos; + + char *outbuf; + size_t outbuf_size; + size_t output_pos; +}; + +static void lzip_delete_decoder(struct LZ_Decoder *decoder) +{ + if(decoder != NULL) { + LZ_decompress_close(decoder); + } +} + +static int lzip_new_decoder(struct LZ_Decoder **resp) +{ + struct LZ_Decoder *decoder; + + decoder = LZ_decompress_open(); + + if(decoder == NULL) { + *resp = NULL; + av_log(AVLOG_ERROR, "LZIP: could not create decompress decoder"); + return -EIO; + } + + *resp = decoder; + return 0; +} + +static int lzipfile_reset(struct lzipfile *fil) +{ + lzip_delete_decoder(fil->decoder); + + fil->iseof = 0; + fil->iserror = 0; + fil->total_in = fil->total_out = 0; + fil->last_member_pos = 0; + return lzip_new_decoder(&fil->decoder); +} + +static int lzipfile_save_index(struct lzipfile *fil, struct lzipcache *zc, + avoff_t o_offset, + avoff_t i_offset) +{ + struct lzipindex **zp; + struct lzipindex *zi; + + for(zp = &zc->indexes; *zp != NULL; zp = &(*zp)->next); + + AV_NEW(zi); + zi->o_offset = o_offset; + zi->i_offset = i_offset; + zi->next = NULL; + + *zp = zi; + + zc->nextindex += INDEXDISTANCE; + zc->cachesize += sizeof(*zi); + + return 0; +} + +static struct lzipindex *lzipcache_find_index(struct lzipcache *c, avoff_t offset) +{ + struct lzipindex *prevzi; + struct lzipindex *zi; + + prevzi = NULL; + for(zi = c->indexes; zi != NULL; zi = zi->next) { + if(zi->o_offset > offset) + break; + prevzi = zi; + } + + return prevzi; +} + +static int lzipfile_fill_inbuf(struct lzipfile *fil) +{ + avssize_t res; + char buf[INBUFSIZE]; + int ret; + int size = AV_MIN(sizeof(buf), LZ_decompress_write_size(fil->decoder)); + + if (size <= 0) { + return 0; + } + + res = av_pread(fil->infile, buf, size, fil->total_in); + if(res < 0) + return res; + + ret = LZ_decompress_write(fil->decoder, (const uint8_t*)buf, res); + if ( ret < 0 ) { + return ret; + } + + fil->total_in += ret; + + if ( res == 0 ) { + LZ_decompress_finish(fil->decoder); + } + + return 0; +} + +static int lzipfile_decompress(struct lzipfile *fil, struct lzipcache *zc) +{ + int res; + int ret; + + if (fil->outbuf_size == 0) return 0; + + for (;;) { + res = lzipfile_fill_inbuf(fil); + if(res < 0) + return res; + + ret = LZ_decompress_read(fil->decoder, (uint8_t*)fil->outbuf + fil->output_pos, fil->outbuf_size - fil->output_pos); + if( ret < 0 ) { + av_log(AVLOG_ERROR, "LZIP: decompress error"); + return -EIO; + } + if (LZ_decompress_member_finished(fil->decoder)){ + AV_LOCK(lzipread_lock); + if(fil->total_out + ret >= zc->nextindex) { + res = lzipfile_save_index(fil, zc, + fil->total_out + ret, + fil->last_member_pos + LZ_decompress_member_position(fil->decoder)); + } + AV_UNLOCK(lzipread_lock); + + fil->last_member_pos += LZ_decompress_member_position(fil->decoder); + } + + fil->total_out += ret; + fil->output_pos += ret; + + if (ret == 0) { + if (LZ_decompress_total_in_size(fil->decoder) == fil->total_in) { + fil->iseof = 1; + AV_LOCK(lzipread_lock); + zc->size = fil->total_out; + AV_UNLOCK(lzipread_lock); + break; + } + } + + if (fil->output_pos == fil->outbuf_size) { + // everything we are requested for is available + break; + } + } + + return 0; +} + + +static int lzipfile_read(struct lzipfile *fil, struct lzipcache *zc, char *buf, + avsize_t nbyte) +{ + int res; + int sum = 0; + + while (nbyte > 0 && !fil->iseof) { + fil->outbuf = buf; + fil->outbuf_size = nbyte; + fil->output_pos = 0; + + res = lzipfile_decompress(fil, zc); + if(res < 0) + return res; + + if (fil->output_pos == 0) { + fil->iseof = 1; + } else { + buf += fil->output_pos; + nbyte -= fil->output_pos; + sum += fil->output_pos; + } + } + + return sum; +} + +static int lzipfile_skip_to(struct lzipfile *fil, struct lzipcache *zc, + avoff_t offset) +{ + int res; + char outbuf[OUTBUFSIZE]; + + while(!fil->iseof) { + avoff_t curroff = fil->total_out; + + if(curroff == offset) + break; + + fil->outbuf = outbuf; + fil->outbuf_size = AV_MIN(OUTBUFSIZE, offset - curroff);; + fil->output_pos = 0; + + res = lzipfile_decompress(fil, zc); + if(res < 0) + return res; + + if (fil->output_pos == 0) { + fil->iseof = 1; + } + } + + return 0; +} + +static int lzipfile_seek(struct lzipfile *fil, struct lzipcache *zc, avoff_t offset) +{ + struct lzipindex *zi; + + if ( fil->total_out < offset && offset - fil->total_out < LOOKUP_COST_DISTANCE ) { + // do nothing if we just need to go slightly forward + return 0; + } + + zi = lzipcache_find_index(zc, offset); + + if(zi == NULL) { + if (fil->total_out > offset) { + return lzipfile_reset(fil); + } + } else { + int res; + + if ( zi->o_offset < fil->total_out && + offset > fil->total_out ) { + return 0; + } + + res = lzipfile_reset(fil); + if ( res < 0 ) { + return res; + } + fil->total_in = zi->i_offset; + fil->total_out = zi->o_offset; + fil->last_member_pos = zi->i_offset; + + LZ_decompress_sync_to_member(fil->decoder); + } + + return 0; +} + +static int lzipfile_goto(struct lzipfile *fil, struct lzipcache *zc, avoff_t offset) +{ + int res; + + AV_LOCK(lzipread_lock); + res = lzipfile_seek(fil, zc, offset); + AV_UNLOCK(lzipread_lock); + if(res == 0) { + res = lzipfile_skip_to(fil, zc, offset); + } + + return res; +} + +static avssize_t av_lzipfile_do_pread(struct lzipfile *fil, struct lzipcache *zc, + char *buf, avsize_t nbyte, avoff_t offset) +{ + avssize_t res; + avoff_t curroff; + + curroff = fil->total_out; + if(offset != curroff) { + res = lzipfile_goto(fil, zc, offset); + if(res < 0) + return res; + } + + res = lzipfile_read(fil, zc, buf, nbyte); + + return res; +} + +avssize_t av_lzipfile_pread(struct lzipfile *fil, struct lzipcache *zc, char *buf, + avsize_t nbyte, avoff_t offset) +{ + avssize_t res; + + if(fil->iserror) + return -EIO; + + res = av_lzipfile_do_pread(fil, zc, buf, nbyte, offset); + if(res < 0) + fil->iserror = 1; + + return res; +} + +int av_lzipfile_size(struct lzipfile *fil, struct lzipcache *zc, avoff_t *sizep) +{ + int res; + avoff_t size; + + AV_LOCK(lzipread_lock); + size = zc->size; + AV_UNLOCK(lzipread_lock); + + if(size != -1 || fil == NULL) { + *sizep = size; + return 0; + } + + res = lzipfile_reset( fil ); + if(res < 0) + return res; + + res = lzipfile_skip_to(fil, zc, AV_MAXOFF); + if(res < 0) + return res; + + AV_LOCK(lzipread_lock); + size = zc->size; + AV_UNLOCK(lzipread_lock); + + if(size == -1) { + av_log(AVLOG_ERROR, "LZIP: Internal error: could not find size"); + return -EIO; + } + + *sizep = size; + return 0; +} + +static void lzipfile_destroy(struct lzipfile *fil) +{ + lzip_delete_decoder(fil->decoder); +} + +struct lzipfile *av_lzipfile_new(vfile *vf) +{ + int res; + struct lzipfile *fil; + + AV_NEW_OBJ(fil, lzipfile_destroy); + fil->iseof = 0; + fil->iserror = 0; + fil->infile = vf; + fil->total_in = fil->total_out = 0; + fil->last_member_pos = 0; + + res = lzip_new_decoder(&fil->decoder); + if(res < 0) + fil->iserror = 1; + + return fil; +} + +static void lzipcache_destroy(struct lzipcache *zc) +{ + struct lzipindex *zi; + struct lzipindex *nextzi; + + for(zi = zc->indexes; zi != NULL; zi = nextzi) { + nextzi = zi->next; + av_free(zi); + } +} + +struct lzipcache *av_lzipcache_new() +{ + struct lzipcache *zc; + + AV_NEW_OBJ(zc, lzipcache_destroy); + zc->size = -1; + zc->cachesize = 0; + zc->indexes = NULL; + zc->nextindex = INDEXDISTANCE; + + return zc; +} + +avoff_t av_lzipcache_size(struct lzipcache *zc) +{ + return zc->cachesize; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/avfs-1.1.3/test/testread.c new/avfs-1.1.4/test/testread.c --- old/avfs-1.1.3/test/testread.c 2020-08-12 22:18:21.000000000 +0200 +++ new/avfs-1.1.4/test/testread.c 2021-04-04 15:41:21.000000000 +0200 @@ -32,7 +32,7 @@ fd = virt_open( argv[1], O_RDONLY, 0 ); if ( fd >= 0 ) { - ssize_t total_len; + ssize_t total_len = 0; for (;;) { len = virt_read( fd, buf, sizeof( buf ) );
