Home | History | Annotate | Line # | Download | only in efs
      1 /*	$NetBSD: efs_extent.h,v 1.3 2007/07/04 19:24:09 rumble Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2006 Stephen M. Rumble <rumble (at) ephemeral.org>
      5  *
      6  * Permission to use, copy, modify, and distribute this software for any
      7  * purpose with or without fee is hereby granted, provided that the above
      8  * copyright notice and this permission notice appear in all copies.
      9  *
     10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17  */
     18 
     19 /*
     20  * EFS extent descriptor format and sundry.
     21  *
     22  * See IRIX inode(4)
     23  */
     24 
     25 #ifndef _FS_EFS_EFS_EXTENT_H_
     26 #define _FS_EFS_EFS_EXTENT_H_
     27 
     28 /*
     29  * EFS on-disk extent descriptor (8 bytes)
     30  *
     31  * SGI smushed this structure's members into bit fields, but we have to
     32  * be a little more portable. Therefore we use the efs_extent (see below)
     33  * type for in-core manipulation and convert immediately to and from disk.
     34  */
     35 struct efs_dextent {
     36 	union {
     37 		uint64_t ex_magic:8,	/* magic number (always 0) */
     38 			 ex_bn:24,	/* bb number in filesystem */
     39 			 ex_length:8,	/* length of extent (in bb) */
     40 			 ex_offset:24;	/* logical file offset (in bb) */
     41 		uint8_t  bytes[8];
     42 		uint32_t words[2];
     43 	} ex_muddle;
     44 } __packed;
     45 #define ex_bytes ex_muddle.bytes
     46 #define ex_words ex_muddle.words
     47 
     48 /*
     49  * In-core, unsquished representation of an extent.
     50  */
     51 struct efs_extent {
     52 	uint8_t  ex_magic;
     53 	uint32_t ex_bn;			/* NB: only 24 bits on disk */
     54 	uint8_t  ex_length;
     55 	uint32_t ex_offset;		/* NB: only 24 bits on disk */
     56 };
     57 
     58 #define EFS_EXTENT_MAGIC	0
     59 #define EFS_EXTENT_BN_MASK	0x00ffffff
     60 #define EFS_EXTENT_OFFSET_MASK	0x00ffffff
     61 
     62 #define EFS_EXTENTS_PER_BB	(EFS_BB_SIZE / sizeof(struct efs_dextent))
     63 
     64 #endif /* !_FS_EFS_EFS_EXTENT_H_ */
     65