/* vi:set cindent tabstop=2 shiftwidth=2: */ /* * libvxfs - library for reading Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * vxfs.h: On-disk VxFS structures * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __VXFS_H #define __VXFS_H #include "config.h" #ifdef HAVE_LINUX_TYPES_H #include #else /* XXX: FIXME! This is really ugly */ typedef unsigned char __u8; typedef unsigned short __u16; typedef unsigned long __u32; typedef unsigned long long __u64; #endif /* * VxFS magic numbers */ #define VXFS_MAGIC 0xa501FCF5 /* vxfs_super.magic */ #define VXFS_OLTMAGIC 0xa504FCF5 /* vxfs_olt.magic */ #define VXFS_NEFREE 32 /* Num of entries in free extent array */ struct vxfs_super { /* Version 1 */ __u32 magic; /* Magic, VXFS_MAGIC */ __u32 version; /* VxFS version, 1,2,3,4 */ __u32 ctime; /* create time - secs */ __u32 cutime; /* create time - usecs */ __u32 unused1; /* ?? */ __u32 unused2; /* ?? */ __u32 old_logstart; /* OLD: addr of first log blk */ __u32 old_logend; /* OLD: addr of last log blk */ __u32 bsize; /* Block size */ __u32 size; /* Number of blocks in FS */ __u32 dsize; /* Number of data blocks */ __u32 old_ninode; /* OLD: number of inodes */ __u32 old_nau; /* Number of allocation units */ __u32 unused3; /* ?? */ __u32 old_defiextsize; /* OLD: dfault indirect ext size */ __u32 old_ilbsize; /* OLD: Ilist block size in bytes */ __u32 immedlen; /* Size of immediate data area */ __u32 ndaddr; /* Number of direct extentes per inode */ __u32 firstau; /* Address of first Allocation Unit */ __u32 emap; /* Offset of extent map in AU */ __u32 imap; /* Offset of inode map in AU (V1) */ __u32 iextop; /* Offset of Ext. Op. map in AU */ __u32 istart; /* Offset of inode list in AU */ __u32 bstart; /* Offset of first data block in AU */ __u32 femap; /* aufirst + emap */ __u32 fimap; /* aufirst + imap */ __u32 fiextop; /* aufirst + iextop */ __u32 fistart; /* aufirst + istart */ __u32 fbstart; /* aufirst + bstart */ __u32 nindir; /* Number of entries in indirect */ __u32 aulen; /* Length of AU in blocks */ __u32 auimlen; /* Length of AU imap in blocks */ __u32 auemlen; /* Length of AU emap in blocks */ __u32 auilen; /* Length of AU ilist in blocks */ __u32 aupad; /* Length of AU pad in blocks */ __u32 aublocks; /* Number of data blocks in AU */ __u32 maxtier; /* Log base 2 of aublocks */ __u32 inopb; /* Number of inodes per blk */ __u32 old_inopau; /* OLD: Number of inodes per AU */ __u32 old_inopilb; /* OLD: Inodes per ilist blocks */ __u32 old_ndiripau; /* OLD: Num of directory inodes per au */ __u32 iaddrlen; /* Size of indirect addr ext. */ __u32 bshift; /* Log base 2 of bsize */ __u32 inoshift; /* Log base 2 of inobp */ __u32 bmask; /* ~( bsize - 1 ) */ __u32 boffmask; /* bsize - 1 */ __u32 old_inomask; /* old_inopilb - 1 */ __u32 checksum; /* Checksum of V1 data */ /* Version 1, writable */ __u32 free; /* Number of free blocks */ __u32 ifree; /* Number of free inodes */ __u32 efree[VXFS_NEFREE]; /* Number of free extents by size */ __u32 flags; /* Flags ?!? */ __u8 mod; /* Filesystem has been changed */ __u8 clean; /* Clean FS */ __u16 unused4; /* ?? */ __u32 firstlogid; /* Mount time log ID */ __u32 wtime; /* Last time written - sec */ __u32 wutime; /* Last time written - usec */ __u8 fname[6]; /* FS name */ __u8 fpack[6]; /* FS pack name */ __u32 logversion; /* Log format version */ __u32 unused5; /* ?? */ /* Version 2, Read-only */ __u32 oltext[2]; /* OLT extent and replica */ __u32 oltsize; /* OLT extent size */ __u32 iauimlen; /* Size of inode map */ __u32 iausize; /* Size of IAU in blocks */ __u32 dinosize; /* Size of inode in bytes */ __u32 old_dniaddr; /* OLD: Sum of indir levels per inode */ __u32 checksum2; /* Checksum of V2 RO */ /* Version 2, writable */ /* Version 3, read-only */ /* Version 3, writable */ }; /* * OLT entry (vxfs_olt*) types */ #define VXFS_OLTFREE 1 #define VXFS_OLTFSHEAD 2 #define VXFS_OLTCUT 3 #define VXFS_OLTILIST 4 #define VXFS_OLTDEV 5 #define VXFS_OLTSB 6 struct vxfs_olt { __u32 magic; /* Magic number */ __u32 size; /* Size of this entry */ __u32 checksum; /* Checksum of extent */ __u32 unused1; /* ?? */ __u32 mtime; /* Time of last OLT modification - sec */ __u32 mutime; /* Time of last OLT modification - usec */ __u32 totfree; /* Free space in OLT extent */ __u32 extents[2]; /* Addr of this extent and it's replica */ __u32 esize; /* Size of this extent */ __u32 next[2]; /* Address of next extent and it's replica */ __u32 nsize; /* Size of next extent */ __u32 unused2; /* Align to 8 byte boundary */ }; /* * Common OLT entry */ struct vxfs_oltcommon { __u32 type; /* Type of this record */ __u32 size; /* Size of this record */ }; /* * Free OLT entry */ struct vxfs_oltfree { __u32 type; /* Type of this record */ __u32 fsize; /* Size of this free record */ }; /* * Initial-inode list */ struct vxfs_oltilist { __u32 type; /* Type of this record */ __u32 size; /* Size of this record */ __u32 iext[2]; /* Initial inode list and it's replica */ }; /* * Current Usage Table */ struct vxfs_oltcut { __u32 type; /* Type of this record */ __u32 size; /* Size of this record */ __u32 cutino; /* Inode of current usage table */ __u32 padding; /* Unused, 8 byte align */ }; /* * Inodes containing Superblock, Intent log and OLTs */ struct vxfs_oltsb { __u32 type; /* Type of this record */ __u32 size; /* Size of this record */ __u32 sbino; /* Inode of superblock file */ __u32 unused1; /* ?? */ __u32 logino[2]; /* Inode of log file and it's replica */ __u32 oltino[2]; /* Unode of OLT ant it's replica */ }; /* * Inode containing device configuration + it's replica */ struct vxfs_oltdev { __u32 type; /* Type of this record */ __u32 size; /* Size of this record */ __u32 devino[2]; /* Inode of device config file and it's repl. */ }; /* * Fileset header */ struct vxfs_oltfshead { __u32 type; /* Type number */ __u32 size; /* Size of this record */ __u32 fsino[2]; /* Inode & replica of fileset header */ }; /* * OLT entry */ union vxfs_oltent { struct vxfs_oltcommon oltcommon; struct vxfs_oltfshead oltfshead; struct vxfs_oltcut oltcut; struct vxfs_oltilist oltilist; struct vxfs_oltdev oltdev; struct vxfs_oltsb oltsb; }; #define VXFS_ISIZE 0x100 /* Inode size */ #define VXFS_NDADDR 10 /* Number of direct addrs in inode */ #define VXFS_NIADDR 2 /* Number of indirect addrs in inode */ #define VXFS_NIMMED 96 /* Size of immediate data in inode */ #define VXFS_NTYPED 6 /* Num of typed extents */ #define VXFS_TYPED_OFFSETMASK ((__u64)0x00FFFFFFFFFFFFFFUL) #define VXFS_TYPED_TYPEMASK ((__u64)0xFF00000000000000UL) #define VXFS_TYPED_TYPESHIFT 56 #define VXFS_TYPED_INDIRECT 1 #define VXFS_TYPED_DATA 2 struct vxfs_typed { __u64 hdr; /* Header, 0xTTOOOOOOOOOOOOOO; T=type,O=offs */ __u32 block; /* Extent block */ __u32 size; /* Size in blocks */ }; struct vxfs_inode { __u32 mode; __u32 nlink; /* Link count */ __u32 uid; /* UID */ __u32 gid; /* GID */ __u64 size; /* Inode size in bytes */ __u32 atime; /* Last time accessed - sec */ __u32 autime; /* Last time accessed - usec */ __u32 mtime; /* Last modify time - sec */ __u32 mutime; /* Last modify time - usec */ __u32 ctime; /* Create time - sec */ __u32 cutime; /* Create time - usec */ __u8 aflags; /* Allocation flags */ __u8 orgtype; /* Organisation type */ __u16 eopflags; __u32 eopdata; union ftarea { __u32 rdev; __u32 dotdot; struct regular { __u32 reserved; __u32 fixextsize; } regular; struct vxspec { __u32 matchino; __u32 fsetindex; } vxspec; } ftarea; __u32 blocks; /* How much blocks does inode occupy */ __u32 gen; /* Inode generation */ __u64 version; /* Version */ union org { __u8 immed[VXFS_NIMMED]; /* Immediate data */ struct ext4 /* Ext4 organisation */ { __u32 spare; /* ?? */ __u32 indsize; /* Indirect extent size */ __u32 indirect; /* Single indirect extent */ __u32 dblindirect; /* Double indirect extent */ struct direct /* Direct extents */ { __u32 extent; /* Extent number */ __u32 size; /* Size of extent */ } direct[VXFS_NDADDR]; } ext4; struct vxfs_typed typed[VXFS_NTYPED]; } org; __u32 iattrino; } __attribute__ ((packed)); /* * File modes. File types above 0xf000 are vxfs internal only, they should * not be passed back to higher levels of the system. vxfs file types must * never have one of the regular file type bits set. */ #define VXFS_IFIFO 0x00001000 /* Named pipe */ #define VXFS_IFCHR 0x00002000 /* Character device */ #define VXFS_IFDIR 0x00004000 /* Directory */ #define VXFS_IFNAM 0x00005000 /* Xenix device ?? */ #define VXFS_IFBLK 0x00006000 /* Block device */ #define VXFS_IFREG 0x00008000 /* Regular file */ #define VXFS_IFCMP 0x00009000 /* Compressed file ?!? */ #define VXFS_IFLNK 0x0000a000 /* Symlink */ #define VXFS_IFSOC 0x0000c000 /* Socket */ /* VxFS internal */ #define VXFS_IFFSH 0x10000000 /* Fileset header */ #define VXFS_IFILT 0x20000000 /* Inode list */ #define VXFS_IFIAU 0x30000000 /* Inode allocation unit */ #define VXFS_IFCUT 0x40000000 /* Current usage table */ #define VXFS_IFATT 0x50000000 /* Attr. inode */ #define VXFS_IFLCT 0x60000000 /* Link count table */ #define VXFS_IFIAT 0x70000000 /* Indirect attribute file */ #define VXFS_IFEMR 0x80000000 /* Extent map reorg file */ #define VXFS_IFQUO 0x90000000 /* BSD quota file */ #define VXFS_IFPTI 0xa0000000 /* "Pass through" inode */ #define VXFS_IFLAB 0x11000000 /* Device label file */ #define VXFS_IFOLT 0x12000000 /* OLT file */ #define VXFS_IFLOG 0x13000000 /* Log file */ #define VXFS_IFEMP 0x14000000 /* Extent map file */ #define VXFS_IFEAU 0x15000000 /* Extent AU file */ #define VXFS_IFAUS 0x16000000 /* Extent AU summary file */ #define VXFS_IFDEV 0x17000000 /* Device config file */ #define VXFS_ISUID 0x0800 /* setuid */ #define VXFS_ISGID 0x0400 /* setgid */ #define VXFS_ISVTX 0x0200 /* sticky bit */ #define VXFS_IREAD 0x0100 /* read */ #define VXFS_IWRITE 0x0080 /* write */ #define VXFS_IEXEC 0x0040 /* exec */ #define VXFS_IS_TYPE(x,y) ( ((x)->mode & 0xfffff000) == y) #define VXFS_ISFIFO(x) VXFS_IS_TYPE(x,VXFS_IFIFO) #define VXFS_ISCHR(x) VXFS_IS_TYPE(x,VXFS_IFCHR) #define VXFS_ISDIR(x) VXFS_IS_TYPE(x,VXFS_IFDIR) #define VXFS_ISNAM(x) VXFS_IS_TYPE(x,VXFS_IFNAM) #define VXFS_ISBLK(x) VXFS_IS_TYPE(x,VXFS_IFBLK) #define VXFS_ISLNK(x) VXFS_IS_TYPE(x,VXFS_IFLNK) #define VXFS_ISREG(x) VXFS_IS_TYPE(x,VXFS_IFREG) #define VXFS_ISCMP(x) VXFS_IS_TYPE(x,VXFS_IFCMP) #define VXFS_ISSOC(x) VXFS_IS_TYPE(x,VXFS_IFSOC) #define VXFS_ISFSH(x) VXFS_IS_TYPE(x,VXFS_IFFSH) #define VXFS_ISILT(x) VXFS_IS_TYPE(x,VXFS_IFILT) /* * org types */ #define VXFS_ORG_NONE 0 /* Inode has *no* format ?!? */ #define VXFS_ORG_EXT4 1 /* Ext4 */ #define VXFS_ORG_IMMED 2 /* All data stored in inode */ #define VXFS_ORG_TYPED 3 /* Typed extents */ #define VXFS_IS_ORG(x,y) ( (x)->orgtype == y) #define VXFS_ISNONE(x) VXFS_IS_ORG(x,VXFS_ORG_NONE) #define VXFS_ISEXT4(x) VXFS_IS_ORG(x,VXFS_ORG_EXT4) #define VXFS_ISIMMED(x) VXFS_IS_ORG(x,VXFS_ORG_IMMED) #define VXFS_ISTYPED(x) VXFS_IS_ORG(x,VXFS_ORG_TYPED) /* * Fileset header */ struct vxfs_fsh { __u32 version; /* Fileset header version */ __u32 fsindex; __u32 time; __u32 utime; __u32 extop; __u32 ninodes; __u32 nau; __u32 old_ilesize; __u32 dflags; __u32 quota; __u32 maxinode; __u32 iauino; __u32 ilistino[2]; __u32 lctino; /* Version 3*/ __u32 uquotino; __u32 gquotino; __u8 old_fsetname[32]; __u32 checksum; __u32 attrilistino[2]; /* Attribute inode and it's replica */ __u32 attriauino; /* IAU for attr ilist */ }; /* * VxFS directory structure */ #define VXFS_MAXNAMELEN 256 struct vxfs_dirblk { __u16 free; __u16 nhash; __u16 hash[1]; }; struct vxfs_direct { __u32 ino; __u16 reclen; __u16 namelen; __u16 hashnext; __u8 name[VXFS_MAXNAMELEN]; }; #endif /* __VXFS_H */