Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* fdisk alignment fixes for alpha
@ 1996-05-13 15:38 Harald Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Koenig @ 1996-05-13 15:38 UTC (permalink / raw)


the patches below fix (all?) those ugly unaligned access messages
for Linux/AXP.

Harald
-------------------------------------------------------------------------------
--- util-linux-2.5/disk-utils/fdisk.c.ORIG	Mon May 13 17:27:08 1996
+++ util-linux-2.5/disk-utils/fdisk.c	Mon May 13 17:25:16 1996
@@ -83,6 +83,7 @@
 #define ALTERNATE_DEVICE "/dev/sda"
 #define LINE_LENGTH	80
 #define MAXIMUM_PARTS	60
+#define PART_ALIGNMENT   2
 #define PART_TABLE_FLAG	0xaa55
 #define table_check(b)	((unsigned short *)((b) + 0x1fe))
 #define offset(b, n)	((struct partition *)((b) + 0x1be + \
@@ -115,9 +116,9 @@
 	*line_ptr,			/* interactive input */
 	line_buffer[LINE_LENGTH],
 	changed[MAXIMUM_PARTS],		/* marks changed buffers */
-	buffer[SECTOR_SIZE],	/* first four partitions */
+	buffer[SECTOR_SIZE+PART_ALIGNMENT],	/* first four partitions */
 	*buffers[MAXIMUM_PARTS]		/* pointers to buffers */
-		= {buffer, buffer, buffer, buffer};
+		= {buffer+PART_ALIGNMENT, buffer+PART_ALIGNMENT, buffer+PART_ALIGNMENT, buffer+PART_ALIGNMENT};
 
 int	fd,				/* the disk */
 	ext_index,			/* the prime extended partition */
@@ -136,8 +137,8 @@
 	offsets[MAXIMUM_PARTS] = {0, 0, 0, 0};
 
 struct	partition *part_table[MAXIMUM_PARTS]	/* partitions */
-		= {offset(buffer, 0), offset(buffer, 1),
-		offset(buffer, 2), offset(buffer, 3)},
+		= {offset(buffer+PART_ALIGNMENT, 0), offset(buffer+PART_ALIGNMENT, 1),
+		offset(buffer+PART_ALIGNMENT, 2), offset(buffer+PART_ALIGNMENT, 3)},
 	*ext_pointers[MAXIMUM_PARTS]		/* link pointers */
 		= {NULL, NULL, NULL, NULL};
 
@@ -414,7 +415,7 @@
 		if (ext2_llseek(fd, (ext2_loff_t)offsets[partitions]
 			       * SECTOR_SIZE, SEEK_SET) < 0)
 			fatal(unable_to_seek);
-		if (!(buffers[partitions] = (char *) malloc(SECTOR_SIZE)))
+		if (!(buffers[partitions] = (char *) malloc(SECTOR_SIZE+PART_ALIGNMENT)))
 			fatal(out_of_memory);
 		buffers[partitions] += PART_ALIGNMENT;
 		if (SECTOR_SIZE != read(fd, buffers[partitions], SECTOR_SIZE))
@@ -463,10 +464,10 @@
 	    else
 		printf("You will not be able to write the partition table.\n");
 	}
-	if (SECTOR_SIZE != read(fd, buffer, SECTOR_SIZE))
+	if (SECTOR_SIZE != read(fd, buffer+PART_ALIGNMENT, SECTOR_SIZE))
 		fatal(unable_to_read);
 
-	if (*(unsigned short *)  (0x1fe + buffer) != 0xAA55) {
+	if (*(unsigned short *)  (0x1fe + buffer+PART_ALIGNMENT) != 0xAA55) {
 	    return 0;
 	}
 #ifdef HDIO_REQ
@@ -684,14 +685,14 @@
 	if (i < 4) {
 		if (p->sys_ind == EXTENDED && i == ext_index) {
 			while (partitions > 4)
-				free(buffers[--partitions]);
+				free(buffers[--partitions]-PART_ALIGNMENT);
 			ext_pointers[ext_index] = NULL;
 			extended_offset = 0;
 		}
 		clear_partition(p);
 	}
 	else if (!q->sys_ind && i > 4) {
-		free(buffers[--partitions]);
+		free(buffers[--partitions]-PART_ALIGNMENT);
 		clear_partition(ext_pointers[--i]);
 	}
 	else if (i > 3) {
@@ -718,7 +719,7 @@
 		}
 		if (partitions > 5) {
 			partitions--;
-			free(buffers[i]);
+			free(buffers[i]-PART_ALIGNMENT);
 			while (i < partitions) {
 				changed[i] = changed[i + 1];
 				buffers[i] = buffers[i + 1];
@@ -1104,7 +1105,7 @@
 	if (start > limit) {
 		printf("No free sectors available\n");
 		if (n > 4) {
-			free(buffers[n]);
+			free(buffers[n]-PART_ALIGNMENT);
 			partitions--;
 		}
 		return;
@@ -1129,7 +1130,7 @@
 		ext_index = n;
 		offsets[4] = extended_offset = start;
 		ext_pointers[n] = p;
-		if (!(buffers[4] = calloc(1, SECTOR_SIZE)))
+		if (!(buffers[4] = calloc(1, SECTOR_SIZE+PART_ALIGNMENT)))
 			fatal(out_of_memory);
 		buffers[4] += PART_ALIGNMENT;
 		part_table[4] = offset(buffers[4], 0);
@@ -1153,7 +1154,7 @@
 void add_logical(void)
 {
 	if (partitions > 5 || part_table[4]->sys_ind) {
-		if (!(buffers[partitions] = calloc(1, SECTOR_SIZE)))
+		if (!(buffers[partitions] = calloc(1, SECTOR_SIZE+PART_ALIGNMENT)))
 			fatal(out_of_memory);
 		buffers[partitions] += PART_ALIGNMENT;
 		part_table[partitions] = offset(buffers[partitions], 0);
-------------------------------------------------------------------------------

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: fdisk alignment fixes for alpha
@ 1996-05-13 18:28 Andries.Brouwer
  0 siblings, 0 replies; 2+ messages in thread
From: Andries.Brouwer @ 1996-05-13 18:28 UTC (permalink / raw)


Thanks!
Andries

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-05-13 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-05-13 15:38 fdisk alignment fixes for alpha Harald Koenig
  -- strict thread matches above, loose matches on Subject: below --
1996-05-13 18:28 Andries.Brouwer

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