From owner-svn-src-all@FreeBSD.ORG Sat Aug 7 11:15:33 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 480D4106564A; Sat, 7 Aug 2010 11:15:33 +0000 (UTC) (envelope-from brucec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 35A708FC1B; Sat, 7 Aug 2010 11:15:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o77BFX6d022279; Sat, 7 Aug 2010 11:15:33 GMT (envelope-from brucec@svn.freebsd.org) Received: (from brucec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o77BFXi4022275; Sat, 7 Aug 2010 11:15:33 GMT (envelope-from brucec@svn.freebsd.org) Message-Id: <201008071115.o77BFXi4022275@svn.freebsd.org> From: Bruce Cran Date: Sat, 7 Aug 2010 11:15:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211002 - stable/7/usr.sbin/sysinstall X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Aug 2010 11:15:33 -0000 Author: brucec Date: Sat Aug 7 11:15:32 2010 New Revision: 211002 URL: http://svn.freebsd.org/changeset/base/211002 Log: MFC r209235, r210381 (bug fix for r209235): * Allow partial MB/GB values to be entered in the slice and label editor. * Don't strdup the name when calling deviceRegister because the string is copied within new_device. * Use a subtype of 165, not 3, when creating a slice in noninteractive mode. PR: bin/135333 PR: bin/66350 Approved by: rrs (mentor) Modified: stable/7/usr.sbin/sysinstall/devices.c stable/7/usr.sbin/sysinstall/disks.c stable/7/usr.sbin/sysinstall/label.c Directory Properties: stable/7/usr.sbin/sysinstall/ (props changed) Modified: stable/7/usr.sbin/sysinstall/devices.c ============================================================================== --- stable/7/usr.sbin/sysinstall/devices.c Sat Aug 7 11:13:50 2010 (r211001) +++ stable/7/usr.sbin/sysinstall/devices.c Sat Aug 7 11:15:32 2010 (r211002) @@ -281,6 +281,8 @@ deviceGetAll(void) msgNotify("Probing devices, please wait (this can take a while)..."); /* First go for the network interfaces. Stolen shamelessly from ifconfig! */ + memset(&ifc, 0, sizeof(ifc)); + memset(buffer, 0, INTERFACE_MAX * sizeof(struct ifreq)); ifc.ifc_len = sizeof(buffer); ifc.ifc_buf = buffer; @@ -357,7 +359,7 @@ skipif: if (fd >= 0) close(fd); snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), + deviceRegister(n, device_names[i].description, strdup(try), DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaShutdownCDROM, NULL); if (isDebug()) @@ -390,7 +392,7 @@ skipif: close(fd); snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), + deviceRegister(n, device_names[i].description, strdup(try), DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaShutdownFloppy, NULL); if (isDebug()) Modified: stable/7/usr.sbin/sysinstall/disks.c ============================================================================== --- stable/7/usr.sbin/sysinstall/disks.c Sat Aug 7 11:13:50 2010 (r211001) +++ stable/7/usr.sbin/sysinstall/disks.c Sat Aug 7 11:15:32 2010 (r211002) @@ -455,6 +455,7 @@ diskPartition(Device *dev) else { char *val, tmp[20], name[16], *cp; daddr_t size; + long double dsize; int subtype; chunk_e partitiontype; #ifdef PC98 @@ -469,11 +470,20 @@ diskPartition(Device *dev) snprintf(tmp, 20, "%jd", (intmax_t)chunk_info[current_chunk]->size); val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n" "or append a trailing `M' for megabytes (e.g. 20M)."); - if (val && (size = strtoimax(val, &cp, 0)) > 0) { + if (val && (dsize = strtold(val, &cp)) > 0 && dsize < UINT32_MAX) { if (*cp && toupper(*cp) == 'M') - size *= ONE_MEG; + size = (daddr_t) (dsize * ONE_MEG); else if (*cp && toupper(*cp) == 'G') - size *= ONE_GIG; + size = (daddr_t) (dsize * ONE_GIG); + else + size = (daddr_t) dsize; + + if (size < ONE_MEG) { + msgConfirm("The minimum slice size is 1MB"); + break; + } + + sprintf(tmp, "%d", SUBTYPE_FREEBSD); val = msgGetInput(tmp, "Enter type of partition to create:\n\n" "Pressing Enter will choose the default, a native FreeBSD\n" @@ -927,7 +937,8 @@ diskPartitionNonInteractive(Device *dev) { char *cp; int i, all_disk = 0; - daddr_t sz; + daddr_t size; + long double dsize; #ifdef PC98 u_char *bootipl; size_t bootipl_size; @@ -971,7 +982,7 @@ diskPartitionNonInteractive(Device *dev) /* If a chunk is at least 10MB in size, use it. */ if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) { Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, - freebsd, 3, + freebsd, SUBTYPE_FREEBSD, (chunk_info[i]->flags & CHUNK_ALIGN), "FreeBSD"); variable_set2(DISK_PARTITIONED, "yes", 0); @@ -995,16 +1006,19 @@ diskPartitionNonInteractive(Device *dev) All_FreeBSD(d, all_disk = TRUE); } - else if ((sz = strtoimax(cp, &cp, 0))) { - /* Look for sz bytes free */ + else if ((dsize = strtold(cp, &cp))) { if (*cp && toupper(*cp) == 'M') - sz *= ONE_MEG; + size *= (daddr_t) (dsize * ONE_MEG); else if (*cp && toupper(*cp) == 'G') - sz *= ONE_GIG; + size = (daddr_t) (dsize * ONE_GIG); + else + size = (daddr_t) dsize; + + /* Look for size bytes free */ for (i = 0; chunk_info[i]; i++) { /* If a chunk is at least sz MB, use it. */ - if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) { - Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, + if (chunk_info[i]->type == unused && chunk_info[i]->size >= size) { + Create_Chunk(d, chunk_info[i]->offset, size, freebsd, SUBTYPE_FREEBSD, (chunk_info[i]->flags & CHUNK_ALIGN), "FreeBSD"); variable_set2(DISK_PARTITIONED, "yes", 0); @@ -1013,7 +1027,7 @@ diskPartitionNonInteractive(Device *dev) } if (!chunk_info[i]) { msgConfirm("Unable to find %jd free blocks on this disk!", - (intmax_t)sz); + (intmax_t)size); return; } } Modified: stable/7/usr.sbin/sysinstall/label.c ============================================================================== --- stable/7/usr.sbin/sysinstall/label.c Sat Aug 7 11:13:50 2010 (r211001) +++ stable/7/usr.sbin/sysinstall/label.c Sat Aug 7 11:15:32 2010 (r211002) @@ -999,6 +999,7 @@ diskLabel(Device *dev) else { char *val; daddr_t size; + long double dsize; struct chunk *tmp; char osize[80]; u_long flags = 0; @@ -1019,22 +1020,27 @@ diskLabel(Device *dev) #endif "%jd blocks (%jdMB) are free.", (intmax_t)sz, (intmax_t)sz / ONE_MEG); - if (!val || (size = strtoimax(val, &cp, 0)) <= 0) { + if (!val || (dsize = strtold(val, &cp)) <= 0) { clear_wins(); break; } if (*cp) { if (toupper(*cp) == 'M') - size *= ONE_MEG; + size = (daddr_t) (dsize * ONE_MEG); else if (toupper(*cp) == 'G') - size *= ONE_GIG; + size = (daddr_t) (dsize * ONE_GIG); #ifndef __ia64__ else if (toupper(*cp) == 'C') - size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect); + size = (daddr_t) dsize * (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect); #endif + else + size = (daddr_t) dsize; + } else { + size = (daddr_t) dsize; } - if (size <= FS_MIN_SIZE) { + + if (size < FS_MIN_SIZE) { msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG); clear_wins(); break;