Summary: dbm(3x) discrepancy on Sun386i / Sun-3

Gerhard Fleischanderl vexpert!gfl at relay.eu.net
Sat Nov 4 05:27:28 AEST 1989


My question was:

> X-Sun-Spots-Digest: Volume 8, Issue 167, message 14 of 17
> 
> 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) !
> 	[...]
> My priority question is: How can I access a dbm file, which has been
> created on a Sun386i, on a Sun-3?  (I need this to run the
> news software in a heterogeneous network.)

madd at world.std.com (Jim Frost):

It should be a byte-ordering problem.  The VAX and 386 architectures are
both little-endian, while the 68k is big-endian.  (Swift would be sickened
at this use of his work, I think :-)

A simple solution is to build a utility which takes a textual key/content
pair and makes a dbm file and another which generates the pairs from a dbm
file, then rsh between the mahines.  We basically did this when building a
product which had to run on just about any architecture.  It was kind of
sickening but it worked.

Alternatively you can modify dbm (or maybe gdbm which is easier to get
source for) to handle all ints the same way.  [...]

Networked hosts have long had the byte-ordering problem, so you'll find
that your standard UNIX libraries have htons, htoni, htonl, ntohs, ntohi,
and ntohl.  What these do is convert from host to network byte orders and
network to host byte orders for short, integer, and long types.  On
most-significant-byte-first systems (or big-endian), these functions
return their argument and are generally implemented as no-ops.  On
little-endian systems they reverse the order of the bytes and return that
value.  

[...]

(Jim, thank you for detailed explanations.)

henry at zoo.toronto.edu (Henry Spencer):

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.

Some others also pointed out that this dbm(3x) incompatibility
is a byte-ordering problem:
	trinkle at cs.purdue.edu (Daniel Trinkle)
	poffen at sj.ate.slb.com (Russ Poffenberger)
		[he, too, mentioned 'htons']
	guy at auspex.UUCP (Guy Harris)
		[he also mentioned "dbz" and proposed NNTP]
	jim at applix.com (Jim Morton)

To access the dbm database on a remote host, some people recommended
to use network routines (RPC, XDR, ...):
	ral at aristotle-gw.jpl.nasa.gov (Roger Lighty)
	lvirden at pro-tcc.cts.com (Larry W. Virden)

Thanks to all of them.

At the moment, I'm still in search of sources for dbm-equivalent routines
(as I prefer treating an NFS-mounted file directly to accessing it via
NNTP).

Gerhard Fleischanderl

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



More information about the Comp.sys.sun mailing list