1 /* vi:set cindent tabstop=2 shiftwidth=2: */
2 /*
3  * libvxfs - library for reading Veritas Journaled FileSystem (VxFS)
4  * Copyright (c) 1999 Martin Hinner <mhi@penguin.cz>
5  *
6  * uw_vtoc.h: UnixWare 2 and 7 vtoc
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  */
24 #ifndef __UW_VTOC_H
25 #define __UW_VTOC_H
26 
27 #define VTOC_SECTOR         29
28 #define VTOC_DOSTYPE        0x63		/* UnixWare / SCO Unix / SysV / GNU HURD */
29 #define VTOC_BSIZE          512
30 #define V_NUMPAR            16			/* VTOC contains 16 partitions */
31 
32 
33 /* This structure comes from genhd.h, Copyright (C) 1992 Drew Eckhardt */
34 struct uw_dospt {
35        __u8 code[0x1be];			 /* MBR code */
36 struct part {
37         __u8 boot_ind;         /* 0x80 - active */
38         __u8 head;             /* starting head */
39         __u8 sector;           /* starting sector */
40 				__u8 cyl;              /* starting cylinder */
41 				__u8 sys_ind;          /* What partition type */
42 				__u8 end_head;         /* end head */
43 				__u8 end_sector;       /* end sector */
44 				__u8 end_cyl;          /* end cylinder */
45 				__u32 start_sect;      /* starting sector counting from 0 */
46 				__u32 nr_sects;        /* nr of sectors in partition */
47 } part[4];
48 				__u16 magic;
49 } __attribute__((packed));
50 
51 
52 struct uw_partition
53 	{
54 		__u16 tag;									/* ID tag of partition */
55 		__u16 flag;									/* Permission flags */
56 		__u32 start;								/* Start sector of partition */
57 		__u32 size;									/* Number of blocks in parition */
58 	};
59 
60 struct uw_vtoc
61 	{
62 		__u32 sanity;								/* to verify vtoc sanity */
63 		__u32 version;							/* layout version */
64 		__u8 name[8];								/* volume name */
65 		__u16 nparts;								/* Number of partitions */
66 		__u16 pad;									/* 4 byte align */
67 		__u32 reserved[10];					/* ?? */
68 		struct uw_partition part[V_NUMPAR];		/* Partitions */
69 		__u32 timestamp[V_NUMPAR];	/* Time stamp ? */
70 	};
71 
72 struct uw_disklabel {
73         __u32   type;                 /* drive type */
74         __u32   magic;                /* the magic number */
75         __u32   version;              /* version number */
76         char    serial[12];           /* serial number of the device */
77         __u32   ncylinders;           /* # of data cylinders per device */
78         __u32   ntracks;              /* # of tracks per cylinder */
79         __u32   nsectors;             /* # of data sectors per track */
80         __u32   secsize;              /* # of bytes per sector */
81         __u32   part_start;           /* # of first sector of this partition */
82         __u32   unknown1[12];         /* ? */
83         __u32   alt_tbl;              /* byte offset of alternate table */
84         __u32   alt_len;              /* byte length of alternate table */
85         __u32   phys_cyl;             /* # of physical cylinders per device */
86         __u32   phys_trk;             /* # of physical tracks per cylinder */
87         __u32   phys_sec;             /* # of physical sectors per track */
88         __u32   phys_bytes;           /* # of physical bytes per sector */
89         __u32   unknown2;             /* ? */
90         __u32   unknown3;             /* ? */
91         __u32   pad[8];               /* pad */
92 				struct uw_vtoc vtoc;
93 };
94 
95 #define VTOC_SANE               0x600DDEEEUL    /* Indicates a sane VTOC */
96 #define UNIXWARE_DISKMAGIC      0xCA5E600DUL    /* The disk magic number */
97 
98 /* Partition identification tags */
99 #define V_UNUSED        0x00		/* Unused slice */
100 #define V_BOOT          0x01		/* Boot slice */
101 #define V_ROOT          0x02		/* Root filesystem */
102 #define V_SWAP          0x03		/* Swap filesystem */
103 #define V_USR           0x04		/* Usr filesystem */
104 #define V_BACKUP        0x05		/* Full disk */
105 #define V_ALTS          0x06		/* Alternate sector space */
106 #define V_OTHER         0x07		/* Non-unix space */
107 #define V_ALTTRK        0x08		/* Alternate track space */
108 #define V_STAND         0x09		/* Stand slice */
109 #define V_VAR           0x0A		/* Var slice */
110 #define V_HOME          0x0B		/* Home slice */
111 #define V_DUMP          0x0C		/* Dump slice */
112 #define V_ALTSCTR       0x0D		/* Alternate sector slice */
113 #define V_MANAGED_1     0x0E		/* Volume management public slice */
114 #define V_MANAGED_2     0x0F		/* Volume management private slice */
115 
116 /* Partition permission flags */
117 #define V_UNMNT         0x0001	/* Unmountable partition */
118 #define V_RONLY         0x0010	/* Read only */
119 #define V_REMAP         0x0020	/* Do alternate sector mapping */
120 #define V_OPEN          0x0100	/* Partition open (for driver use) */
121 #define V_VALID         0x0200	/* Partition is valid to use */
122 
123 #endif /* __UW_VTOC_H */
124