Subject: Re: more on dinode
To: Jukka Marin <jmarin@pyy.jmp.fi>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 12/03/1997 06:45:31
On Wed, 3 Dec 1997 07:32:53 +0200 
 Jukka Marin <jmarin@pyy.jmp.fi> wrote:

 > Sorry, but I think this is one of the worst things on mac. ;-)  When an
 > average user (like me) transfers a file from mac to some real computer
 > (sorry :), he will soon discover that he can't read the gif/tiff/whatever
 > file on other systems because mac has corrupted the file by adding 128
 > bytes of garbage in front of it.  I think the Amiga's way was better -
 > keeping the Amiga specific information in a separate .info file so the
 > data file remained untouched.
 > 
 > Well, this is Yet Another Religious Issue.. but puh-lease don't force me
 > to use mac-like kludges on NetBSD :-(

The only think kludgy about the MacOS resource fork, IMO, is the fact that
you DO have the small bit of metadata at the front of the file.

In NetBSD, however, the pointer to a resource-fork like item could indeed
be in the dinode.

I would suggest:

	int32_t		di_spare[2];	/* 120: Reserved; currently unused */
becomes
	ufs_daddr_t	di_aux;		/* 120: Pointer to auxillary data */
	int32_t		di_spare;	/* 124: Reserved; currently unused */

...adding a "aux is valid" flag to di_flags, and creating a new structure:

struct dinode_aux {
	u_int32_t	dia_tag;	/*   0: Opaque tag */
	u_int32_t	dia_flags;	/*   4: Flags; see below */
	u_int32_t	dia_len;	/*   8: Length of variable size data */
	ufs_daddr_t	dia_next;	/*  12: Linked list of aux data */
	/*
	 * 16: Auxillary data, variable size, bounded by file system
	 *     block size.
	 */
	u_int32_t	dia_data[1];
};

/* dia_flags */
#define	DIAF_NEXT_VALID	0x00000001	/* dia_next is valid */

There should be a set of functions that:

	* allocate a fs block for a dinode_aux

	* attach dinode_aux to dinode (possibly at end of linked list),
	  storing it at the specified fs block number.

	* find a dinode_aux matching a specified tag

	* remove a dinode_aux from dinode

	* free a fs block used by a dinode_aux

Note allocation and freeing of dinode_aux blocks are separate from
attach/remove so that dinode_aux data can be easily moved from inode to
inode.

Thoughts/comments?

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-6                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 415 428 6939