Scott Grosch <[EMAIL PROTECTED]> write:
> I have a call open with Transarc on this, but I figure somebody might hav
> done this already.  If I do a vos dump, I want to be able to parse that
> output and find out what files are in the dump.  I don't care what any of
> the data is, or how to read it, if you can just give me something like:
>
> read 89 bytes of header info, then every time you hit the XXX block, you'll
> know the next thing is a filename.

The program in 
        /afs/umich.edu/group/itd/ftp/sysadm/perfmon/xd.c
can read and parse vos dumps.

We use it to filter vos dumps as part of populating new user
home directories; specifically, it changes the acl's & file ownership
to match that of the person who is being issued a home directory.
It gets used in this rather unlikely looking shell script line:

/home/hdserver/xd -Q $QUOTA -M '' ${UID} -M 29048 ${UID} -M -101 '' \
        -M 2 '' -M -204 '' -M -1376 -101 -L "#user.generic.backup." \
        "#${user_vol}.${id}.backup." -o - /home/hdserver/generic.backup \
        | /usr/vice/bin/vos restore -server $vol_server -partition \
        $vol_part -name $user_vol.${id}

This won't suffice to return filenames, because they are not stored
as you might think in front of each file.  Instead, you will have
to read through the entire vos dump, parse the contents of
each "vDirectory" type file found in the dump, and at
the end, you will then have the information needed to construct
all the filenames.  The work involved in doing this is very much
like the UNIX utility "ncheck".

In order to parse AFS directory contents, you might be able to
make use of the "libdir" directory distributed with AFS,
in lib/afs/libdir.a.  There is an dir_EnumerateDir function
that looks like what you want.  You will need to supply a
"DRead" function that can fetch elements from the vos dump.
I don't know if transarc describes either of these functions
in enough detail to make them useful.

If you can't figure out how it works or find they aren't useful
as they stand, then you will need to figure out how to parse directories
on your own.  The file include/afs/dir.h has some structures and other
manifests that should make this possible.  It may help to know that
entries are stored in a list of one or more contiguous 32-byte blobs
(struct DirEntry and struct DirXEntry).  Directories are enumerated
by reading through the hash table ((struct DirHeader).hashTable), which
is found at the start of the directory, and then traversing each chain
so found (the hash link is (struct DirEntry).next).

Good luck.

                                -Marcus Watts
                                UM ITD PD&D Umich Systems Group

Reply via email to