1 /* $NetBSD: readufs.h,v 1.8 2005/12/11 12:19:44 christos Exp $ */
2 /* from Id: readufs.h,v 1.9 2003/10/15 14:16:58 itohy Exp */
5 * Written in 1999, 2002, 2003 by ITOH Yasufumi (itohy@NetBSD.org).
10 #include <sys/param.h>
11 #include <ufs/ufs/dinode.h>
12 #include <ufs/ufs/dir.h>
19 struct ufs1_dinode di1
;
22 struct ufs2_dinode di2
;
26 /* For more compact code and independence on 64-bit types and ops */
27 typedef uint32_t ino32_t
;
29 /* short-cut for common fields (di_mode, di_nlink) */
31 # define di_common di1
32 #elif defined USE_UFS2
33 # define di_common di2
36 /* for fields of same names and different locations */
37 #if !(defined(USE_UFS1) && defined(USE_UFS2))
39 # define di_thisver di1
42 # define di_thisver di2
46 /* this is a size hack */
47 #if defined(USE_UFS1) && defined(USE_UFS2)
48 # define DI_SIZE(di) ((di)->di1.di_size)
50 # define DI_SIZE(di) ((di)->di_thisver.di_size)
52 /* and may break following fields on UFS2 */
53 #define di_gid di_gid__is_not_available
54 #define di_blksize di_blksize__is_not_available
57 * filesystem information
69 #if defined(USE_UFS1) && defined(USE_UFS2)
71 UFSTYPE_UFS1
, UFSTYPE_UFS2
74 int (*get_inode
)(ino32_t ino
, union ufs_dinode
*dibuf
);
76 /* superblock information */
77 u_int32_t bsize
; /* fs block size */
78 u_int32_t nindir
; /* # indirect per block */
79 u_int32_t fsbtodb
; /* block -> sector shift count */
83 daddr_t iblkno
; /* inode-block offset */
84 int32_t old_cgoffset
; /* cylinder group offset */
85 int32_t old_cgmask
; /* cylinder group mask */
86 int32_t fragshift
; /* block to fragmentation */
87 int32_t inopb
; /* # inodes per block */
88 int32_t ipg
; /* # inodes per group */
89 int32_t fpg
; /* # inodes per group * frag */
90 int32_t magic
; /* FS_UFSx_MAGIC */
95 u_int32_t version
; /* LFS version # */
96 daddr_t idaddr
; /* ifile inode disk address */
97 u_int32_t inopb
; /* inodes per block (v1) */
98 /* inodes per frag (v2) */
99 u_int32_t ifpb
; /* inode addrs / ifile block */
100 u_int32_t ioffset
; /* start of inode in ifile */
102 u_int32_t ibsize
; /* size of inode block */
108 extern struct ufs_info ufs_info
;
109 #define ufs_get_inode(ino, di) ((*ufs_info.get_inode)((ino), (di)))
111 void RAW_READ(void *buf
, daddr_t blkpos
, size_t bytelen
);
113 size_t ufs_read(union ufs_dinode
*di
, void *buf
, unsigned off
,
115 ino32_t
ufs_lookup(ino32_t dirino
, const char *fn
);
116 ino32_t
ufs_lookup_path(const char *path
);
117 size_t ufs_load_file(void *buf
, ino32_t dirino
, const char *fn
);
128 #ifdef DEBUG_WITH_STDIO
138 # define alloca(n) __builtin_alloca(n)
141 # define strcmp(p, q) __builtin_strcmp(p, q)