Deleted Added
full compact
geom_pc98.c (108591) geom_pc98.c (108650)
1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/geom/geom_pc98.c 108591 2003-01-03 07:13:36Z nyan $
32 * $FreeBSD: head/sys/geom/geom_pc98.c 108650 2003-01-04 08:50:48Z nyan $
33 */
34
35#include <sys/param.h>
36#ifndef _KERNEL
37#include <signal.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>

--- 9 unchanged lines hidden (view full) ---

50
51#include <sys/diskpc98.h>
52#include <geom/geom.h>
53#include <geom/geom_slice.h>
54
55#define PC98_CLASS_NAME "PC98"
56
57static void
33 */
34
35#include <sys/param.h>
36#ifndef _KERNEL
37#include <signal.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>

--- 9 unchanged lines hidden (view full) ---

50
51#include <sys/diskpc98.h>
52#include <geom/geom.h>
53#include <geom/geom_slice.h>
54
55#define PC98_CLASS_NAME "PC98"
56
57static void
58g_dec_dos_partition(u_char *ptr, struct dos_partition *d)
58g_dec_pc98_partition(u_char *ptr, struct pc98_partition *d)
59{
60 u_int u;
61
62 d->dp_mid = ptr[0];
63 d->dp_sid = ptr[1];
64 d->dp_dum1 = ptr[2];
65 d->dp_dum2 = ptr[3];
66 d->dp_ipl_sct = ptr[4];

--- 11 unchanged lines hidden (view full) ---

78
79struct g_pc98_softc {
80 u_int fwsectors, fwheads, sectorsize;
81 int type[NDOSPART];
82 u_char sec[8192];
83};
84
85static void
59{
60 u_int u;
61
62 d->dp_mid = ptr[0];
63 d->dp_sid = ptr[1];
64 d->dp_dum1 = ptr[2];
65 d->dp_dum2 = ptr[3];
66 d->dp_ipl_sct = ptr[4];

--- 11 unchanged lines hidden (view full) ---

78
79struct g_pc98_softc {
80 u_int fwsectors, fwheads, sectorsize;
81 int type[NDOSPART];
82 u_char sec[8192];
83};
84
85static void
86g_pc98_print(int i, struct dos_partition *dp)
86g_pc98_print(int i, struct pc98_partition *dp)
87{
88 char sname[17];
89
90 strncpy(sname, dp->dp_name, 16);
91 sname[16] = '\0';
92
93 g_hexdump(dp, sizeof(dp[0]));
94 printf("[%d] mid:%d(0x%x) sid:%d(0x%x)",
95 i, dp->dp_mid, dp->dp_mid, dp->dp_sid, dp->dp_sid);
96 printf(" s:%d/%d/%d", dp->dp_scyl, dp->dp_shd, dp->dp_ssect);
97 printf(" e:%d/%d/%d", dp->dp_ecyl, dp->dp_ehd, dp->dp_esect);
98 printf(" sname:%s\n", sname);
99}
100
101static int
102g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec)
103{
104 int i, error;
105 off_t s[NDOSPART], l[NDOSPART];
87{
88 char sname[17];
89
90 strncpy(sname, dp->dp_name, 16);
91 sname[16] = '\0';
92
93 g_hexdump(dp, sizeof(dp[0]));
94 printf("[%d] mid:%d(0x%x) sid:%d(0x%x)",
95 i, dp->dp_mid, dp->dp_mid, dp->dp_sid, dp->dp_sid);
96 printf(" s:%d/%d/%d", dp->dp_scyl, dp->dp_shd, dp->dp_ssect);
97 printf(" e:%d/%d/%d", dp->dp_ecyl, dp->dp_ehd, dp->dp_esect);
98 printf(" sname:%s\n", sname);
99}
100
101static int
102g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec)
103{
104 int i, error;
105 off_t s[NDOSPART], l[NDOSPART];
106 struct dos_partition dp[NDOSPART];
106 struct pc98_partition dp[NDOSPART];
107
108 g_topology_assert();
109
110 if (sec[0x1fe] != 0x55 || sec[0x1ff] != 0xaa)
111 return (EBUSY);
112
113#if 0
114 /*
115 * XXX: Some sources indicate this is a magic sequence, but appearantly
116 * XXX: it is not universal. Documentation would be wonderfule to have.
117 */
118 if (sec[4] != 'I' || sec[5] != 'P' || sec[6] != 'L' || sec[7] != '1')
119 return (EBUSY);
120#endif
121
122 for (i = 0; i < NDOSPART; i++)
107
108 g_topology_assert();
109
110 if (sec[0x1fe] != 0x55 || sec[0x1ff] != 0xaa)
111 return (EBUSY);
112
113#if 0
114 /*
115 * XXX: Some sources indicate this is a magic sequence, but appearantly
116 * XXX: it is not universal. Documentation would be wonderfule to have.
117 */
118 if (sec[4] != 'I' || sec[5] != 'P' || sec[6] != 'L' || sec[7] != '1')
119 return (EBUSY);
120#endif
121
122 for (i = 0; i < NDOSPART; i++)
123 g_dec_dos_partition(
124 sec + 512 + i * sizeof(struct dos_partition), &dp[i]);
123 g_dec_pc98_partition(
124 sec + 512 + i * sizeof(struct pc98_partition), &dp[i]);
125
126 for (i = 0; i < NDOSPART; i++) {
127 /* If start and end are identical it's bogus */
128 if (dp[i].dp_ssect == dp[i].dp_esect &&
129 dp[i].dp_shd == dp[i].dp_ehd &&
130 dp[i].dp_scyl == dp[i].dp_ecyl)
131 s[i] = l[i] = 0;
132 else if (dp[i].dp_ecyl == 0)

--- 117 unchanged lines hidden (view full) ---

250}
251
252static void
253g_pc98_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
254 struct g_consumer *cp __unused, struct g_provider *pp)
255{
256 struct g_pc98_softc *mp;
257 struct g_slicer *gsp;
125
126 for (i = 0; i < NDOSPART; i++) {
127 /* If start and end are identical it's bogus */
128 if (dp[i].dp_ssect == dp[i].dp_esect &&
129 dp[i].dp_shd == dp[i].dp_ehd &&
130 dp[i].dp_scyl == dp[i].dp_ecyl)
131 s[i] = l[i] = 0;
132 else if (dp[i].dp_ecyl == 0)

--- 117 unchanged lines hidden (view full) ---

250}
251
252static void
253g_pc98_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
254 struct g_consumer *cp __unused, struct g_provider *pp)
255{
256 struct g_pc98_softc *mp;
257 struct g_slicer *gsp;
258 struct dos_partition dp;
258 struct pc98_partition dp;
259 char sname[17];
260
261 gsp = gp->softc;
262 mp = gsp->softc;
263 g_slice_dumpconf(sb, indent, gp, cp, pp);
264 if (pp != NULL) {
259 char sname[17];
260
261 gsp = gp->softc;
262 mp = gsp->softc;
263 g_slice_dumpconf(sb, indent, gp, cp, pp);
264 if (pp != NULL) {
265 g_dec_dos_partition(
265 g_dec_pc98_partition(
266 mp->sec + 512 +
266 mp->sec + 512 +
267 pp->index * sizeof(struct dos_partition), &dp);
267 pp->index * sizeof(struct pc98_partition), &dp);
268 strncpy(sname, dp.dp_name, 16);
269 sname[16] = '\0';
270 if (indent == NULL) {
271 sbuf_printf(sb, " ty %d", mp->type[pp->index]);
272 sbuf_printf(sb, " sn %s", sname);
273 } else {
274 sbuf_printf(sb, "%s<type>%d</type>\n", indent,
275 mp->type[pp->index]);

--- 76 unchanged lines hidden ---
268 strncpy(sname, dp.dp_name, 16);
269 sname[16] = '\0';
270 if (indent == NULL) {
271 sbuf_printf(sb, " ty %d", mp->type[pp->index]);
272 sbuf_printf(sb, " sn %s", sname);
273 } else {
274 sbuf_printf(sb, "%s<type>%d</type>\n", indent,
275 mp->type[pp->index]);

--- 76 unchanged lines hidden ---