]>
git.wh0rd.org - dump.git/blob - bsdcompat.h
881f50582b725fb65987aa08e0b7b58483740751
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.16 2002/01/16 09:32:14 stelian Exp $
15 #define __dead volatile
22 #define MIN(a,b) ((a < b) ? a : b)
28 #define MAXBSIZE EXT2_MAX_BLOCK_SIZE
29 #define ROOTINO EXT2_ROOT_INO
31 #define UF_NODUMP EXT2_NODUMP_FL
34 #define howmany(x,y) (((x)+((y)-1))/(y))
35 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
36 #define powerof2(x) ((((x)-1)&(x))==0)
38 #define dbtob(b) ((unsigned)(b) << DEV_BSHIFT)
39 #define fsbtodb(sb,b) ((int)(((long long)b * EXT2_BLOCK_SIZE(sb->super)) / DEV_BSIZE))
42 #define fs_fsize fragsize
43 #define fs_bsize blocksize
44 #define fs_size super->s_blocks_count
52 #define IFSOCK S_IFSOCK
57 typedef __u64 u_quad_t
;
61 * The BSD dump format reserves 4 bytes for a time_t, but other architectures
62 * (notably axp) have larger time_t. ctime4() is a modified ctime() which
63 * always accepts short 4-byte times.
65 #define ctime4(timep) ({ time_t t = *(timep); ctime(&t); })
68 * This is the ext2_inode structure but the fields have been renamed
69 * to match 4.4BSD's names
74 #define NINDIR(fs) EXT2_ADDR_PER_BLOCK(fs->super)
89 daddr_t di_db
[NDADDR
];
90 daddr_t di_ib
[NIADDR
];
101 #define di_rdev di_db[0]
102 /* #define di_ouid di_uid */
103 /* #define di_ogid di_gid */
104 #define di_size_high di_dir_acl
107 * This is the ext2_dir_entry structure but the fields have been renamed
108 * to match 4.4BSD's names
110 * This is the 4.4BSD directory entry structure
112 #define DIRBLKSIZ DEV_BSIZE
114 #define MAXNAMLEN 255
132 #define d_fileno d_ino
136 * This is the direct structure used by dump. In needs to be
137 * different from direct because linux dump generates only
138 * 'old inode format' dumps. And BSD supposes that the old
139 * inode dumps have the d_namelen field written in machine byte
146 char d_name
[MAXNAMLEN
+ 1];
150 * The direct structure used by restore.
157 char d_name
[MAXNAMLEN
+ 1];
160 * Convert between stat structure types and directory types.
162 #define IFTODT(mode) (((mode) & 0170000) >> 12)
163 #define DTTOIF(dirtype) ((dirtype) << 12)
166 * The DIRSIZ macro gives the minimum record length which will hold
167 * the directory entry. This requires the amount of space in struct direct
168 * without the d_name field, plus enough space for the name with a terminating
169 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
172 #if (BYTE_ORDER == LITTLE_ENDIAN)
173 #define DIRSIZ(oldfmt, dp) \
175 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_type+1 + 3) &~ 3)) : \
176 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)))
178 #define DIRSIZ(oldfmt, dp) \
179 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
183 #define DIRSIZ(oldfmt,dp) EXT2_DIR_REC_LEN(((dp)->d_namlen & 0xff) + 1)
188 * This is the old (Net/2) BSD inode structure
189 * copied from the FreeBSD 1.1.5.1 <ufs/dinode.h> include file
191 #define MAXFASTLINK (((NDADDR + NIADDR) * sizeof(unsigned long)) - 1)
193 struct old_bsd_inode
{
215 daddr_t di_udb
[NDADDR
];
216 daddr_t di_uib
[NIADDR
];
218 char di_usymlink
[MAXFASTLINK
+ 1];
221 daddr_t di_db
[NDADDR
];
222 daddr_t di_ib
[NIADDR
];
230 struct bsdtimeval
{ /* XXX alpha-*-linux is deviant */
236 * This is the new (4.4) BSD inode structure
237 * copied from the FreeBSD 2.0 <ufs/ufs/dinode.h> include file
239 struct new_bsd_inode
{
247 struct bsdtimeval di_atime
;
248 struct bsdtimeval di_mtime
;
249 struct bsdtimeval di_ctime
;
250 daddr_t di_db
[NDADDR
];
251 daddr_t di_ib
[NIADDR
];
260 #define di_ouid di_u.oldids[0]
261 #define di_ogid di_u.oldids[1]