Home | History | Annotate | Line # | Download | only in efs
efs_dinode.h revision 1.2.12.2
      1  1.2.12.2  yamt /*	$NetBSD: efs_dinode.h,v 1.2.12.2 2007/09/03 14:40:09 yamt Exp $	*/
      2  1.2.12.2  yamt 
      3  1.2.12.2  yamt /*
      4  1.2.12.2  yamt  * Copyright (c) 2006 Stephen M. Rumble <rumble (at) ephemeral.org>
      5  1.2.12.2  yamt  *
      6  1.2.12.2  yamt  * Permission to use, copy, modify, and distribute this software for any
      7  1.2.12.2  yamt  * purpose with or without fee is hereby granted, provided that the above
      8  1.2.12.2  yamt  * copyright notice and this permission notice appear in all copies.
      9  1.2.12.2  yamt  *
     10  1.2.12.2  yamt  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11  1.2.12.2  yamt  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12  1.2.12.2  yamt  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13  1.2.12.2  yamt  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14  1.2.12.2  yamt  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15  1.2.12.2  yamt  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16  1.2.12.2  yamt  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17  1.2.12.2  yamt  */
     18  1.2.12.2  yamt 
     19  1.2.12.2  yamt /*
     20  1.2.12.2  yamt  * EFS on-disk inode format.
     21  1.2.12.2  yamt  *
     22  1.2.12.2  yamt  * See IRIX inode(4)
     23  1.2.12.2  yamt  */
     24  1.2.12.2  yamt 
     25  1.2.12.2  yamt #ifndef _FS_EFS_EFS_DINODE_H_
     26  1.2.12.2  yamt #define _FS_EFS_EFS_DINODE_H_
     27  1.2.12.2  yamt 
     28  1.2.12.2  yamt /*
     29  1.2.12.2  yamt  * Historical locations are always good.
     30  1.2.12.2  yamt  */
     31  1.2.12.2  yamt #define EFS_ROOTINO	((ino_t)2)
     32  1.2.12.2  yamt 
     33  1.2.12.2  yamt /*
     34  1.2.12.2  yamt  * EFS on-disk inode structure (128 bytes)
     35  1.2.12.2  yamt  *
     36  1.2.12.2  yamt  * [0] - NetBSD native uid_t is uint32_t.
     37  1.2.12.2  yamt  * [1] - NetBSD native gid_t is uint32_t.
     38  1.2.12.2  yamt  * [2] - NetBSD native off_t is int64_t.
     39  1.2.12.2  yamt  * [3] - See notes for di_u below for meanings of di_numextents.
     40  1.2.12.2  yamt  * [4] - Always 0 with EFS. Apparently it could take on other values when
     41  1.2.12.2  yamt  *	 used in conjunction with AFS.
     42  1.2.12.2  yamt  */
     43  1.2.12.2  yamt 
     44  1.2.12.2  yamt #define EFS_DIRECTEXTENTS 12
     45  1.2.12.2  yamt struct efs_dinode {
     46  1.2.12.2  yamt 	uint16_t	di_mode;	/* 0:  file type and permissions */
     47  1.2.12.2  yamt 	int16_t		di_nlink;	/* 2:  link count (minimum 2) */
     48  1.2.12.2  yamt 	uint16_t	di_uid;		/* 4:  user ID [0] */
     49  1.2.12.2  yamt 	uint16_t	di_gid;		/* 6:  group ID [1] */
     50  1.2.12.2  yamt 	int32_t		di_size;	/* 8:  file size (in bytes) [2] */
     51  1.2.12.2  yamt 	uint32_t	di_atime;	/* 12: file access time */
     52  1.2.12.2  yamt 	uint32_t	di_mtime;	/* 16: file modification time */
     53  1.2.12.2  yamt 	uint32_t	di_ctime;	/* 20: inode modification time */
     54  1.2.12.2  yamt 	int32_t		di_gen;		/* 24: inode generation number */
     55  1.2.12.2  yamt 	int16_t		di_numextents;	/* 28: number of extents in file [3] */
     56  1.2.12.2  yamt 	uint8_t		di_version;	/* 30: inode version [4] */
     57  1.2.12.2  yamt 	uint8_t		di_spare;	/* 31: unused */
     58  1.2.12.2  yamt 
     59  1.2.12.2  yamt 	union {
     60  1.2.12.2  yamt 		/*
     61  1.2.12.2  yamt 		 * If di_numextents <= EFS_DIRECTEXTENTS, _di_extents contains
     62  1.2.12.2  yamt 		 * direct extent descriptors.
     63  1.2.12.2  yamt 		 *
     64  1.2.12.2  yamt 		 * else (di_numextents > EFS_DIRECTEXTENTS), _di_extents
     65  1.2.12.2  yamt 		 * contains indirect extent descriptors.
     66  1.2.12.2  yamt 		 *
     67  1.2.12.2  yamt 		 * If indirect extents are being used, extents[0].ex_offset
     68  1.2.12.2  yamt 		 * contains the number of indirect extents, i.e. the valid
     69  1.2.12.2  yamt 		 * offsets in 'extents' are:
     70  1.2.12.2  yamt 		 *     extents[0 ... (extents[0].ex_offset - 1)]
     71  1.2.12.2  yamt 		 * It's not presently known if the ex_offset fields in
     72  1.2.12.2  yamt 		 * extents[1 ... EFS_DIRECTEXTENTS] have any meaning.
     73  1.2.12.2  yamt 		 */
     74  1.2.12.2  yamt 		struct efs_dextent extents[EFS_DIRECTEXTENTS];
     75  1.2.12.2  yamt 
     76  1.2.12.2  yamt 		/*
     77  1.2.12.2  yamt 		 * If di_numextents == 0 and di_mode indicates a symlink, the
     78  1.2.12.2  yamt 		 * symlink path is inlined into _di_symlink. Otherwise, the
     79  1.2.12.2  yamt 		 * symlink exists in extents.
     80  1.2.12.2  yamt 		 *
     81  1.2.12.2  yamt 		 * Note that the symlink is stored without nul-termination,
     82  1.2.12.2  yamt 		 * and di_size reflects this length.
     83  1.2.12.2  yamt 		 */
     84  1.2.12.2  yamt 		char symlink[sizeof(struct efs_dextent) * EFS_DIRECTEXTENTS];
     85  1.2.12.2  yamt 
     86  1.2.12.2  yamt 		/*
     87  1.2.12.2  yamt 		 * If di_numextents == 0 and di_mode indicates a character or
     88  1.2.12.2  yamt 		 * block special file, the device tag is contained in _di_dev.
     89  1.2.12.2  yamt 		 *
     90  1.2.12.2  yamt 		 * Note that IRIX moved from 16bit to 32bit dev_t's at some
     91  1.2.12.2  yamt 		 * point and a new field was added. It appears that when 32bit
     92  1.2.12.2  yamt 		 * dev_t's are used, di_odev is set to 0xffff.
     93  1.2.12.2  yamt 		 */
     94  1.2.12.2  yamt 		struct {
     95  1.2.12.2  yamt 			uint16_t dev_old;
     96  1.2.12.2  yamt 			uint32_t dev_new;
     97  1.2.12.2  yamt 		} __packed dev;
     98  1.2.12.2  yamt 	} di_u;
     99  1.2.12.2  yamt } __packed;
    100  1.2.12.2  yamt 
    101  1.2.12.2  yamt #define di_extents	di_u.extents
    102  1.2.12.2  yamt #define di_symlink	di_u.symlink
    103  1.2.12.2  yamt #define di_odev		di_u.dev.dev_old
    104  1.2.12.2  yamt #define di_ndev		di_u.dev.dev_new
    105  1.2.12.2  yamt 
    106  1.2.12.2  yamt #define EFS_DINODE_SIZE		sizeof(struct efs_dinode)
    107  1.2.12.2  yamt #define EFS_DINODES_PER_BB	(EFS_BB_SIZE / EFS_DINODE_SIZE)
    108  1.2.12.2  yamt 
    109  1.2.12.2  yamt #define EFS_DINODE_ODEV_INVALID	(0xffff)
    110  1.2.12.2  yamt #define EFS_DINODE_ODEV_MAJ(_x)	(((_x) >>  8) & 0x7f)
    111  1.2.12.2  yamt #define EFS_DINODE_ODEV_MIN(_x)	(((_x) >>  0) & 0xff)
    112  1.2.12.2  yamt #define EFS_DINODE_NDEV_MAJ(_x)	(((_x) >> 18) & 0x1ff)
    113  1.2.12.2  yamt #define EFS_DINODE_NDEV_MIN(_x)	(((_x) >>  0) & 0x3ffff)
    114  1.2.12.2  yamt 
    115  1.2.12.2  yamt /* EFS file permissions. */
    116  1.2.12.2  yamt #define EFS_IEXEC	0000100		/* executable */
    117  1.2.12.2  yamt #define EFS_IWRITE	0000200		/* writable */
    118  1.2.12.2  yamt #define EFS_IREAD	0000400		/* readable */
    119  1.2.12.2  yamt #define EFS_ISVTX	0001000		/* sticky bit */
    120  1.2.12.2  yamt #define EFS_ISGID	0002000		/* setgid */
    121  1.2.12.2  yamt #define EFS_ISUID	0004000		/* setuid */
    122  1.2.12.2  yamt 
    123  1.2.12.2  yamt /* EFS file types. */
    124  1.2.12.2  yamt #define EFS_IFMT	0170000		/* file type mask */
    125  1.2.12.2  yamt #define EFS_IFIFO	0010000		/* named pipe */
    126  1.2.12.2  yamt #define EFS_IFCHR	0020000		/* character device */
    127  1.2.12.2  yamt #define EFS_IFDIR	0040000		/* directory */
    128  1.2.12.2  yamt #define EFS_IFBLK	0060000		/* block device */
    129  1.2.12.2  yamt #define EFS_IFREG	0100000		/* regular file */
    130  1.2.12.2  yamt #define EFS_IFLNK	0120000		/* symlink */
    131  1.2.12.2  yamt #define EFS_IFSOCK	0140000		/* UNIX domain socket */
    132  1.2.12.2  yamt 
    133  1.2.12.2  yamt #endif /* !_FS_EFS_EFS_DINODE_H_ */
    134