fdisk.c (1254a3ba7b2244fde84af7aa9a8f7aaf89c70a4b) fdisk.c (29ea697d8a504bd4018486ff5c415f7b31c37d0a)
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

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

467 ,partp->dp_ehd
468 ,DPSECT(partp->dp_esect));
469}
470
471
472static void
473init_boot(void)
474{
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

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

467 ,partp->dp_ehd
468 ,DPSECT(partp->dp_esect));
469}
470
471
472static void
473init_boot(void)
474{
475#ifndef __ia64__
475 const char *fname;
476 int fdesc, n;
477 struct stat sb;
478
479 fname = b_flag ? b_flag : "/boot/mbr";
480 if ((fdesc = open(fname, O_RDONLY)) == -1 ||
481 fstat(fdesc, &sb) == -1)
482 err(1, "%s", fname);
483 if ((mboot.bootinst_size = sb.st_size) % secsize != 0)
484 errx(1, "%s: length must be a multiple of sector size", fname);
485 if (mboot.bootinst != NULL)
486 free(mboot.bootinst);
487 if ((mboot.bootinst = malloc(mboot.bootinst_size = sb.st_size)) == NULL)
488 errx(1, "%s: unable to allocate read buffer", fname);
489 if ((n = read(fdesc, mboot.bootinst, mboot.bootinst_size)) == -1 ||
490 close(fdesc))
491 err(1, "%s", fname);
492 if (n != mboot.bootinst_size)
493 errx(1, "%s: short read", fname);
476 const char *fname;
477 int fdesc, n;
478 struct stat sb;
479
480 fname = b_flag ? b_flag : "/boot/mbr";
481 if ((fdesc = open(fname, O_RDONLY)) == -1 ||
482 fstat(fdesc, &sb) == -1)
483 err(1, "%s", fname);
484 if ((mboot.bootinst_size = sb.st_size) % secsize != 0)
485 errx(1, "%s: length must be a multiple of sector size", fname);
486 if (mboot.bootinst != NULL)
487 free(mboot.bootinst);
488 if ((mboot.bootinst = malloc(mboot.bootinst_size = sb.st_size)) == NULL)
489 errx(1, "%s: unable to allocate read buffer", fname);
490 if ((n = read(fdesc, mboot.bootinst, mboot.bootinst_size)) == -1 ||
491 close(fdesc))
492 err(1, "%s", fname);
493 if (n != mboot.bootinst_size)
494 errx(1, "%s: short read", fname);
495#else
496 if (mboot.bootinst != NULL)
497 free(mboot.bootinst);
498 mboot.bootinst_size = secsize;
499 if ((mboot.bootinst = malloc(mboot.bootinst_size)) == NULL)
500 errx(1, "unable to allocate boot block buffer");
501 memset(mboot.bootinst, 0, mboot.bootinst_size);
502 *(uint16_t *)&mboot.bootinst[MBRSIGOFF] = BOOT_MAGIC;
503#endif
494}
495
496
497static void
498init_sector0(unsigned long start)
499{
500 struct dos_partition *partp = (struct dos_partition *) (&mboot.parts[3]);
501

--- 840 unchanged lines hidden ---
504}
505
506
507static void
508init_sector0(unsigned long start)
509{
510 struct dos_partition *partp = (struct dos_partition *) (&mboot.parts[3]);
511

--- 840 unchanged lines hidden ---