Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Martin Ostermann <ost@comnets.rwth-aachen.de>
Subject: isomarkboot for 32 bit machines
Date: 07 Oct 1996 12:10:05 +0200	[thread overview]
Message-ID: <e78418aa1c777d8470b88aaa6bd98764.axp-list@archive.invalid> (raw)

Hi,

isomarkboot.c assumed, that 'long's are 64 bit. I discovered this
after burning the new RedHat CD on a FreeBSD[1] machine, but since I
just had to upgrade, that wasn't a big problem.

Anyway, I patched 'isomarkboot.c' to work on 32 bit architectures as
well. Now the basic assumption is, that a 'char' is 1 byte, and 
sizeof(int) > sizeof(char). And the size of the ISO-fs is limitated by
sizeof(long), that's 4GB on 32 bit machines.

I havn't really tested this[2], I just compared the results on one image
-- they were identical with the Linux/axp version. Also I havn't
tested this on the Alpha jet, but there should be no problem.

Martin

[1] Using linux kernel headerfiles, isomarkboot compiled well.
[2] The FreeBSD machine is at work, the Alpha at home.

diff -ubr aboot-0.5/tools/isomarkboot.c aboot-0.5.new/tools/isomarkboot.c
--- aboot-0.5/tools/isomarkboot.c	Wed Jul  3 01:55:50 1996
+++ aboot-0.5.new/tools/isomarkboot.c	Mon Oct  7 10:47:38 1996
@@ -54,15 +54,47 @@
 	return read(disk, buf, size);
 }
 
+void
+write_8bytes(unsigned char *dst, long value)
+{ 
+	int i;
+	for(i=0;i<8;i++){
+		*dst++ = (unsigned char)(value & 0xff);
+		value>>=8;
+		}
+}
+
+void
+add_8bytes(unsigned char *sum, unsigned char* new)
+{
+	int i,r,v;
+	v=0;
+	for(i=0;i<8;i++){
+		r = (int)(sum[i]) + (int)(new[i]) + v;
+		v = r>>8;
+		if(v>1) printf("Error! v>1\n");
+		sum[i] = (unsigned char) (r & 0xff);
+		}
+}
+
+void
+calc_checksum(unsigned char *sector)
+{
+	int i;
 
+	for(i=0;i<8;i++)
+		sector[8*63+i] = 0;
+	for(i=0;i<63;i++)
+		add_8bytes(sector+8*63, sector+8*i);
+}
 
 int
 main (int argc, char ** argv)
 {
-	unsigned long sector[512 / sizeof(unsigned long)], sum;
+	unsigned char sector[512];
 	size_t nbytes, aboot_size;
 	off_t aboot_pos;
-	int i, aboot_fd;
+	int  aboot_fd;
 
 	prog_name = argv[0];
 
@@ -91,7 +123,7 @@
 	aboot_pos = iso_map (aboot_fd, 0);
 
 	printf("%s: %s is at offset %ld and is %lu bytes long\n",
-	       prog_name, argv[2], aboot_pos, aboot_size);
+	       prog_name, argv[2], (long)aboot_pos, (long)aboot_size);
 
 	if (lseek(disk, 0, SEEK_SET) != 0) {
 		perror("lseek");
@@ -109,15 +141,12 @@
 	}
 
 	strcpy((char *) sector, "Linux/Alpha aboot for ISO filesystem.");
-	sector[60] = aboot_size / 512;		/* sector count */
-	sector[61] = aboot_pos / 512;		/* starting LBM */
-	sector[62] = 0;				/* flags */
+	write_8bytes(sector+8*60, aboot_size/512 );	/* sector count */
+	write_8bytes(sector+8*61, aboot_pos / 512 );		/* starting LBM */
+	write_8bytes(sector+8*62, 0 );				/* flags */
 
 	/* update checksum: */
-	sum = 0;
-	for (i = 0; i < 63; ++i)
-		sum += sector[i];
-	sector[63] = sum;
+	calc_checksum(sector);
 
 	if (lseek(disk, 0, SEEK_SET) != 0) {
 		perror("lseek");

-- 
Martin Ostermann                | mailto:ost@comnets.rwth-aachen.de
Communication Networks          | http://www.comnets.rwth-aachen.de/~ost
Aachen University of Technology | phoneto:++49/241/807917
Germany                         | faxto:++49/241/8890378

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

                 reply	other threads:[~1996-10-07 10:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox