]>
git.wh0rd.org - dump.git/blob - compat/include/bsdcompat.h
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 <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
8 * $Id: bsdcompat.h,v 1.20 2003/10/26 16:05:46 stelian Exp $
15 #define __dead volatile
16 #define UNUSED(x) x __attribute__ ((unused))
23 #define MIN(a,b) ((a < b) ? a : b)
31 #define MAXBSIZE EXT2_MAX_BLOCK_SIZE
32 #define ROOTINO EXT2_ROOT_INO
37 #define UF_NODUMP EXT2_NODUMP_FL
40 #define howmany(x,y) (((x)+((y)-1))/(y))
41 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
42 #define powerof2(x) ((((x)-1)&(x))==0)
44 #define fsbtodb(sb,b) ((int)(((long long)(b) * EXT2_BLOCK_SIZE((sb)->super)) / DEV_BSIZE))
45 #define dbtofsb(sb,b) ((int)(((long long)(b) * DEV_BSIZE) / EXT2_BLOCK_SIZE((sb)->super)))
48 #define fs_fsize fragsize
49 #define fs_bsize blocksize
50 #define fs_size super->s_blocks_count
58 #define IFSOCK S_IFSOCK
63 typedef __u64 u_quad_t
;
67 * The BSD dump format reserves 4 bytes for a time_t, but other architectures
68 * (notably axp) have larger time_t. ctime4() is a modified ctime() which
69 * always accepts short 4-byte times.
71 #define ctime4(timep) ({ time_t t = *(timep); ctime(&t); })
74 * This is the ext2_inode structure but the fields have been renamed
75 * to match 4.4BSD's names
80 #define NINDIR(fs) EXT2_ADDR_PER_BLOCK(fs->super)
84 typedef uint16_t __u16
;
85 typedef uint32_t __u32
;
87 typedef int16_t __s16
;
88 typedef int32_t __s32
;
90 #typedef unsigned int u_int;
93 typedef unsigned short u_int16_t
;
96 typedef unsigned char u_char
;
98 typedef int64_t quad_t
;
114 daddr_t di_db
[NDADDR
];
115 daddr_t di_ib
[NIADDR
];
128 #define di_rdev di_db[0]
129 /* #define di_ouid di_uid */
130 /* #define di_ogid di_gid */
131 #define di_size_high di_dir_acl
134 * This is the ext2_dir_entry structure but the fields have been renamed
135 * to match 4.4BSD's names
137 * This is the 4.4BSD directory entry structure
139 #define DIRBLKSIZ DEV_BSIZE
141 #define MAXNAMLEN 255
145 #define MAXNAMLEN 255
167 #define d_fileno d_ino
171 * The direct structure used by dump/restore.
178 char d_name
[MAXNAMLEN
+ 1];
181 * Convert between stat structure types and directory types.
183 #define IFTODT(mode) (((mode) & 0170000) >> 12)
184 #define DTTOIF(dirtype) ((dirtype) << 12)
187 * The DIRSIZ macro gives the minimum record length which will hold
188 * the directory entry. This requires the amount of space in struct direct
189 * without the d_name field, plus enough space for the name with a terminating
190 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
194 #if (BYTE_ORDER == LITTLE_ENDIAN)
195 #define DIRSIZ(oldfmt, dp) \
197 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \
198 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)))
199 #else /* BYTE_ORDER */
200 #define DIRSIZ(oldfmt, dp) \
201 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
204 #define DIRSIZ(oldfmt,dp) EXT2_DIR_REC_LEN(((dp)->d_namlen & 0xff) + 1)
206 #else /* __linux__ */
207 #define DIRSIZ(oldfmt, dp) \
208 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
212 * This is the old (Net/2) BSD inode structure
213 * copied from the FreeBSD 1.1.5.1 <ufs/dinode.h> include file
215 #define MAXFASTLINK (((NDADDR + NIADDR) * sizeof(unsigned long)) - 1)
217 struct old_bsd_inode
{
239 daddr_t di_udb
[NDADDR
];
240 daddr_t di_uib
[NIADDR
];
242 char di_usymlink
[MAXFASTLINK
+ 1];
245 daddr_t di_db
[NDADDR
];
246 daddr_t di_ib
[NIADDR
];
254 struct bsdtimeval
{ /* XXX alpha-*-linux is deviant */
260 * This is the new (4.4) BSD inode structure
261 * copied from the FreeBSD 2.0 <ufs/ufs/dinode.h> include file
263 struct new_bsd_inode
{
271 struct bsdtimeval di_atime
;
272 struct bsdtimeval di_mtime
;
273 struct bsdtimeval di_ctime
;
274 daddr_t di_db
[NDADDR
];
275 daddr_t di_ib
[NIADDR
];
284 #define di_ouid di_u.oldids[0]
285 #define di_ogid di_u.oldids[1]