From owner-freebsd-bugs Thu Mar 22 20:50:16 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 732A437B71B for ; Thu, 22 Mar 2001 20:50:04 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f2N4o4v77364; Thu, 22 Mar 2001 20:50:04 -0800 (PST) (envelope-from gnats) Date: Thu, 22 Mar 2001 20:50:04 -0800 (PST) Message-Id: <200103230450.f2N4o4v77364@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Seth Kingsley Subject: Re: bin/24435: Changing slice type causes Auto-partition to not work Reply-To: Seth Kingsley Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/24435; it has been noted by GNATS. From: Seth Kingsley To: freebsd-gnats-submit@FreeBSD.org, rwatson@FreeBSD.org Cc: Subject: Re: bin/24435: Changing slice type causes Auto-partition to not work Date: Thu, 22 Mar 2001 20:48:05 -0800 This has to do with libdisk(3) not creating an 'unused' partition for slice types other than 'freebsd'. This patch to libdisk checks for the existance of the 'unused' partition and creates one if need be: Index: chunk.c =================================================================== RCS file: /ncvs/src/lib/libdisk/chunk.c,v retrieving revision 1.24 diff -u -r1.24 chunk.c --- chunk.c 2001/03/18 21:30:10 1.24 +++ chunk.c 2001/03/23 04:42:56 @@ -109,6 +109,32 @@ return c2; } +/* + * Check to see if this slice has no partitions. If it does not, create + * an empty one spanning the entire slice. This can happen when an + * existing slice of a different type is changed into a 'freebsd' slice. + */ +void +Check_Unused(struct chunk *cp) +{ + struct chunk *ncp = new_chunk(); + + if (cp->part) + return; + if (!ncp) barfout(1,"malloc failed"); + memset(ncp,0,sizeof *ncp); + ncp->disk = cp->disk; + ncp->offset = cp->offset; + ncp->size = cp->size; + ncp->end = cp->end; + ncp->type = unused; +#ifdef PC98 + ncp->sname = strdup(cp->sname); +#endif /* PC98 */ + ncp->name = strdup("-"); + cp->part = ncp; +} + int #ifdef PC98 Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, @@ -263,6 +289,8 @@ c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd); if(!c1) return __LINE__; + if(type == part) + Check_Unused(c1); for(c2=c1->part;c2;c2=c2->next) { if (c2->type != unused) continue; Index: create_chunk.c =================================================================== RCS file: /ncvs/src/lib/libdisk/create_chunk.c,v retrieving revision 1.55 diff -u -r1.55 create_chunk.c --- create_chunk.c 2001/03/18 21:30:10 1.55 +++ create_chunk.c 2001/03/23 04:45:41 @@ -240,6 +240,7 @@ if (!parent) parent = d->chunks; + Check_Unused(parent); for (c1=parent->part; c1 ; c1 = c1->next) { if (c1->type != unused) continue; if (c1->size < size) continue; Index: libdisk.h =================================================================== RCS file: /ncvs/src/lib/libdisk/libdisk.h,v retrieving revision 1.37 diff -u -r1.37 libdisk.h --- libdisk.h 2001/03/18 21:30:10 1.37 +++ libdisk.h 2001/03/23 04:44:47 @@ -265,6 +265,7 @@ void Debug_Chunk(struct chunk *); void Free_Chunk(struct chunk *); struct chunk * Clone_Chunk(struct chunk *); +void Check_Unused(struct chunk *); #ifdef PC98 int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long, const char *); #else -- || Seth Kingsley || BSDi/Open Source Division || sethk@osd.bsdi.com || To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message