]>
git.wh0rd.org - dump.git/blob - compat/include/bsdcompat.h
d19687fd298836047c537c435032c05792db1e1c
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.25 2011/06/10 12:46:41 stelian Exp $
14 #include <ext2fs/ext2fs.h>
17 #define _BSDCOMPAT_H 1
19 #define __dead volatile
20 #define UNUSED(x) x __attribute__ ((unused))
27 #define MIN(a,b) ((a < b) ? a : b)
35 #define MAXBSIZE EXT2_MAX_BLOCK_SIZE
36 #define ROOTINO EXT2_ROOT_INO
41 #define UF_NODUMP EXT2_NODUMP_FL
45 #define howmany(x,y) (((x)+((y)-1))/(y))
48 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
51 #define powerof2(x) ((((x)-1)&(x))==0)
54 #define fsbtodb(sb,b) ((ext2_loff_t)(((long long)(b) * EXT2_BLOCK_SIZE((sb)->super)) / DEV_BSIZE))
55 #define dbtofsb(sb,b) ((int)(((long long)(b) * DEV_BSIZE) / EXT2_BLOCK_SIZE((sb)->super)))
58 #define fs_fsize fragsize
59 #define fs_bsize blocksize
60 #define fs_size super->s_blocks_count
68 #define IFSOCK S_IFSOCK
73 typedef __u64 u_quad_t
;
77 * The BSD dump format reserves 4 bytes for a time_t, but other architectures
78 * (notably axp) have larger time_t. ctime4() is a modified ctime() which
79 * always accepts short 4-byte times.
81 #define ctime4(timep) ({ time_t t = *(timep); ctime(&t); })
84 * This is the ext2_inode structure but the fields have been renamed
85 * to match 4.4BSD's names
90 #define NINDIR(fs) EXT2_ADDR_PER_BLOCK(fs->super)
94 typedef uint16_t __u16
;
95 typedef uint32_t __u32
;
97 typedef int16_t __s16
;
98 typedef int32_t __s32
;
100 typedef unsigned int u_int
;
103 typedef unsigned short u_int16_t
;
106 typedef unsigned char u_char
;
108 typedef int64_t quad_t
;
140 #define di_rdev di_db[0]
141 /* #define di_ouid di_uid */
142 /* #define di_ogid di_gid */
143 #define di_size_high di_dir_acl
146 * This is the ext2_dir_entry structure but the fields have been renamed
147 * to match 4.4BSD's names
149 * This is the 4.4BSD directory entry structure
151 #define DIRBLKSIZ DEV_BSIZE
153 #define MAXNAMLEN 255
157 #define MAXNAMLEN 255
179 #define d_fileno d_ino
183 * The direct structure used by dump/restore.
190 char d_name
[MAXNAMLEN
+ 1];
193 * Convert between stat structure types and directory types.
195 #define IFTODT(mode) (((mode) & 0170000) >> 12)
196 #define DTTOIF(dirtype) ((dirtype) << 12)
199 * The DIRSIZ macro gives the minimum record length which will hold
200 * the directory entry. This requires the amount of space in struct direct
201 * without the d_name field, plus enough space for the name with a terminating
202 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
206 #if (BYTE_ORDER == LITTLE_ENDIAN)
207 #define DIRSIZ(oldfmt, dp) \
209 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \
210 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)))
211 #else /* BYTE_ORDER */
212 #define DIRSIZ(oldfmt, dp) \
213 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
216 #define DIRSIZ(oldfmt,dp) EXT2_DIR_REC_LEN(((dp)->d_namlen & 0xff) + 1)
218 #else /* __linux__ */
219 #define DIRSIZ(oldfmt, dp) \
220 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
224 * This is the old (Net/2) BSD inode structure
225 * copied from the FreeBSD 1.1.5.1 <ufs/dinode.h> include file
227 #define MAXFASTLINK (((NDADDR + NIADDR) * sizeof(unsigned long)) - 1)
229 struct old_bsd_inode
{
251 daddr_t di_udb
[NDADDR
];
252 daddr_t di_uib
[NIADDR
];
254 char di_usymlink
[MAXFASTLINK
+ 1];
266 struct bsdtimeval
{ /* XXX alpha-*-linux is deviant */
272 * This is the new (4.4) BSD inode structure
273 * copied from the FreeBSD 2.0 <ufs/ufs/dinode.h> include file
275 struct new_bsd_inode
{
283 struct bsdtimeval di_atime
;
284 struct bsdtimeval di_mtime
;
285 struct bsdtimeval di_ctime
;
296 #define di_ouid di_u.oldids[0]
297 #define di_ogid di_u.oldids[1]
298 #endif /* _BSDCOMPAT_H */