1995-04-29 03:21:14 -04:00
|
|
|
/*
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
2002-03-25 08:52:45 -05:00
|
|
|
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
|
1995-04-29 03:21:14 -04:00
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2001-09-30 17:16:57 -04:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
1995-04-29 03:21:14 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/disklabel.h>
|
2000-06-28 18:28:50 -04:00
|
|
|
#include <paths.h>
|
1995-04-29 03:21:14 -04:00
|
|
|
#include "libdisk.h"
|
|
|
|
|
|
2002-10-23 15:52:32 -04:00
|
|
|
void
|
2002-11-15 08:24:29 -05:00
|
|
|
Fill_Disklabel(struct disklabel *dl, const struct disk *new,
|
2003-02-04 12:35:23 -05:00
|
|
|
const struct chunk *c1)
|
1995-04-30 02:09:29 -04:00
|
|
|
{
|
|
|
|
|
struct chunk *c2;
|
2002-10-23 15:32:18 -04:00
|
|
|
int j;
|
1995-04-30 02:09:29 -04:00
|
|
|
|
2001-04-01 08:18:20 -04:00
|
|
|
memset(dl, 0, sizeof *dl);
|
1995-04-30 02:09:29 -04:00
|
|
|
|
2002-11-15 08:24:29 -05:00
|
|
|
for (c2 = c1->part; c2; c2 = c2->next) {
|
|
|
|
|
if (c2->type == unused)
|
|
|
|
|
continue;
|
|
|
|
|
if (!strcmp(c2->name, "X"))
|
|
|
|
|
continue;
|
1999-01-29 06:39:24 -05:00
|
|
|
j = c2->name[strlen(c2->name) - 1] - 'a';
|
2002-10-23 15:32:18 -04:00
|
|
|
if (j < 0 || j >= MAXPARTITIONS || j == RAW_PART)
|
1995-04-30 02:09:29 -04:00
|
|
|
continue;
|
|
|
|
|
dl->d_partitions[j].p_size = c2->size;
|
1995-04-30 18:51:05 -04:00
|
|
|
dl->d_partitions[j].p_offset = c2->offset;
|
1995-04-30 07:04:16 -04:00
|
|
|
dl->d_partitions[j].p_fstype = c2->subtype;
|
1995-04-30 02:09:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl->d_bbsize = BBSIZE;
|
1995-08-26 00:57:03 -04:00
|
|
|
/*
|
|
|
|
|
* Add in defaults for superblock size, interleave, and rpms
|
|
|
|
|
*/
|
2002-10-22 05:13:02 -04:00
|
|
|
dl->d_sbsize = 0;
|
1995-04-30 02:09:29 -04:00
|
|
|
|
2001-04-01 08:18:20 -04:00
|
|
|
strcpy(dl->d_typename, c1->name);
|
1995-04-30 02:09:29 -04:00
|
|
|
|
1995-04-30 07:04:16 -04:00
|
|
|
dl->d_secsize = 512;
|
1995-04-30 02:09:29 -04:00
|
|
|
dl->d_secperunit = new->chunks->size;
|
2002-11-15 08:24:29 -05:00
|
|
|
dl->d_ncylinders = new->bios_cyl;
|
|
|
|
|
dl->d_ntracks = new->bios_hd;
|
|
|
|
|
dl->d_nsectors = new->bios_sect;
|
1995-04-30 07:04:16 -04:00
|
|
|
dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors;
|
1995-04-30 02:09:29 -04:00
|
|
|
|
|
|
|
|
dl->d_npartitions = MAXPARTITIONS;
|
|
|
|
|
|
1998-06-26 22:01:25 -04:00
|
|
|
dl->d_type = new->name[0] == 's' || new->name[0] == 'd' ||
|
|
|
|
|
new->name[0] == 'o' ? DTYPE_SCSI : DTYPE_ESDI;
|
1995-04-30 02:09:29 -04:00
|
|
|
dl->d_partitions[RAW_PART].p_size = c1->size;
|
1995-04-30 18:51:05 -04:00
|
|
|
dl->d_partitions[RAW_PART].p_offset = c1->offset;
|
2000-03-29 10:10:28 -05:00
|
|
|
dl->d_rpm = 3600;
|
|
|
|
|
dl->d_interleave = 1;
|
1995-04-30 02:09:29 -04:00
|
|
|
|
|
|
|
|
dl->d_magic = DISKMAGIC;
|
|
|
|
|
dl->d_magic2 = DISKMAGIC;
|
|
|
|
|
dl->d_checksum = dkcksum(dl);
|
2002-10-23 15:32:18 -04:00
|
|
|
}
|