From owner-svn-src-stable-9@FreeBSD.ORG Mon Apr 9 14:05:02 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D751106566C; Mon, 9 Apr 2012 14:05:02 +0000 (UTC) (envelope-from andreast@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2960F8FC12; Mon, 9 Apr 2012 14:05:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q39E52Hc063294; Mon, 9 Apr 2012 14:05:02 GMT (envelope-from andreast@svn.freebsd.org) Received: (from andreast@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q39E51Si063293; Mon, 9 Apr 2012 14:05:01 GMT (envelope-from andreast@svn.freebsd.org) Message-Id: <201204091405.q39E51Si063293@svn.freebsd.org> From: Andreas Tobler Date: Mon, 9 Apr 2012 14:05:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234055 - stable/9/usr.sbin/makefs/cd9660 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2012 14:05:02 -0000 Author: andreast Date: Mon Apr 9 14:05:01 2012 New Revision: 234055 URL: http://svn.freebsd.org/changeset/base/234055 Log: MFC r233783: - Write the ISO9660 descriptor after the apm partition entries. - Fill the needed pmPartStatus flags. At least the OpenBIOS implementation relies on these flags. This commit fixes the panic seen on OS-X when inserting a FreeBSD/ppc disc. Additionally OpenBIOS recognizes the partition where the boot code is located. This lets us load a FreeBSD/ppc PowerMac kernel inside qemu. PR: powerpc/16209 Modified: stable/9/usr.sbin/makefs/cd9660/cd9660_eltorito.c Modified: stable/9/usr.sbin/makefs/cd9660/cd9660_eltorito.c ============================================================================== --- stable/9/usr.sbin/makefs/cd9660/cd9660_eltorito.c Mon Apr 9 13:29:24 2012 (r234054) +++ stable/9/usr.sbin/makefs/cd9660/cd9660_eltorito.c Mon Apr 9 14:05:01 2012 (r234055) @@ -538,9 +538,19 @@ cd9660_write_apm_partition_entry(FILE *f off_t sector_start, off_t nsectors, off_t sector_size, const char *part_name, const char *part_type) { - uint32_t apm32; + uint32_t apm32, part_status; uint16_t apm16; + /* See Apple Tech Note 1189 for the details about the pmPartStatus + * flags. + * Below the flags which are default: + * - IsValid 0x01 + * - IsAllocated 0x02 + * - IsReadable 0x10 + * - IsWritable 0x20 + */ + part_status = 0x01 | 0x02 | 0x10 | 0x20; + if (fseeko(fd, (off_t)(idx + 1) * sector_size, SEEK_SET) == -1) err(1, "fseeko"); @@ -562,6 +572,17 @@ cd9660_write_apm_partition_entry(FILE *f fwrite(part_name, strlen(part_name) + 1, 1, fd); fseek(fd, 32 - strlen(part_name) - 1, SEEK_CUR); fwrite(part_type, strlen(part_type) + 1, 1, fd); + fseek(fd, 32 - strlen(part_type) - 1, SEEK_CUR); + + apm32 = 0; + /* pmLgDataStart */ + fwrite(&apm32, sizeof(apm32), 1, fd); + /* pmDataCnt */ + apm32 = htobe32(nsectors); + fwrite(&apm32, sizeof(apm32), 1, fd); + /* pmPartStatus */ + apm32 = htobe32(part_status); + fwrite(&apm32, sizeof(apm32), 1, fd); return 0; } @@ -666,12 +687,6 @@ cd9660_write_boot(FILE *fd) cd9660_write_apm_partition_entry(fd, 0, total_parts, 1, total_parts, 512, "Apple", "Apple_partition_map"); - /* Write ISO9660 descriptor, enclosing the whole disk */ - cd9660_write_apm_partition_entry(fd, 1, total_parts, 0, - diskStructure.totalSectors * - (diskStructure.sectorSize / 512), 512, "ISO9660", - "CD_ROM_Mode_1"); - /* Write all partition entries */ apm_partitions = 0; TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) { @@ -679,11 +694,16 @@ cd9660_write_boot(FILE *fd) continue; cd9660_write_apm_partition_entry(fd, - 2 + apm_partitions++, total_parts, + 1 + apm_partitions++, total_parts, t->sector * (diskStructure.sectorSize / 512), t->num_sectors * (diskStructure.sectorSize / 512), 512, "CD Boot", "Apple_Bootstrap"); } + /* Write ISO9660 descriptor, enclosing the whole disk */ + cd9660_write_apm_partition_entry(fd, 2 + apm_partitions, + total_parts, 0, diskStructure.totalSectors * + (diskStructure.sectorSize / 512), 512, "ISO9660", + "CD_ROM_Mode_1"); } return 0;