[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] split fdisk.c 2/3
From: Denis Vlasenko <vda () ilport ! com ! ua>
Date: 2006-02-27 14:51:58
Message-ID: 200602271651.58799.vda () ilport ! com ! ua
[Download RAW message or body]
On Monday 27 February 2006 16:51, Denis Vlasenko wrote:
> On Monday 27 February 2006 16:50, Denis Vlasenko wrote:
> > On Monday 27 February 2006 16:49, Denis Vlasenko wrote:
> > > Please apply or comment.
> > > Patches will be sent in separate mails.
["fdisk_split3.patch" (text/x-diff)]
diff -urpN busybox.fdisk3/util-linux/Makefile busybox.fdisk4/util-linux/Makefile
--- busybox.fdisk3/util-linux/Makefile Thu Feb 9 11:43:16 2006
+++ busybox.fdisk4/util-linux/Makefile Mon Feb 27 16:34:58 2006
@@ -14,5 +14,7 @@ include Makefile.in
all: $(libraries-y)
-include $(top_builddir)/.depend
+fdisk.c: fdisk_aix.c fdisk_osf.c fdisk_sgi.c fdisk_sun.c
+
clean:
rm -f *.o *.a $(AR_TARGET)
diff -urpN busybox.fdisk3/util-linux/fdisk.c busybox.fdisk4/util-linux/fdisk.c
--- busybox.fdisk3/util-linux/fdisk.c Mon Feb 27 16:12:21 2006
+++ busybox.fdisk4/util-linux/fdisk.c Mon Feb 27 16:32:33 2006
@@ -72,9 +72,6 @@
#define LINUX_LVM 0x8e
#define LINUX_RAID 0xfd
-#define SUNOS_SWAP 3
-#define WHOLE_DISK 5
-
#define IS_EXTENDED(i) \
((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED)
@@ -399,8 +396,22 @@ __swap32(uint32_t x)
#include "fdisk_aix.c"
static void bselect(void);
+static void xbsd_print_disklabel(int);
#include "fdisk_osf.c"
+#define SGI_VOLHDR 0x00
+/* 1 and 2 were used for drive types no longer supported by SGI */
+#define SGI_SWAP 0x03
+/* 4 and 5 were for filesystem types SGI haven't ever supported on MIPS CPUs */
+#define SGI_VOLUME 0x06
+#define SGI_EFS 0x07
+#define SGI_LVOL 0x08
+#define SGI_RLVOL 0x09
+#define SGI_XFS 0x0a
+#define SGI_XFSLOG 0x0b
+#define SGI_XLV 0x0c
+#define SGI_XVM 0x0d
+#define SGI_ENTIRE_DISK SGI_VOLUME
static const struct systypes sgi_sys_types[];
static unsigned int sgi_get_num_sectors(int i);
static int sgi_get_sysid(int i);
@@ -414,8 +425,40 @@ static void sgi_set_swappartition(int i)
static const char *sgi_get_bootfile(void);
static void sgi_set_bootfile(const char* aFile);
static void create_sgiinfo(void);
+static void sgi_write_table(void);
+static void sgi_set_bootpartition(int i);
#include "fdisk_sgi.c"
+typedef struct {
+ unsigned char info[128]; /* Informative text string */
+ unsigned char spare0[14];
+ struct sun_info {
+ unsigned char spare1;
+ unsigned char id;
+ unsigned char spare2;
+ unsigned char flags;
+ } infos[8];
+ unsigned char spare1[246]; /* Boot information etc. */
+ unsigned short rspeed; /* Disk rotational speed */
+ unsigned short pcylcount; /* Physical cylinder count */
+ unsigned short sparecyl; /* extra sects per cylinder */
+ unsigned char spare2[4]; /* More magic... */
+ unsigned short ilfact; /* Interleave factor */
+ unsigned short ncyl; /* Data cylinder count */
+ unsigned short nacyl; /* Alt. cylinder count */
+ unsigned short ntrks; /* Tracks per cylinder */
+ unsigned short nsect; /* Sectors per track */
+ unsigned char spare3[4]; /* Even more magic... */
+ struct sun_partinfo {
+ uint32_t start_cylinder;
+ uint32_t num_sectors;
+ } partitions[8];
+ unsigned short magic; /* Magic number */
+ unsigned short csum; /* Label xor'd checksum */
+} sun_partition;
+#define sunlabel ((sun_partition *)MBRbuffer)
+#define SUNOS_SWAP 3
+#define SUN_WHOLE_DISK 5
static const struct systypes sun_sys_types[];
static void sun_delete_partition(int i);
static void sun_change_sysid(int i, int sys);
@@ -429,6 +472,8 @@ static void sun_set_ilfact(void);
static void sun_set_rspeed(void);
static void sun_set_pcylcount(void);
static void toggle_sunflags(int i, unsigned char mask);
+static void verify_sun(void);
+static void sun_write_table(void);
#include "fdisk_sun.c"
/* DOS partition types */
@@ -1752,14 +1797,14 @@ change_sysid(void)
}
if (sys < 256) {
- if (LABEL_IS_SUN && i == 2 && sys != WHOLE_DISK)
+ if (LABEL_IS_SUN && i == 2 && sys != SUN_WHOLE_DISK)
printf(_("Consider leaving partition 3 "
"as Whole disk (5),\n"
"as SunOS/Solaris expects it and "
"even Linux likes it.\n\n"));
if (LABEL_IS_SGI &&
(
- (i == 10 && sys != ENTIRE_DISK) ||
+ (i == 10 && sys != SGI_ENTIRE_DISK) ||
(i == 8 && sys != 0)
)
){
diff -urpN busybox.fdisk3/util-linux/fdisk_osf.c busybox.fdisk4/util-linux/fdisk_osf.c
--- busybox.fdisk3/util-linux/fdisk_osf.c Mon Feb 27 16:00:56 2006
+++ busybox.fdisk4/util-linux/fdisk_osf.c Mon Feb 27 16:32:18 2006
@@ -299,8 +299,6 @@ check_osf_label(void)
return 1;
}
-static void xbsd_print_disklabel(int);
-
static int
btrydev(const char * dev)
{
diff -urpN busybox.fdisk3/util-linux/fdisk_sgi.c busybox.fdisk4/util-linux/fdisk_sgi.c
--- busybox.fdisk3/util-linux/fdisk_sgi.c Mon Feb 27 15:59:58 2006
+++ busybox.fdisk4/util-linux/fdisk_sgi.c Mon Feb 27 16:26:32 2006
@@ -32,19 +32,6 @@ struct device_parameter { /* 48 bytes */
unsigned short xylogics_writecont;
};
-#define SGI_VOLHDR 0x00
-/* 1 and 2 were used for drive types no longer supported by SGI */
-#define SGI_SWAP 0x03
-/* 4 and 5 were for filesystem types SGI haven't ever supported on MIPS CPUs */
-#define SGI_VOLUME 0x06
-#define SGI_EFS 0x07
-#define SGI_LVOL 0x08
-#define SGI_RLVOL 0x09
-#define SGI_XFS 0x0a
-#define SGI_XFSLOG 0x0b
-#define SGI_XLV 0x0c
-#define SGI_XVM 0x0d
-#define ENTIRE_DISK SGI_VOLUME
/*
* controller flags
*/
@@ -181,7 +168,7 @@ static const struct systypes sgi_sys_typ
/* SGI_SWAP */ { "\x03" "SGI raw" },
/* 0x04 */ { "\x04" "SGI bsd" },
/* 0x05 */ { "\x05" "SGI sysv" },
-/* ENTIRE_DISK */ { "\x06" "SGI volume" },
+/* SGI_ENTIRE_DISK */ { "\x06" "SGI volume" },
/* SGI_EFS */ { "\x07" "SGI efs" },
/* 0x08 */ { "\x08" "SGI lvol" },
/* 0x09 */ { "\x09" "SGI rlvol" },
@@ -496,7 +483,7 @@ verify_sgi(int verbose)
for (i = 0; i < 16; i++) {
if (sgi_get_num_sectors(i) != 0) {
Index[sortcount++] = i;
- if (sgi_get_sysid(i) == ENTIRE_DISK) {
+ if (sgi_get_sysid(i) == SGI_ENTIRE_DISK) {
if (entire++ == 1) {
if (verbose)
printf(_("More than one entire disk entry present.\n"));
@@ -510,7 +497,7 @@ verify_sgi(int verbose)
return (lastblock > 0) ? 1 : (lastblock == 0) ? 0 : -1;
}
qsort(Index, sortcount, sizeof(Index[0]), (void*)compare_start);
- if (sgi_get_sysid(Index[0]) == ENTIRE_DISK) {
+ if (sgi_get_sysid(Index[0]) == SGI_ENTIRE_DISK) {
if ((Index[0] != 10) && verbose)
printf(_("IRIX likes when Partition 11 covers the entire disk.\n"));
if ((sgi_get_start_sector(Index[0]) != 0) && verbose)
@@ -547,7 +534,7 @@ verify_sgi(int verbose)
Index[i]+1);
}
/* We cannot handle several "entire disk" entries. */
- if (sgi_get_sysid(Index[i]) == ENTIRE_DISK) continue;
+ if (sgi_get_sysid(Index[i]) == SGI_ENTIRE_DISK) continue;
if (start > sgi_get_start_sector(Index[i])) {
if (verbose)
printf(_("The Partition %d and %d overlap by %d sectors.\n"),
@@ -621,7 +608,7 @@ sgi_change_sysid(int i, int sys)
printf(_("Sorry You may change the Tag of non-empty partitions.\n"));
return;
}
- if (((sys != ENTIRE_DISK ) && (sys != SGI_VOLHDR))
+ if (((sys != SGI_ENTIRE_DISK) && (sys != SGI_VOLHDR))
&& (sgi_get_start_sector(i) < 1) ) {
read_chars(
_("It is highly recommended that the partition at offset 0\n"
diff -urpN busybox.fdisk3/util-linux/fdisk_sun.c busybox.fdisk4/util-linux/fdisk_sun.c
--- busybox.fdisk3/util-linux/fdisk_sun.c Mon Feb 27 15:59:10 2006
+++ busybox.fdisk4/util-linux/fdisk_sun.c Mon Feb 27 16:29:21 2006
@@ -1,36 +1,7 @@
#ifdef CONFIG_FEATURE_SUN_LABEL
-typedef struct {
- unsigned char info[128]; /* Informative text string */
- unsigned char spare0[14];
- struct sun_info {
- unsigned char spare1;
- unsigned char id;
- unsigned char spare2;
- unsigned char flags;
- } infos[8];
- unsigned char spare1[246]; /* Boot information etc. */
- unsigned short rspeed; /* Disk rotational speed */
- unsigned short pcylcount; /* Physical cylinder count */
- unsigned short sparecyl; /* extra sects per cylinder */
- unsigned char spare2[4]; /* More magic... */
- unsigned short ilfact; /* Interleave factor */
- unsigned short ncyl; /* Data cylinder count */
- unsigned short nacyl; /* Alt. cylinder count */
- unsigned short ntrks; /* Tracks per cylinder */
- unsigned short nsect; /* Sectors per track */
- unsigned char spare3[4]; /* Even more magic... */
- struct sun_partinfo {
- uint32_t start_cylinder;
- uint32_t num_sectors;
- } partitions[8];
- unsigned short magic; /* Magic number */
- unsigned short csum; /* Label xor'd checksum */
-} sun_partition;
-
#define SUN_LABEL_MAGIC 0xDABE
#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
-#define sunlabel ((sun_partition *)MBRbuffer)
#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) \
: (uint16_t)(x))
#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) \
@@ -89,7 +60,7 @@ static const struct systypes sun_sys_typ
{ "\x02" "SunOS root" }, /* 2 */
{ "\x03" "SunOS swap" }, /* SUNOS_SWAP */
{ "\x04" "SunOS usr" }, /* 4 */
- { "\x05" "Whole disk" }, /* WHOLE_DISK */
+ { "\x05" "Whole disk" }, /* SUN_WHOLE_DISK */
{ "\x06" "SunOS stand" }, /* 6 */
{ "\x07" "SunOS var" }, /* 7 */
{ "\x08" "SunOS home" }, /* 8 */
@@ -361,7 +332,7 @@ create_sunlabel(void)
set_sun_partition(1, ndiv * heads * sectors, cylinders * heads * sectors, LINUX_SWAP);
sunlabel->infos[1].flags |= 0x01; /* Not mountable */
}
- set_sun_partition(2, 0, cylinders * heads * sectors, WHOLE_DISK);
+ set_sun_partition(2, 0, cylinders * heads * sectors, SUN_WHOLE_DISK);
{
unsigned short *ush = (unsigned short *)sunlabel;
unsigned short csum = 0;
@@ -395,7 +366,7 @@ fetch_sun(uint *starts, uint *lens, uint
for (i = 0; i < partitions; i++) {
if (sunlabel->partitions[i].num_sectors
&& sunlabel->infos[i].id
- && sunlabel->infos[i].id != WHOLE_DISK) {
+ && sunlabel->infos[i].id != SUN_WHOLE_DISK) {
starts[i] = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors;
lens[i] = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
if (continuous) {
@@ -597,7 +568,7 @@ and is of type `Whole disk'\n");
last = stop;
if (whole_disk)
- sys = WHOLE_DISK;
+ sys = SUN_WHOLE_DISK;
set_sun_partition(n, first, last, sys);
}
@@ -607,7 +578,7 @@ sun_delete_partition(int i)
unsigned int nsec;
if (i == 2
- && sunlabel->infos[i].id == WHOLE_DISK
+ && sunlabel->infos[i].id == SUN_WHOLE_DISK
&& !sunlabel->partitions[i].start_cylinder
&& (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) == heads * sectors * cylinders)
printf(_("If you want to maintain SunOS/Solaris compatibility, "
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic