[comp.sys.sun] dbm

gfl@relay.eu.net (Gerhard Fleischanderl) (10/17/89)

When I tried to use a dbm database from Sun386i and Sun-3 (both running
SunOS 4.0.1), I encountered a strange effect.  If the dbm file is created
on a Sun386i, I cannot read it from the Sun-3 (and vice versa) !

The dbm(3x) routines firstkey() and fetch() both report "bad block" and
dump core, when they access a dbm file created on the other architecture.
The respective ".pag" files, which are created by identical instructions,
differ in their 10 leading bytes obeying to the following pattern:

   Byte  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  10  |
---------|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
Sun386i  |  A  |  B  |  C  |  D  |  E  |  F  |  G  |  H  |  I  |  J   |
  Sun-3  |  B  |  A  |  D  |  C  |  F  |  E  |  H  |  G  |  J  |  I   |

Maybe the difference in byte ordering on 68020 and 80386, resp., is the
reason for this incompatibility.  An interesting aspect is that dbm files
created on a MicroVax (Ultrix 3.0) are identical to those from a Sun386i.

My priority question is: How can I access a dbm file, which has been
created on a Sun386i (== MicroVax), on a Sun-3?  (I need this to run the
news software in a heterogeneous network.)

Any help will be appreciated. If I will receive anything interesting, I
will summarize to the list.

Gerhard Fleischanderl

Institut fuer Angewandte Informatik, Technical University Vienna
Paniglgasse 16,  A-1040 Vienna, Austria
e-mail: gfl@vexpert.uucp

henry@cs.utexas.edu (10/24/89)

>When I tried to use a dbm database from Sun386i and Sun-3 (both running
>SunOS 4.0.1), I encountered a strange effect.  If the dbm file is created
>on a Sun386i, I cannot read it from the Sun-3 (and vice versa) !

The format of dbm databases is (a) undocumented, and (b) machine-specific.
Short of reimplementing dbm, there is no general cure that I know of.  It
isn't necessarily just a byte-ordering problem; there is also the question
of whether dbm's hash function is machine-dependent.

>... (I need this to run the news software in a heterogeneous network.)

I am exploring the possibility of fixing Jon Zeeff's "dbz", which is a
partial dbm lookalike sufficient for news, to be byte-order-independent.

                                     Henry Spencer at U of Toronto Zoology
                                 uunet!attcan!utzoo!henry henry@zoo.toronto.edu