Create_Chunk_DWIM() is here, though it doesn't quite do what the name implies.
This commit is contained in:
parent
f900359daa
commit
b06a2da118
@ -12,7 +12,7 @@ NOSHARED= yes
|
||||
|
||||
BOOTS=/usr/mdec
|
||||
|
||||
data.c:
|
||||
data.c: libdisk.h ${BOOTS}/boot1 ${BOOTS}/boot2
|
||||
file2c 'const unsigned char boot1[] = {' '};' \
|
||||
< ${BOOTS}/boot1 > tmp.c
|
||||
file2c 'const unsigned char boot2[] = {' '};' \
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: create_chunk.c,v 1.11 1995/05/08 00:44:46 phk Exp $
|
||||
* $Id: create_chunk.c,v 1.12 1995/05/08 01:26:47 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -164,3 +164,35 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty
|
||||
Fixup_Names(d);
|
||||
return i;
|
||||
}
|
||||
|
||||
struct chunk *
|
||||
Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags)
|
||||
{
|
||||
int i;
|
||||
struct chunk *c1;
|
||||
u_long offset;
|
||||
|
||||
if (!parent)
|
||||
parent = d->chunks;
|
||||
if (type == freebsd)
|
||||
subtype = 0xa5;
|
||||
for (c1=parent->part; c1 ; c1 = c1->next) {
|
||||
if (c1->type != unused) continue;
|
||||
if (c1->size < size) continue;
|
||||
offset = c1->offset;
|
||||
goto found;
|
||||
}
|
||||
warn("Not enough unused space");
|
||||
return 0;
|
||||
found:
|
||||
i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
|
||||
if (i) {
|
||||
warn("Didn't cut it");
|
||||
return 0;
|
||||
}
|
||||
Fixup_Names(d);
|
||||
for (c1=parent->part; c1 ; c1 = c1->next)
|
||||
if (c1->offset == offset)
|
||||
return c1;
|
||||
err(1,"Serious internal trouble");
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: libdisk.h,v 1.13 1995/05/06 03:28:30 phk Exp $
|
||||
* $Id: libdisk.h,v 1.14 1995/05/08 02:08:30 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -199,6 +199,13 @@ Prev_Track_Aligned(struct disk *d, u_long offset);
|
||||
* bios geometry
|
||||
*/
|
||||
|
||||
struct chunk *
|
||||
Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags);
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation details >>> DO NOT USE <<<
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: tst01.c,v 1.9 1995/05/03 17:38:00 jkh Exp $
|
||||
* $Id: tst01.c,v 1.10 1995/05/04 07:00:56 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -168,6 +168,16 @@ main(int argc, char **argv)
|
||||
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) );
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
|
||||
printf("delete = %d\n",
|
||||
Delete_Chunk(d,
|
||||
|
@ -12,7 +12,7 @@ NOSHARED= yes
|
||||
|
||||
BOOTS=/usr/mdec
|
||||
|
||||
data.c:
|
||||
data.c: libdisk.h ${BOOTS}/boot1 ${BOOTS}/boot2
|
||||
file2c 'const unsigned char boot1[] = {' '};' \
|
||||
< ${BOOTS}/boot1 > tmp.c
|
||||
file2c 'const unsigned char boot2[] = {' '};' \
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: create_chunk.c,v 1.11 1995/05/08 00:44:46 phk Exp $
|
||||
* $Id: create_chunk.c,v 1.12 1995/05/08 01:26:47 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -164,3 +164,35 @@ Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subty
|
||||
Fixup_Names(d);
|
||||
return i;
|
||||
}
|
||||
|
||||
struct chunk *
|
||||
Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags)
|
||||
{
|
||||
int i;
|
||||
struct chunk *c1;
|
||||
u_long offset;
|
||||
|
||||
if (!parent)
|
||||
parent = d->chunks;
|
||||
if (type == freebsd)
|
||||
subtype = 0xa5;
|
||||
for (c1=parent->part; c1 ; c1 = c1->next) {
|
||||
if (c1->type != unused) continue;
|
||||
if (c1->size < size) continue;
|
||||
offset = c1->offset;
|
||||
goto found;
|
||||
}
|
||||
warn("Not enough unused space");
|
||||
return 0;
|
||||
found:
|
||||
i = Add_Chunk(d,offset,size,"X",type,subtype,flags);
|
||||
if (i) {
|
||||
warn("Didn't cut it");
|
||||
return 0;
|
||||
}
|
||||
Fixup_Names(d);
|
||||
for (c1=parent->part; c1 ; c1 = c1->next)
|
||||
if (c1->offset == offset)
|
||||
return c1;
|
||||
err(1,"Serious internal trouble");
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: libdisk.h,v 1.13 1995/05/06 03:28:30 phk Exp $
|
||||
* $Id: libdisk.h,v 1.14 1995/05/08 02:08:30 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -199,6 +199,13 @@ Prev_Track_Aligned(struct disk *d, u_long offset);
|
||||
* bios geometry
|
||||
*/
|
||||
|
||||
struct chunk *
|
||||
Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags);
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation details >>> DO NOT USE <<<
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: tst01.c,v 1.9 1995/05/03 17:38:00 jkh Exp $
|
||||
* $Id: tst01.c,v 1.10 1995/05/04 07:00:56 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -168,6 +168,16 @@ main(int argc, char **argv)
|
||||
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) );
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
|
||||
printf("delete = %d\n",
|
||||
Delete_Chunk(d,
|
||||
|
Loading…
x
Reference in New Issue
Block a user