summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-04-01 12:18:20 +0000
committerobrien <obrien@FreeBSD.org>2001-04-01 12:18:20 +0000
commitbe7c1d12489eca9263a2127dedf1cdfeb2ad8b93 (patch)
treea48d82e5adc3563378b2bd88d4318266ec48cd3e /lib
parent51dae2254ac1cd5dc67d293758322c96c592a731 (diff)
downloadFreeBSD-src-be7c1d12489eca9263a2127dedf1cdfeb2ad8b93.zip
FreeBSD-src-be7c1d12489eca9263a2127dedf1cdfeb2ad8b93.tar.gz
Add spaces around operators.
It's OK, the Project and afford them now -- they aren't as expensive as they used to be.
Diffstat (limited to 'lib')
-rw-r--r--lib/libdisk/blocks.c8
-rw-r--r--lib/libdisk/change.c30
-rw-r--r--lib/libdisk/chunk.c100
-rw-r--r--lib/libdisk/create_chunk.c70
-rw-r--r--lib/libdisk/disk.c147
-rw-r--r--lib/libdisk/disklabel.c2
-rw-r--r--lib/libdisk/rules.c58
-rw-r--r--lib/libdisk/write_disk.c77
8 files changed, 248 insertions, 244 deletions
diff --git a/lib/libdisk/blocks.c b/lib/libdisk/blocks.c
index 28e6a5f..38e2846 100644
--- a/lib/libdisk/blocks.c
+++ b/lib/libdisk/blocks.c
@@ -22,11 +22,11 @@ read_block(int fd, daddr_t block)
foo = malloc(512);
if (!foo)
- barfout(1,"malloc");
+ barfout(1, "malloc");
if (-1 == lseek(fd, (off_t)block * 512, SEEK_SET))
barfout(1, "lseek");
- if (512 != read(fd,foo, 512))
- barfout(1,"read");
+ if (512 != read(fd, foo, 512))
+ barfout(1, "read");
return foo;
}
@@ -36,5 +36,5 @@ write_block(int fd, daddr_t block, void *foo)
if (-1 == lseek(fd, (off_t)block * 512, SEEK_SET))
barfout(1, "lseek");
if (512 != write(fd,foo, 512))
- barfout(1,"write");
+ barfout(1, "write");
}
diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c
index a010f33..3c0dc54 100644
--- a/lib/libdisk/change.c
+++ b/lib/libdisk/change.c
@@ -30,7 +30,9 @@ Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
void
Sanitize_Bios_Geom(struct disk *disk)
{
- int sane = 1;
+ int sane;
+
+ sane = 1;
if (disk->bios_cyl > 1024)
sane = 0;
@@ -38,8 +40,7 @@ Sanitize_Bios_Geom(struct disk *disk)
sane = 0;
if (disk->bios_sect > 63)
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;
@@ -47,14 +48,14 @@ 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);
if (disk->bios_cyl < 1024)
return;
/* Hmm, try harder... */
disk->bios_hd = 255;
- disk->bios_cyl = disk->chunks->size/(disk->bios_sect*disk->bios_hd);
+ disk->bios_cyl = disk->chunks->size / (disk->bios_sect*disk->bios_hd);
return;
}
@@ -65,26 +66,27 @@ All_FreeBSD(struct disk *d, int force_all)
struct chunk *c;
again:
- for (c=d->chunks->part;c;c=c->next)
+ for (c = d->chunks->part; c; c = c->next)
if (c->type != unused) {
- Delete_Chunk(d,c);
+ Delete_Chunk(d, c);
goto again;
}
- c=d->chunks;
+ c = d->chunks;
if (force_all) {
Sanitize_Bios_Geom(d);
#ifdef PC98
- Create_Chunk(d,c->offset,c->size,freebsd,0x494,
- CHUNK_FORCE_ALL,"FreeBSD");
+ Create_Chunk(d, c->offset, c->size, freebsd, 0x494,
+ CHUNK_FORCE_ALL, "FreeBSD");
#else
- Create_Chunk(d,c->offset,c->size,freebsd,0xa5,
- CHUNK_FORCE_ALL);
+ Create_Chunk(d, c->offset, c->size, freebsd, 0xa5,
+ CHUNK_FORCE_ALL);
#endif
} else {
#ifdef PC98
- Create_Chunk(d,c->offset,c->size,freebsd,0x494, 0,"FreeBSD");
+ Create_Chunk(d, c->offset, c->size, freebsd, 0x494, 0,
+ "FreeBSD");
#else
- Create_Chunk(d,c->offset,c->size,freebsd,0xa5, 0);
+ Create_Chunk(d, c->offset, c->size, freebsd, 0xa5, 0);
#endif
}
}
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index b9d5c4d..aa8f308 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -38,32 +38,33 @@ struct chunk *
Find_Mother_Chunk(struct chunk *chunks, u_long offset, u_long end, chunk_e type)
{
struct chunk *c1,*c2,ct;
+
ct.offset = offset;
ct.end = end;
switch (type) {
case whole:
- if (Chunk_Inside(chunks,&ct))
+ if (Chunk_Inside(chunks, &ct))
return chunks;
#ifndef PC98
case extended:
- for(c1=chunks->part;c1;c1=c1->next) {
+ for(c1 = chunks->part; c1; c1 = c1->next) {
if (c1->type != type)
continue;
- if (Chunk_Inside(c1,&ct))
+ if (Chunk_Inside(c1, &ct))
return c1;
}
return 0;
#endif
case freebsd:
- for(c1=chunks->part;c1;c1=c1->next) {
+ for(c1 = chunks->part; c1; c1 = c1->next) {
if (c1->type == type)
- if (Chunk_Inside(c1,&ct))
+ if (Chunk_Inside(c1, &ct))
return c1;
if (c1->type != extended)
continue;
- for(c2=c1->part;c2;c2=c2->next)
+ for(c2 = c1->part; c2; c2 = c2->next)
if (c2->type == type
- && Chunk_Inside(c2,&ct))
+ && Chunk_Inside(c2, &ct))
return c2;
}
return 0;
@@ -94,10 +95,11 @@ struct chunk *
Clone_Chunk(struct chunk *c1)
{
struct chunk *c2;
+
if(!c1)
return 0;
c2 = new_chunk();
- if (!c2) barfout(1,"malloc failed");
+ if (!c2) barfout(1, "malloc failed");
*c2 = *c1;
if (c1->private_data && c1->private_clone)
c2->private_data = c2->private_clone(c2->private_data);
@@ -126,8 +128,8 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
return __LINE__;
ct = new_chunk();
- if (!ct) barfout(1,"malloc failed");
- memset(ct,0,sizeof *ct);
+ if (!ct) barfout(1, "malloc failed");
+ memset(ct, 0, sizeof *ct);
ct->disk = c2->disk;
ct->offset = offset;
ct->size = size;
@@ -140,15 +142,15 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
ct->subtype = subtype;
ct->flags = flags;
- if (!Chunk_Inside(c2,ct)) {
+ if (!Chunk_Inside(c2, ct)) {
Free_Chunk(ct);
return __LINE__;
}
if(type==freebsd || type==extended) {
cs = new_chunk();
- if (!cs) barfout(1,"malloc failed");
- memset(cs,0,sizeof *cs);
+ if (!cs) barfout(1, "malloc failed");
+ memset(cs, 0, sizeof *cs);
cs->disk = c2->disk;
cs->offset = offset;
cs->size = size;
@@ -164,7 +166,7 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
/* Make a new chunk for any trailing unused space */
if (c2->end > ct->end) {
cs = new_chunk();
- if (!cs) barfout(1,"malloc failed");
+ if (!cs) barfout(1, "malloc failed");
*cs = *c2;
cs->disk = c2->disk;
cs->offset = ct->end + 1;
@@ -222,10 +224,10 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
if (type == whole) {
d->chunks = c1 = new_chunk();
- if (!c1) barfout(1,"malloc failed");
- memset(c1,0,sizeof *c1);
+ if (!c1) barfout(1, "malloc failed");
+ memset(c1, 0, sizeof *c1);
c2 = c1->part = new_chunk();
- if (!c2) barfout(1,"malloc failed");
+ if (!c2) barfout(1, "malloc failed");
memset(c2,0,sizeof *c2);
c2->disk = c1->disk = d;
c2->offset = c1->offset = offset;
@@ -252,22 +254,22 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
c1 = 0;
#ifndef PC98
if(!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks,offset,end,extended);
+ c1 = Find_Mother_Chunk(d->chunks, offset, end, extended);
#endif
if(!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks,offset,end,whole);
+ c1 = Find_Mother_Chunk(d->chunks, offset, end, whole);
#ifndef PC98
if(!c1 && type == extended)
- c1 = Find_Mother_Chunk(d->chunks,offset,end,whole);
+ c1 = Find_Mother_Chunk(d->chunks, offset, end, whole);
#endif
if(!c1 && type == part)
- c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd);
+ c1 = Find_Mother_Chunk(d->chunks, offset, end, freebsd);
if(!c1)
return __LINE__;
- for(c2=c1->part;c2;c2=c2->next) {
+ for(c2 = c1->part; c2; c2 = c2->next) {
if (c2->type != unused)
continue;
- if(Chunk_Inside(c2,&ct)) {
+ if(Chunk_Inside(c2, &ct)) {
if (type != freebsd)
goto doit;
if (!(flags & CHUNK_ALIGN))
@@ -282,31 +284,31 @@ Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
if (offset < c2->offset)
offset = c2->offset;
/* Round up to next cylinder */
- offset = Next_Cyl_Aligned(d,offset);
+ offset = Next_Cyl_Aligned(d, offset);
/* Keep one track clear in front of parent */
if (offset == c1->offset)
- offset = Next_Track_Aligned(d,offset+1);
+ offset = Next_Track_Aligned(d, offset + 1);
/* Work on the (end+1) */
size += offset;
/* Round up to cylinder */
- size = Next_Cyl_Aligned(d,size);
+ size = Next_Cyl_Aligned(d, size);
/* Stay inside parent */
if ((size-1) > c2->end)
- size = c2->end+1;
+ size = c2->end + 1;
/* Round down to cylinder */
- size = Prev_Cyl_Aligned(d,size);
+ size = Prev_Cyl_Aligned(d, size);
/* Convert back to size */
size -= offset;
doit:
#ifdef PC98
- return Insert_Chunk(c2,offset,size,name,
- type,subtype,flags,sname);
+ return Insert_Chunk(c2, offset, size, name,
+ type, subtype, flags, sname);
#else
- return Insert_Chunk(c2,offset,size,name,
- type,subtype,flags);
+ return Insert_Chunk(c2, offset, size, name,
+ type, subtype, flags);
#endif
}
}
@@ -332,10 +334,10 @@ 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('-');
+ for(i = 0; i < offset - 2; i++) putchar(' ');
+ for(; i < offset; i++) putchar('-');
putchar('>');
- for(;i<10;i++) putchar(' ');
+ for(; i < 10; i++) putchar(' ');
#ifdef PC98
printf("%p %8ld %8lu %8lu %-8s %-16s %-8s 0x%02x %s",
c1, c1->offset, c1->size, c1->end, c1->name, c1->sname,
@@ -343,11 +345,11 @@ Print_Chunk(struct chunk *c1,int offset)
printf("%p %8ld %8lu %8lu %-8s %-8s 0x%02x %s",
c1, c1->offset, c1->size, c1->end, c1->name,
#endif
- chunk_n[c1->type],c1->subtype,
+ chunk_n[c1->type], c1->subtype,
ShowChunkFlags(c1));
putchar('\n');
- Print_Chunk(c1->part,offset + 2);
- Print_Chunk(c1->next,offset);
+ Print_Chunk(c1->part, offset + 2);
+ Print_Chunk(c1->next, offset);
}
void
@@ -359,26 +361,26 @@ Debug_Chunk(struct chunk *c1)
int
Delete_Chunk(struct disk *d, struct chunk *c)
{
- struct chunk *c1=0,*c2,*c3;
+ struct chunk *c1=0, *c2, *c3;
chunk_e type = c->type;
if(type == whole)
return 1;
#ifndef PC98
if(!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,extended);
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, extended);
#endif
if(!c1 && (type == freebsd || type == fat || type == unknown))
- c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole);
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
#ifndef PC98
if(!c1 && type == extended)
- c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,whole);
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, whole);
#endif
if(!c1 && type == part)
- c1 = Find_Mother_Chunk(d->chunks,c->offset,c->end,freebsd);
+ c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end, freebsd);
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;
@@ -396,7 +398,7 @@ Delete_Chunk(struct disk *d, struct chunk *c)
}
return 1;
scan:
- for(c2=c1->part;c2;c2=c2->next) {
+ for(c2 = c1->part; c2; c2 = c2->next) {
if (c2->type != unused)
continue;
if (!c2->next)
@@ -421,7 +423,7 @@ 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) {
@@ -436,19 +438,19 @@ Collapse_Chunk(struct disk *d, struct chunk *c1)
c3 = c1->part;
if(!c3)
return 0;
- if (Collapse_Chunk(d,c1->part))
+ if (Collapse_Chunk(d, c1->part))
return 1;
if (c1->type == whole)
return 0;
if(c3->type == unused && c3->size == c1->size) {
- Delete_Chunk(d,c1);
+ Delete_Chunk(d, c1);
return 1;
}
if(c3->type == unused) {
c2 = new_chunk();
- if (!c2) barfout(1,"malloc failed");
+ if (!c2) barfout(1, "malloc failed");
*c2 = *c1;
c1->next = c2;
c1->disk = d;
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 59a83dc..6a4ded3 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -65,59 +65,59 @@ Fixup_FreeBSD_Names(struct disk *d, struct chunk *c)
if (!strcmp(c->name, "X")) return;
/* reset all names to "X" */
- for (c1 = c->part; c1 ; c1 = c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
c1->oname = c1->name;
c1->name = malloc(12);
- if(!c1->name) barfout(1,"Malloc failed");
+ if(!c1->name) barfout(1, "Malloc failed");
strcpy(c1->name,"X");
}
/* Allocate the first swap-partition we find */
- for (c1 = c->part; c1 ; c1 = c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type == unused) continue;
if (c1->subtype != FS_SWAP) continue;
- sprintf(c1->name,"%s%c",c->name,SWAP_PART+'a');
+ 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) {
+ for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type == unused) continue;
if (!(c1->flags & CHUNK_IS_ROOT)) continue;
- sprintf(c1->name,"%s%c",c->name,0+'a');
+ 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 (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;
}
- strcpy(c1->name,c1->oname);
+ strcpy(c1->name, c1->oname);
newname:
}
/* Allocate the rest sequentially */
- for (c1 = c->part; c1 ; c1 = c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
const char order[] = "efghabd";
if (c1->type == unused) continue;
- if (strcmp("X",c1->name)) continue;
+ if (strcmp("X", c1->name)) continue;
- for(j=0;j<strlen(order);j++) {
- sprintf(c1->name,"%s%c",c->name,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)
if (c1 != c3 && !strcmp(c3->name, c1->name))
goto match;
break;
match:
- strcpy(c1->name,"X");
+ strcpy(c1->name, "X");
continue;
}
}
- for (c1 = c->part; c1 ; c1 = c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
free(c1->oname);
c1->oname = 0;
}
@@ -129,14 +129,14 @@ Fixup_Extended_Names(struct disk *d, struct chunk *c)
struct chunk *c1;
int j=5;
- for (c1 = c->part; c1 ; c1 = c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type == unused) continue;
free(c1->name);
c1->name = malloc(12);
- if(!c1->name) barfout(1,"malloc failed");
- sprintf(c1->name,"%ss%d",d->chunks->name,j++);
+ if(!c1->name) barfout(1, "malloc failed");
+ sprintf(c1->name, "%ss%d", d->chunks->name, j++);
if (c1->type == freebsd)
- Fixup_FreeBSD_Names(d,c1);
+ Fixup_FreeBSD_Names(d, c1);
}
}
@@ -155,14 +155,14 @@ Fixup_Names(struct disk *d)
c2->flags &= ~CHUNK_BSD_COMPAT;
if (c2->type == unused)
continue;
- if (strcmp(c2->name,"X"))
+ if (strcmp(c2->name, "X"))
continue;
#ifdef __i386__
c2->oname = malloc(12);
- if(!c2->oname) barfout(1,"malloc failed");
- for(j=1;j<=NDOSPART;j++) {
- sprintf(c2->oname,"%ss%d",c1->name,j);
- for(c3 = c1->part; c3 ; c3 = c3->next)
+ if(!c2->oname) barfout(1, "malloc failed");
+ for(j = 1; j <= NDOSPART; j++) {
+ sprintf(c2->oname, "%ss%d", c1->name, j);
+ for(c3 = c1->part; c3; c3 = c3->next)
if (c3 != c2 && !strcmp(c3->name, c2->oname))
goto match;
free(c2->name);
@@ -179,18 +179,18 @@ 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) {
c2->flags |= CHUNK_BSD_COMPAT;
break;
}
}
- 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);
+ Fixup_FreeBSD_Names(d, c2);
#ifndef PC98
if (c2->type == extended)
- Fixup_Extended_Names(d,c2);
+ Fixup_Extended_Names(d, c2);
#endif
}
}
@@ -227,9 +227,9 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty
}
#ifdef PC98
- i = Add_Chunk(d,offset,size,"X",type,subtype,flags,sname);
+ i = Add_Chunk(d, offset, size, "X", type, subtype, flags, sname);
#else
- i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
+ i = Add_Chunk(d, offset, size, "X", type, subtype, flags);
#endif
Fixup_Names(d);
return i;
@@ -244,7 +244,7 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty
if (!parent)
parent = d->chunks;
- for (c1=parent->part; c1 ; c1 = c1->next) {
+ for (c1=parent->part; c1; c1 = c1->next) {
if (c1->type != unused) continue;
if (c1->size < size) continue;
offset = c1->offset;
@@ -253,17 +253,17 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty
return 0;
found:
#ifdef PC98
- i = Add_Chunk(d,offset,size,"X",type,subtype,flags,"-");
+ i = Add_Chunk(d, offset, size, "X", type, subtype, flags, "-");
#else
- i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
+ i = Add_Chunk(d, offset, size, "X", type, subtype, flags);
#endif
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");
+ barfout(1, "Serious internal trouble");
return 0;
}
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index 1c36346..36b8986 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -42,7 +42,7 @@ const char *chunk_n[] = {
struct disk *
Open_Disk(const char *name)
{
- return Int_Open_Disk(name,0);
+ return Int_Open_Disk(name, 0);
}
#ifndef PC98
@@ -70,37 +70,37 @@ Int_Open_Disk(const char *name, u_long size)
#endif
u_long offset = 0;
- strcpy(device,_PATH_DEV);
- strcat(device,name);
+ strcpy(device, _PATH_DEV);
+ strcat(device, name);
d = (struct disk *)malloc(sizeof *d);
- if(!d) barfout(1,"malloc failed");
- memset(d,0,sizeof *d);
+ if(!d) barfout(1, "malloc failed");
+ memset(d, 0, sizeof *d);
- fd = open(device,O_RDONLY);
+ fd = open(device, O_RDONLY);
if (fd < 0) {
#ifdef DEBUG
- warn("open(%s) failed",device);
+ warn("open(%s) failed", device);
#endif
return 0;
}
- memset(&dl,0,sizeof dl);
- ioctl(fd,DIOCGDINFO,&dl);
- i = ioctl(fd,DIOCGSLICEINFO,&ds);
+ memset(&dl, 0, sizeof dl);
+ ioctl(fd, DIOCGDINFO, &dl);
+ i = ioctl(fd, DIOCGSLICEINFO, &ds);
if (i < 0) {
#ifdef DEBUG
- warn("DIOCGSLICEINFO(%s) failed",device);
+ warn("DIOCGSLICEINFO(%s) failed", device);
#endif
close(fd);
return 0;
}
#ifdef DEBUG
- for(i=0;i<ds.dss_nslices;i++)
+ for(i = 0; i < ds.dss_nslices; i++)
if(ds.dss_slices[i].ds_openmask)
printf(" open(%d)=0x%2x",
- i,ds.dss_slices[i].ds_openmask);
+ i, ds.dss_slices[i].ds_openmask);
printf("\n");
#endif
@@ -114,11 +114,11 @@ Int_Open_Disk(const char *name, u_long size)
#endif
#ifdef PC98
- p = (unsigned char*)read_block(fd,1);
+ p = (unsigned char*)read_block(fd, 1);
#else
- p = read_block(fd,0);
- dp = (struct dos_partition*)(p+DOSPARTOFF);
- for (i=0; i < NDOSPART; i++) {
+ p = read_block(fd, 0);
+ dp = (struct dos_partition*)(p + DOSPARTOFF);
+ for (i = 0; i < NDOSPART; i++) {
if (Read_Int32(&dp->dp_start) >= size)
continue;
if (Read_Int32(&dp->dp_start) + Read_Int32(&dp->dp_size) >= size)
@@ -142,7 +142,7 @@ Int_Open_Disk(const char *name, u_long size)
if (dl.d_ntracks && dl.d_nsectors)
- d->bios_cyl = size/(dl.d_ntracks*dl.d_nsectors);
+ d->bios_cyl = size / (dl.d_ntracks * dl.d_nsectors);
#ifdef PC98
if (Add_Chunk(d, -offset, size, name, whole, 0, 0, "-"))
@@ -174,10 +174,11 @@ Int_Open_Disk(const char *name, u_long size)
chunk_e ce;
u_long flags=0;
int subtype=0;
+
if (! ds.dss_slices[i].ds_size)
continue;
ds.dss_slices[i].ds_offset -= offset;
- sprintf(sname,"%ss%d",name,i-1);
+ sprintf(sname, "%ss%d", name, i - 1);
#ifdef PC98
subtype = ds.dss_slices[i].ds_type |
ds.dss_slices[i].ds_subtype << 8;
@@ -216,7 +217,7 @@ Int_Open_Disk(const char *name, u_long size)
break;
}
#ifdef PC98
- if (Add_Chunk(d,ds.dss_slices[i].ds_offset,
+ if (Add_Chunk(d, ds.dss_slices[i].ds_offset,
ds.dss_slices[i].ds_size, sname, ce, subtype, flags,
ds.dss_slices[i].ds_name))
#else
@@ -238,35 +239,35 @@ Int_Open_Disk(const char *name, u_long size)
{
struct disklabel dl;
char pname[20];
- int j,k;
+ int j, k;
- strcpy(pname,_PATH_DEV);
- strcat(pname,sname);
- j = open(pname,O_RDONLY);
+ strcpy(pname, _PATH_DEV);
+ strcat(pname, sname);
+ j = open(pname, O_RDONLY);
if (j < 0) {
#ifdef DEBUG
- warn("open(%s)",pname);
+ warn("open(%s)", pname);
#endif
continue;
}
- k = ioctl(j,DIOCGDINFO,&dl);
+ k = ioctl(j, DIOCGDINFO, &dl);
if (k < 0) {
#ifdef DEBUG
- warn("ioctl(%s,DIOCGDINFO)",pname);
+ warn("ioctl(%s, DIOCGDINFO)", pname);
#endif
close(j);
continue;
}
close(j);
- for(j=0; j <= dl.d_npartitions; j++) {
+ for(j = 0; j <= dl.d_npartitions; j++) {
if (j == RAW_PART)
continue;
if (j == 3)
continue;
if (j == dl.d_npartitions) {
j = 3;
- dl.d_npartitions=0;
+ dl.d_npartitions = 0;
}
if (!dl.d_partitions[j].p_size)
continue;
@@ -274,7 +275,7 @@ Int_Open_Disk(const char *name, u_long size)
dl.d_partitions[j].p_offset >
ds.dss_slices[i].ds_size)
continue;
- sprintf(pname,"%s%c",sname,j+'a');
+ sprintf(pname, "%s%c", sname, j + 'a');
if (Add_Chunk(d,
dl.d_partitions[j].p_offset +
ds.dss_slices[i].ds_offset,
@@ -290,7 +291,7 @@ Int_Open_Disk(const char *name, u_long size)
#ifdef DEBUG
warn(
"Failed to add chunk for partition %c [%lu,%lu]",
- j + 'a',dl.d_partitions[j].p_offset,
+ j + 'a', dl.d_partitions[j].p_offset,
dl.d_partitions[j].p_size);
#else
{}
@@ -305,19 +306,19 @@ Int_Open_Disk(const char *name, u_long size)
char pname[20];
int j,k;
- strcpy(pname,_PATH_DEV);
- strcat(pname,name);
- j = open(pname,O_RDONLY);
+ strcpy(pname, _PATH_DEV);
+ strcat(pname, name);
+ j = open(pname, O_RDONLY);
if (j < 0) {
#ifdef DEBUG
- warn("open(%s)",pname);
+ warn("open(%s)", pname);
#endif
goto nolabel;
}
- k = ioctl(j,DIOCGDINFO,&dl);
+ k = ioctl(j, DIOCGDINFO, &dl);
if (k < 0) {
#ifdef DEBUG
- warn("ioctl(%s,DIOCGDINFO)",pname);
+ warn("ioctl(%s, DIOCGDINFO)", pname);
#endif
close(j);
goto nolabel;
@@ -325,14 +326,14 @@ Int_Open_Disk(const char *name, u_long size)
close(j);
All_FreeBSD(d, 1);
- for(j=0; j <= dl.d_npartitions; j++) {
+ for(j = 0; j <= dl.d_npartitions; j++) {
if (j == RAW_PART)
continue;
if (j == 3)
continue;
if (j == dl.d_npartitions) {
j = 3;
- dl.d_npartitions=0;
+ dl.d_npartitions = 0;
}
if (!dl.d_partitions[j].p_size)
continue;
@@ -340,7 +341,7 @@ Int_Open_Disk(const char *name, u_long size)
dl.d_partitions[j].p_offset >
ds.dss_slices[WHOLE_DISK_SLICE].ds_size)
continue;
- sprintf(pname,"%s%c",name,j+'a');
+ sprintf(pname, "%s%c", name, j + 'a');
if (Add_Chunk(d,
dl.d_partitions[j].p_offset,
dl.d_partitions[j].p_size,
@@ -350,7 +351,7 @@ Int_Open_Disk(const char *name, u_long size)
#ifdef DEBUG
warn(
"Failed to add chunk for partition %c [%lu,%lu]",
- j + 'a',dl.d_partitions[j].p_offset,
+ j + 'a', dl.d_partitions[j].p_offset,
dl.d_partitions[j].p_size);
#else
{}
@@ -370,23 +371,23 @@ pc98_mo_done:
void
Debug_Disk(struct disk *d)
{
- printf("Debug_Disk(%s)",d->name);
- printf(" flags=%lx",d->flags);
+ printf("Debug_Disk(%s)", d->name);
+ printf(" flags=%lx", d->flags);
#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,
- d->bios_cyl*d->bios_hd*d->bios_sect);
+ d->bios_cyl, d->bios_hd, d->bios_sect,
+ d->bios_cyl * d->bios_hd * d->bios_sect);
#if defined(PC98)
printf(" boot1=%p, boot2=%p, bootipl=%p, bootmenu=%p\n",
- d->boot1,d->boot2,d->bootipl,d->bootmenu);
+ d->boot1, d->boot2, d->bootipl, d->bootmenu);
#elif defined(__i386__)
printf(" boot1=%p, boot2=%p, bootmgr=%p\n",
- d->boot1,d->boot2,d->bootmgr);
+ d->boot1, d->boot2, d->bootmgr);
#elif defined(__alpha__)
printf(" boot1=%p, bootmgr=%p\n",
- d->boot1,d->bootmgr);
+ d->boot1, d->bootmgr);
#endif
Debug_Chunk(d->chunks);
}
@@ -415,38 +416,38 @@ Clone_Disk(struct disk *d)
struct disk *d2;
d2 = (struct disk*) malloc(sizeof *d2);
- if(!d2) barfout(1,"malloc failed");
+ if(!d2) barfout(1, "malloc failed");
*d2 = *d;
d2->name = strdup(d2->name);
d2->chunks = Clone_Chunk(d2->chunks);
#ifdef PC98
if(d2->bootipl) {
d2->bootipl = malloc(d2->bootipl_size);
- memcpy(d2->bootipl,d->bootipl,d2->bootipl_size);
+ memcpy(d2->bootipl, d->bootipl, d2->bootipl_size);
}
if(d2->bootmenu) {
d2->bootmenu = malloc(d2->bootmenu_size);
- memcpy(d2->bootmenu,d->bootmenu,d2->bootmenu_size);
+ memcpy(d2->bootmenu, d->bootmenu, d2->bootmenu_size);
}
#else
if(d2->bootmgr) {
d2->bootmgr = malloc(d2->bootmgr_size);
- memcpy(d2->bootmgr,d->bootmgr,d2->bootmgr_size);
+ memcpy(d2->bootmgr, d->bootmgr, d2->bootmgr_size);
}
#endif
#if defined(__i386__)
if(d2->boot1) {
d2->boot1 = malloc(512);
- memcpy(d2->boot1,d->boot1,512);
+ memcpy(d2->boot1, d->boot1, 512);
}
if(d2->boot2) {
- d2->boot2 = malloc(512*15);
- memcpy(d2->boot2,d->boot2,512*15);
+ d2->boot2 = malloc(512 * 15);
+ memcpy(d2->boot2, d->boot2, 512 * 15);
}
#elif defined(__alpha__)
if(d2->boot1) {
- d2->boot1 = malloc(512*15);
- memcpy(d2->boot1,d->boot1,512*15);
+ d2->boot1 = malloc(512 * 15);
+ memcpy(d2->boot1, d->boot1, 512 * 15);
}
#endif
return d2;
@@ -457,7 +458,7 @@ void
Collapse_Disk(struct disk *d)
{
- while(Collapse_Chunk(d,d->chunks))
+ while(Collapse_Chunk(d, d->chunks))
;
}
#endif
@@ -540,8 +541,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) barfout(1,"malloc failed");
- memcpy(d->bootipl,bootipl,bootipl_size);
+ if(!d->bootipl) barfout(1, "malloc failed");
+ memcpy(d->bootipl, bootipl, bootipl_size);
}
/* XXX - assumes sector size of 512 */
@@ -554,8 +555,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) barfout(1,"malloc failed");
- memcpy(d->bootmenu,bootmenu,bootmenu_size);
+ if(!d->bootmenu) barfout(1, "malloc failed");
+ memcpy(d->bootmenu, bootmenu, bootmenu_size);
}
#else
/* XXX - assumes sector size of 512 */
@@ -568,8 +569,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) barfout(1,"malloc failed");
- memcpy(d->bootmgr,b,s);
+ if(!d->bootmgr) barfout(1, "malloc failed");
+ memcpy(d->bootmgr, b, s);
}
#endif
}
@@ -580,17 +581,17 @@ Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2)
#if defined(__i386__)
if (d->boot1) free(d->boot1);
d->boot1 = malloc(512);
- if(!d->boot1) barfout(1,"malloc failed");
- memcpy(d->boot1,b1,512);
+ if(!d->boot1) barfout(1, "malloc failed");
+ memcpy(d->boot1, b1, 512);
if (d->boot2) free(d->boot2);
- d->boot2 = malloc(15*512);
- if(!d->boot2) barfout(1,"malloc failed");
- memcpy(d->boot2,b2,15*512);
+ d->boot2 = malloc(15 * 512);
+ if(!d->boot2) barfout(1, "malloc failed");
+ memcpy(d->boot2, b2, 15 * 512);
#elif defined(__alpha__)
if (d->boot1) free(d->boot1);
- d->boot1 = malloc(15*512);
- if(!d->boot1) barfout(1,"malloc failed");
- memcpy(d->boot1,b1,15*512);
+ d->boot1 = malloc(15 * 512);
+ if(!d->boot1) barfout(1, "malloc failed");
+ memcpy(d->boot1, b1, 15 * 512);
#endif
}
diff --git a/lib/libdisk/disklabel.c b/lib/libdisk/disklabel.c
index a493d2a..69dc2cc 100644
--- a/lib/libdisk/disklabel.c
+++ b/lib/libdisk/disklabel.c
@@ -21,7 +21,7 @@ read_disklabel(int fd, daddr_t block)
{
struct disklabel *dp;
- dp = (struct disklabel *) read_block(fd,block);
+ dp = (struct disklabel *) read_block(fd, block);
if (dp->d_magic != DISKMAGIC)
return 0;
if (dp->d_magic2 != DISKMAGIC)
diff --git a/lib/libdisk/rules.c b/lib/libdisk/rules.c
index 0dc26f7..f73f6eb 100644
--- a/lib/libdisk/rules.c
+++ b/lib/libdisk/rules.c
@@ -42,7 +42,7 @@ Next_Track_Aligned(struct disk *d, u_long offset)
{
if (!d->bios_sect)
return offset;
- return Prev_Track_Aligned(d,offset + d->bios_sect-1);
+ return Prev_Track_Aligned(d, offset + d->bios_sect-1);
}
int
@@ -88,7 +88,7 @@ Rule_000(struct disk *d, struct chunk *c, char *msg)
if (c->type != whole)
return;
- for (c1=c->part; c1; c1=c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type != unused) continue;
#ifndef PC98
if (c1->flags & CHUNK_ACTIVE)
@@ -97,12 +97,12 @@ Rule_000(struct disk *d, struct chunk *c, char *msg)
i++;
}
if (i > NDOSPART)
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"%d is too many children of the 'whole' chunk. Max is %d\n",
i, NDOSPART);
#ifndef PC98
if (j > 1)
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"Too many active children of 'whole'");
#endif
}
@@ -120,28 +120,28 @@ Rule_001(struct disk *d, struct chunk *c, char *msg)
if (c->type != whole && c->type != extended)
return;
- for (i=0, c1=c->part; c1; c1=c1->next) {
+ for (i = 0, c1 = c->part; c1; c1 = c1->next) {
if (c1->type == unused) continue;
c1->flags |= CHUNK_ALIGN;
#ifdef PC98
- if (!Cyl_Aligned(d,c1->offset))
+ if (!Cyl_Aligned(d, c1->offset))
#else
- if (!Track_Aligned(d,c1->offset))
+ if (!Track_Aligned(d, c1->offset))
#endif
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
#ifdef PC98
"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",
#endif
- c1->name,c1->offset,c1->end);
+ c1->name, c1->offset, c1->end);
if ((c->type == whole || c->end == c1->end)
- || Cyl_Aligned(d,c1->end+1))
+ || Cyl_Aligned(d, c1->end + 1))
;
else
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"chunk '%s' [%ld..%ld] does not end on a cylinder boundary\n",
- c1->name,c1->offset,c1->end);
+ c1->name, c1->offset, c1->end);
}
}
@@ -158,13 +158,13 @@ Rule_002(struct disk *d, struct chunk *c, char *msg)
if (c->type != whole)
return;
- for (i=0, c1=c->part; c1; c1=c1->next) {
+ for (i = 0, c1 = c->part; c1; c1 = c1->next) {
if (c1->type != fat)
continue;
i++;
}
if (i > 1) {
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"Max one 'fat' allowed as child of 'whole'\n");
}
#endif
@@ -183,13 +183,13 @@ Rule_003(struct disk *d, struct chunk *c, char *msg)
if (c->type != whole)
return;
- for (i=0, c1=c->part; c1; c1=c1->next) {
+ for (i = 0, c1 = c->part; c1; c1 = c1->next) {
if (c1->type != extended)
continue;
i++;
}
if (i > 1) {
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"Max one 'extended' allowed as child of 'whole'\n");
}
#endif
@@ -209,7 +209,7 @@ Rule_004(struct disk *d, struct chunk *c, char *msg)
if (c->type != freebsd)
return;
- for (c1=c->part; c1; c1=c1->next) {
+ for (c1 = c->part; c1; c1 = c1->next) {
if (c1->type != part)
continue;
if (c1->flags & CHUNK_IS_ROOT)
@@ -217,11 +217,11 @@ Rule_004(struct disk *d, struct chunk *c, char *msg)
i++;
}
if (i > 7) {
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"Max seven partitions per freebsd slice\n");
}
if (k > 1) {
- sprintf(msg+strlen(msg),
+ sprintf(msg + strlen(msg),
"Max one root partition child per freebsd slice\n");
}
}
@@ -229,15 +229,15 @@ Rule_004(struct disk *d, struct chunk *c, char *msg)
void
Check_Chunk(struct disk *d, struct chunk *c, char *msg)
{
- Rule_000(d,c,msg);
- Rule_001(d,c,msg);
- Rule_002(d,c,msg);
- Rule_003(d,c,msg);
- Rule_004(d,c,msg);
+ Rule_000(d, c, msg);
+ Rule_001(d, c, msg);
+ Rule_002(d, c, msg);
+ Rule_003(d, c, msg);
+ Rule_004(d, c, msg);
if (c->part)
- Check_Chunk(d,c->part,msg);
+ Check_Chunk(d, c->part, msg);
if (c->next)
- Check_Chunk(d,c->next,msg);
+ Check_Chunk(d, c->next, msg);
}
char *
@@ -246,7 +246,7 @@ CheckRules(struct disk *d)
char msg[BUFSIZ];
*msg = '\0';
- Check_Chunk(d,d->chunks,msg);
+ Check_Chunk(d, d->chunks, msg);
if (*msg)
return strdup(msg);
return 0;
@@ -260,8 +260,8 @@ ChunkCanBeRoot(struct chunk *c)
char msg[BUFSIZ];
*msg = '\0';
- for (c1=d->chunks->part;;) {
- for (; c1; c1=c1->next)
+ for (c1 = d->chunks->part; ; ) {
+ for (; c1; c1 = c1->next)
if (c1->offset <= c->offset && c1->end >= c->end)
break;
if (!c1) {
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index cf75d7f..bdf04e5 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -46,28 +46,28 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
u_long *lp, sum;
#endif
- for(i=0;i<BBSIZE/512;i++) {
- p = read_block(fd,WHERE(i + c1->offset,new));
- memcpy(buf+512*i,p,512);
+ for(i = 0; i < BBSIZE/512; i++) {
+ p = read_block(fd, WHERE(i + c1->offset, new));
+ memcpy(buf + 512 * i, p, 512);
free(p);
}
#if defined(__i386__)
if(new->boot1)
- memcpy(buf,new->boot1,512);
+ memcpy(buf, new->boot1, 512);
if(new->boot2)
- memcpy(buf+512,new->boot2,BBSIZE-512);
+ memcpy(buf + 512, new->boot2, BBSIZE-512);
#elif defined(__alpha__)
if(new->boot1)
- memcpy(buf+512,new->boot1,BBSIZE-512);
+ memcpy(buf + 512, new->boot1, BBSIZE-512);
#endif
- dl = (struct disklabel *) (buf+512*LABELSECTOR+LABELOFFSET);
- memset(dl,0,sizeof *dl);
+ dl = (struct disklabel *)(buf + 512 * LABELSECTOR + LABELOFFSET);
+ memset(dl, 0, sizeof *dl);
- 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 (!strcmp(c2->name, "X")) continue;
#ifdef __alpha__
j = c2->name[strlen(c2->name) - 1] - 'a';
#else
@@ -75,7 +75,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
#endif
if (j < 0 || j >= MAXPARTITIONS || j == RAW_PART) {
#ifdef DEBUG
- warn("weird partition letter %c",c2->name[strlen(new->name) + 2]);
+ warn("weird partition letter %c", c2->name[strlen(new->name) + 2]);
#endif
continue;
}
@@ -92,7 +92,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
dl->d_interleave = DEF_INTERLEAVE;
dl->d_rpm = DEF_RPM;
- strcpy(dl->d_typename,c1->name);
+ strcpy(dl->d_typename, c1->name);
dl->d_secsize = 512;
dl->d_secperunit = new->chunks->size;
@@ -140,7 +140,7 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
#endif /*__alpha__*/
for(i=0;i<BBSIZE/512;i++) {
- write_block(fd,WHERE(i + c1->offset,new),buf+512*i);
+ write_block(fd,WHERE(i + c1->offset, new), buf + 512 * i);
}
return 0;
@@ -219,7 +219,7 @@ Write_Disk(struct disk *d1)
fd = open(device,O_RDWR);
if (fd < 0) {
#ifdef DEBUG
- warn("open(%s) failed",device);
+ warn("open(%s) failed", device);
#endif
return 1;
}
@@ -227,17 +227,17 @@ Write_Disk(struct disk *d1)
memset(s,0,sizeof s);
#ifdef PC98
- mbr = read_block(fd,WHERE(1,d1));
+ mbr = read_block(fd, WHERE(1, d1));
#else
- mbr = read_block(fd,WHERE(0,d1));
+ mbr = read_block(fd, WHERE(0, d1));
#endif
- dp = (struct dos_partition*) (mbr + DOSPARTOFF);
- memcpy(work,dp,sizeof work);
+ dp = (struct dos_partition*)(mbr + DOSPARTOFF);
+ memcpy(work, dp, sizeof work);
dp = work;
free(mbr);
- for (c1=d1->chunks->part; c1 ; c1 = c1->next) {
+ for (c1 = d1->chunks->part; c1; c1 = c1->next) {
if (c1->type == unused) continue;
- if (!strcmp(c1->name,"X")) continue;
+ if (!strcmp(c1->name, "X")) continue;
#ifdef __i386__
j = c1->name[4] - '1';
j = c1->name[strlen(d1->name) + 1] - '1';
@@ -251,10 +251,10 @@ Write_Disk(struct disk *d1)
#endif
#ifndef PC98
if (c1->type == extended)
- ret += Write_Extended(fd, d1,old,c1);
+ ret += Write_Extended(fd, d1, old, c1);
#endif
if (c1->type == freebsd)
- ret += Write_FreeBSD(fd, d1,old,c1);
+ ret += Write_FreeBSD(fd, d1, old, c1);
#ifdef __i386__
#ifndef PC98
@@ -292,7 +292,7 @@ Write_Disk(struct disk *d1)
#ifdef DEBUG
printf("S:%lu = (%x/%x/%x)",
- c1->offset,dp[j].dp_scyl,dp[j].dp_shd,dp[j].dp_ssect);
+ c1->offset, dp[j].dp_scyl, dp[j].dp_shd, dp[j].dp_ssect);
#endif
i = c1->end;
@@ -324,7 +324,7 @@ Write_Disk(struct disk *d1)
#ifdef DEBUG
printf(" E:%lu = (%x/%x/%x)\n",
- c1->end,dp[j].dp_ecyl,dp[j].dp_ehd,dp[j].dp_esect);
+ c1->end, dp[j].dp_ecyl, dp[j].dp_ehd, dp[j].dp_esect);
#endif
#ifdef PC98
@@ -345,9 +345,9 @@ Write_Disk(struct disk *d1)
}
#ifdef __i386__
j = 0;
- for(i=0;i<NDOSPART;i++) {
+ for(i = 0; i < NDOSPART; i++) {
if (!s[i])
- memset(dp+i,0,sizeof *dp);
+ memset(dp + i, 0, sizeof *dp);
#ifndef PC98
if (dp[i].dp_flag)
j++;
@@ -355,46 +355,46 @@ Write_Disk(struct disk *d1)
}
#ifndef PC98
if (!j)
- for(i=0;i<NDOSPART;i++)
+ for(i = 0; i < NDOSPART; i++)
if (dp[i].dp_typ == 0xa5)
dp[i].dp_flag = 0x80;
#endif
#ifdef PC98
if (d1->bootipl)
- write_block(fd,WHERE(0,d1),d1->bootipl);
+ write_block(fd, WHERE(0, d1), d1->bootipl);
- mbr = read_block(fd,WHERE(1,d1));
- memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
+ mbr = read_block(fd, WHERE(1, d1));
+ memcpy(mbr + DOSPARTOFF, dp, sizeof *dp * NDOSPART);
/* XXX - for entire FreeBSD(98) */
for (c1 = d1->chunks->part; c1; c1 = c1->next)
if (((c1->type == freebsd) || (c1->type == fat))
&& (c1->offset == 0))
PC98_EntireDisk = 1;
if (PC98_EntireDisk == 0)
- write_block(fd,WHERE(1,d1),mbr);
+ write_block(fd, WHERE(1, d1), mbr);
if (d1->bootmenu)
for (i = 0; i * 512 < d1->bootmenu_size; i++)
- write_block(fd,WHERE(2+i,d1),&d1->bootmenu[i * 512]);
+ write_block(fd, WHERE(2 + i, d1), &d1->bootmenu[i * 512]);
#else
- mbr = read_block(fd,WHERE(0,d1));
+ mbr = read_block(fd, WHERE(0, d1));
if (d1->bootmgr) {
- memcpy(mbr,d1->bootmgr,DOSPARTOFF);
+ memcpy(mbr, d1->bootmgr, DOSPARTOFF);
Cfg_Boot_Mgr(mbr, need_edd);
}
- memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
+ memcpy(mbr + DOSPARTOFF, dp, sizeof *dp * NDOSPART);
mbr[512-2] = 0x55;
mbr[512-1] = 0xaa;
- write_block(fd,WHERE(0,d1),mbr);
+ write_block(fd, WHERE(0, d1), mbr);
if (d1->bootmgr && d1->bootmgr_size > 512)
for(i = 1; i * 512 <= d1->bootmgr_size; i++)
- write_block(fd,WHERE(i,d1),&d1->bootmgr[i * 512]);
+ write_block(fd, WHERE(i, d1), &d1->bootmgr[i * 512]);
#endif
#endif
i = 1;
- i = ioctl(fd,DIOCSYNCSLICEINFO,&i);
+ i = ioctl(fd, DIOCSYNCSLICEINFO, &i);
#ifdef DEBUG
if (i != 0)
warn("ioctl(DIOCSYNCSLICEINFO)");
@@ -403,4 +403,3 @@ Write_Disk(struct disk *d1)
close(fd);
return 0;
}
-
OpenPOWER on IntegriCloud