1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
|
diff --exclude=*~ -urN util-linux-2.10f/fdisk/fdisk.c util-linux-2.10f.patched/fdisk/fdisk.c
--- util-linux-2.10f/fdisk/fdisk.c Fri Jan 21 19:19:37 2000
+++ util-linux-2.10f.patched/fdisk/fdisk.c Wed Mar 1 14:36:06 2000
@@ -72,6 +72,9 @@
* Sat Mar 20 09:31:05 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* Internationalization
*
+ * Wed Mar 1 14:34:53 EST 2000 David Huggins-Daines <dhuggins@linuxcare.com>
+ * Better support for OSF/1 disklabels on Alpha.
+ *
* Corrected deleting last logical partition -- aeb, 990430.
* Removed all assumptions on file names -- aeb, 990709
* [modprobe gave ugly error messages, and the number of devices to probe
@@ -108,6 +111,7 @@
#include "fdisksunlabel.h"
#include "fdisksgilabel.h"
#include "fdiskaixlabel.h"
+#include "fdiskbsdlabel.h"
#include "../defines.h"
#ifdef HAVE_blkpg_h
@@ -222,6 +226,7 @@
int sun_label = 0; /* looking at sun disklabel */
int sgi_label = 0; /* looking at sgi disklabel */
int aix_label = 0; /* looking at aix disklabel */
+int osf_label = 0; /* looking at osf disklabel */
struct partition *part_table[MAXIMUM_PARTS] /* partitions */
= {offset(buffer, 0), offset(buffer, 1),
@@ -517,7 +522,7 @@
void warn_cylinders(void)
{
- if (!sun_label && !sgi_label && cylinders > 1024 && !nowarn)
+ if (!sun_label && !sgi_label && !osf_label && cylinders > 1024 && !nowarn)
fprintf(stderr, "\n\
The number of cylinders for this disk is set to %d.\n\
There is nothing wrong with that, but this is larger than 1024,\n\
@@ -686,12 +691,15 @@
if (check_aix_label())
return 0;
+ if (check_osf_label())
+ return 0;
+
if (!valid_part_table_flag(buffer)) {
switch(what) {
case fdisk:
fprintf(stderr,
_("Device contains neither a valid DOS partition"
- " table, nor Sun or SGI disklabel\n"));
+ " table, nor Sun, SGI, or OSF disklabel\n"));
#ifdef __sparc__
create_sunlabel();
#else
@@ -1176,6 +1184,11 @@
return;
}
+ if (osf_label) {
+ list_disk_geometry();
+ xbsd_print_disklabel(xtra);
+ return;
+ }
w = strlen(disk_device);
/* Heuristic: we list partition 3 of /dev/foo as /dev/foo3,
but if the device name ends in a digit, say /dev/foo1,
@@ -1967,6 +1980,18 @@
fatal(usage2);
get_boot(fdisk);
+ /* On alpha, if we detect a disklabel, go directly to
+ disklabel mode (typically you'll be switching from DOS
+ partition tables to disklabels, not the other way around)
+ - dhuggins@linuxcare.com */
+#ifdef __alpha__
+ if (osf_label) {
+ printf(_("Detected an OSF/1 disklabel on %s, entering disklabel mode.\n"
+ "To return to DOS partition table mode, use the 'r' command.\n"),
+ disk_device);
+ bselect();
+ }
+#endif
while (1) {
putchar('\n');
diff --exclude=*~ -urN util-linux-2.10f/fdisk/fdiskbsdlabel.c util-linux-2.10f.patched/fdisk/fdiskbsdlabel.c
--- util-linux-2.10f/fdisk/fdiskbsdlabel.c Thu Dec 9 09:29:21 1999
+++ util-linux-2.10f.patched/fdisk/fdiskbsdlabel.c Wed Mar 1 14:37:10 2000
@@ -36,6 +36,10 @@
Changes:
19990319 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> - i18n/nls
+
+ 20000101 - David Huggins-Daines <dhuggins@linuxcare.com> - Better
+ support for OSF/1 disklabels on Alpha. Also fixed unaligned
+ accesses in alpha_bootblock_checksum()
*/
#include <unistd.h>
@@ -61,7 +65,6 @@
static void xbsd_delete_part (void);
static void xbsd_new_part (void);
-static void xbsd_print_disklabel (int show_all);
static void xbsd_write_disklabel (void);
static int xbsd_create_disklabel (void);
static void xbsd_edit_disklabel (void);
@@ -84,7 +87,17 @@
#endif
static struct xbsd_disklabel xbsd_dlabel;
-static char buffer[BSD_BBSIZE];
+
+/* We need our own internal buffer because the disklabel lives
+ elsewhere on platforms that are damaged by DOS -
+ dhuggins@linuxcare.com */
+#if defined (__alpha__)
+/* Also, we access this through a u_int64_t * when checksumming */
+static char dlbuffer[BSD_BBSIZE] __attribute__((aligned(8)));
+#else
+static char dlbuffer[BSD_BBSIZE];
+#endif
+
#if defined (i386) || defined (__sparc__) || defined (__arm__)
static struct partition *xbsd_part;
static int xbsd_part_index;
@@ -99,6 +112,25 @@
return 0;
}
+int
+check_osf_label(void)
+{
+ extern void update_units(void);
+
+ if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0)
+ return 0;
+ osf_label = 1;
+ /* Get *correct* geometry info from the disklabel (otherwise disks
+ previously partitioned under Digital Unix won't work) -
+ dhuggins@linuxcare.com */
+ heads = xbsd_dlabel.d_ntracks;
+ cylinders = xbsd_dlabel.d_ncylinders;
+ sectors = xbsd_dlabel.d_nsectors;
+ update_units();
+
+ return 1;
+}
+
void
bmenu (void)
{
@@ -111,11 +143,10 @@
puts (_(" n add a new BSD partition"));
puts (_(" p print BSD partition table"));
puts (_(" q quit without saving changes"));
-#if defined (i386) || defined (__sparc__) || defined (__arm__)
puts (_(" r return to main menu"));
-#endif
puts (_(" s show complete disklabel"));
puts (_(" t change a partition's filesystem id"));
+ puts (_(" u change units (cylinders/sectors)"));
puts (_(" w write disklabel to disk"));
#if defined (i386) || defined (__sparc__) || defined (__arm__)
puts (_(" x link BSD partition to non-BSD partition"));
@@ -134,6 +165,7 @@
void
bselect (void) {
+ extern void change_units(void);
#if defined (i386) || defined (__sparc__) || defined (__arm__)
int t, ss;
@@ -200,12 +232,15 @@
case 't':
xbsd_change_fstype ();
break;
+ case 'u':
+ change_units();
+ break;
case 'w':
xbsd_write_disklabel ();
break;
-#if defined (i386) || defined (__sparc__) || defined (__arm__)
case 'r':
return;
+#if defined (i386) || defined (__sparc__) || defined (__arm__)
case 'x':
xbsd_link_part ();
break;
@@ -262,14 +297,14 @@
cround (begin), mesg);
if (display_in_cyl_units)
- end = end * units_per_sector - 1;
+ end = (end - 1) * units_per_sector;
xbsd_dlabel.d_partitions[i].p_size = end - begin + 1;
xbsd_dlabel.d_partitions[i].p_offset = begin;
- xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED;
+ xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED;
}
-static void
+void
xbsd_print_disklabel (int show_all)
{
struct xbsd_disklabel *lp = &xbsd_dlabel;
@@ -321,12 +356,25 @@
fprintf(f, "%ld ", (long) lp->d_drivedata[j]);
}
fprintf (f, _("\n%d partitions:\n"), lp->d_npartitions);
- fprintf (f, _("# size offset fstype [fsize bsize cpg]\n"));
+ fprintf (f, _("# start end size fstype [fsize bsize cpg]\n"));
pp = lp->d_partitions;
for (i = 0; i < lp->d_npartitions; i++, pp++) {
if (pp->p_size) {
- fprintf(f, " %c: %8ld %8ld ", 'a' + i,
- (long) pp->p_size, (long) pp->p_offset);
+ if (display_in_cyl_units) {
+ fprintf(f, " %c: %8d%c %8d%c %8d%c ", 'a' + i,
+ cround(pp->p_offset),
+ (pp->p_offset % lp->d_secpercyl) ? '*' : ' ',
+ cround(pp->p_offset + pp->p_size - 1),
+ ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ',
+ pp->p_size / lp->d_secpercyl,
+ (pp->p_size % lp->d_secpercyl) ? '*' : ' ');
+
+ } else {
+ fprintf(f, " %c: %8d %8d %8d ", 'a' + i,
+ pp->p_offset,
+ pp->p_offset + pp->p_size - 1,
+ pp->p_size);
+ }
if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES)
fprintf(f, "%8.8s", xbsd_fstypes[pp->p_fstype].name);
else
@@ -348,27 +396,7 @@
fprintf(f, "%20.20s", "");
break;
}
- fprintf(f, "\t# (Cyl. %4ld", (long)
-#if 0
- pp->p_offset / lp->d_secpercyl); /* differs from Linux fdisk */
-#else
- pp->p_offset / lp->d_secpercyl + 1);
-#endif
- if (pp->p_offset % lp->d_secpercyl)
- putc('*', f);
- else
- putc(' ', f);
- fprintf(f, "- %ld",
- (long) (pp->p_offset +
- pp->p_size + lp->d_secpercyl - 1) /
-#if 0
- lp->d_secpercyl - 1); /* differs from Linux fdisk */
-#else
- lp->d_secpercyl);
-#endif
- if (pp->p_size % lp->d_secpercyl)
- putc('*', f);
- fprintf(f, ")\n");
+ putc('\n', f);
}
}
}
@@ -507,18 +535,18 @@
dkbasename = line_ptr;
}
sprintf (path, "%s/%sboot", bootdir, dkbasename);
- if (!xbsd_get_bootstrap (path, buffer, (int) xbsd_dlabel.d_secsize))
+ if (!xbsd_get_bootstrap (path, dlbuffer, (int) xbsd_dlabel.d_secsize))
return;
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
- d = &buffer[BSD_LABELSECTOR * SECTOR_SIZE];
+ d = &dlbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
bcopy (d, &dl, sizeof (struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */
bzero (d, sizeof (struct xbsd_disklabel));
sprintf (path, "%s/boot%s", bootdir, dkbasename);
- if (!xbsd_get_bootstrap (path, &buffer[xbsd_dlabel.d_secsize],
+ if (!xbsd_get_bootstrap (path, &dlbuffer[xbsd_dlabel.d_secsize],
(int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize))
return;
@@ -538,12 +566,12 @@
sector = 0;
#elif defined (__alpha__)
sector = 0;
- alpha_bootblock_checksum (buffer);
+ alpha_bootblock_checksum (dlbuffer);
#endif
if (ext2_llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
fatal (unable_to_seek);
- if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE))
+ if (BSD_BBSIZE != write (fd, dlbuffer, BSD_BBSIZE))
fatal (unable_to_write);
#if defined (i386) || defined (__sparc__) || defined (__arm__)
@@ -707,10 +735,10 @@
if (ext2_llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
fatal (unable_to_seek);
- if (BSD_BBSIZE != read (fd, buffer, BSD_BBSIZE))
+ if (BSD_BBSIZE != read (fd, dlbuffer, BSD_BBSIZE))
fatal (unable_to_read);
- bcopy (&buffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ bcopy (&dlbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
d, sizeof (struct xbsd_disklabel));
for (t = d -> d_npartitions; t < BSD_MAXPARTITIONS; t++)
@@ -745,14 +773,14 @@
/* This is necessary if we want to write the bootstrap later,
otherwise we'd write the old disklabel with the bootstrap.
*/
- bcopy (d, &buffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ bcopy (d, &dlbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
sizeof (struct xbsd_disklabel));
#if defined (__alpha__) && BSD_LABELSECTOR == 0
- alpha_bootblock_checksum (buffer);
+ alpha_bootblock_checksum (dlbuffer);
if (ext2_llseek (fd, 0, SEEK_SET) == -1)
fatal (unable_to_seek);
- if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE))
+ if (BSD_BBSIZE != write (fd, dlbuffer, BSD_BBSIZE))
fatal (unable_to_write);
#else
if (ext2_llseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1)
diff --exclude=*~ -urN util-linux-2.10f/fdisk/fdiskbsdlabel.h util-linux-2.10f.patched/fdisk/fdiskbsdlabel.h
--- util-linux-2.10f/fdisk/fdiskbsdlabel.h Fri Nov 5 11:59:06 1999
+++ util-linux-2.10f.patched/fdisk/fdiskbsdlabel.h Wed Mar 1 14:00:51 2000
@@ -182,6 +182,7 @@
#define BSD_FS_BOOT 13 /* partition contains bootstrap */
#define BSD_FS_ADOS 14 /* AmigaDOS fast file system */
#define BSD_FS_HFS 15 /* Macintosh HFS */
+#define BSD_FS_ADVFS 16 /* Digital Unix AdvFS */
/* this is annoying, but it's also the way it is :-( */
#ifdef __alpha__
@@ -212,6 +213,7 @@
{BSD_FS_BOOT, "boot"},
{BSD_FS_ADOS, "ADOS"},
{BSD_FS_HFS, "HFS"},
+ {BSD_FS_ADVFS, "AdvFS"},
{ 0, NULL }
};
#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1)
@@ -227,3 +229,8 @@
#define BSD_D_RAMDISK 0x08 /* disk emulator */
#define BSD_D_CHAIN 0x10 /* can do back-back transfers */
#define BSD_D_DOSPART 0x20 /* within MSDOS partition */
+
+extern uint heads, sectors, cylinders;
+extern int osf_label;
+extern int check_osf_label(void);
+extern void xbsd_print_disklabel(int);
diff --exclude=*~ -urN util-linux-2.10f/po/cat-id-tbl.c util-linux-2.10f.patched/po/cat-id-tbl.c
--- util-linux-2.10f/po/cat-id-tbl.c Wed Mar 1 10:26:44 2000
+++ util-linux-2.10f.patched/po/cat-id-tbl.c Wed Mar 1 10:30:22 2000
@@ -841,7 +841,7 @@
{"\
\n\
%d partitions:\n", 627},
- {"# size offset fstype [fsize bsize cpg]\n", 628},
+ {"# start end size fstype [fsize bsize cpg]\n", 628},
{"Writing disklabel to %s%d.\n", 629},
{"Writing disklabel to %s.\n", 630},
{"%s%d contains no disklabel.\n", 631},
|