/* vi:set shiftwidth=2 cindent tabstop=2: */ /* * vxtools - Tools for accessing Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * vxidump.c: Dump an inode * * 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 char *usage = "Usage: %s [-dh] [name...]\n" "\n" "Report bugs to \n"; void dumpfile (char *filename) { int ino; struct vxfs_inode *inode; long long size; int blkno; char *buf; int i; ino = vxlookup (filename); if (ino < 0) { printf ("%s: No such file or directory\n", filename); return; } inode = vxiget (ino); if (inode == NULL) { printf ("%s: Can't get inode %u\n", filename, ino); return; } printf ("%s:\n", filename); vxidump (inode); vxiput (inode); } int main (int argc, char **argv) { int ch; char *argv0 = argv[0]; char device[0x100], cwd[0x100]; int subpart; char path[0x100]; vxverboseon (); subpart = 0; while ((ch = getopt (argc, argv, "dh")) != -1) { switch (ch) { case 'd': vxdebugon (); break; case 'h': fprintf (stderr, usage, argv0); exit (0); default: fprintf (stderr, usage, argv0); exit (1); } } argc -= optind; argv += optind; if (argc < 1) { fprintf (stderr, usage, argv0); exit (1); } if (vxreadcwd (device, &subpart, cwd) < 0) { fprintf (stderr, "%s: No VxFS filesystem mounted, use vxmount(8)\n", argv0); exit (1); } if (vx_open (device, subpart) < 0) { fprintf (stderr, "%s: Can't mount VxFS %s\n", argv0, device); exit (1); } while (argc--) { if (argv[0][0] == '/') strcpy (path, argv[0]); else { strcpy (path, cwd); strcat (path, "/"); strcat (path, argv[0]); } dumpfile (path); argv++; } return 0; }