Subject: RE: NeXT file systems
To: None <mycroft@domino.org>
From: Marc Boschma <marcb@bms.itg.telecom.com.au>
List: current-users
Date: 02/08/1996 11:07:30
Charles M. Hannum <mycroft@domino.org> wrote:

>Just for the record, if someone wrote changes to byte-swap a FFS file
>system automatically, and they didn't intrude on performance too much
>for native byte-order file systems, I'd be quite happy to see them...

Maybe the best way to acheieve this is that a separate file system, based
(or utilising the source of FFS with #defines) could be the best way.

ie. beffs	Big Endian FFS
    lefss	Little Endian FFS

In fact all that FFS would be is one of those, depending upon the architecture.

Maybe the ntoh?/hton? routines could be used...

I'd do a something like this to the FFS code:

#if defined(BEFFS)
#include <sys/param.h>
#	if BYTE_ORDER == BIG_ENDIAN
#define HTOFSL(x)		htonl(x)	/* host to FFS long */
....
#	else
#define HTOFSL(x)		(x)	/* host to FFS long */
....
#endif /* BYTE_ORDER */

#elsif defined(LEFSS)
#include <sys/param.h>
#       if BYTE_ORDER == LITTLE_ENDIAN
#define HTOFSL(x)		htonl(htonl((x))) /* host to FFS long */
....
#	else
#define HTOFSL(x)		htonl(htonl((x))) /* host to FFS long */
....
#	endif /* BYTE_ORDER */

#else /* native FSS */
#define HTOFSL(x)		(x)	/* host to FFS long */
....
#endif

and then when structures are being written out (read in), utilise the
macros. Since on big endian machines hton?/ntoh? are null macros's the
BEFSS would be as fast as native FFS.

In the case where the macros are null, the compiler should remove
the conversions.

ie.

	unsigned long	f = some_value;

	readin(f);
	f = FSTOHL(f);
...
	f = HTOFSL(f);
	writeout(f);

would end up being:

	readin(f);
	f = (f);
...
	f = (f);
	writeout(f);

the advantage of all this is that any changes to the FFS code would be
reflected in BEFFS and LEFSS.

Now is it enough to just convert the structures, or are there size problems
with the structures on different architecures (different pack rules for
alignment etc.) ?

I can see a possible problem with 64 bit machines, or FFS clean enough on
that score ?

Marc B.
-------
Marc Boschma                          Email:    marcb@telstra.com.au
Senior Software Specialist            Smail:    Locked Bag No. 4840
Broadband and Multimedia Systems,               Melbourne, VIC  8100
Network Systems, ITG.                 Phone:    +61 3 9634 8798
Telstra                               Fax:      +61 3 9634 5469