[AVFS] Patch for inode calculation and fix of bzlib

Ralf Hoffmann <[email protected]> Thu, 26 May 2005 19:51:59 +0200
Newsgroups gmane.comp.file-systems.avfs.user
Message-ID <[email protected]>
Hi,

Attached is another patch which changes the inode calculation for the
virtual files in /#avfsstat as discussed. I also fixed the bzlib so it
doesn't hangs anymore when accessing a corrupt bz2 archive.
"bzfile_decompress" will now return -EIO if there are no bytes available
after fill_inbuf. I hope this solution is okay.

I will also update the extfs scripts to include the latest versions from
mc. Is there something I need to care about (changes in extfs interface
or something)?

Currently I change the build process to use automake/libtool. Using
automake the package should be easier to maintain. As a side effect the
shared library gets version information so it's much easier to change
the code as the linker will refuse to use the library if the version
doesn't match. The build process already works for the shared library
but I have problems with the kernel modules and additional scripts for
avfscode (emacs script/rc scripts and so), but nothing unsolveable (I
hope :-)
In the end I hope that new version are much easier to do (think of "make
dist") and perhaps at least the shared library will be portable to more
systems (as libtool handles the build process).

What do you think about this?

Best Regards,

Ralf Hoffmann

-- 
Homepage: http://www.boomerangsworld.de
E-Mail: Ralf Hoffmann <[email protected]>
  english or german
avfs-cvs-patch4.diff (text/x-patch, 1.7 KB)
diff -u -r1.1.1.1 -r1.2
--- bzlib/bzread.c	25 May 2005 18:10:46 -0000	1.1.1.1
+++ bzlib/bzread.c	25 May 2005 19:05:20 -0000	1.2
@@ -260,6 +260,11 @@
         res = bzfile_fill_inbuf(fil);
         if(res < 0)
             return res;
+	if(fil->s->avail_in == 0) {
+	  /* still no byte available */
+	  av_log(AVLOG_ERROR, "BZFILE: decompress error");
+	  return -EIO;
+	}
     }
     
     start = fil->s->next_out;
diff -u -r1.1.1.1 -r1.2
--- src/state.c	25 May 2005 18:10:47 -0000	1.1.1.1
+++ src/state.c	25 May 2005 19:05:49 -0000	1.2
@@ -273,6 +273,11 @@
 
     /* FIXME: Make ino be some hash function of param and entry */
     buf->ino = (int) stf + st_paramhash(sf->stent->param);
+    /* add hash of entry name to hash */
+    buf->ino += st_paramhash( buf->name );
+    /* make sure ino is not 0 or 1 */
+    buf->ino = (avino_t)((((unsigned int)buf->ino) % (~0U - 1)) + 2);
+    
     buf->type = 0;
     av_unref_obj(ent);
     
@@ -285,6 +290,7 @@
 {
     struct stfile *sf = st_vfile_stfile(vf);
     struct statefile *stf;
+    char *ent_name;
 
     if(sf->stent->ent != NULL)
         stf = (struct statefile *) av_namespace_get(sf->stent->ent);
@@ -294,6 +300,16 @@
     av_default_stat(buf);
     /* This isn't perfect, but... */
     buf->ino = (int) stf + st_paramhash(sf->stent->param);
+
+    /* add hash of entry name to hash */
+    if( sf->stent->ent != NULL ) {
+      ent_name = av_namespace_name( sf->stent->ent );
+      buf->ino += st_paramhash( ent_name );
+      av_free( ent_name );
+    }
+    /* make sure ino is not 0 or 1 */
+    buf->ino = (avino_t)((((unsigned int)buf->ino) % (~0U - 1)) + 2);
+    
     buf->dev = vf->mnt->avfs->dev;
     if(stf != NULL) {
         if(stf->set != NULL)