Deleted Added
full compact
fdisk.c (108470) fdisk.c (108650)
1/*
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

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

21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27#ifndef lint
28static const char rcsid[] =
1/*
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

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

21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27#ifndef lint
28static const char rcsid[] =
29 "$FreeBSD: head/sbin/fdisk_pc98/fdisk.c 108470 2002-12-30 21:18:15Z schweikh $";
29 "$FreeBSD: head/sbin/fdisk_pc98/fdisk.c 108650 2003-01-04 08:50:48Z nyan $";
30#endif /* not lint */
31
32#include <sys/disk.h>
33#include <sys/disklabel.h>
34#include <sys/diskpc98.h>
35#include <sys/param.h>
36#include <sys/stat.h>
37#include <sys/mount.h>

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

78
79static int cyls, sectors, heads, cylsecs, disksecs;
80
81#ifdef PC98
82struct mboot {
83 unsigned char padding[2]; /* force the longs to be long aligned */
84 unsigned char bootinst[510];
85 unsigned short int signature;
30#endif /* not lint */
31
32#include <sys/disk.h>
33#include <sys/disklabel.h>
34#include <sys/diskpc98.h>
35#include <sys/param.h>
36#include <sys/stat.h>
37#include <sys/mount.h>

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

78
79static int cyls, sectors, heads, cylsecs, disksecs;
80
81#ifdef PC98
82struct mboot {
83 unsigned char padding[2]; /* force the longs to be long aligned */
84 unsigned char bootinst[510];
85 unsigned short int signature;
86 struct dos_partition parts[8];
86 struct pc98_partition parts[8];
87 unsigned char large_sector_overflow[MAX_SEC_SIZE-MIN_SEC_SIZE];
88};
89#else /* PC98 */
90struct mboot {
91 unsigned char padding[2]; /* force the longs to be long aligned */
92 unsigned char *bootinst; /* boot code */
93 off_t bootinst_size;
94 struct dos_partition parts[4];

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

214#endif
215
216int
217main(int argc, char *argv[])
218{
219 struct stat sb;
220 int c, i;
221 int partition = -1;
87 unsigned char large_sector_overflow[MAX_SEC_SIZE-MIN_SEC_SIZE];
88};
89#else /* PC98 */
90struct mboot {
91 unsigned char padding[2]; /* force the longs to be long aligned */
92 unsigned char *bootinst; /* boot code */
93 off_t bootinst_size;
94 struct dos_partition parts[4];

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

214#endif
215
216int
217main(int argc, char *argv[])
218{
219 struct stat sb;
220 int c, i;
221 int partition = -1;
222 struct dos_partition *partp;
222 struct pc98_partition *partp;
223
224#ifdef PC98
225 while ((c = getopt(argc, argv, "Ba:f:istuv12345678")) != -1)
226#else
227 while ((c = getopt(argc, argv, "BIab:f:istuv1234")) != -1)
228#endif
229 switch (c) {
230 case 'B':

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

314 if (s_flag) {
315 if (read_s0())
316 err(1, "read_s0");
317 printf("%s: %d cyl %d hd %d sec\n", disk, dos_cyls, dos_heads,
318 dos_sectors);
319#ifdef PC98
320 printf("Part %11s %11s SID\n", "Start", "Size");
321 for (i = 0; i < NDOSPART; i++) {
223
224#ifdef PC98
225 while ((c = getopt(argc, argv, "Ba:f:istuv12345678")) != -1)
226#else
227 while ((c = getopt(argc, argv, "BIab:f:istuv1234")) != -1)
228#endif
229 switch (c) {
230 case 'B':

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

314 if (s_flag) {
315 if (read_s0())
316 err(1, "read_s0");
317 printf("%s: %d cyl %d hd %d sec\n", disk, dos_cyls, dos_heads,
318 dos_sectors);
319#ifdef PC98
320 printf("Part %11s %11s SID\n", "Start", "Size");
321 for (i = 0; i < NDOSPART; i++) {
322 partp = ((struct dos_partition *) &mboot.parts) + i;
322 partp = ((struct pc98_partition *) &mboot.parts) + i;
323 if (partp->dp_sid == 0)
324 continue;
325 printf("%4d: %11lu %11lu 0x%02x\n", i + 1,
326 partp->dp_scyl * cylsecs,
327 (partp->dp_ecyl - partp->dp_scyl + 1) * cylsecs,
328 partp->dp_sid);
329#else
330 printf("Part %11s %11s Type Flags\n", "Start", "Size");

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

432 printf("Information from DOS bootblock is:\n");
433 if (which == -1)
434 for (i = 1; i <= NDOSPART; i++)
435 printf("%d: ", i), print_part(i);
436 else
437 print_part(which);
438}
439
323 if (partp->dp_sid == 0)
324 continue;
325 printf("%4d: %11lu %11lu 0x%02x\n", i + 1,
326 partp->dp_scyl * cylsecs,
327 (partp->dp_ecyl - partp->dp_scyl + 1) * cylsecs,
328 partp->dp_sid);
329#else
330 printf("Part %11s %11s Type Flags\n", "Start", "Size");

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

432 printf("Information from DOS bootblock is:\n");
433 if (which == -1)
434 for (i = 1; i <= NDOSPART; i++)
435 printf("%d: ", i), print_part(i);
436 else
437 print_part(which);
438}
439
440static struct dos_partition mtpart;
440static struct pc98_partition mtpart;
441
442static void
443print_part(int i)
444{
441
442static void
443print_part(int i)
444{
445 struct dos_partition *partp;
445 struct pc98_partition *partp;
446 u_int64_t part_sz, part_mb;
447
446 u_int64_t part_sz, part_mb;
447
448 partp = ((struct dos_partition *) &mboot.parts) + i - 1;
448 partp = ((struct pc98_partition *) &mboot.parts) + i - 1;
449
449
450 if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
450 if (!bcmp(partp, &mtpart, sizeof (struct pc98_partition))) {
451 printf("<UNUSED>\n");
452 return;
453 }
454 /*
455 * Be careful not to overflow.
456 */
457#ifdef PC98
458 part_sz = (partp->dp_ecyl - partp->dp_scyl + 1) * cylsecs;

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

517#endif
518}
519
520
521static void
522init_sector0(unsigned long start)
523{
524#ifdef PC98
451 printf("<UNUSED>\n");
452 return;
453 }
454 /*
455 * Be careful not to overflow.
456 */
457#ifdef PC98
458 part_sz = (partp->dp_ecyl - partp->dp_scyl + 1) * cylsecs;

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

517#endif
518}
519
520
521static void
522init_sector0(unsigned long start)
523{
524#ifdef PC98
525 struct dos_partition *partp =
526 (struct dos_partition *)(&mboot.parts[3]);
525 struct pc98_partition *partp =
526 (struct pc98_partition *)(&mboot.parts[3]);
527 unsigned long size = disksecs - start;
528
529 init_boot();
530
531 partp->dp_mid = DOSMID_386BSD;
532 partp->dp_sid = DOSSID_386BSD;
533
534 dos(start, size, &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);

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

552
553 dos(partp);
554#endif
555}
556
557static void
558change_part(int i)
559{
527 unsigned long size = disksecs - start;
528
529 init_boot();
530
531 partp->dp_mid = DOSMID_386BSD;
532 partp->dp_sid = DOSSID_386BSD;
533
534 dos(start, size, &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);

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

552
553 dos(partp);
554#endif
555}
556
557static void
558change_part(int i)
559{
560 struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i - 1;
560 struct pc98_partition *partp =
561 ((struct pc98_partition *) &mboot.parts) + i - 1;
561
562 printf("The data for partition %d is:\n", i);
563 print_part(i);
564
565 if (u_flag && ok("Do you want to change it?")) {
566 int tmp;
567
568 if (i_flag) {
562
563 printf("The data for partition %d is:\n", i);
564 print_part(i);
565
566 if (u_flag && ok("Do you want to change it?")) {
567 int tmp;
568
569 if (i_flag) {
569 bzero((char *)partp, sizeof (struct dos_partition));
570 bzero((char *)partp, sizeof (struct pc98_partition));
570 if (i == 4) {
571 init_sector0(1);
572 printf("\nThe static data for the DOS partition 4 has been reinitialized to:\n");
573 print_part(i);
574 }
575 }
576
577 do {

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

664 printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
665 ,dos_cyls,dos_heads,dos_sectors,dos_cylsecs);
666}
667
668static void
669change_active(int which)
670{
671#ifdef PC98
571 if (i == 4) {
572 init_sector0(1);
573 printf("\nThe static data for the DOS partition 4 has been reinitialized to:\n");
574 print_part(i);
575 }
576 }
577
578 do {

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

665 printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
666 ,dos_cyls,dos_heads,dos_sectors,dos_cylsecs);
667}
668
669static void
670change_active(int which)
671{
672#ifdef PC98
672 struct dos_partition *partp = ((struct dos_partition *) &mboot.parts);
673 struct pc98_partition *partp = ((struct pc98_partition *) &mboot.parts);
673 int active, i, tmp;
674
675 active = 8;
676#else
677 struct dos_partition *partp = &mboot.parts[0];
678 int active, i, new, tmp;
679
680 active = -1;

--- 529 unchanged lines hidden ---
674 int active, i, tmp;
675
676 active = 8;
677#else
678 struct dos_partition *partp = &mboot.parts[0];
679 int active, i, new, tmp;
680
681 active = -1;

--- 529 unchanged lines hidden ---