[BACK]Return to efs_dinode.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / efs

File: [cvs.NetBSD.org] / src / sys / fs / efs / efs_dinode.h (download)

Revision 1.2, Sat Jun 30 15:56:16 2007 UTC (13 years, 9 months ago) by rumble
Branch: MAIN
CVS Tags: yamt-x86pmap-base4, yamt-x86pmap-base3, yamt-x86pmap-base2, yamt-x86pmap-base, yamt-x86pmap, yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, yamt-nfs-mp-base9, yamt-nfs-mp-base8, yamt-nfs-mp-base7, yamt-nfs-mp-base6, yamt-nfs-mp-base5, yamt-nfs-mp-base4, yamt-nfs-mp-base3, yamt-nfs-mp-base2, yamt-nfs-mp-base11, yamt-nfs-mp-base10, yamt-nfs-mp-base, yamt-nfs-mp, yamt-lazymbuf-base15, yamt-lazymbuf-base14, yamt-kmem-base3, yamt-kmem-base2, yamt-kmem-base, yamt-kmem, wrstuden-revivesa-base-4, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, vmlocking2-base3, vmlocking2-base2, vmlocking2-base1, vmlocking2, vmlocking-nbase, vmlocking-base, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, uebayasi-xip-base, uebayasi-xip, tls-maxphys-base, tls-earlyentropy-base, tls-earlyentropy, simonb-wapbl-nbase, simonb-wapbl-base, simonb-wapbl, rmind-uvmplock-nbase, rmind-uvmplock-base, rmind-uvmplock, rmind-smpnet-nbase, rmind-smpnet-base, rmind-smpnet, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, reinoud-bufcleanup-nbase, reinoud-bufcleanup-base, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-net80211-sync-base, nick-net80211-sync, nick-hppapmap-base4, nick-hppapmap-base3, nick-hppapmap-base2, nick-hppapmap-base, nick-hppapmap, nick-csl-alignment-base5, nick-csl-alignment-base, nick-csl-alignment, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, mjf-ufs-trans-base, mjf-devfs2-base, mjf-devfs2, mjf-devfs-base, mjf-devfs, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, khorben-n900, keiichi-mipv6-nbase, keiichi-mipv6-base, keiichi-mipv6, jymxensuspend-base, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, jruoho-x86intr-base, jruoho-x86intr, jmcneill-usbmp-pre-base2, jmcneill-usbmp-base9, jmcneill-usbmp-base8, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2, jmcneill-usbmp-base10, jmcneill-usbmp-base, jmcneill-usbmp, jmcneill-pm-base, jmcneill-pm, jmcneill-base, jmcneill-audiomp3-base, jmcneill-audiomp3, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, haad-nbase2, haad-dm-base2, haad-dm-base1, haad-dm-base, haad-dm, cube-autoconf-base, cube-autoconf, cherry-xenmp-base, cherry-xenmp, bouyer-xeni386-nbase, bouyer-xeni386-merge1, bouyer-xeni386-base, bouyer-xeni386, bouyer-xenamd64-base2, bouyer-xenamd64-base, bouyer-xenamd64, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, ad-socklock-base1, ad-audiomp2-base, ad-audiomp2
Branch point for: yamt-lazymbuf, vmlocking, tls-maxphys, nick-nhusb
Changes since 1.1: +8 -1 lines

Additional documentation on extents and some artificial limitations SGI
has introduced (and changed in backwards-incompatible ways) over the years.

/*	$NetBSD: efs_dinode.h,v 1.2 2007/06/30 15:56:16 rumble Exp $	*/

/*
 * Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * EFS on-disk inode format.
 *
 * See IRIX inode(4)
 */

#ifndef _FS_EFS_EFS_DINODE_H_
#define _FS_EFS_EFS_DINODE_H_

/*
 * Historical locations are always good.
 */
#define EFS_ROOTINO	((ino_t)2)

/*
 * EFS on-disk inode structure (128 bytes)
 *
 * [0] - NetBSD native uid_t is uint32_t.
 * [1] - NetBSD native gid_t is uint32_t.
 * [2] - NetBSD native off_t is int64_t.
 * [3] - See notes for di_u below for meanings of di_numextents.
 * [4] - Always 0 with EFS. Apparently it could take on other values when
 *	 used in conjunction with AFS.
 */

