/* vi:set shiftwidth=2 cindent tabstop=2: */ /* * vxtools - Tools for accessing Veritas Journaled FileSystem (VxFS) * Copyright (c) 1999 Martin Hinner * * prtvtoc.c: Print a vtoc * * 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 char *usage = "Usage: %s [-adehp] [special]\n" "\n" "Report bugs to \n"; char *tags[] = { "UNUSED\t", "BOOT\t", "ROOT\t", "SWAP\t", "USR\t", "BACKUP\t", "ALT SEC\t", "OTHER\t", "ALT TRK\t", "STAND\t", "VAR\t", "HOME\t", "DUMP\t", "ALT SEC/TRK", "VOLPUBLIC", "VOLPRIVATE" }; int main (int argc, char **argv) { int ch; char *argv0 = argv[0]; struct uw_vtoc *vtoc; int i; vxverboseon (); while ((ch = getopt (argc, argv, "adehp")) != -1) { switch (ch) { case 'd': vxdebugon (); break; case 'h': fprintf (stderr, usage, argv0); exit (0); case 'a': case 'e': case 'p': break; default: fprintf (stderr, usage, argv0); exit (1); } } argc -= optind; argv += optind; if (argc != 1) { fprintf (stderr, usage, argv0); exit (1); } if (vxopendev (argv[0]) < 0) { fprintf (stderr, "%s: Can't open %s\n", argv0, argv[0]); exit (1); } vtoc = vxreaduwvtoc (); if (vtoc == NULL) { fprintf (stderr, "%s: vxreaduwvtoc failed\n", argv0); exit (1); } for (i = 0; i < V_NUMPAR; i++) { if (vtoc->part[i].tag != V_UNUSED) { printf ("slice %u:\t%s\tpermissions:\t", i, (vtoc->part[i].tag>0x0F?"?":tags[vtoc->part[i].tag])); if (vtoc->part[i].flag & V_UNMNT) printf("UNMOUNTABLE "); if (vtoc->part[i].flag & V_RONLY) printf("READONLY "); if (vtoc->part[i].flag & V_REMAP) printf("REMAP "); if (vtoc->part[i].flag & V_OPEN) printf("OPEN "); if (vtoc->part[i].flag & V_VALID) printf("VALID "); printf ("\n"); printf ("\tstarting sector:\t%u\t\tlength:\t%u\n", vtoc->part[i].start, vtoc->part[i].size); } } return 0; }