summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2002-11-15 13:24:29 +0000
committernyan <nyan@FreeBSD.org>2002-11-15 13:24:29 +0000
commit6677381325604b5404dc24855d477b72fcd3ad95 (patch)
treed03d1e9b1f00b3ca30c6b7c90866d9495e4dfeed
parentabff45d114507b07cdaace4b07ff55e179442f82 (diff)
downloadFreeBSD-src-6677381325604b5404dc24855d477b72fcd3ad95.zip
FreeBSD-src-6677381325604b5404dc24855d477b72fcd3ad95.tar.gz
Fixed style(9)
-rw-r--r--lib/libdisk/change.c14
-rw-r--r--lib/libdisk/chunk.c131
-rw-r--r--lib/libdisk/create_chunk.c86
-rw-r--r--lib/libdisk/disk.c102
-rw-r--r--lib/libdisk/libdisk.h77
-rw-r--r--lib/libdisk/rules.c43
-rw-r--r--lib/libdisk/tst01.c129
-rw-r--r--lib/libdisk/write_alpha_disk.c8
-rw-r--r--lib/libdisk/write_amd64_disk.c87
-rw-r--r--lib/libdisk/write_disk.c19
-rw-r--r--lib/libdisk/write_i386_disk.c87
-rw-r--r--lib/libdisk/write_ia64_disk.c22
-rw-r--r--lib/libdisk/write_pc98_disk.c72
-rw-r--r--lib/libdisk/write_sparc64_disk.c18
14 files changed, 485 insertions, 410 deletions
diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c
index 7788534..fa12ad9 100644
--- a/lib/libdisk/change.c
+++ b/lib/libdisk/change.c
@@ -21,6 +21,7 @@ __FBSDID("$FreeBSD$");
void
Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
{
+
disk->bios_cyl = cyl;
disk->bios_hd = hd;
disk->bios_sect = sect;
@@ -47,7 +48,8 @@ Sanitize_Bios_Geom(struct disk *disk)
if (disk->bios_sect > 63)
#endif
sane = 0;
- if (disk->bios_cyl*disk->bios_hd*disk->bios_sect != disk->chunks->size)
+ if (disk->bios_cyl * disk->bios_hd * disk->bios_sect !=
+ disk->chunks->size)
sane = 0;
if (sane)
return;
@@ -55,7 +57,8 @@ Sanitize_Bios_Geom(struct disk *disk)
/* First try something that IDE can handle */
disk->bios_sect = 63;
disk->bios_hd = 16;
- disk->bios_cyl = disk->chunks->size / (disk->bios_sect*disk->bios_hd);
+ disk->bios_cyl = disk->chunks->size /
+ (disk->bios_sect * disk->bios_hd);
#ifdef PC98
if (disk->bios_cyl < 65536)
@@ -72,9 +75,8 @@ Sanitize_Bios_Geom(struct disk *disk)
#else
disk->bios_hd = 255;
#endif
- disk->bios_cyl = disk->chunks->size / (disk->bios_sect*disk->bios_hd);
-
- return;
+ disk->bios_cyl = disk->chunks->size /
+ (disk->bios_sect * disk->bios_hd);
}
void
@@ -89,7 +91,7 @@ All_FreeBSD(struct disk *d, int force_all)
type = 0xa5;
#endif
- again:
+again:
for (c = d->chunks->part; c; c = c->next)
if (c->type != unused) {
Delete_Chunk(d, c);
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index f1f95b6..49df0e5 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -44,40 +44,40 @@ Chunk_Inside(const struct chunk *c1, const struct chunk *c2)
}
static struct chunk *
-Find_Mother_Chunk(struct chunk *chunks, u_long offset, u_long end, chunk_e type)
+Find_Mother_Chunk(struct chunk *chunks, u_long offset, u_long end,
+ chunk_e type)
{
- struct chunk *c1,*c2,ct;
+ struct chunk *c1, *c2, ct;
ct.offset = offset;
ct.end = end;
switch (type) {
- case whole:
- if (Chunk_Inside(chunks, &ct))
- return chunks;
- case extended:
- for(c1 = chunks->part; c1; c1 = c1->next) {
- if (c1->type != type)
- continue;
+ case whole:
+ if (Chunk_Inside(chunks, &ct))
+ return chunks;
+ case extended:
+ for (c1 = chunks->part; c1; c1 = c1->next) {
+ if (c1->type != type)
+ continue;
+ if (Chunk_Inside(c1, &ct))
+ return c1;
+ }
+ return 0;
+ case freebsd:
+ for (c1 = chunks->part; c1; c1 = c1->next) {
+ if (c1->type == type)
if (Chunk_Inside(c1, &ct))
return c1;
- }
- return 0;
- case freebsd:
- for(c1 = chunks->part; c1; c1 = c1->next) {
- if (c1->type == type)
- if (Chunk_Inside(c1, &ct))
- return c1;
- if (c1->type != extended)
- continue;
- for(c2 = c1->part; c2; c2 = c2->next)
- if (c2->type == type
- && Chunk_Inside(c2, &ct))
- return c2;
- }
- return 0;
- default:
- warn("Unsupported mother type in Find_Mother_Chunk");
- return 0;
+ if (c1->type != extended)
+ continue;
+ for (c2 = c1->part; c2; c2 = c2->next)
+ if (c2->type == type && Chunk_Inside(c2, &ct))
+ return c2;
+ }
+ return 0;
+ default:
+ warn("Unsupported mother type in Find_Mother_Chunk");
+ return 0;
}
}
@@ -149,7 +149,7 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
return __LINE__;
}
- if(type==freebsd || type==extended) {
+ if (type == freebsd || type == extended) {
cs = New_Chunk();
if (cs == NULL)
return __LINE__;
@@ -173,9 +173,9 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
cs->disk = c2->disk;
cs->offset = ct->end + 1;
cs->size = c2->end - ct->end;
- if(c2->sname != NULL)
+ if (c2->sname != NULL)
cs->sname = strdup(c2->sname);
- if(c2->name)
+ if (c2->name)
cs->name = strdup(c2->name);
c2->next = cs;
c2->size -= c2->end - ct->end;
@@ -205,9 +205,9 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
int
Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
- chunk_e type, int subtype, u_long flags, const char *sname)
+ chunk_e type, int subtype, u_long flags, const char *sname)
{
- struct chunk *c1,*c2,ct;
+ struct chunk *c1, *c2, ct;
u_long end = offset + size - 1;
ct.offset = offset;
ct.end = end;
@@ -322,8 +322,8 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
break;
if (!(flags & CHUNK_ALIGN))
break;
- if (offset == d->chunks->offset
- && end == d->chunks->end)
+ if (offset == d->chunks->offset &&
+ end == d->chunks->end)
break;
/* Round down to prev cylinder */
@@ -355,20 +355,24 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
}
if (c2 == NULL)
return (__LINE__);
- return Insert_Chunk(c2, offset, size, name,
- type, subtype, flags, sname);
+ return Insert_Chunk(c2, offset, size, name, type, subtype, flags,
+ sname);
}
char *
ShowChunkFlags(struct chunk *c)
{
static char ret[10];
-
- int i=0;
- if (c->flags & CHUNK_ACTIVE) ret[i++] = 'A';
- if (c->flags & CHUNK_ALIGN) ret[i++] = '=';
- if (c->flags & CHUNK_IS_ROOT) ret[i++] = 'R';
+ int i = 0;
+
+ if (c->flags & CHUNK_ACTIVE)
+ ret[i++] = 'A';
+ if (c->flags & CHUNK_ALIGN)
+ ret[i++] = '=';
+ if (c->flags & CHUNK_IS_ROOT)
+ ret[i++] = 'R';
ret[i++] = '\0';
+
return ret;
}
@@ -376,11 +380,16 @@ static void
Print_Chunk(struct chunk *c1,int offset)
{
int i;
- if(!c1) return;
- for(i = 0; i < offset - 2; i++) putchar(' ');
- for(; i < offset; i++) putchar('-');
+
+ if (!c1)
+ return;
+ for (i = 0; i < offset - 2; i++)
+ putchar(' ');
+ for (; i < offset; i++)
+ putchar('-');
putchar('>');
- for(; i < 10; i++) putchar(' ');
+ for (; i < 10; i++)
+ putchar(' ');
printf("%p %8ld %8lu %8lu %-8s %-16s %-8s 0x%02x %s",
c1, c1->offset, c1->size, c1->end, c1->name, c1->sname,
chunk_name(c1->type), c1->subtype,
@@ -393,39 +402,41 @@ Print_Chunk(struct chunk *c1,int offset)
void
Debug_Chunk(struct chunk *c1)
{
+
Print_Chunk(c1,2);
}
int
Delete_Chunk(struct disk *d, struct chunk *c)
{
+
return(Delete_Chunk2(d, c, 0));
}
int
Delete_Chunk2(struct disk *d, struct chunk *c, int rflags)
{
- struct chunk *c1=0, *c2, *c3;
+ struct chunk *c1 = 0, *c2, *c3;
chunk_e type = c->type;
u_long offset = c->offset;
if(type == whole)
return 1;
#ifndef PC98
- if(!c1 && (type == freebsd || type == fat || type == unknown))
+ if (!c1 && (type == freebsd || type == fat || type == unknown))
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended);
#endif
- if(!c1 && (type == freebsd || type == fat || type == unknown))
+ if (!c1 && (type == freebsd || type == fat || type == unknown))
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
#ifndef PC98
- if(!c1 && type == extended)
+ if (!c1 && type == extended)
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
#endif
- if(!c1 && type == part)
+ if (!c1 && type == part)
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, freebsd);
- if(!c1)
+ if (!c1)
return 1;
- for(c2 = c1->part; c2; c2 = c2->next) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
if (c2 == c) {
c2->type = unused;
c2->subtype = 0;
@@ -441,7 +452,7 @@ Delete_Chunk2(struct disk *d, struct chunk *c, int rflags)
}
}
return 1;
- scan:
+scan:
/*
* Collapse multiple unused elements together, and attempt
* to extend the previous chunk into the freed chunk.
@@ -450,7 +461,7 @@ Delete_Chunk2(struct disk *d, struct chunk *c, int rflags)
* for newfs (we can't extend working filesystems), and
* only if we are called with DELCHUNK_RECOVER.
*/
- for(c2 = c1->part; c2; c2 = c2->next) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type != unused) {
if (c2->offset + c2->size != offset ||
(rflags & DELCHUNK_RECOVER) == 0 ||
@@ -481,10 +492,10 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
{
struct chunk *c2, *c3;
- if(c1->next && Collapse_Chunk(d, c1->next))
+ if (c1->next && Collapse_Chunk(d, c1->next))
return 1;
- if(c1->type == unused && c1->next && c1->next->type == unused) {
+ if (c1->type == unused && c1->next && c1->next->type == unused) {
c3 = c1->next;
c1->size += c3->size;
c1->end = c3->end;
@@ -494,7 +505,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
return 1;
}
c3 = c1->part;
- if(!c3)
+ if (!c3)
return 0;
if (Collapse_Chunk(d, c1->part))
return 1;
@@ -502,11 +513,11 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
if (c1->type == whole)
return 0;
- if(c3->type == unused && c3->size == c1->size) {
+ if (c3->type == unused && c3->size == c1->size) {
Delete_Chunk(d, c1);
return 1;
}
- if(c3->type == unused) {
+ if (c3->type == unused) {
c2 = New_Chunk();
if (c2 == NULL)
barfout(1, "malloc failed");
@@ -528,7 +539,7 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
Free_Chunk(c3);
return 1;
}
- for(c2=c3;c2->next;c2 = c2->next)
+ for (c2 = c3; c2->next; c2 = c2->next)
c3 = c2;
if (c2 && c2->type == unused) {
c3->next = 0;
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 7acb9b5..dfccb9d 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -39,57 +39,66 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
struct chunk *c1, *c3;
int j;
- if (!strcmp(c->name, "X")) return 0;
+ if (!strcmp(c->name, "X"))
+ return 0;
/* reset all names to "X" */
for (c1 = c->part; c1; c1 = c1->next) {
c1->oname = c1->name;
c1->name = malloc(12);
- if(!c1->name) return -1;
+ if (!c1->name)
+ return -1;
strcpy(c1->name,"X");
}
/* Allocate the first swap-partition we find */
for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
- if (c1->subtype != FS_SWAP) continue;
+ if (c1->type == unused)
+ continue;
+ if (c1->subtype != FS_SWAP)
+ continue;
sprintf(c1->name, "%s%c", c->name, SWAP_PART + 'a');
break;
}
/* Allocate the first root-partition we find */
for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
- if (!(c1->flags & CHUNK_IS_ROOT)) continue;
+ if (c1->type == unused)
+ continue;
+ if (!(c1->flags & CHUNK_IS_ROOT))
+ continue;
sprintf(c1->name, "%s%c", c->name, 0 + 'a');
break;
}
/* Try to give them the same as they had before */
for (c1 = c->part; c1; c1 = c1->next) {
- if (strcmp(c1->name, "X")) continue;
- for(c3 = c->part; c3 ; c3 = c3->next)
- if (c1 != c3 && !strcmp(c3->name, c1->oname)) {
- goto newname;
- }
+ if (strcmp(c1->name, "X"))
+ continue;
+ for (c3 = c->part; c3 ; c3 = c3->next)
+ if (c1 != c3 && !strcmp(c3->name, c1->oname))
+ goto newname;
strcpy(c1->name, c1->oname);
- newname: ;
+ newname:
+ ;
}
-
-
+
/* Allocate the rest sequentially */
for (c1 = c->part; c1; c1 = c1->next) {
const char order[] = "defghab";
- if (c1->type == unused) continue;
- if (strcmp("X", c1->name)) continue;
+
+ if (c1->type == unused)
+ continue;
+ if (strcmp("X", c1->name))
+ continue;
- for(j = 0; j < strlen(order); j++) {
+ for (j = 0; j < strlen(order); j++) {
sprintf(c1->name, "%s%c", c->name, order[j]);
- for(c3 = c->part; c3 ; c3 = c3->next)
+ for (c3 = c->part; c3 ; c3 = c3->next)
if (c1 != c3 && !strcmp(c3->name, c1->name))
goto match;
break;
- match:
+ match:
strcpy(c1->name, "X");
continue;
}
@@ -106,13 +115,15 @@ static int
Fixup_Extended_Names(struct disk *d, struct chunk *c)
{
struct chunk *c1;
- int j=5;
+ int j = 5;
for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
+ if (c1->type == unused)
+ continue;
free(c1->name);
c1->name = malloc(12);
- if(!c1->name) return -1;
+ if (!c1->name)
+ return -1;
sprintf(c1->name, "%ss%d", d->chunks->name, j++);
if (c1->type == freebsd)
if (Fixup_FreeBSD_Names(d, c1) != 0)
@@ -132,17 +143,18 @@ Fixup_Names(struct disk *d)
#endif
c1 = d->chunks;
- for(c2 = c1->part; c2 ; c2 = c2->next) {
+ for (c2 = c1->part; c2 ; c2 = c2->next) {
if (c2->type == unused)
continue;
if (strcmp(c2->name, "X"))
continue;
#if defined(__i386__) || defined(__ia64__)
c2->oname = malloc(12);
- if(!c2->oname) return -1;
- for(j = 1; j <= NDOSPART; j++) {
+ if (!c2->oname)
+ return -1;
+ for (j = 1; j <= NDOSPART; j++) {
sprintf(c2->oname, "%ss%d", c1->name, j);
- for(c3 = c1->part; c3; c3 = c3->next)
+ for (c3 = c1->part; c3; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, c2->oname))
goto match;
free(c2->name);
@@ -159,7 +171,7 @@ Fixup_Names(struct disk *d)
c2->name = strdup(c1->name);
#endif /*__i386__*/
}
- for(c2 = c1->part; c2; c2 = c2->next) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type == freebsd)
Fixup_FreeBSD_Names(d, c2);
#ifndef PC98
@@ -171,12 +183,13 @@ Fixup_Names(struct disk *d)
}
int
-Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags, const char *sname)
+Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type,
+ int subtype, u_long flags, const char *sname)
{
int i;
u_long l;
- if(!(flags & CHUNK_FORCE_ALL)) {
+ if (!(flags & CHUNK_FORCE_ALL)) {
#ifdef PC98
/* Never use the first cylinder */
if (!offset) {
@@ -202,7 +215,8 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty
}
struct chunk *
-Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags)
+Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size,
+ chunk_e type, int subtype, u_long flags)
{
int i;
struct chunk *c1;
@@ -210,19 +224,21 @@ Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size, chun
if (!parent)
parent = d->chunks;
- for (c1=parent->part; c1; c1 = c1->next) {
- if (c1->type != unused) continue;
- if (c1->size < size) continue;
+ for (c1 = parent->part; c1; c1 = c1->next) {
+ if (c1->type != unused)
+ continue;
+ if (c1->size < size)
+ continue;
offset = c1->offset;
goto found;
}
return 0;
- found:
+found:
i = Add_Chunk(d, offset, size, "X", type, subtype, flags, "-");
if (i)
return 0;
Fixup_Names(d);
- for (c1=parent->part; c1; c1 = c1->next)
+ for (c1 = parent->part; c1; c1 = c1->next)
if (c1->offset == offset)
return c1;
/* barfout(1, "Serious internal trouble"); */
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index ee917be..54dda63 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -90,6 +90,7 @@ uuid_type(uuid_t *uuid)
struct disk *
Open_Disk(const char *name)
{
+
return Int_Open_Disk(name);
}
@@ -153,11 +154,17 @@ Int_Open_Disk(const char *name)
a = strsep(&p, " "); /* length in bytes */
len = strtoimax(a, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
a = strsep(&p, " "); /* sectorsize */
s = strtoul(a, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
d->sector_size = s;
len /= s; /* media size in number of sectors. */
@@ -171,7 +178,10 @@ Int_Open_Disk(const char *name)
break;
b = strsep(&p, " ");
o = strtoul(b, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
if (!strcmp(a, "hd"))
d->bios_hd = o;
else if (!strcmp(a, "sc"))
@@ -198,15 +208,24 @@ Int_Open_Disk(const char *name)
if (!strcmp(a, "0"))
break;
l = strtoimax(a, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
t = strsep(&p, " "); /* Type {SUN, BSD, MBR, GPT} */
n = strsep(&p, " "); /* name */
a = strsep(&p, " "); /* len */
len = strtoimax(a, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
a = strsep(&p, " "); /* secsize */
s = strtoimax(a, &r, 0);
- if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
+ if (*r) {
+ printf("BARF %d <%d>\n", __LINE__, *r);
+ exit (0);
+ }
for (;;) {
a = strsep(&p, " ");
if (a == NULL)
@@ -237,7 +256,7 @@ Int_Open_Disk(const char *name)
alt = o;
}
- /* PLATFORM POLICY BEGIN ------------------------------------- */
+ /* PLATFORM POLICY BEGIN ----------------------------------- */
if (platform == p_sparc64 && !strcmp(t, "SUN") && i == 2)
continue;
if (platform == p_sparc64 && !strcmp(t, "SUN") &&
@@ -252,12 +271,13 @@ Int_Open_Disk(const char *name)
}
if (platform == p_alpha && !strcmp(t, "BSD") &&
d->chunks->part->part == NULL) {
- if (Add_Chunk(d, 0, d->chunks->size, name, freebsd, 0, 0, "-"))
+ if (Add_Chunk(d, 0, d->chunks->size, name, freebsd,
+ 0, 0, "-"))
DPRINT(("Failed to add 'freebsd' chunk"));
}
if (!strcmp(t, "BSD") && i == RAW_PART)
continue;
- /* PLATFORM POLICY END --------------------------------------- */
+ /* PLATFORM POLICY END ------------------------------------- */
off /= s;
len /= s;
@@ -305,8 +325,10 @@ Int_Open_Disk(const char *name)
}
} else if (!strcmp(t, "GPT"))
i = Add_Chunk(d, off, len, n, ty, 0, 0, 0);
- else
- { printf("BARF %d\n", __LINE__); exit(0); }
+ else {
+ printf("BARF %d\n", __LINE__);
+ exit(0);
+ }
}
/* PLATFORM POLICY BEGIN ------------------------------------- */
/* We have a chance to do things on a blank disk here */
@@ -328,9 +350,11 @@ Int_Open_Disk(const char *name)
void
Debug_Disk(struct disk *d)
{
+
printf("Debug_Disk(%s)", d->name);
#if 0
- printf(" real_geom=%lu/%lu/%lu", d->real_cyl, d->real_hd, d->real_sect);
+ printf(" real_geom=%lu/%lu/%lu",
+ d->real_cyl, d->real_hd, d->real_sect);
#endif
printf(" bios_geom=%lu/%lu/%lu = %lu\n",
d->bios_cyl, d->bios_hd, d->bios_sect,
@@ -355,21 +379,28 @@ Debug_Disk(struct disk *d)
void
Free_Disk(struct disk *d)
{
- if(d->chunks) Free_Chunk(d->chunks);
- if(d->name) free(d->name);
+ if (d->chunks)
+ Free_Chunk(d->chunks);
+ if (d->name)
+ free(d->name);
#ifdef PC98
- if(d->bootipl) free(d->bootipl);
- if(d->bootmenu) free(d->bootmenu);
+ if (d->bootipl)
+ free(d->bootipl);
+ if (d->bootmenu)
+ free(d->bootmenu);
#else
#if !defined(__ia64__)
- if(d->bootmgr) free(d->bootmgr);
+ if (d->bootmgr)
+ free(d->bootmgr);
#endif
#endif
#if !defined(__ia64__)
- if(d->boot1) free(d->boot1);
+ if (d->boot1)
+ free(d->boot1);
#endif
#if defined(__i386__)
- if(d->boot2) free(d->boot2);
+ if (d->boot2)
+ free(d->boot2);
#endif
free(d);
}
@@ -379,7 +410,7 @@ void
Collapse_Disk(struct disk *d)
{
- while(Collapse_Chunk(d, d->chunks))
+ while (Collapse_Chunk(d, d->chunks))
;
}
#endif
@@ -387,9 +418,9 @@ Collapse_Disk(struct disk *d)
static int
qstrcmp(const void* a, const void* b)
{
-
char *str1 = *(char**)a;
char *str2 = *(char**)b;
+
return strcmp(str1, str2);
}
@@ -428,7 +459,7 @@ Disk_Names()
disks[disk_cnt] = strsep(&disklist, " ");
if (disks[disk_cnt] == NULL)
break;
- }
+ }
qsort(disks, disk_cnt, sizeof(char*), qstrcmp);
return disks;
}
@@ -453,7 +484,8 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
} else {
d->bootipl_size = bootipl_size;
d->bootipl = malloc(bootipl_size);
- if(!d->bootipl) return;
+ if (!d->bootipl)
+ return;
memcpy(d->bootipl, bootipl, bootipl_size);
}
@@ -466,7 +498,8 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
} else {
d->bootmenu_size = bootmenu_size;
d->bootmenu = malloc(bootmenu_size);
- if(!d->bootmenu) return;
+ if (!d->bootmenu)
+ return;
memcpy(d->bootmenu, bootmenu, bootmenu_size);
}
#else
@@ -479,7 +512,8 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
} else {
d->bootmgr_size = s;
d->bootmgr = malloc(s);
- if(!d->bootmgr) return;
+ if (!d->bootmgr)
+ return;
memcpy(d->bootmgr, b, s);
}
#endif
@@ -490,18 +524,24 @@ int
Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2)
{
#if defined(__i386__)
- if (d->boot1) free(d->boot1);
+ if (d->boot1)
+ free(d->boot1);
d->boot1 = malloc(512);
- if(!d->boot1) return -1;
+ if (!d->boot1)
+ return -1;
memcpy(d->boot1, b1, 512);
- if (d->boot2) free(d->boot2);
+ if (d->boot2)
+ free(d->boot2);
d->boot2 = malloc(15 * 512);
- if(!d->boot2) return -1;
+ if (!d->boot2)
+ return -1;
memcpy(d->boot2, b2, 15 * 512);
#elif defined(__alpha__)
- if (d->boot1) free(d->boot1);
+ if (d->boot1)
+ free(d->boot1);
d->boot1 = malloc(15 * 512);
- if(!d->boot1) return -1;
+ if (!d->boot1)
+ return -1;
memcpy(d->boot1, b1, 15 * 512);
#elif defined(__sparc64__)
if (d->boot1 != NULL)
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index 406eb18..b3c5e08 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -48,9 +48,6 @@ const static enum platform {
#endif
;
-
-
-
typedef enum {
whole,
unknown,
@@ -151,33 +148,27 @@ const char *chunk_name(chunk_e);
const char *
slice_type_name(int, int);
-/* "chunk_n" for subtypes too
- */
+/* "chunk_n" for subtypes too */
struct disk *
Open_Disk(const char *);
-/* Will open the named disk, and return populated tree.
- */
+/* Will open the named disk, and return populated tree. */
void
Free_Disk(struct disk *);
-/* Free a tree made with Open_Disk() or Clone_Disk()
- */
+/* Free a tree made with Open_Disk() or Clone_Disk() */
void
Debug_Disk(struct disk *);
-/* Print the content of the tree to stdout
- */
+/* Print the content of the tree to stdout */
void
Set_Bios_Geom(struct disk *, u_long, u_long, u_long);
-/* Set the geometry the bios uses.
- */
+/* Set the geometry the bios uses. */
void
Sanitize_Bios_Geom(struct disk *);
-/* Set the bios geometry to something sane
- */
+/* Set the bios geometry to something sane */
int
Insert_Chunk(struct chunk *, u_long, u_long, const char *, chunk_e, int,
@@ -185,44 +176,40 @@ Insert_Chunk(struct chunk *, u_long, u_long, const char *, chunk_e, int,
int
Delete_Chunk2(struct disk *, struct chunk *, int);
-/* Free a chunk of disk_space modified by the passed
- * flags.
- */
+/* Free a chunk of disk_space modified by the passed flags. */
int
Delete_Chunk(struct disk *, struct chunk *);
-/* Free a chunk of disk_space
- */
+/* Free a chunk of disk_space */
void
Collapse_Disk(struct disk *);
-/* Experimental, do not use.
- */
+/* Experimental, do not use. */
+
int
Collapse_Chunk(struct disk *, struct chunk *);
-/* Experimental, do not use.
- */
+/* Experimental, do not use. */
int
Create_Chunk(struct disk *, u_long, u_long, chunk_e, int, u_long, const char *);
-/* Create a chunk with the specified paramters
- */
+/* Create a chunk with the specified paramters */
void
All_FreeBSD(struct disk *, int);
-/* Make one FreeBSD chunk covering the entire disk;
+/*
+ * Make one FreeBSD chunk covering the entire disk;
* if force_all is set, bypass all BIOS geometry
* considerations.
*/
char *
CheckRules(const struct disk *);
-/* Return char* to warnings about broken design rules in this disklayout
- */
+/* Return char* to warnings about broken design rules in this disklayout */
char **
Disk_Names(void);
-/* Return char** with all disk's names (wd0, wd1 ...). You must free
+/*
+ * Return char** with all disk's names (wd0, wd1 ...). You must free
* each pointer, as well as the array by hand
*/
@@ -234,53 +221,47 @@ Set_Boot_Mgr(struct disk *, const u_char *, const size_t, const u_char *,
void
Set_Boot_Mgr(struct disk *, const u_char *, const size_t);
#endif
-/* Use this boot-manager on this disk. Gets written when Write_Disk()
+/*
+ * Use this boot-manager on this disk. Gets written when Write_Disk()
* is called
*/
int
Set_Boot_Blocks(struct disk *, const u_char *, const u_char *);
-/* Use these boot-blocks on this disk. Gets written when Write_Disk()
+/*
+ * Use these boot-blocks on this disk. Gets written when Write_Disk()
* is called. Returns nonzero upon failure.
*/
int
Write_Disk(const struct disk *);
-/* Write all the MBRs, disklabels, bootblocks and boot managers
- */
+/* Write all the MBRs, disklabels, bootblocks and boot managers */
u_long
Next_Cyl_Aligned(const struct disk *, u_long);
-/* Round offset up to next cylinder according to the bios-geometry
- */
+/* Round offset up to next cylinder according to the bios-geometry */
u_long
Prev_Cyl_Aligned(const struct disk *, u_long);
-/* Round offset down to previous cylinder according to the bios-
- * geometry
- */
+/* Round offset down to previous cylinder according to the bios-geometry */
int
Track_Aligned(const struct disk *, u_long);
-/* Check if offset is aligned on a track according to the
- * bios geometry
- */
+/* Check if offset is aligned on a track according to the bios geometry */
u_long
Next_Track_Aligned(const struct disk *, u_long);
-/* Round offset up to next track according to the bios-geometry
- */
+/* Round offset up to next track according to the bios-geometry */
u_long
Prev_Track_Aligned(const struct disk *, u_long);
-/* Check if offset is aligned on a track according to the
- * bios geometry
- */
+/* Check if offset is aligned on a track according to the bios geometry */
struct chunk *
Create_Chunk_DWIM(struct disk *, const struct chunk *, u_long, chunk_e, int,
u_long);
-/* This one creates a partition inside the given parent of the given
+/*
+ * This one creates a partition inside the given parent of the given
* size, and returns a pointer to it. The first unused chunk big
* enough is used.
*/
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c
index b6a35fc..a49c587 100644
--- a/lib/libdisk/rules.c
+++ b/lib/libdisk/rules.c
@@ -27,6 +27,7 @@ __FBSDID("$FreeBSD$");
int
Track_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect)
return 1;
if (offset % d->bios_sect)
@@ -37,6 +38,7 @@ Track_Aligned(const struct disk *d, u_long offset)
u_long
Prev_Track_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect)
return offset;
return (offset / d->bios_sect) * d->bios_sect;
@@ -45,6 +47,7 @@ Prev_Track_Aligned(const struct disk *d, u_long offset)
u_long
Next_Track_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect)
return offset;
return Prev_Track_Aligned(d, offset + d->bios_sect-1);
@@ -53,6 +56,7 @@ Next_Track_Aligned(const struct disk *d, u_long offset)
static int
Cyl_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect || !d->bios_hd)
return 1;
if (offset % (d->bios_sect * d->bios_hd))
@@ -63,6 +67,7 @@ Cyl_Aligned(const struct disk *d, u_long offset)
u_long
Prev_Cyl_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect || !d->bios_hd)
return offset;
return (offset / (d->bios_sect*d->bios_hd)) * d->bios_sect * d->bios_hd;
@@ -71,9 +76,10 @@ Prev_Cyl_Aligned(const struct disk *d, u_long offset)
u_long
Next_Cyl_Aligned(const struct disk *d, u_long offset)
{
+
if (!d->bios_sect || !d->bios_hd)
return offset;
- return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd)-1);
+ return Prev_Cyl_Aligned(d,offset + (d->bios_sect * d->bios_hd) - 1);
}
/*
@@ -85,16 +91,17 @@ static void
Rule_000(const struct disk *d, const struct chunk *c, char *msg)
{
#ifdef PC98
- int i=0;
+ int i = 0;
#else
- int i=0,j=0;
+ int i = 0, j = 0;
#endif
struct chunk *c1;
if (c->type != whole)
return;
for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type != unused) continue;
+ if (c1->type != unused)
+ continue;
#ifndef PC98
if (c1->flags & CHUNK_ACTIVE)
j++;
@@ -103,12 +110,12 @@ Rule_000(const struct disk *d, const struct chunk *c, char *msg)
}
if (i > NDOSPART)
sprintf(msg + strlen(msg),
- "%d is too many children of the 'whole' chunk. Max is %d\n",
- i, NDOSPART);
+ "%d is too many children of the 'whole' chunk."
+ " Max is %d\n", i, NDOSPART);
#ifndef PC98
if (j > 1)
sprintf(msg + strlen(msg),
- "Too many active children of 'whole'");
+ "Too many active children of 'whole'");
#endif
}
@@ -125,7 +132,8 @@ Rule_001(const struct disk *d, const struct chunk *c, char *msg)
if (c->type != whole && c->type != extended)
return;
for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
+ if (c1->type == unused)
+ continue;
c1->flags |= CHUNK_ALIGN;
#ifdef PC98
if (!Cyl_Aligned(d, c1->offset))
@@ -134,9 +142,11 @@ Rule_001(const struct disk *d, const struct chunk *c, char *msg)
#endif
sprintf(msg + strlen(msg),
#ifdef PC98
- "chunk '%s' [%ld..%ld] does not start on a cylinder boundary\n",
+ "chunk '%s' [%ld..%ld] does not start"
+ " on a cylinder boundary\n",
#else
- "chunk '%s' [%ld..%ld] does not start on a track boundary\n",
+ "chunk '%s' [%ld..%ld] does not start"
+ " on a track boundary\n",
#endif
c1->name, c1->offset, c1->end);
if ((c->type == whole || c->end == c1->end)
@@ -144,7 +154,8 @@ Rule_001(const struct disk *d, const struct chunk *c, char *msg)
;
else
sprintf(msg + strlen(msg),
- "chunk '%s' [%ld..%ld] does not end on a cylinder boundary\n",
+ "chunk '%s' [%ld..%ld] does not end"
+ " on a cylinder boundary\n",
c1->name, c1->offset, c1->end);
}
}
@@ -168,7 +179,7 @@ Rule_002(const struct disk *d, const struct chunk *c, char *msg)
}
if (i > 1) {
sprintf(msg + strlen(msg),
- "Max one 'fat' allowed as child of 'whole'\n");
+ "Max one 'fat' allowed as child of 'whole'\n");
}
}
@@ -191,7 +202,7 @@ Rule_003(const struct disk *d, const struct chunk *c, char *msg)
}
if (i > 1) {
sprintf(msg + strlen(msg),
- "Max one 'extended' allowed as child of 'whole'\n");
+ "Max one 'extended' allowed as child of 'whole'\n");
}
}
@@ -203,7 +214,7 @@ Rule_003(const struct disk *d, const struct chunk *c, char *msg)
static void
Rule_004(const struct disk *d, const struct chunk *c, char *msg)
{
- int i=0,k=0;
+ int i = 0, k = 0;
struct chunk *c1;
if (c->type != freebsd)
@@ -218,11 +229,11 @@ Rule_004(const struct disk *d, const struct chunk *c, char *msg)
}
if (i > 7) {
sprintf(msg + strlen(msg),
- "Max seven partitions per freebsd slice\n");
+ "Max seven partitions per freebsd slice\n");
}
if (k > 1) {
sprintf(msg + strlen(msg),
- "Max one root partition child per freebsd slice\n");
+ "Max one root partition child per freebsd slice\n");
}
}
diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c
index 83a6a6f..b260635 100644
--- a/lib/libdisk/tst01.c
+++ b/lib/libdisk/tst01.c
@@ -82,7 +82,7 @@ scan_block(int fd, daddr_t block)
if (-1 == lseek(fd, (off_t)block * 512, SEEK_SET))
err(1, "lseek");
- if (512 != read(fd,foo, 512))
+ if (512 != read(fd, foo, 512))
return 1;
return 0;
}
@@ -92,27 +92,27 @@ Scan_Disk(struct disk *d)
{
char device[64];
u_long l;
- int i,j,fd;
+ int i, j, fd;
- strcpy(device,_PATH_DEV);
- strcat(device,d->name);
+ strcpy(device, _PATH_DEV);
+ strcat(device, d->name);
- fd = open(device,O_RDWR);
+ fd = open(device, O_RDWR);
if (fd < 0) {
- warn("open(%s) failed",device);
+ warn("open(%s) failed", device);
return;
}
- for(i=-1,l=0;;l++) {
- j = scan_block(fd,l);
+ for (i = -1, l = 0; ; l++) {
+ j = scan_block(fd, l);
if (j != i) {
if (i == -1) {
printf("%c: %lu.",j ? 'B' : 'G', l);
fflush(stdout);
} else if (i == 0) {
- printf(".%lu\nB: %lu.",l-1,l);
+ printf(".%lu\nB: %lu.", l - 1, l);
fflush(stdout);
} else {
- printf(".%lu\nG: %lu.",l-1,l);
+ printf(".%lu\nG: %lu.", l - 1, l);
fflush(stdout);
}
i = j;
@@ -129,20 +129,20 @@ main(int argc, char **argv)
#ifndef READLINE
char input[BUFSIZ];
#endif
- char *p,*q=0;
- char **cp,*cmds[200];
- int ncmd,i;
+ char *p,*q = 0;
+ char **cp, *cmds[200];
+ int ncmd, i;
if (argc < 2) {
- fprintf(stderr,"Usage:\n\t%s diskname\n",argv[0]);
+ fprintf(stderr, "Usage:\n\t%s diskname\n", argv[0]);
exit(1);
}
d = Open_Disk(argv[1]);
if (!d)
- err(1,"Couldn't open disk %s",argv[1]);
+ err(1, "Couldn't open disk %s", argv[1]);
- sprintf(myprompt,"%s %s> ",argv[0],argv[1]);
- while(1) {
+ sprintf(myprompt, "%s %s> ", argv[0], argv[1]);
+ while (1) {
printf("--==##==--\n");
p = CheckRules(d);
Debug_Disk(d);
@@ -157,82 +157,84 @@ main(int argc, char **argv)
#else
printf("%s", myprompt);
fflush(stdout);
- q = p = fgets(input,sizeof(input),stdin);
+ q = p = fgets(input, sizeof(input), stdin);
#endif
if(!p)
break;
- for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
+ for (cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
if (**cp != '\0')
cp++;
ncmd = cp - cmds;
- if(!ncmd)
+ if (!ncmd)
continue;
- if (!strcasecmp(*cmds,"quit")) { break; }
- if (!strcasecmp(*cmds,"exit")) { break; }
- if (!strcasecmp(*cmds,"q")) { break; }
- if (!strcasecmp(*cmds,"x")) { break; }
- if (!strcasecmp(*cmds,"dwim") && ncmd == 6) {
+ if (!strcasecmp(*cmds, "quit"))
+ break;
+ if (!strcasecmp(*cmds, "exit"))
+ break;
+ if (!strcasecmp(*cmds, "q"))
+ break;
+ if (!strcasecmp(*cmds, "x"))
+ break;
+ if (!strcasecmp(*cmds, "dwim") && ncmd == 6) {
printf("dwim = %p\n",
- Create_Chunk_DWIM(d,
- (struct chunk *)strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
- strtol(cmds[5],0,0)));
+ Create_Chunk_DWIM(d,
+ (struct chunk *)strtol(cmds[1], 0, 0),
+ strtol(cmds[2], 0, 0),
+ strtol(cmds[3], 0, 0),
+ strtol(cmds[4], 0, 0),
+ strtol(cmds[5], 0, 0)));
continue;
}
- if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
+ if (!strcasecmp(*cmds, "delete") && ncmd == 2) {
printf("delete = %d\n",
- Delete_Chunk(d,
- (struct chunk *)strtol(cmds[1],0,0)));
+ Delete_Chunk(d,
+ (struct chunk *)strtol(cmds[1], 0, 0)));
continue;
}
- if (!strcasecmp(*cmds,"allfreebsd")) {
+ if (!strcasecmp(*cmds, "allfreebsd")) {
All_FreeBSD(d, 0);
continue;
}
- if (!strcasecmp(*cmds,"dedicate")) {
+ if (!strcasecmp(*cmds, "dedicate")) {
All_FreeBSD(d, 1);
continue;
}
- if (!strcasecmp(*cmds,"sanitize")) {
+ if (!strcasecmp(*cmds, "sanitize")) {
Sanitize_Bios_Geom(d);
continue;
}
- if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
- Set_Bios_Geom(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0));
+ if (!strcasecmp(*cmds, "bios") && ncmd == 4) {
+ Set_Bios_Geom(d, strtol(cmds[1], 0, 0),
+ strtol(cmds[2], 0, 0),
+ strtol(cmds[3], 0, 0));
continue;
}
- if (!strcasecmp(*cmds,"list")) {
+ if (!strcasecmp(*cmds, "list")) {
cp = Disk_Names();
printf("Disks:");
- for(i=0;cp[i];i++) {
- printf(" %s",cp[i]);
+ for (i = 0; cp[i]; i++) {
+ printf(" %s", cp[i]);
free(cp[i]);
}
free(cp);
continue;
}
#ifdef PC98
- if (!strcasecmp(*cmds,"create") && ncmd == 7) {
+ if (!strcasecmp(*cmds, "create") && ncmd == 7) {
#else
if (!strcasecmp(*cmds,"create") && ncmd == 6) {
#endif
printf("Create=%d\n",
- Create_Chunk(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
+ Create_Chunk(d,
+ strtol(cmds[1], 0, 0),
+ strtol(cmds[2], 0, 0),
+ strtol(cmds[3], 0, 0),
+ strtol(cmds[4], 0, 0),
#ifdef PC98
- strtol(cmds[5],0,0),
- cmds[6]));
+ strtol(cmds[5], 0, 0), cmds[6]));
#else
- strtol(cmds[5],0,0), NULL));
+ strtol(cmds[5], 0, 0), NULL));
#endif
continue;
}
@@ -254,28 +256,28 @@ main(int argc, char **argv)
}
#ifndef PC98
if (!strcasecmp(*cmds,"bteasy")) {
- Set_Boot_Mgr(d,bteasy17,sizeof (bteasy17));
+ Set_Boot_Mgr(d, bteasy17, sizeof (bteasy17));
continue;
}
- if (!strcasecmp(*cmds,"mbr")) {
- Set_Boot_Mgr(d,mbrboot,sizeof (mbrboot));
+ if (!strcasecmp(*cmds, "mbr")) {
+ Set_Boot_Mgr(d, mbrboot, sizeof (mbrboot));
continue;
}
#endif
#if 0 /* XXX boot1 undefined, fix me */
- if (!strcasecmp(*cmds,"boot")) {
- Set_Boot_Blocks(d,boot1,boot2);
+ if (!strcasecmp(*cmds, "boot")) {
+ Set_Boot_Blocks(d, boot1, boot2);
continue;
}
#endif
- if (!strcasecmp(*cmds,"write")) {
+ if (!strcasecmp(*cmds, "write")) {
printf("Write=%d\n",
Write_Disk(d));
Free_Disk(d);
d = Open_Disk(argv[1]);
continue;
}
- if (strcasecmp(*cmds,"help"))
+ if (strcasecmp(*cmds, "help"))
printf("\007ERROR\n");
printf("CMDS:\n");
printf("\tallfreebsd\n");
@@ -308,8 +310,9 @@ main(int argc, char **argv)
printf("\twrite\n");
printf("\nENUM:\n\t");
#if 0
- for(i=0;chunk_n[i];i++)
- printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
+ for (i = 0; chunk_n[i]; i++)
+ printf("%d = %s%s", i, chunk_n[i],
+ i == 4 ? "\n\t" : " ");
#endif
printf("\n");
diff --git a/lib/libdisk/write_alpha_disk.c b/lib/libdisk/write_alpha_disk.c
index ba17c91..8b81b39 100644
--- a/lib/libdisk/write_alpha_disk.c
+++ b/lib/libdisk/write_alpha_disk.c
@@ -23,8 +23,10 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include "libdisk.h"
-/* XXX: A lot of hardcoded 512s probably should be foo->sector_size;
- I'm not sure which, so I leave it like it worked before. --schweikh */
+/*
+ * XXX: A lot of hardcoded 512s probably should be foo->sector_size;
+ * I'm not sure which, so I leave it like it worked before. --schweikh
+ */
int
Write_Disk(const struct disk *d1)
{
@@ -54,7 +56,7 @@ Write_Disk(const struct disk *d1)
memcpy(buf + 512 * i, p, 512);
free(p);
}
- if(d1->boot1)
+ if (d1->boot1)
memcpy(buf + 512, d1->boot1, BBSIZE - 512);
dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
diff --git a/lib/libdisk/write_amd64_disk.c b/lib/libdisk/write_amd64_disk.c
index 15808c8..168e1a5 100644
--- a/lib/libdisk/write_amd64_disk.c
+++ b/lib/libdisk/write_amd64_disk.c
@@ -23,34 +23,35 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include "libdisk.h"
-/* XXX: A lot of hardcoded 512s probably should be foo->sector_size;
- I'm not sure which, so I leave it like it worked before. --schweikh */
+/*
+ * XXX: A lot of hardcoded 512s probably should be foo->sector_size;
+ * I'm not sure which, so I leave it like it worked before. --schweikh
+ */
static int
-Write_FreeBSD(int fd, const struct disk *new, const struct disk *old, const struct chunk *c1)
+Write_FreeBSD(int fd, const struct disk *new, const struct disk *old,
+ const struct chunk *c1)
{
struct disklabel *dl;
int i;
void *p;
u_char buf[BBSIZE];
- for(i = 0; i < BBSIZE/512; i++) {
+ for (i = 0; i < BBSIZE/512; i++) {
p = read_block(fd, i + c1->offset, 512);
memcpy(buf + 512 * i, p, 512);
free(p);
}
- if(new->boot1)
+ if (new->boot1)
memcpy(buf, new->boot1, 512);
- if(new->boot2)
- memcpy(buf + 512, new->boot2, BBSIZE-512);
+ if (new->boot2)
+ memcpy(buf + 512, new->boot2, BBSIZE - 512);
dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
Fill_Disklabel(dl, new, old, c1);
-
- for(i=0;i<BBSIZE/512;i++) {
+ for (i = 0; i < BBSIZE / 512; i++)
write_block(fd, i + c1->offset, buf + 512 * i, 512);
- }
return 0;
}
@@ -58,11 +59,12 @@ Write_FreeBSD(int fd, const struct disk *new, const struct disk *old, const stru
static void
Write_Int32(u_int32_t *p, u_int32_t v)
{
- u_int8_t *bp = (u_int8_t *)p;
- bp[0] = (v >> 0) & 0xff;
- bp[1] = (v >> 8) & 0xff;
- bp[2] = (v >> 16) & 0xff;
- bp[3] = (v >> 24) & 0xff;
+ u_int8_t *bp = (u_int8_t *)p;
+
+ bp[0] = (v >> 0) & 0xff;
+ bp[1] = (v >> 8) & 0xff;
+ bp[2] = (v >> 16) & 0xff;
+ bp[3] = (v >> 24) & 0xff;
}
/*
@@ -71,19 +73,19 @@ Write_Int32(u_int32_t *p, u_int32_t v)
static void
Cfg_Boot_Mgr(u_char *mbr, int edd)
{
- if (mbr[0x1b0] == 0x66 && mbr[0x1b1] == 0xbb) {
- if (edd)
- mbr[0x1bb] |= 0x80; /* Packet mode on */
- else
- mbr[0x1bb] &= 0x7f; /* Packet mode off */
- }
+
+ if (mbr[0x1b0] == 0x66 && mbr[0x1b1] == 0xbb) {
+ if (edd)
+ mbr[0x1bb] |= 0x80; /* Packet mode on */
+ else
+ mbr[0x1bb] &= 0x7f; /* Packet mode off */
+ }
}
int
Write_Disk(const struct disk *d1)
{
- int fd,i;
- int j;
+ int fd, i, j;
struct disk *old = 0;
struct chunk *c1;
int ret = 0;
@@ -93,23 +95,24 @@ Write_Disk(const struct disk *d1)
int s[4];
int need_edd = 0; /* Need EDD (packet interface) */
- strcpy(device,_PATH_DEV);
- strcat(device,d1->name);
-
+ strcpy(device, _PATH_DEV);
+ strcat(device, d1->name);
- fd = open(device,O_RDWR);
+ fd = open(device, O_RDWR);
if (fd < 0)
return 1;
- memset(s,0,sizeof s);
+ memset(s, 0, sizeof s);
mbr = read_block(fd, 0, d1->sector_size);
- dp = (struct dos_partition*)(mbr + DOSPARTOFF);
+ dp = (struct dos_partition *)(mbr + DOSPARTOFF);
memcpy(work, dp, sizeof work);
dp = work;
free(mbr);
for (c1 = d1->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
- if (!strcmp(c1->name, "X")) continue;
+ if (c1->type == unused)
+ continue;
+ if (!strcmp(c1->name, "X"))
+ continue;
j = c1->name[strlen(d1->name) + 1] - '1';
if (j < 0 || j > 3)
continue;
@@ -121,7 +124,7 @@ Write_Disk(const struct disk *d1)
Write_Int32(&dp[j].dp_size, c1->size);
i = c1->offset;
- if (i >= 1024*d1->bios_sect*d1->bios_hd) {
+ if (i >= 1024 * d1->bios_sect * d1->bios_hd) {
dp[j].dp_ssect = 0xff;
dp[j].dp_shd = 0xff;
dp[j].dp_scyl = 0xff;
@@ -137,10 +140,9 @@ Write_Disk(const struct disk *d1)
i -= dp[j].dp_scyl;
dp[j].dp_ssect |= i >> 2;
}
-
#ifdef DEBUG
- printf("S:%lu = (%x/%x/%x)",
- c1->offset, dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
+ printf("S:%lu = (%x/%x/%x)", c1->offset,
+ dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
#endif
i = c1->end;
@@ -150,14 +152,14 @@ Write_Disk(const struct disk *d1)
dp[j].dp_ehd = i % d1->bios_hd;
i -= dp[j].dp_ehd;
i /= d1->bios_hd;
- if (i>1023) i = 1023;
+ if (i > 1023)
+ i = 1023;
dp[j].dp_ecyl = i;
i -= dp[j].dp_ecyl;
dp[j].dp_esect |= i >> 2;
-
#ifdef DEBUG
- printf(" E:%lu = (%x/%x/%x)\n",
- c1->end, dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
+ printf(" E:%lu = (%x/%x/%x)\n", c1->end,
+ dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
#endif
dp[j].dp_typ = c1->subtype;
@@ -167,7 +169,7 @@ Write_Disk(const struct disk *d1)
dp[j].dp_flag = 0;
}
j = 0;
- for(i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < NDOSPART; i++) {
if (!s[i])
memset(dp + i, 0, sizeof *dp);
if (dp[i].dp_flag)
@@ -188,8 +190,9 @@ Write_Disk(const struct disk *d1)
mbr[512-1] = 0xaa;
write_block(fd, 0, mbr, d1->sector_size);
if (d1->bootmgr && d1->bootmgr_size > d1->sector_size)
- for(i = 1; i * d1->sector_size <= d1->bootmgr_size; i++)
- write_block(fd, i, &d1->bootmgr[i * d1->sector_size], d1->sector_size);
+ for (i = 1; i * d1->sector_size <= d1->bootmgr_size; i++)
+ write_block(fd, i, &d1->bootmgr[i * d1->sector_size],
+ d1->sector_size);
close(fd);
return 0;
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index 0a27ac9..ac50b62 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -24,16 +24,19 @@ __FBSDID("$FreeBSD$");
#include "libdisk.h"
void
-Fill_Disklabel(struct disklabel *dl, const struct disk *new, const struct disk *old, const struct chunk *c1)
+Fill_Disklabel(struct disklabel *dl, const struct disk *new,
+ const struct disk *old, const struct chunk *c1)
{
struct chunk *c2;
int j;
memset(dl, 0, sizeof *dl);
- for(c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == unused) continue;
- if (!strcmp(c2->name, "X")) continue;
+ for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c2->type == unused)
+ continue;
+ if (!strcmp(c2->name, "X"))
+ continue;
j = c2->name[strlen(c2->name) - 1] - 'a';
if (j < 0 || j >= MAXPARTITIONS || j == RAW_PART)
continue;
@@ -52,9 +55,9 @@ Fill_Disklabel(struct disklabel *dl, const struct disk *new, const struct disk *
dl->d_secsize = 512;
dl->d_secperunit = new->chunks->size;
- dl->d_ncylinders = new->bios_cyl;
- dl->d_ntracks = new->bios_hd;
- dl->d_nsectors = new->bios_sect;
+ dl->d_ncylinders = new->bios_cyl;
+ dl->d_ntracks = new->bios_hd;
+ dl->d_nsectors = new->bios_sect;
dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors;
dl->d_npartitions = MAXPARTITIONS;
@@ -69,6 +72,4 @@ Fill_Disklabel(struct disklabel *dl, const struct disk *new, const struct disk *
dl->d_magic = DISKMAGIC;
dl->d_magic2 = DISKMAGIC;
dl->d_checksum = dkcksum(dl);
-
- return;
}
diff --git a/lib/libdisk/write_i386_disk.c b/lib/libdisk/write_i386_disk.c
index 15808c8..168e1a5 100644
--- a/lib/libdisk/write_i386_disk.c
+++ b/lib/libdisk/write_i386_disk.c
@@ -23,34 +23,35 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include "libdisk.h"
-/* XXX: A lot of hardcoded 512s probably should be foo->sector_size;
- I'm not sure which, so I leave it like it worked before. --schweikh */
+/*
+ * XXX: A lot of hardcoded 512s probably should be foo->sector_size;
+ * I'm not sure which, so I leave it like it worked before. --schweikh
+ */
static int
-Write_FreeBSD(int fd, const struct disk *new, const struct disk *old, const struct chunk *c1)
+Write_FreeBSD(int fd, const struct disk *new, const struct disk *old,
+ const struct chunk *c1)
{
struct disklabel *dl;
int i;
void *p;
u_char buf[BBSIZE];
- for(i = 0; i < BBSIZE/512; i++) {
+ for (i = 0; i < BBSIZE/512; i++) {
p = read_block(fd, i + c1->offset, 512);
memcpy(buf + 512 * i, p, 512);
free(p);
}
- if(new->boot1)
+ if (new->boot1)
memcpy(buf, new->boot1, 512);
- if(new->boot2)
- memcpy(buf + 512, new->boot2, BBSIZE-512);
+ if (new->boot2)
+ memcpy(buf + 512, new->boot2, BBSIZE - 512);
dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
Fill_Disklabel(dl, new, old, c1);
-
- for(i=0;i<BBSIZE/512;i++) {
+ for (i = 0; i < BBSIZE / 512; i++)
write_block(fd, i + c1->offset, buf + 512 * i, 512);
- }
return 0;
}
@@ -58,11 +59,12 @@ Write_FreeBSD(int fd, const struct disk *new, const struct disk *old, const stru
static void
Write_Int32(u_int32_t *p, u_int32_t v)
{
- u_int8_t *bp = (u_int8_t *)p;
- bp[0] = (v >> 0) & 0xff;
- bp[1] = (v >> 8) & 0xff;
- bp[2] = (v >> 16) & 0xff;
- bp[3] = (v >> 24) & 0xff;
+ u_int8_t *bp = (u_int8_t *)p;
+
+ bp[0] = (v >> 0) & 0xff;
+ bp[1] = (v >> 8) & 0xff;
+ bp[2] = (v >> 16) & 0xff;
+ bp[3] = (v >> 24) & 0xff;
}
/*
@@ -71,19 +73,19 @@ Write_Int32(u_int32_t *p, u_int32_t v)
static void
Cfg_Boot_Mgr(u_char *mbr, int edd)
{
- if (mbr[0x1b0] == 0x66 && mbr[0x1b1] == 0xbb) {
- if (edd)
- mbr[0x1bb] |= 0x80; /* Packet mode on */
- else
- mbr[0x1bb] &= 0x7f; /* Packet mode off */
- }
+
+ if (mbr[0x1b0] == 0x66 && mbr[0x1b1] == 0xbb) {
+ if (edd)
+ mbr[0x1bb] |= 0x80; /* Packet mode on */
+ else
+ mbr[0x1bb] &= 0x7f; /* Packet mode off */
+ }
}
int
Write_Disk(const struct disk *d1)
{
- int fd,i;
- int j;
+ int fd, i, j;
struct disk *old = 0;
struct chunk *c1;
int ret = 0;
@@ -93,23 +95,24 @@ Write_Disk(const struct disk *d1)
int s[4];
int need_edd = 0; /* Need EDD (packet interface) */
- strcpy(device,_PATH_DEV);
- strcat(device,d1->name);
-
+ strcpy(device, _PATH_DEV);
+ strcat(device, d1->name);
- fd = open(device,O_RDWR);
+ fd = open(device, O_RDWR);
if (fd < 0)
return 1;
- memset(s,0,sizeof s);
+ memset(s, 0, sizeof s);
mbr = read_block(fd, 0, d1->sector_size);
- dp = (struct dos_partition*)(mbr + DOSPARTOFF);
+ dp = (struct dos_partition *)(mbr + DOSPARTOFF);
memcpy(work, dp, sizeof work);
dp = work;
free(mbr);
for (c1 = d1->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
- if (!strcmp(c1->name, "X")) continue;
+ if (c1->type == unused)
+ continue;
+ if (!strcmp(c1->name, "X"))
+ continue;
j = c1->name[strlen(d1->name) + 1] - '1';
if (j < 0 || j > 3)
continue;
@@ -121,7 +124,7 @@ Write_Disk(const struct disk *d1)
Write_Int32(&dp[j].dp_size, c1->size);
i = c1->offset;
- if (i >= 1024*d1->bios_sect*d1->bios_hd) {
+ if (i >= 1024 * d1->bios_sect * d1->bios_hd) {
dp[j].dp_ssect = 0xff;
dp[j].dp_shd = 0xff;
dp[j].dp_scyl = 0xff;
@@ -137,10 +140,9 @@ Write_Disk(const struct disk *d1)
i -= dp[j].dp_scyl;
dp[j].dp_ssect |= i >> 2;
}
-
#ifdef DEBUG
- printf("S:%lu = (%x/%x/%x)",
- c1->offset, dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
+ printf("S:%lu = (%x/%x/%x)", c1->offset,
+ dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
#endif
i = c1->end;
@@ -150,14 +152,14 @@ Write_Disk(const struct disk *d1)
dp[j].dp_ehd = i % d1->bios_hd;
i -= dp[j].dp_ehd;
i /= d1->bios_hd;
- if (i>1023) i = 1023;
+ if (i > 1023)
+ i = 1023;
dp[j].dp_ecyl = i;
i -= dp[j].dp_ecyl;
dp[j].dp_esect |= i >> 2;
-
#ifdef DEBUG
- printf(" E:%lu = (%x/%x/%x)\n",
- c1->end, dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
+ printf(" E:%lu = (%x/%x/%x)\n", c1->end,
+ dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
#endif
dp[j].dp_typ = c1->subtype;
@@ -167,7 +169,7 @@ Write_Disk(const struct disk *d1)
dp[j].dp_flag = 0;
}
j = 0;
- for(i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < NDOSPART; i++) {
if (!s[i])
memset(dp + i, 0, sizeof *dp);
if (dp[i].dp_flag)
@@ -188,8 +190,9 @@ Write_Disk(const struct disk *d1)
mbr[512-1] = 0xaa;
write_block(fd, 0, mbr, d1->sector_size);
if (d1->bootmgr && d1->bootmgr_size > d1->sector_size)
- for(i = 1; i * d1->sector_size <= d1->bootmgr_size; i++)
- write_block(fd, i, &d1->bootmgr[i * d1->sector_size], d1->sector_size);
+ for (i = 1; i * d1->sector_size <= d1->bootmgr_size; i++)
+ write_block(fd, i, &d1->bootmgr[i * d1->sector_size],
+ d1->sector_size);
close(fd);
return 0;
diff --git a/lib/libdisk/write_ia64_disk.c b/lib/libdisk/write_ia64_disk.c
index 024a8e3..99d36b6 100644
--- a/lib/libdisk/write_ia64_disk.c
+++ b/lib/libdisk/write_ia64_disk.c
@@ -23,8 +23,10 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include "libdisk.h"
-/* XXX: A lot of hardcoded 512s probably should be foo->sector_size;
- I'm not sure which, so I leave it like it worked before. --schweikh */
+/*
+ * XXX: A lot of hardcoded 512s probably should be foo->sector_size;
+ * I'm not sure which, so I leave it like it worked before. --schweikh
+ */
static int
Write_FreeBSD(int fd, const struct disk *new, const struct chunk *c1)
{
@@ -44,7 +46,7 @@ Write_FreeBSD(int fd, const struct disk *new, const struct chunk *c1)
dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
Fill_Disklabel(dl, new, NULL, c1);
- for (i = 0; i < BBSIZE/512; i++) {
+ for (i = 0; i < BBSIZE / 512; i++) {
if (write_block(fd, i + c1->offset, buf + 512 * i, 512) != 0)
return (1);
}
@@ -56,6 +58,7 @@ static void
Write_Int32(u_int32_t *p, u_int32_t v)
{
u_int8_t *bp = (u_int8_t *)p;
+
bp[0] = (v >> 0) & 0xff;
bp[1] = (v >> 8) & 0xff;
bp[2] = (v >> 16) & 0xff;
@@ -75,7 +78,7 @@ Write_Disk(const struct disk *d1)
strcpy(device, _PATH_DEV);
strcat(device, d1->name);
- fd = open(device,O_RDWR);
+ fd = open(device, O_RDWR);
if (fd < 0)
return (1);
@@ -83,7 +86,7 @@ Write_Disk(const struct disk *d1)
mbr = read_block(fd, 0, 512);
if (mbr == NULL)
goto fail;
- dp = (struct dos_partition*)(mbr + DOSPARTOFF);
+ dp = (struct dos_partition *)(mbr + DOSPARTOFF);
memcpy(work, dp, sizeof(work));
dp = work;
free(mbr);
@@ -102,7 +105,7 @@ Write_Disk(const struct disk *d1)
Write_Int32(&dp[j].dp_start, c1->offset);
Write_Int32(&dp[j].dp_size, c1->size);
- i = 1024*d1->bios_sect*d1->bios_hd;
+ i = 1024 * d1->bios_sect * d1->bios_hd;
if (i == 0 || c1->offset >= i) {
/* Start */
dp[j].dp_ssect = 0xff;
@@ -138,11 +141,10 @@ Write_Disk(const struct disk *d1)
i -= dp[j].dp_ecyl;
dp[j].dp_esect |= i >> 2;
}
-
#ifdef DEBUG
printf("S:%lu = (%x/%x/%x) E:%lu = (%x/%x/%x)\n", c1->offset,
- dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect, c1->end,
- dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
+ dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect, c1->end,
+ dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
#endif
dp[j].dp_typ = c1->subtype;
@@ -152,7 +154,7 @@ Write_Disk(const struct disk *d1)
dp[j].dp_flag = 0;
}
- for(i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < NDOSPART; i++) {
if (!s[i])
memset(dp + i, 0, sizeof(*dp));
}
diff --git a/lib/libdisk/write_pc98_disk.c b/lib/libdisk/write_pc98_disk.c
index bc18e4c..14ebda5 100644
--- a/lib/libdisk/write_pc98_disk.c
+++ b/lib/libdisk/write_pc98_disk.c
@@ -25,56 +25,55 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include "libdisk.h"
-/* XXX: A lot of hardcoded 512s probably should be foo->sector_size;
- I'm not sure which, so I leave it like it worked before. --schweikh */
+/*
+ * XXX: A lot of hardcoded 512s probably should be foo->sector_size;
+ * I'm not sure which, so I leave it like it worked before. --schweikh
+ */
static int
-Write_FreeBSD(int fd, const struct disk *new, const struct disk *old, const struct chunk *c1)
+Write_FreeBSD(int fd, const struct disk *new, const struct disk *old,
+ const struct chunk *c1)
{
struct disklabel *dl;
int i;
void *p;
u_char buf[BBSIZE];
- for(i = 0; i < BBSIZE/512; i++) {
+ for (i = 0; i < BBSIZE / 512; i++) {
p = read_block(fd, i + c1->offset, 512);
memcpy(buf + 512 * i, p, 512);
free(p);
}
- if(new->boot1)
+ if (new->boot1)
memcpy(buf, new->boot1, 512);
- if(new->boot2)
- memcpy(buf + 512, new->boot2, BBSIZE-512);
+ if (new->boot2)
+ memcpy(buf + 512, new->boot2, BBSIZE - 512);
dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
Fill_Disklabel(dl, new, old, c1);
-
- for(i=0;i<BBSIZE/512;i++) {
+ for (i = 0; i < BBSIZE / 512; i++)
write_block(fd, i + c1->offset, buf + 512 * i, 512);
- }
return 0;
}
-
int
Write_Disk(const struct disk *d1)
{
- int fd,i;
- int j;
- struct disk *old = 0;
+ int fd, i, j;
+ struct disk *old = NULL;
struct chunk *c1;
int ret = 0;
char device[64];
u_char *mbr;
- struct dos_partition *dp,work[NDOSPART];
+ struct dos_partition *dp, work[NDOSPART];
int s[7];
int PC98_EntireDisk = 0;
- strcpy(device,_PATH_DEV);
- strcat(device,d1->name);
+ strcpy(device, _PATH_DEV);
+ strcat(device, d1->name);
/* XXX - for entire FreeBSD(98) */
for (c1 = d1->chunks->part; c1; c1 = c1->next) {
@@ -82,23 +81,25 @@ Write_Disk(const struct disk *d1)
device[9] = 0;
}
- fd = open(device,O_RDWR);
- if (fd < 0) {
+ fd = open(device, O_RDWR);
+ if (fd < 0) {
#ifdef DEBUG
- warn("open(%s) failed", device);
+ warn("open(%s) failed", device);
#endif
- return 1;
- }
+ return 1;
+ }
- memset(s,0,sizeof s);
+ memset(s, 0, sizeof s);
mbr = read_block(fd, 1, d1->sector_size);
- dp = (struct dos_partition*)(mbr + DOSPARTOFF);
+ dp = (struct dos_partition *)(mbr + DOSPARTOFF);
memcpy(work, dp, sizeof work);
dp = work;
free(mbr);
for (c1 = d1->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused) continue;
- if (!strcmp(c1->name, "X")) continue;
+ if (c1->type == unused)
+ continue;
+ if (!strcmp(c1->name, "X"))
+ continue;
j = c1->name[strlen(d1->name) + 1] - '1';
if (j < 0 || j > 7)
continue;
@@ -106,7 +107,6 @@ Write_Disk(const struct disk *d1)
if (c1->type == freebsd)
ret += Write_FreeBSD(fd, d1, old, c1);
-
i = c1->offset;
dp[j].dp_ssect = dp[j].dp_ipl_sct = i % d1->bios_sect;
i -= dp[j].dp_ssect;
@@ -115,10 +115,9 @@ Write_Disk(const struct disk *d1)
i -= dp[j].dp_shd;
i /= d1->bios_hd;
dp[j].dp_scyl = dp[j].dp_ipl_cyl = i;
-
#ifdef DEBUG
- printf("S:%lu = (%x/%x/%x)",
- c1->offset, dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
+ printf("S:%lu = (%x/%x/%x)", c1->offset,
+ dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
#endif
i = c1->end;
@@ -129,15 +128,14 @@ Write_Disk(const struct disk *d1)
dp[j].dp_esect = i % d1->bios_sect;
i -= dp[j].dp_esect;
i /= d1->bios_sect;
- dp[j].dp_ehd = i % d1->bios_hd;
+ dp[j].dp_ehd = i % d1->bios_hd;
i -= dp[j].dp_ehd;
i /= d1->bios_hd;
dp[j].dp_ecyl = i;
#endif
-
#ifdef DEBUG
- printf(" E:%lu = (%x/%x/%x)\n",
- c1->end, dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
+ printf(" E:%lu = (%x/%x/%x)\n", c1->end,
+ dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
#endif
dp[j].dp_mid = c1->subtype & 0xff;
@@ -148,7 +146,7 @@ Write_Disk(const struct disk *d1)
strncpy(dp[j].dp_name, c1->sname, 16);
}
j = 0;
- for(i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < NDOSPART; i++) {
if (!s[i])
memset(dp + i, 0, sizeof *dp);
}
@@ -168,7 +166,9 @@ Write_Disk(const struct disk *d1)
if (d1->bootmenu)
for (i = 0; i * d1->sector_size < d1->bootmenu_size; i++)
- write_block(fd, 2 + i, &d1->bootmenu[i * d1->sector_size], d1->sector_size);
+ write_block(fd, 2 + i,
+ &d1->bootmenu[i * d1->sector_size],
+ d1->sector_size);
close(fd);
return 0;
diff --git a/lib/libdisk/write_sparc64_disk.c b/lib/libdisk/write_sparc64_disk.c
index 1269a06..0668141 100644
--- a/lib/libdisk/write_sparc64_disk.c
+++ b/lib/libdisk/write_sparc64_disk.c
@@ -36,10 +36,10 @@ Write_Disk(const struct disk *d1)
char device[64];
int fd;
- strcpy(device,_PATH_DEV);
- strcat(device,d1->name);
+ strcpy(device, _PATH_DEV);
+ strcat(device, d1->name);
- fd = open(device,O_RDWR);
+ fd = open(device, O_RDWR);
if (fd < 0) {
warn("open(%s) failed", device);
return (1);
@@ -57,14 +57,14 @@ Write_Disk(const struct disk *d1)
sl->sl_ntracks = d1->bios_hd;
if (c->size > 4999 * 1024 * 2) {
sprintf(sl->sl_text, "FreeBSD%luG cyl %u alt %u hd %u sec %u",
- (c->size + 1024 * 1024) / (2 * 1024 * 1024),
- sl->sl_ncylinders, sl->sl_acylinders,
- sl->sl_ntracks, sl->sl_nsectors);
+ (c->size + 1024 * 1024) / (2 * 1024 * 1024),
+ sl->sl_ncylinders, sl->sl_acylinders,
+ sl->sl_ntracks, sl->sl_nsectors);
} else {
sprintf(sl->sl_text, "FreeBSD%luM cyl %u alt %u hd %u sec %u",
- (c->size + 1024) / (2 * 1024),
- sl->sl_ncylinders, sl->sl_acylinders,
- sl->sl_ntracks, sl->sl_nsectors);
+ (c->size + 1024) / (2 * 1024),
+ sl->sl_ncylinders, sl->sl_acylinders,
+ sl->sl_ntracks, sl->sl_nsectors);
}
sl->sl_interleave = 1;
sl->sl_sparespercyl = 0;
OpenPOWER on IntegriCloud