#define EFS_DIRECTEXTENTS 12
struct efs_dinode {
	uint16_t	di_mode;	/* 0:  file type and permissions */
	int16_t		di_nlink;	/* 2:  link count (minimum 2) */
	uint16_t	di_uid;		/* 4:  user ID [0] */
	uint16_t	di_gid;		/* 6:  group ID [1] */
	int32_t		di_size;	/* 8:  file size (in bytes) [2] */
	uint32_t	di_atime;	/* 12: file access time */
	uint32_t	di_mtime;	/* 16: file modification time */
	uint32_t	di_ctime;	/* 20: inode modification time */
	int32_t		di_gen;		/* 24: inode generation number */
	int16_t		di_numextents;	/* 28: number of extents in file [3] */
	uint8_t		di_version;	/* 30: inode version [4] */
	uint8_t		di_spare;	/* 31: unused */

	union {
		/*
		 * If di_numextents <= EFS_DIRECTEXTENTS, _di_extents contains
		 * direct extent descriptors. 
		 *
		 * else (di_numextents > EFS_DIRECTEXTENTS), _di_extents
		 * contains indirect extent descriptors.
		 *
		 * If indirect extents are being used, extents[0].ex_offset
		 * contains the number of indirect extents, i.e. the valid
		 * offsets in 'extents' are:
		 *     extents[0 ... (extents[0].ex_offset - 1)]
		 * It's not presently known if the ex_offset fields in
		 * extents[1 ... EFS_DIRECTEXTENTS] have any meaning.
		 */
		struct efs_dextent extents[EFS_DIRECTEXTENTS];

		/*
		 * If di_numextents == 0 and di_mode indicates a symlink, the
		 * symlink path is inlined into _di_symlink. Otherwise, the
		 * symlink exists in extents.
		 *
		 * Note that the symlink is stored without nul-termination,
		 * and di_size reflects this length.
		 */
		char symlink[sizeof(struct efs_dextent) * EFS_DIRECTEXTENTS];

		/*
		 * If di_numextents == 0 and di_mode indicates a character or
		 * block special file, the device tag is contained in _di_dev. 
		 *
		 * Note that IRIX moved from 16bit to 32bit dev_t's at some 
		 * point and a new field was added. It appears that when 32bit
		 * dev_t's are used, di_odev is set to 0xffff.
		 */
		struct {
			uint16_t dev_old; 
			uint32_t dev_new;
		} __packed dev;
	} di_u;
} __packed; 

#define di_extents	di_u.extents
#define di_symlink	di_u.symlink
#define di_odev		di_u.dev.dev_old
#define di_ndev		di_u.dev.dev_new

#define EFS_DINODE_SIZE		sizeof(struct efs_dinode)
#define EFS_DINODES_PER_BB	(EFS_BB_SIZE / EFS_DINODE_SIZE)

#define EFS_DINODE_ODEV_INVALID	(0xffff)
#define EFS_DINODE_ODEV_MAJ(_x)	(((_x) >>  8) & 0x7f)
#define EFS_DINODE_ODEV_MIN(_x)	(((_x) >>  0) & 0xff)
#define EFS_DINODE_NDEV_MAJ(_x)	(((_x) >> 18) & 0x1ff)
#define EFS_DINODE_NDEV_MIN(_x)	(((_x) >>  0) & 0x3ffff)

/* EFS file permissions. */
#define EFS_IEXEC	0000100		/* executable */
#define EFS_IWRITE	0000200		/* writable */
#define EFS_IREAD	0000400		/* readable */
#define EFS_ISVTX	0001000		/* sticky bit */
#define EFS_ISGID	0002000		/* setgid */
#define EFS_ISUID	0004000		/* setuid */

/* EFS file types. */
#define EFS_IFMT	0170000		/* file type mask */
#define EFS_IFIFO	0010000		/* named pipe */
#define EFS_IFCHR	0020000		/* character device */
#define EFS_IFDIR	0040000		/* directory */
#define EFS_IFBLK	0060000		/* block device */
#define EFS_IFREG	0100000		/* regular file */
#define EFS_IFLNK	0120000		/* symlink */
#define EFS_IFSOCK	0140000		/* UNIX domain socket */

#endif /* !_FS_EFS_EFS_DINODE_H_ */