]>
git.wh0rd.org - dump.git/blob - compat/include/bsdcompat.h
7a3b11e23edf259db31d53062f9534ea8760d032
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <pop@cybercable.fr>, 1999
13 #define __dead volatile
20 #define MIN(a,b) ((a < b) ? a : b)
23 #define WINO ((ino_t)1)
26 #define MAXBSIZE EXT2_MAX_BLOCK_SIZE
27 #define ROOTINO EXT2_ROOT_INO
29 #define UF_NODUMP EXT2_NODUMP_FL
32 #define howmany(x,y) (((x)+((y)-1))/(y))
33 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
34 #define powerof2(x) ((((x)-1)&(x))==0)
36 #define dbtob(b) ((unsigned)(b) << DEV_BSHIFT)
37 #define fsbtodb(sb,b) ((int)(((long long)b * EXT2_BLOCK_SIZE(sb->super)) / DEV_BSIZE))
40 #define fs_fsize fragsize
41 #define fs_bsize blocksize
42 #define fs_size super->s_blocks_count
50 #define IFSOCK S_IFSOCK
55 typedef __u64 u_quad_t
;
59 * The BSD dump format reserves 4 bytes for a time_t, but other architectures
60 * (notably axp) have larger time_t. ctime4() is a modified ctime() which
61 * always accepts short 4-byte times. time4() is a similarly modified time().
63 #define ctime4(timep) ({ time_t t = *(timep); ctime(&t); })
64 #define time4(timep) ({time_t t; t = time(0); if (timep) *timep=t; t; })
67 * This is the ext2_inode structure but the fields have been renamed
68 * to match 4.4BSD's names
73 #define NINDIR(fs) EXT2_ADDR_PER_BLOCK(fs->super)
88 daddr_t di_db
[NDADDR
];
89 daddr_t di_ib
[NIADDR
];
100 #define di_rdev di_db[0]
101 /* #define di_ouid di_uid */
102 /* #define di_ogid di_gid */
105 * This is the ext2_dir_entry structure but the fields have been renamed
106 * to match 4.4BSD's names
108 * This is the 4.4BSD directory entry structure
110 #define DIRBLKSIZ DEV_BSIZE
112 #define MAXNAMLEN 255
124 char d_name
[MAXNAMLEN
+ 1];
128 * Convert between stat structure types and directory types.
130 #define IFTODT(mode) (((mode) & 0170000) >> 12)
131 #define DTTOIF(dirtype) ((dirtype) << 12)
134 * The DIRSIZ macro gives the minimum record length which will hold
135 * the directory entry. This requires the amount of space in struct direct
136 * without the d_name field, plus enough space for the name with a terminating
137 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
140 #if (BYTE_ORDER == LITTLE_ENDIAN)
141 #define DIRSIZ(oldfmt, dp) \
143 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \
144 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)))
146 #define DIRSIZ(oldfmt, dp) \
147 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
151 #define DIRSIZ(oldfmt,dp) EXT2_DIR_REC_LEN(((dp)->d_namlen & 0xff) + 1)
156 * This is the old (Net/2) BSD inode structure
157 * copied from the FreeBSD 1.1.5.1 <ufs/dinode.h> include file
159 #define MAXFASTLINK (((NDADDR + NIADDR) * sizeof(unsigned long)) - 1)
161 struct old_bsd_inode
{
183 daddr_t di_udb
[NDADDR
];
184 daddr_t di_uib
[NIADDR
];
186 char di_usymlink
[MAXFASTLINK
+ 1];
189 daddr_t di_db
[NDADDR
];
190 daddr_t di_ib
[NIADDR
];
198 struct bsdtimeval
{ /* XXX alpha-*-linux is deviant */
204 * This is the new (4.4) BSD inode structure
205 * copied from the FreeBSD 2.0 <ufs/ufs/dinode.h> include file
207 struct new_bsd_inode
{
215 struct bsdtimeval di_atime
;
216 struct bsdtimeval di_mtime
;
217 struct bsdtimeval di_ctime
;
218 daddr_t di_db
[NDADDR
];
219 daddr_t di_ib
[NIADDR
];
228 #define di_ouid di_u.oldids[0]
229 #define di_ogid di_u.oldids[1]