/* vi:set tabstop=2 cindent shiftwidth=2: */ /* * libvxfs - library for reading Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * iread.c: VxFS inode block read 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 void * vxiread (struct vxfs_inode *ino, int blknum, int count) { void *blk, *rblk; int blkno; int i; if (count == 0) return 0; blk = malloc (vxbsize * count); if (!blk) { if (vxverbose) fprintf (stderr, "vxiread(%u): Not enough memory!\n", blknum); return 0; } /* Process IMMED data */ if (ino->orgtype == VXFS_ORG_IMMED) { if (blknum != 0 || count != 1) { free (blk); return 0; } memcpy (blk, ino->org.immed, VXFS_NIMMED); return blk; } for (i = 0; i < count; i++) { switch (ino->orgtype) { case VXFS_ORG_EXT4: blkno = vxbmap_ext4 (ino, blknum + i); break; case VXFS_ORG_TYPED: blkno = vxbmap_typed (ino, blknum + i); break; } if (blkno == -1) { if (vxverbose) printf ("vxiread: bxbmap returned -1\n"); free (blk); return 0; } rblk = vxread (blkno, 1); if (rblk == 0) { if (vxverbose) printf ("vxiread: vxread() failed\n"); free (blk); return 0; } memcpy ((char *) blk + (i * vxbsize), rblk, vxbsize); free (rblk); } return blk; }