/* vi:set tabstop=2 shiftwidth=2 cindent: */ /* * libvxfs - library for reading Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * olt.c: Object Location Table routines * * 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. * * $Id$ */ #include #include #include struct vxfs_olt vxolt; struct vxfs_oltilist vxoltilist; struct vxfs_oltcut vxoltcut; struct vxfs_oltfshead vxoltfshead; struct vxfs_inode *vxilistino; struct vxfs_inode *vxstructuralilistino; int have_oltilist = 0; int have_oltfshead = 0; int vx_readolt (void) { void *block; int blocks; struct vxfs_fsh *primary_fsh; struct vxfs_fsh *structural_fsh; union vxfs_oltent *ent; struct vxfs_inode *fshino; struct vxfs_inode *ino; int i; if (vxdebug) printf ("Reading OLT (%u blocks at %08x)...\n", vxsb.oltsize, vxsb.oltext[0]); block = vxread (vxsb.oltext[0], vxsb.oltsize); memcpy (&vxolt, block, sizeof (vxolt)); if (vxolt.magic != VXFS_OLTMAGIC) { if (vxverbose) fprintf (stderr, "read_olt: Invalid magic number (vxolt.magic=%08x)\n", vxolt.magic); return -1; } memcpy (&vxolt, block, sizeof (vxolt)); ent = block + vxolt.size; while (ent < (block + (vxsb.oltsize * vxbsize))) { switch (ent->oltcommon.type) { case VXFS_OLTFREE: break; case VXFS_OLTFSHEAD: memcpy (&vxoltfshead, ent, sizeof (vxoltfshead)); have_oltfshead = 1; break; case VXFS_OLTCUT: break; case VXFS_OLTILIST: memcpy (&vxoltilist, ent, sizeof (vxoltilist)); have_oltilist = 1; break; case VXFS_OLTDEV: break; case VXFS_OLTSB: break; } ent = (char *) ent + ent->oltcommon.size; } if (vxdebug) { printf ("vxoltilist.iext[0] = %u\n", vxoltilist.iext[0]); printf ("vxoltilist.iext[1] = %u\n", vxoltilist.iext[1]); printf ("vxoltfshead.fsino[0] = %u\n", vxoltfshead.fsino[0]); printf ("vxoltfshead.fsino[1] = %u\n", vxoltfshead.fsino[2]); } /* * Inodes are stored in extent(s) vxoltilist.iext[0,1]. Inode size is * 0x100. */ fshino = vxblkiget (vxoltilist.iext[0], vxoltfshead.fsino[0]); structural_fsh = vxiread (fshino, 0, 1); primary_fsh = vxiread (fshino, 1, 1); #if 0 printf ("fsh.version = %u\n", fsh->version); printf ("fsh.fsindex = %u\n", fsh->fsindex); printf ("fsh.iauino = %u\n", fsh->iauino); printf ("fsh.ninodes = %u\n", fsh->ninodes); printf ("fsh.maxinode = %u\n", fsh->maxinode); printf ("fsh.lctino = %u\n", fsh->lctino); printf ("fsh.nau = %u\n", fsh->nau); printf ("fsh.ilistino[0] = %u\n", fsh->ilistino[0]); printf ("fsh.ilistino[1] = %u\n", fsh->ilistino[1]); #endif vxstructuralilistino = vxblkiget (vxoltilist.iext[0], structural_fsh->ilistino[0]); if (!VXFS_ISILT(vxstructuralilistino)) { if (vxdebug) printf("Warning: vxstructuralilistino is not type VXFS_FSILT!\n"); } vxilistino = vxigetstructural (primary_fsh->ilistino[0]); if (!VXFS_ISILT(vxilistino)) { if (vxdebug) printf("Warning: vxilistino is not type VXFS_FSILT!\n"); } free (block); return 0; }