/* vi:set tabstop=2 shiftwidth=2 cindent: */ /* * libvxfs - library for reading Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * super.c: VxFS superblock and mount 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 #include #include struct vxfs_super vxsb; int vx_readsuper (void) { void *block; block = vxread (1, 1); memcpy (&vxsb, block, sizeof (vxsb)); if (vxsb.magic != VXFS_MAGIC) { if (vxverbose) fprintf (stderr, "read_super: Invalid magic number (vxsb.magic=%08x)\n", vxsb.magic); return -1; } /* * XXX: superblock checksum */ /* * XXX: Check version */ if (vxdebug) { printf ("VxFS version = %u\n", vxsb.version); printf ("Volume label = %s\n", vxsb.fname); printf ("Pack label = %s\n", vxsb.fpack); } free (block); return 0; } int vx_open (char *device, int subpart) { if (vxdebug) printf ("Opening VxFS %s..\n", device); if (vxopendev (device) < 0) { if (vxverbose) fprintf (stderr, "vx_open: vxopendev failed\n"); return -1; } if (vxsetpart (subpart) < 0) { if (vxverbose) fprintf (stderr, "vx_open: vxsetpart failed\n"); return -1; } if (vxdebug) printf("Reading filesystem structures...\n"); if (vx_readsuper () < 0) return -1; if (vx_readolt () < 0) return -1; /* * XXX: current usage table */ if (vxdebug) printf ("VxFS initialized\n"); return 0; }