2006-12-07 00:25:35 +01:00
|
|
|
/*
|
|
|
|
* fdisksunlabel.c
|
|
|
|
*
|
|
|
|
* I think this is mostly, or entirely, due to
|
|
|
|
* Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996
|
|
|
|
*
|
|
|
|
* Merged with fdisk for other architectures, aeb, June 1998.
|
2006-12-07 00:25:39 +01:00
|
|
|
*
|
|
|
|
* Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
|
|
|
* Internationalization
|
2006-12-07 00:25:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h> /* stderr */
|
2006-12-07 00:26:12 +01:00
|
|
|
#include <stdlib.h> /* qsort */
|
2006-12-07 00:25:35 +01:00
|
|
|
#include <string.h> /* strstr */
|
|
|
|
#include <unistd.h> /* write */
|
|
|
|
#include <sys/ioctl.h> /* ioctl */
|
|
|
|
#include <sys/stat.h> /* stat */
|
2006-12-07 00:26:05 +01:00
|
|
|
#include <sys/sysmacros.h> /* major */
|
|
|
|
|
2006-12-07 00:25:39 +01:00
|
|
|
#include "nls.h"
|
2007-11-07 19:05:31 +01:00
|
|
|
#include "blkdev.h"
|
2006-12-07 00:25:35 +01:00
|
|
|
|
|
|
|
#include <endian.h>
|
2007-11-28 10:40:32 +01:00
|
|
|
#ifdef HAVE_LINUX_MAJOR_H
|
2006-12-07 00:25:35 +01:00
|
|
|
#include <linux/major.h> /* FLOPPY_MAJOR */
|
2007-11-28 10:40:32 +01:00
|
|
|
#endif
|
2006-12-07 00:25:35 +01:00
|
|
|
|
2006-12-07 00:25:39 +01:00
|
|
|
#include "common.h"
|
2006-12-07 00:25:35 +01:00
|
|
|
#include "fdisk.h"
|
|
|
|
#include "fdisksunlabel.h"
|
|
|
|
|
2006-12-07 00:25:37 +01:00
|
|
|
static int other_endian = 0;
|
|
|
|
static int scsi_disk = 0;
|
|
|
|
static int floppy = 0;
|
2006-12-07 00:25:35 +01:00
|
|
|
|
|
|
|
struct systypes sun_sys_types[] = {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
{SUN_TAG_UNASSIGNED, N_("Unassigned")},
|
|
|
|
{SUN_TAG_BOOT, N_("Boot")},
|
|
|
|
{SUN_TAG_ROOT, N_("SunOS root")},
|
|
|
|
{SUN_TAG_SWAP, N_("SunOS swap")},
|
|
|
|
{SUN_TAG_USR, N_("SunOS usr")},
|
|
|
|
{SUN_TAG_BACKUP, N_("Whole disk")},
|
|
|
|
{SUN_TAG_STAND, N_("SunOS stand")},
|
|
|
|
{SUN_TAG_VAR, N_("SunOS var")},
|
|
|
|
{SUN_TAG_HOME, N_("SunOS home")},
|
|
|
|
{SUN_TAG_ALTSCTR, N_("SunOS alt sectors")},
|
|
|
|
{SUN_TAG_CACHE, N_("SunOS cachefs")},
|
|
|
|
{SUN_TAG_RESERVED, N_("SunOS reserved")},
|
|
|
|
{SUN_TAG_LINUX_SWAP, N_("Linux swap")},
|
|
|
|
{SUN_TAG_LINUX_NATIVE, N_("Linux native")},
|
|
|
|
{SUN_TAG_LINUX_LVM, N_("Linux LVM")},
|
|
|
|
{SUN_TAG_LINUX_RAID, N_("Linux raid autodetect")},
|
2006-12-07 00:25:35 +01:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2006-12-07 00:25:37 +01:00
|
|
|
static inline unsigned short __swap16(unsigned short x) {
|
2007-10-27 18:27:31 +01:00
|
|
|
return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
2007-10-27 18:27:31 +01:00
|
|
|
static inline uint32_t __swap32(uint32_t x) {
|
|
|
|
return (((uint32_t)(x) & 0xFF) << 24) | (((uint32_t)(x) & 0xFF00) << 8) | (((uint32_t)(x) & 0xFF0000) >> 8) | (((uint32_t)(x) & 0xFF000000) >> 24);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
#define SSWAP16(x) (other_endian ? __swap16(x) \
|
2007-10-27 18:27:31 +01:00
|
|
|
: (uint16_t)(x))
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
#define SSWAP32(x) (other_endian ? __swap32(x) \
|
2007-10-27 18:27:31 +01:00
|
|
|
: (uint32_t)(x))
|
2006-12-07 00:25:35 +01:00
|
|
|
|
2007-11-28 10:40:32 +01:00
|
|
|
#ifndef FLOPPY_MAJOR
|
|
|
|
#define FLOPPY_MAJOR 2
|
|
|
|
#endif
|
2006-12-07 00:25:44 +01:00
|
|
|
#ifndef IDE0_MAJOR
|
|
|
|
#define IDE0_MAJOR 3
|
|
|
|
#endif
|
|
|
|
#ifndef IDE1_MAJOR
|
|
|
|
#define IDE1_MAJOR 22
|
|
|
|
#endif
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void guess_device_type(int fd)
|
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
struct stat bootstat;
|
|
|
|
|
|
|
|
if (fstat (fd, &bootstat) < 0) {
|
|
|
|
scsi_disk = 0;
|
|
|
|
floppy = 0;
|
|
|
|
} else if (S_ISBLK(bootstat.st_mode)
|
2006-12-07 00:26:05 +01:00
|
|
|
&& (major(bootstat.st_rdev) == IDE0_MAJOR ||
|
|
|
|
major(bootstat.st_rdev) == IDE1_MAJOR)) {
|
2006-12-07 00:25:35 +01:00
|
|
|
scsi_disk = 0;
|
|
|
|
floppy = 0;
|
|
|
|
} else if (S_ISBLK(bootstat.st_mode)
|
2006-12-07 00:26:05 +01:00
|
|
|
&& major(bootstat.st_rdev) == FLOPPY_MAJOR) {
|
2006-12-07 00:25:35 +01:00
|
|
|
scsi_disk = 0;
|
|
|
|
floppy = 1;
|
|
|
|
} else {
|
|
|
|
scsi_disk = 1;
|
|
|
|
floppy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-27 18:27:31 +01:00
|
|
|
static void set_sun_partition(int i, uint32_t start, uint32_t stop, uint16_t sysid)
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
{
|
|
|
|
sunlabel->part_tags[i].tag = SSWAP16(sysid);
|
|
|
|
sunlabel->part_tags[i].flag = SSWAP16(0);
|
2006-12-07 00:25:35 +01:00
|
|
|
sunlabel->partitions[i].start_cylinder =
|
|
|
|
SSWAP32(start / (heads * sectors));
|
|
|
|
sunlabel->partitions[i].num_sectors =
|
|
|
|
SSWAP32(stop - start);
|
2006-12-07 00:25:43 +01:00
|
|
|
set_changed(i);
|
2011-08-17 13:21:12 +02:00
|
|
|
print_partition_size(i + 1, start, stop, sysid);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_nolabel(void)
|
|
|
|
{
|
2006-12-07 00:25:37 +01:00
|
|
|
sunlabel->magic = 0;
|
|
|
|
partitions = 4;
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
int check_sun_label(void)
|
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
unsigned short *ush;
|
|
|
|
int csum;
|
2006-12-07 00:26:03 +01:00
|
|
|
|
2006-12-07 00:25:37 +01:00
|
|
|
if (sunlabel->magic != SUN_LABEL_MAGIC &&
|
|
|
|
sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {
|
2006-12-07 00:25:35 +01:00
|
|
|
other_endian = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
other_endian = (sunlabel->magic == SUN_LABEL_MAGIC_SWAPPED);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
ush = ((unsigned short *) (sunlabel + 1)) - 1;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
for (csum = 0; ush >= (unsigned short *)sunlabel;)
|
|
|
|
csum ^= *ush--;
|
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
if (csum) {
|
2006-12-07 00:25:39 +01:00
|
|
|
fprintf(stderr,_("Detected sun disklabel with wrong checksum.\n"
|
2006-12-07 00:25:35 +01:00
|
|
|
"Probably you'll have to set all the values,\n"
|
|
|
|
"e.g. heads, sectors, cylinders and partitions\n"
|
2006-12-07 00:25:39 +01:00
|
|
|
"or force a fresh label (s command in main menu)\n"));
|
2006-12-07 00:25:35 +01:00
|
|
|
} else {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
int need_fixing = 0;
|
|
|
|
|
|
|
|
heads = SSWAP16(sunlabel->nhead);
|
2006-12-07 00:25:35 +01:00
|
|
|
cylinders = SSWAP16(sunlabel->ncyl);
|
|
|
|
sectors = SSWAP16(sunlabel->nsect);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
|
|
|
if (sunlabel->version != SSWAP32(SUN_LABEL_VERSION)) {
|
|
|
|
fprintf(stderr,_("Detected sun disklabel with wrong version [0x%08x].\n"),
|
2010-02-19 16:11:49 +01:00
|
|
|
SSWAP32(sunlabel->version));
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
need_fixing = 1;
|
|
|
|
}
|
|
|
|
if (sunlabel->sanity != SSWAP32(SUN_LABEL_SANE)) {
|
|
|
|
fprintf(stderr,_("Detected sun disklabel with wrong sanity [0x%08x].\n"),
|
2010-02-19 16:11:49 +01:00
|
|
|
SSWAP32(sunlabel->sanity));
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
need_fixing = 1;
|
|
|
|
}
|
|
|
|
if (sunlabel->num_partitions != SSWAP16(SUN_NUM_PARTITIONS)) {
|
|
|
|
fprintf(stderr,_("Detected sun disklabel with wrong num_partitions [%u].\n"),
|
2010-02-19 16:11:49 +01:00
|
|
|
SSWAP16(sunlabel->num_partitions));
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
need_fixing = 1;
|
|
|
|
}
|
|
|
|
if (need_fixing) {
|
|
|
|
fprintf(stderr, _("Warning: Wrong values need to be "
|
|
|
|
"fixed up and will be corrected "
|
|
|
|
"by w(rite)\n"));
|
|
|
|
sunlabel->version = SSWAP32(SUN_LABEL_VERSION);
|
|
|
|
sunlabel->sanity = SSWAP32(SUN_LABEL_SANE);
|
|
|
|
sunlabel->num_partitions = SSWAP16(SUN_NUM_PARTITIONS);
|
|
|
|
|
|
|
|
ush = (unsigned short *)sunlabel;
|
|
|
|
csum = 0;
|
|
|
|
while(ush < (unsigned short *)(&sunlabel->cksum))
|
|
|
|
csum ^= *ush++;
|
|
|
|
sunlabel->cksum = csum;
|
|
|
|
|
|
|
|
set_changed(0);
|
|
|
|
}
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
update_units();
|
2011-07-03 12:01:21 +02:00
|
|
|
disklabel = SUN_LABEL;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
partitions = SUN_NUM_PARTITIONS;
|
2006-12-07 00:25:35 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void create_sunlabel(void)
|
|
|
|
{
|
|
|
|
struct hd_geometry geometry;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
unsigned long long llsectors, llcyls;
|
2010-02-26 16:06:18 +01:00
|
|
|
unsigned int ndiv, sec_fac;
|
|
|
|
int res;
|
2006-12-07 00:25:35 +01:00
|
|
|
|
2006-12-07 00:25:39 +01:00
|
|
|
fprintf(stderr,
|
|
|
|
_("Building a new sun disklabel. Changes will remain in memory only,\n"
|
|
|
|
"until you decide to write them. After that, of course, the previous\n"
|
|
|
|
"content won't be recoverable.\n\n"));
|
2006-12-07 00:25:35 +01:00
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
|
|
other_endian = 1;
|
|
|
|
#else
|
|
|
|
other_endian = 0;
|
|
|
|
#endif
|
2009-10-16 21:49:33 +02:00
|
|
|
zeroize_mbr_buffer();
|
2006-12-07 00:25:35 +01:00
|
|
|
sunlabel->magic = SSWAP16(SUN_LABEL_MAGIC);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sunlabel->sanity = SSWAP32(SUN_LABEL_SANE);
|
|
|
|
sunlabel->version = SSWAP32(SUN_LABEL_VERSION);
|
|
|
|
sunlabel->num_partitions = SSWAP16(SUN_NUM_PARTITIONS);
|
|
|
|
|
2007-11-07 19:05:31 +01:00
|
|
|
res = blkdev_get_sectors(fd, &llsectors);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sec_fac = sector_size / 512;
|
|
|
|
|
2008-07-24 00:46:05 +02:00
|
|
|
#ifdef HDIO_GETGEO
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
|
2006-12-07 00:25:35 +01:00
|
|
|
heads = geometry.heads;
|
|
|
|
sectors = geometry.sectors;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
if (res == 0) {
|
|
|
|
llcyls = llsectors / (heads * sectors * sec_fac);
|
|
|
|
cylinders = llcyls;
|
|
|
|
if (cylinders != llcyls)
|
|
|
|
cylinders = ~0;
|
|
|
|
} else {
|
|
|
|
cylinders = geometry.cylinders;
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Warning: BLKGETSIZE ioctl failed on %s. "
|
|
|
|
"Using geometry cylinder value of %d.\n"
|
|
|
|
"This value may be truncated for devices"
|
|
|
|
" > 33.8 GB.\n"), disk_device, cylinders);
|
|
|
|
}
|
2008-07-24 00:46:05 +02:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
heads = read_int(1,1,1024,0,_("Heads"));
|
|
|
|
sectors = read_int(1,1,1024,0,_("Sectors/track"));
|
|
|
|
cylinders = read_int(1,1,65535,0,_("Cylinders"));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
2006-12-07 00:25:43 +01:00
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sunlabel->acyl = SSWAP16(2);
|
|
|
|
sunlabel->pcyl = SSWAP16(cylinders);
|
|
|
|
sunlabel->ncyl = SSWAP16(cylinders - 2);
|
|
|
|
sunlabel->rpm = SSWAP16(5400);
|
|
|
|
sunlabel->intrlv = SSWAP16(1);
|
|
|
|
sunlabel->apc = SSWAP16(0);
|
2006-12-07 00:25:43 +01:00
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sunlabel->nhead = SSWAP16(heads);
|
2006-12-07 00:25:35 +01:00
|
|
|
sunlabel->nsect = SSWAP16(sectors);
|
|
|
|
sunlabel->ncyl = SSWAP16(cylinders);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
|
|
|
snprintf(sunlabel->label_id, sizeof(sunlabel->label_id),
|
|
|
|
"Linux cyl %d alt %d hd %d sec %llu",
|
|
|
|
cylinders, SSWAP16(sunlabel->acyl), heads, sectors);
|
|
|
|
|
|
|
|
if (cylinders * heads * sectors >= 150 * 2048) {
|
2006-12-07 00:25:35 +01:00
|
|
|
ndiv = cylinders - (50 * 2048 / (heads * sectors)); /* 50M swap */
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
} else
|
2006-12-07 00:25:35 +01:00
|
|
|
ndiv = cylinders * 2 / 3;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
2011-08-17 13:21:12 +02:00
|
|
|
/* Make sure print_partition_size() uses correct sysid names */
|
|
|
|
disklabel = SUN_LABEL;
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
set_sun_partition(0, 0, ndiv * heads * sectors,
|
|
|
|
SUN_TAG_LINUX_NATIVE);
|
|
|
|
set_sun_partition(1, ndiv * heads * sectors,
|
|
|
|
cylinders * heads * sectors,
|
|
|
|
SUN_TAG_LINUX_SWAP);
|
|
|
|
sunlabel->part_tags[1].flag |= SSWAP16(SUN_FLAG_UNMNT);
|
|
|
|
|
|
|
|
set_sun_partition(2, 0, cylinders * heads * sectors, SUN_TAG_BACKUP);
|
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
{
|
|
|
|
unsigned short *ush = (unsigned short *)sunlabel;
|
|
|
|
unsigned short csum = 0;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
while(ush < (unsigned short *)(&sunlabel->cksum))
|
2006-12-07 00:25:35 +01:00
|
|
|
csum ^= *ush++;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sunlabel->cksum = csum;
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
2006-12-07 00:25:43 +01:00
|
|
|
|
|
|
|
set_all_unchanged();
|
2006-12-07 00:25:49 +01:00
|
|
|
get_boot(create_empty_sun);
|
2006-12-07 00:26:28 +01:00
|
|
|
set_changed(0);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 18:27:31 +01:00
|
|
|
void toggle_sunflags(int i, uint16_t mask)
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
{
|
|
|
|
struct sun_tag_flag *p = &sunlabel->part_tags[i];
|
|
|
|
|
|
|
|
p->flag ^= SSWAP16(mask);
|
|
|
|
|
2006-12-07 00:25:43 +01:00
|
|
|
set_changed(i);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 18:27:31 +01:00
|
|
|
static void fetch_sun(uint32_t *starts, uint32_t *lens, uint32_t *start, uint32_t *stop)
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
int i, continuous = 1;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
|
|
|
*start = 0;
|
|
|
|
*stop = cylinders * heads * sectors;
|
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
for (i = 0; i < partitions; i++) {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
struct sun_partition *part = &sunlabel->partitions[i];
|
|
|
|
struct sun_tag_flag *tag = &sunlabel->part_tags[i];
|
|
|
|
|
|
|
|
if (part->num_sectors &&
|
|
|
|
tag->tag != SSWAP16(SUN_TAG_UNASSIGNED) &&
|
|
|
|
tag->tag != SSWAP16(SUN_TAG_BACKUP)) {
|
|
|
|
starts[i] = (SSWAP32(part->start_cylinder) *
|
|
|
|
heads * sectors);
|
|
|
|
lens[i] = SSWAP32(part->num_sectors);
|
2006-12-07 00:25:35 +01:00
|
|
|
if (continuous) {
|
|
|
|
if (starts[i] == *start)
|
|
|
|
*start += lens[i];
|
|
|
|
else if (starts[i] + lens[i] >= *stop)
|
|
|
|
*stop = starts[i];
|
|
|
|
else
|
2006-12-07 00:25:43 +01:00
|
|
|
continuous = 0;
|
|
|
|
/* There will be probably more gaps
|
|
|
|
than one, so lets check afterwards */
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
starts[i] = 0;
|
|
|
|
lens[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-07 00:26:12 +01:00
|
|
|
static unsigned int *verify_sun_starts;
|
2006-12-07 00:25:43 +01:00
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
static int verify_sun_cmp(int *a, int *b)
|
|
|
|
{
|
|
|
|
if (*a == -1)
|
|
|
|
return 1;
|
|
|
|
if (*b == -1)
|
|
|
|
return -1;
|
|
|
|
if (verify_sun_starts[*a] > verify_sun_starts[*b])
|
|
|
|
return 1;
|
2006-12-07 00:25:35 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void verify_sun(void)
|
|
|
|
{
|
2007-10-27 18:27:31 +01:00
|
|
|
uint32_t starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS], start, stop;
|
2011-08-01 15:19:53 +02:00
|
|
|
uint32_t i,j,k,starto,endo;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
int array[SUN_NUM_PARTITIONS];
|
2006-12-07 00:25:35 +01:00
|
|
|
|
|
|
|
verify_sun_starts = starts;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
|
|
|
fetch_sun(starts, lens, &start, &stop);
|
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
for (k = 0; k < 7; k++) {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
for (i = 0; i < SUN_NUM_PARTITIONS; i++) {
|
2006-12-07 00:25:35 +01:00
|
|
|
if (k && (lens[i] % (heads * sectors))) {
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("Partition %d doesn't end on cylinder boundary\n"), i+1);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
if (lens[i]) {
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
if (lens[j]) {
|
|
|
|
if (starts[j] == starts[i]+lens[i]) {
|
|
|
|
starts[j] = starts[i]; lens[j] += lens[i];
|
|
|
|
lens[i] = 0;
|
|
|
|
} else if (starts[i] == starts[j]+lens[j]){
|
|
|
|
lens[j] += lens[i];
|
|
|
|
lens[i] = 0;
|
|
|
|
} else if (!k) {
|
|
|
|
if (starts[i] < starts[j]+lens[j] &&
|
|
|
|
starts[j] < starts[i]+lens[i]) {
|
|
|
|
starto = starts[i];
|
|
|
|
if (starts[j] > starto)
|
|
|
|
starto = starts[j];
|
|
|
|
endo = starts[i]+lens[i];
|
|
|
|
if (starts[j]+lens[j] < endo)
|
|
|
|
endo = starts[j]+lens[j];
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("Partition %d overlaps with others in "
|
|
|
|
"sectors %d-%d\n"), i+1, starto, endo);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
for (i = 0; i < SUN_NUM_PARTITIONS; i++) {
|
2006-12-07 00:25:35 +01:00
|
|
|
if (lens[i])
|
|
|
|
array[i] = i;
|
|
|
|
else
|
|
|
|
array[i] = -1;
|
|
|
|
}
|
2009-10-16 01:26:46 +02:00
|
|
|
qsort(array,ARRAY_SIZE(array),sizeof(array[0]),
|
2006-12-07 00:25:35 +01:00
|
|
|
(int (*)(const void *,const void *)) verify_sun_cmp);
|
|
|
|
if (array[0] == -1) {
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("No partitions defined\n"));
|
2006-12-07 00:25:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
stop = cylinders * heads * sectors;
|
|
|
|
if (starts[array[0]])
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
printf(_("Unused gap - sectors 0-%d\n"), starts[array[0]]);
|
2006-12-07 00:25:35 +01:00
|
|
|
for (i = 0; i < 7 && array[i+1] != -1; i++) {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
printf(_("Unused gap - sectors %d-%d\n"),
|
|
|
|
(starts[array[i]] + lens[array[i]]),
|
|
|
|
starts[array[i+1]]);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
start = (starts[array[i]] + lens[array[i]]);
|
2006-12-07 00:25:35 +01:00
|
|
|
if (start < stop)
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
printf(_("Unused gap - sectors %d-%d\n"), start, stop);
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void add_sun_partition(int n, int sys)
|
|
|
|
{
|
2007-10-27 18:27:31 +01:00
|
|
|
uint32_t starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS];
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
struct sun_partition *part = &sunlabel->partitions[n];
|
|
|
|
struct sun_tag_flag *tag = &sunlabel->part_tags[n];
|
2007-10-27 18:27:31 +01:00
|
|
|
uint32_t start, stop, stop2;
|
2006-12-07 00:25:35 +01:00
|
|
|
int whole_disk = 0;
|
|
|
|
|
2006-12-07 00:25:41 +01:00
|
|
|
char mesg[256];
|
2011-08-01 15:19:53 +02:00
|
|
|
int i;
|
|
|
|
unsigned int first, last;
|
2006-12-07 00:25:35 +01:00
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
if (part->num_sectors && tag->tag != SSWAP16(SUN_TAG_UNASSIGNED)) {
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("Partition %d is already defined. Delete "
|
|
|
|
"it before re-adding it.\n"), n + 1);
|
2006-12-07 00:25:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
fetch_sun(starts, lens, &start, &stop);
|
2006-12-07 00:25:35 +01:00
|
|
|
if (stop <= start) {
|
|
|
|
if (n == 2)
|
|
|
|
whole_disk = 1;
|
|
|
|
else {
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("Other partitions already cover the whole disk.\nDelete "
|
|
|
|
"some/shrink them before retry.\n"));
|
2006-12-07 00:25:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-12-07 00:25:46 +01:00
|
|
|
snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR));
|
2006-12-07 00:25:35 +01:00
|
|
|
for (;;) {
|
|
|
|
if (whole_disk)
|
2006-12-07 00:25:37 +01:00
|
|
|
first = read_int(0, 0, 0, 0, mesg);
|
2006-12-07 00:25:35 +01:00
|
|
|
else
|
2006-12-07 00:25:37 +01:00
|
|
|
first = read_int(scround(start), scround(stop)+1,
|
|
|
|
scround(stop), 0, mesg);
|
2006-12-07 00:25:39 +01:00
|
|
|
if (display_in_cyl_units)
|
|
|
|
first *= units_per_sector;
|
2006-12-07 00:26:33 +01:00
|
|
|
else {
|
2006-12-07 00:25:37 +01:00
|
|
|
/* Starting sector has to be properly aligned */
|
2006-12-07 00:26:33 +01:00
|
|
|
int cs = heads * sectors;
|
|
|
|
int x = first % cs;
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
first += cs - x;
|
|
|
|
}
|
2006-12-07 00:25:37 +01:00
|
|
|
if (n == 2 && first != 0)
|
2008-10-03 08:52:35 +02:00
|
|
|
printf (_("\
|
2006-12-07 00:25:37 +01:00
|
|
|
It is highly recommended that the third partition covers the whole disk\n\
|
2008-10-03 08:52:35 +02:00
|
|
|
and is of type `Whole disk'\n"));
|
2006-12-07 00:25:48 +01:00
|
|
|
/* ewt asks to add: "don't start a partition at cyl 0"
|
|
|
|
However, edmundo@rano.demon.co.uk writes:
|
|
|
|
"In addition to having a Sun partition table, to be able to
|
|
|
|
boot from the disc, the first partition, /dev/sdX1, must
|
|
|
|
start at cylinder 0. This means that /dev/sdX1 contains
|
|
|
|
the partition table and the boot block, as these are the
|
|
|
|
first two sectors of the disc. Therefore you must be
|
|
|
|
careful what you use /dev/sdX1 for. In particular, you must
|
|
|
|
not use a partition starting at cylinder 0 for Linux swap,
|
|
|
|
as that would overwrite the partition table and the boot
|
|
|
|
block. You may, however, use such a partition for a UFS
|
|
|
|
or EXT2 file system, as these file systems leave the first
|
|
|
|
1024 bytes undisturbed. */
|
|
|
|
/* On the other hand, one should not use partitions
|
|
|
|
starting at block 0 in an md, or the label will
|
|
|
|
be trashed. */
|
2006-12-07 00:25:35 +01:00
|
|
|
for (i = 0; i < partitions; i++)
|
2006-12-07 00:25:37 +01:00
|
|
|
if (lens[i] && starts[i] <= first
|
|
|
|
&& starts[i] + lens[i] > first)
|
2006-12-07 00:25:35 +01:00
|
|
|
break;
|
|
|
|
if (i < partitions && !whole_disk) {
|
|
|
|
if (n == 2 && !first) {
|
|
|
|
whole_disk = 1;
|
|
|
|
break;
|
|
|
|
}
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("Sector %d is already allocated\n"), first);
|
2006-12-07 00:25:35 +01:00
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
2006-12-07 00:26:33 +01:00
|
|
|
stop = cylinders * heads * sectors; /* ancient */
|
2006-12-07 00:25:35 +01:00
|
|
|
stop2 = stop;
|
|
|
|
for (i = 0; i < partitions; i++) {
|
|
|
|
if (starts[i] > first && starts[i] < stop)
|
|
|
|
stop = starts[i];
|
|
|
|
}
|
2006-12-07 00:25:46 +01:00
|
|
|
snprintf(mesg, sizeof(mesg),
|
|
|
|
_("Last %s or +size or +sizeM or +sizeK"),
|
|
|
|
str_units(SINGULAR));
|
2006-12-07 00:25:35 +01:00
|
|
|
if (whole_disk)
|
2006-12-07 00:25:37 +01:00
|
|
|
last = read_int(scround(stop2), scround(stop2), scround(stop2),
|
|
|
|
0, mesg);
|
2006-12-07 00:25:35 +01:00
|
|
|
else if (n == 2 && !first)
|
|
|
|
last = read_int(scround(first), scround(stop2), scround(stop2),
|
2006-12-07 00:25:37 +01:00
|
|
|
scround(first), mesg);
|
2006-12-07 00:25:35 +01:00
|
|
|
else
|
|
|
|
last = read_int(scround(first), scround(stop), scround(stop),
|
2006-12-07 00:25:37 +01:00
|
|
|
scround(first), mesg);
|
2006-12-07 00:25:39 +01:00
|
|
|
if (display_in_cyl_units)
|
|
|
|
last *= units_per_sector;
|
2006-12-07 00:25:35 +01:00
|
|
|
if (n == 2 && !first) {
|
|
|
|
if (last >= stop2) {
|
|
|
|
whole_disk = 1;
|
|
|
|
last = stop2;
|
|
|
|
} else if (last > stop) {
|
2006-12-07 00:25:39 +01:00
|
|
|
printf (
|
|
|
|
_("You haven't covered the whole disk with the 3rd partition, but your value\n"
|
|
|
|
"%d %s covers some other partition. Your entry has been changed\n"
|
|
|
|
"to %d %s\n"),
|
|
|
|
scround(last), str_units(SINGULAR),
|
|
|
|
scround(stop), str_units(SINGULAR));
|
2006-12-07 00:25:35 +01:00
|
|
|
last = stop;
|
|
|
|
}
|
|
|
|
} else if (!whole_disk && last > stop)
|
|
|
|
last = stop;
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
if (whole_disk)
|
|
|
|
sys = SUN_TAG_BACKUP;
|
|
|
|
|
2006-12-07 00:25:35 +01:00
|
|
|
set_sun_partition(n, first, last, sys);
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_delete_partition(int i)
|
|
|
|
{
|
|
|
|
struct sun_partition *part = &sunlabel->partitions[i];
|
|
|
|
struct sun_tag_flag *tag = &sunlabel->part_tags[i];
|
2006-12-07 00:26:12 +01:00
|
|
|
unsigned int nsec;
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
if (i == 2 &&
|
|
|
|
tag->tag == SSWAP16(SUN_TAG_BACKUP) &&
|
|
|
|
!part->start_cylinder &&
|
|
|
|
(nsec = SSWAP32(part->num_sectors))
|
2006-12-07 00:25:37 +01:00
|
|
|
== heads * sectors * cylinders)
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("If you want to maintain SunOS/Solaris compatibility, "
|
2006-12-07 00:25:37 +01:00
|
|
|
"consider leaving this\n"
|
|
|
|
"partition as Whole disk (5), starting at 0, with %u "
|
2006-12-07 00:26:12 +01:00
|
|
|
"sectors\n"), nsec);
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
tag->tag = SSWAP16(SUN_TAG_UNASSIGNED);
|
|
|
|
part->num_sectors = 0;
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 18:27:31 +01:00
|
|
|
int sun_change_sysid(int i, uint16_t sys)
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
{
|
|
|
|
struct sun_partition *part = &sunlabel->partitions[i];
|
|
|
|
struct sun_tag_flag *tag = &sunlabel->part_tags[i];
|
|
|
|
|
|
|
|
if (sys == SUN_TAG_LINUX_SWAP && !part->start_cylinder) {
|
2006-12-07 00:25:35 +01:00
|
|
|
read_chars(
|
2006-12-07 00:25:39 +01:00
|
|
|
_("It is highly recommended that the partition at offset 0\n"
|
2006-12-07 00:25:35 +01:00
|
|
|
"is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n"
|
|
|
|
"there may destroy your partition table and bootblock.\n"
|
|
|
|
"Type YES if you're very sure you would like that partition\n"
|
2006-12-07 00:25:39 +01:00
|
|
|
"tagged with 82 (Linux swap): "));
|
2006-12-07 00:25:49 +01:00
|
|
|
if (strcmp (line_ptr, _("YES\n")))
|
2007-07-14 13:32:37 -04:00
|
|
|
return 0;
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
switch (sys) {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
case SUN_TAG_SWAP:
|
|
|
|
case SUN_TAG_LINUX_SWAP:
|
2006-12-07 00:25:35 +01:00
|
|
|
/* swaps are not mountable by default */
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
tag->flag |= SSWAP16(SUN_FLAG_UNMNT);
|
2006-12-07 00:25:35 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* assume other types are mountable;
|
|
|
|
user can change it anyway */
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
tag->flag &= ~SSWAP16(SUN_FLAG_UNMNT);
|
2006-12-07 00:25:35 +01:00
|
|
|
break;
|
|
|
|
}
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
tag->tag = SSWAP16(sys);
|
2007-07-14 13:32:37 -04:00
|
|
|
return 1;
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_list_table(int xtra)
|
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
int i, w;
|
|
|
|
char *type;
|
|
|
|
|
|
|
|
w = strlen(disk_device);
|
|
|
|
if (xtra)
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(
|
2010-02-26 16:06:18 +01:00
|
|
|
_("\nDisk %s (Sun disk label): %u heads, %llu sectors, %d rpm\n"
|
|
|
|
"%u cylinders, %d alternate cylinders, %d physical cylinders\n"
|
2006-12-07 00:25:39 +01:00
|
|
|
"%d extra sects/cyl, interleave %d:1\n"
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
"Label ID: %s\n"
|
|
|
|
"Volume ID: %s\n"
|
2006-12-07 00:25:39 +01:00
|
|
|
"Units = %s of %d * 512 bytes\n\n"),
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
disk_device, heads, sectors, SSWAP16(sunlabel->rpm),
|
|
|
|
cylinders, SSWAP16(sunlabel->acyl),
|
|
|
|
SSWAP16(sunlabel->pcyl),
|
|
|
|
SSWAP16(sunlabel->apc),
|
|
|
|
SSWAP16(sunlabel->intrlv),
|
|
|
|
sunlabel->label_id,
|
|
|
|
sunlabel->volume_id,
|
2006-12-07 00:25:39 +01:00
|
|
|
str_units(PLURAL), units_per_sector);
|
2006-12-07 00:25:35 +01:00
|
|
|
else
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(
|
2010-02-26 16:06:18 +01:00
|
|
|
_("\nDisk %s (Sun disk label): %u heads, %llu sectors, %u cylinders\n"
|
2006-12-07 00:25:39 +01:00
|
|
|
"Units = %s of %d * 512 bytes\n\n"),
|
2006-12-07 00:25:35 +01:00
|
|
|
disk_device, heads, sectors, cylinders,
|
2006-12-07 00:25:39 +01:00
|
|
|
str_units(PLURAL), units_per_sector);
|
2006-12-07 00:25:35 +01:00
|
|
|
|
2006-12-07 00:25:39 +01:00
|
|
|
printf(_("%*s Flag Start End Blocks Id System\n"),
|
|
|
|
w + 1, _("Device"));
|
2006-12-07 00:25:35 +01:00
|
|
|
for (i = 0 ; i < partitions; i++) {
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
struct sun_partition *part = &sunlabel->partitions[i];
|
|
|
|
struct sun_tag_flag *tag = &sunlabel->part_tags[i];
|
|
|
|
|
|
|
|
if (part->num_sectors) {
|
2007-10-27 18:27:31 +01:00
|
|
|
uint32_t start = SSWAP32(part->start_cylinder) * heads * sectors;
|
|
|
|
uint32_t len = SSWAP32(part->num_sectors);
|
2006-12-07 00:25:35 +01:00
|
|
|
printf(
|
2010-02-26 16:06:18 +01:00
|
|
|
"%s %c%c %9lu %9lu %9lu%c %2x %s\n",
|
2006-12-07 00:25:58 +01:00
|
|
|
/* device */ partname(disk_device, i+1, w),
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
/* flags */ (tag->flag & SSWAP16(SUN_FLAG_UNMNT)) ? 'u' : ' ',
|
|
|
|
(tag->flag & SSWAP16(SUN_FLAG_RONLY)) ? 'r' : ' ',
|
2010-02-26 16:06:18 +01:00
|
|
|
/* start */ (unsigned long) scround(start),
|
|
|
|
/* end */ (unsigned long) scround(start+len),
|
|
|
|
/* odd flag on end */ (unsigned long) len / 2, len & 1 ? '+' : ' ',
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
/* type id */ SSWAP16(tag->tag),
|
|
|
|
/* type name */ (type = partition_type(SSWAP16(tag->tag)))
|
2006-12-07 00:25:39 +01:00
|
|
|
? type : _("Unknown"));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_alt_cyl(void)
|
|
|
|
{
|
|
|
|
sunlabel->acyl =
|
|
|
|
SSWAP16(read_int(0,SSWAP16(sunlabel->acyl), 65535, 0,
|
2006-12-07 00:25:39 +01:00
|
|
|
_("Number of alternate cylinders")));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_ncyl(int cyl)
|
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
sunlabel->ncyl = SSWAP16(cyl);
|
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_xcyl(void)
|
|
|
|
{
|
|
|
|
sunlabel->apc =
|
|
|
|
SSWAP16(read_int(0, SSWAP16(sunlabel->apc), sectors, 0,
|
2006-12-07 00:25:39 +01:00
|
|
|
_("Extra sectors per cylinder")));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_ilfact(void)
|
|
|
|
{
|
|
|
|
sunlabel->intrlv =
|
|
|
|
SSWAP16(read_int(1, SSWAP16(sunlabel->intrlv), 32, 0,
|
2006-12-07 00:25:39 +01:00
|
|
|
_("Interleave factor")));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_rspeed(void)
|
|
|
|
{
|
|
|
|
sunlabel->rpm =
|
|
|
|
SSWAP16(read_int(1, SSWAP16(sunlabel->rpm), 100000, 0,
|
2006-12-07 00:25:39 +01:00
|
|
|
_("Rotation speed (rpm)")));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_set_pcylcount(void)
|
|
|
|
{
|
|
|
|
sunlabel->pcyl =
|
|
|
|
SSWAP16(read_int(0, SSWAP16(sunlabel->pcyl), 65535, 0,
|
2006-12-07 00:25:39 +01:00
|
|
|
_("Number of physical cylinders")));
|
2006-12-07 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
void sun_write_table(void)
|
|
|
|
{
|
2006-12-07 00:25:35 +01:00
|
|
|
unsigned short *ush = (unsigned short *)sunlabel;
|
|
|
|
unsigned short csum = 0;
|
|
|
|
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
while(ush < (unsigned short *)(&sunlabel->cksum))
|
2006-12-07 00:25:35 +01:00
|
|
|
csum ^= *ush++;
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
sunlabel->cksum = csum;
|
2006-12-07 00:25:35 +01:00
|
|
|
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
|
|
fatal(unable_to_seek);
|
|
|
|
if (write(fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE)
|
|
|
|
fatal(unable_to_write);
|
|
|
|
}
|
fdisk: many significant improvements and fixes to Sun label handling
1) Properly describe the exact layout and fields of the sun disk
label. Several fields were incorrectly mentioned and others
wrongly sized.
2) Properly set the version, sane, and num_partitions fields.
Because we weren't doing this, programs such as Solaris's format
and the Solaris kernel itself refused to recognize our disk labels
as valid.
3) Move SSWAP*() macros into fdisksunlabel.c as there is no reason
for them to be exposed to the rest of fdisk.
4) Kill the sun_predefined_drives array hack and assosciated code.
Instead size the disk and figure out the geometry properly just
like the SGI and MSDOS partition handling do, by means of the
HD_GETGEO ioctl() and disksize().
5) If the disk label read is found to not have the proper values
set in version, sane, or num_partitions, fix them, recompute the
label checksum, dirty the disk label, and let the user know what
we did and that the fixed values will be written out if they 'w'.
This gives users an easy way to fix up disk labels created by
disk labelling programs which had this bug.
6) Create a sun_sys_getid() function so that fdisk.c does not need
to reference the sun disk label details directly, just like the
SGI code does.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-06-29 15:50:21 -07:00
|
|
|
|
|
|
|
int sun_get_sysid(int i)
|
|
|
|
{
|
|
|
|
return SSWAP16(sunlabel->part_tags[i].tag);
|
|
|
|
}
|