Re: VFS for afio



Pavel Roskin said on 02.04.2004 09:59:

cpio is handled internally now, see vfs/cpio.c.  Unfortunately, it's only
supported read-only.
You don't have to use awk.  Many extfs scripts use Perl.  If afio archives
are indeed cpio compatible as
http://www.gnu.org/directory/All_Packages_in_Directory/afio.html claims,
you can use internal read-only cpio support instead of writing an extfs
script.  See the cpio entry in mc.ext.

Yes, I know. But that seems to work only for uncompressed ASCII afio
archives (-Z option within afio). So I fired up vi and used Stas
Maximov's ucpio script as a basis for my uafio script:

,---- [ uafio ]
| #!/bin/sh
|
| uni_cat ()
| # $1 is the archive name
| {
|     case "$1" in
|     *.gz.afio)  afio -Ztv "$1"
|       ;;
|     *.afio)     afio -tv  "$1"
|       ;;
|     *)          echo "unknown extension"
|     esac
| }
|
| uni_extr ()
| # $1 is the archive name
| # $2 is the name of the file within the archive
| {
|     case "$1" in
|     *.gz.afio)  afio -iZy "$2" "$1"
|       ;;
|     *.afio)     afio -iy  "$2" "$1"
|       ;;
|     *)          echo "unknown extension"
|     esac
| }
|
| mcafiofs_list ()
| # $1 is the archive name
| {
|     uni_cat "$1" | awk '
|         {
|             if (substr($1,1,1) != "-")  # Dir, Symlink, ...
|             {
|               $4  = $4." 0";
|               tmp = $7; $7 = $8; $8 = tmp;
|               $8  = substr($8,1,5);
|             }
|             else
|             {
|               tmp = $8; $8 = $9; $9 = tmp;
|               $9 = substr($9,1,5);
|             }
|
|             sub("S->","->",$0);
|             sub(" -- compressed$","",$0);
|
|             print $0
|         }'
| }
|
| mcafiofs_copyout ()
| # $1 is the archive name
| # $2 is a name of a file within the archive
| # $3 is a name of a file within the system (to add from or extract to)
| {
|     TMPDIR=/tmp/mctmpdir.$$
| # FIXME: Try harder to generate a unique directory if this fails
|     mkdir -m 0700 $TMPDIR || exit 1
|     cd $TMPDIR
|     uni_extr "$1" "$2" 2>/dev/null
|     mv "$2" "$3"
|     cd /
|     rm -rf $TMPDIR
| }
|
| #
| # main
| #
|     umask 077
|
|     case "$1" in
|     list)    mcafiofs_list $2
|              exit 0
|                ;;
|     copyout) mcafiofs_copyout $2 $3 $4
|              exit 0
|                ;;
|     esac
|
|     exit 1
|
`----

Yes, I know it's ugly... ;-) But it seems to work - at least a bit. It
is possible to view a afio archive. It is also possible to copyout a
file. But there are still two problems with that script:

1. It is not possible to view a file within the archive (F3 button).
   What happens is that mc only shows part of the file?!? Why?

2. "uafio list" seems to produce correct output for mc. But still the
    time always shows up as "00.00". Why?

I can't figure out what the problem is, so maybe someone could point me
to the right direction?! Thanks a lot!

Regards,

--
Tom
list billroth de





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]