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