Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 May 2011 17:27:32 +0200
From:      Baptiste Daroussin <bapt@freebsd.org>
To:        Nathan Whitehorn <nwhitehorn@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r221387 - head/usr.sbin/makefs/cd9660
Message-ID:  <BANLkTi=i_nKhQeNHPb%2BnRD0kJz%2BdAz4YKg@mail.gmail.com>
In-Reply-To: <201105031512.p43FC1Jr099140@svn.freebsd.org>
References:  <201105031512.p43FC1Jr099140@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2011/5/3 Nathan Whitehorn <nwhitehorn@freebsd.org>:
> Author: nwhitehorn
> Date: Tue May =A03 15:12:01 2011
> New Revision: 221387
> URL: http://svn.freebsd.org/changeset/base/221387
>
> Log:
> =A0Add support for synthesizing an APM partition map to map Mac PowerPC
> =A0bootstrap partitions from the ISO9660 boot catalog. This preserves OS =
X's
> =A0ability to mount the CD, while allowing us a way to provide HFS-ified
> =A0bootstrap code for Open Firmware.
>
> Modified:
> =A0head/usr.sbin/makefs/cd9660/cd9660_eltorito.c
>
> Modified: head/usr.sbin/makefs/cd9660/cd9660_eltorito.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/usr.sbin/makefs/cd9660/cd9660_eltorito.c =A0 =A0 =A0 Tue May =A0=
3 14:43:16 2011 =A0 =A0 =A0 =A0(r221386)
> +++ head/usr.sbin/makefs/cd9660/cd9660_eltorito.c =A0 =A0 =A0 Tue May =A0=
3 15:12:01 2011 =A0 =A0 =A0 =A0(r221387)
> @@ -31,6 +31,9 @@
> =A0* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
> =A0* OF SUCH DAMAGE.
> =A0*/
> +
> +#include <netinet/in.h>
> +
> =A0#include "cd9660.h"
> =A0#include "cd9660_eltorito.h"
>
> @@ -497,11 +500,43 @@ cd9660_setup_boot_volume_descriptor(volu
> =A0 =A0 =A0 =A0return 1;
> =A0}
>
> +static int
> +cd9660_write_apm_partition_entry(FILE *fd, int index, int total_partitio=
ns,
> + =A0 =A0off_t sector_start, off_t nsectors, off_t sector_size,
> + =A0 =A0const char *part_name, const char *part_type) {
> + =A0 =A0 =A0 uint32_t apm32;
> + =A0 =A0 =A0 uint16_t apm16;
> +
> + =A0 =A0 =A0 fseeko(fd, (off_t)(index + 1) * sector_size, SEEK_SET);
> +
> + =A0 =A0 =A0 /* Signature */
> + =A0 =A0 =A0 apm16 =3D htons(0x504d);
> + =A0 =A0 =A0 fwrite(&apm16, sizeof(apm16), 1, fd);
> + =A0 =A0 =A0 apm16 =3D 0;
> + =A0 =A0 =A0 fwrite(&apm16, sizeof(apm16), 1, fd);
> +
> + =A0 =A0 =A0 /* Total number of partitions */
> + =A0 =A0 =A0 apm32 =3D htonl(total_partitions);
> + =A0 =A0 =A0 fwrite(&apm32, sizeof(apm32), 1, fd);
> + =A0 =A0 =A0 /* Bounds */
> + =A0 =A0 =A0 apm32 =3D htonl(sector_start);
> + =A0 =A0 =A0 fwrite(&apm32, sizeof(apm32), 1, fd);
> + =A0 =A0 =A0 apm32 =3D htonl(nsectors);
> + =A0 =A0 =A0 fwrite(&apm32, sizeof(apm32), 1, fd);
> +
> + =A0 =A0 =A0 fwrite(part_name, strlen(part_name) + 1, 1, fd);
> + =A0 =A0 =A0 fseek(fd, 32 - strlen(part_name) - 1, SEEK_CUR);
> + =A0 =A0 =A0 fwrite(part_type, strlen(part_type) + 1, 1, fd);
> +
> + =A0 =A0 =A0 return 0;
> +}
> +
> =A0int
> =A0cd9660_write_boot(FILE *fd)
> =A0{
> =A0 =A0 =A0 =A0struct boot_catalog_entry *e;
> =A0 =A0 =A0 =A0struct cd9660_boot_image *t;
> + =A0 =A0 =A0 int apm_partitions =3D 0;
>
> =A0 =A0 =A0 =A0/* write boot catalog */
> =A0 =A0 =A0 =A0if (fseeko(fd, (off_t)diskStructure.boot_catalog_sector *
> @@ -533,7 +568,51 @@ cd9660_write_boot(FILE *fd)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0t->filename, t->se=
ctor);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cd9660_copy_file(fd, t->sector, t->filenam=
e);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (t->system =3D=3D ET_SYS_MAC)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 apm_partitions++;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 if (apm_partitions > 0) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Write DDR and global APM info */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint32_t apm32;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint16_t apm16;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 int total_parts;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fseek(fd, 0, SEEK_SET);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 apm16 =3D htons(0x4552);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fwrite(&apm16, sizeof(apm16), 1, fd);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 apm16 =3D htons(diskStructure.sectorSize);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fwrite(&apm16, sizeof(apm16), 1, fd);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 apm32 =3D htonl(diskStructure.totalSectors)=
;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fwrite(&apm32, sizeof(apm32), 1, fd);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Count total needed entries */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 total_parts =3D 2 + apm_partitions; /* Self=
 + ISO9660 */
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Write self-descriptor */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cd9660_write_apm_partition_entry(fd, 0,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 total_parts, 1, total_parts, diskSt=
ructure.sectorSize,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Apple", "Apple_partition_map");
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Write ISO9660 descriptor, enclosing the =
whole disk */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cd9660_write_apm_partition_entry(fd, 1,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 total_parts, 0, diskStructure.total=
Sectors,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 diskStructure.sectorSize, "", "CD_R=
OM_Mode_1");
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Write all partition entries */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 apm_partitions =3D 0;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 TAILQ_FOREACH(t, &diskStructure.boot_images=
, image_list) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (t->system !=3D ET_SYS_M=
AC)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cd9660_write_apm_partition_=
entry(fd,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 2 + apm_partitions+=
+, total_parts,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t->sector, t->num_s=
ectors, diskStructure.sectorSize,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "CD Boot", "Apple_B=
ootstrap");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0return 0;
> =A0}
> +
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
>

Nice,

Do not forget to send this to the netbsd folks so that both makefs
keep as in sync as possible, christos@NetBSD.org should be interested
by this.

if you already did this, sorry for the noise.

regards,
Bapt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTi=i_nKhQeNHPb%2BnRD0kJz%2BdAz4YKg>