AVFS

Overview

AVFS is virtual file system layer for transparently accessing the content of archives and remote directories just like local files. Currently it can access natively tar, rar, zip, ar, gzip, bzip2, ftp, http, dav and some other.

AVFS also supports extfs, the same extensible interface as known from Midnight Commander, so AVFS can be extended to support new file systems easily. Support for debian archives, rpm archives, iso9660 images, patch files and other archives like lha, arj or cpio is available.

AVFS can be used with FUSE to enable access to archives from any application. AVFS can also be used as a stand-alone shared library if FUSE is not available or unwanted.

AVFS is

AVFS has been developed by Miklos Szeredi and it's currently developed by him and myself.

On the project home page you can find downloads, issue tracker, and also the git repository.

Latest version and download

The current release is avfs 1.1.5 (609 kB) (signature) from 2023-02-18.

AVFS for users

For example, the user can access archives by just adding the character # at the end of the file name:

linux-2.6.10.tar.gz#
It also works when accessing an archive inside another archive:
archive1.tar.gz#/some_other_archive.zip#

This is much easier than URL like access (e.g., tar://linux-2.6.10.tar.gz).

AVFS for developers

Adding support for AVFS for own programs is almost as easy as using it. Since AVFS can be used program independently by using the FUSE interface, the programmer just has to take care of the additional # character to support AVFS.

But even if FUSE support is not available or unwanted (for portability reasons) the programmer can still use AVFS as shared or static linked library. The developer just needs to replace the usual file access functions open, read, write, close and so on by the AVFS equivalents virt_open, virt_read, virt_write, virt_close.

Here is a small example. It outputs the first 128 bytes of a file:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main( int argc, char **argv )
{
  int fd;
  ssize_t len;
  char buf[128];
  
  fd = open( "testfile", O_RDONLY, 0 );
  if ( fd >= 0 ) {
    len = read( fd, buf, sizeof(buf) );
    buf[ sizeof( buf ) - 1 ] = '\0';
    printf("Bytes read: %dn%sn", len, buf );
    close( fd );
  }
  return 0;
}
and here the equivalent implementation using AVFS:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <virtual.h>  /* AVFS include */

int main( int argc, char **argv )
{
  int fd;
  ssize_t len;
  char buf[128];
  
  fd = virt_open( "testfile", O_RDONLY, 0 );
  if ( fd >= 0 ) {
    len = virt_read( fd, buf, sizeof(buf) );
    buf[ sizeof( buf ) - 1 ] = '\0';
    printf("Bytes read: %dn%sn", len, buf );
    virt_close( fd );
  }
  return 0;
}