sfdisk: fix coding style.
The style in the file is really horrible and unreadable. This patch uses: indent -linux -i4 -psl -brf sfdisk.c to fix the style. The ideal solution is to call the indent with only -linux option, but it's too invasive... Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
fa41c8b530
commit
37b94458bd
342
fdisk/sfdisk.c
342
fdisk/sfdisk.c
|
@ -489,10 +489,11 @@ get_cylindersize(char *dev, int fd, int silent) {
|
|||
B.cylinders = B.total_size / B.cylindersize;
|
||||
|
||||
if (R.start && !force) {
|
||||
my_warn(
|
||||
_("Warning: start=%lu - this looks like a partition rather than\n"
|
||||
my_warn(_
|
||||
("Warning: start=%lu - this looks like a partition rather than\n"
|
||||
"the entire disk. Using fdisk on it is probably meaningless.\n"
|
||||
"[Use the --force option if you really want this]\n"), R.start);
|
||||
"[Use the --force option if you really want this]\n"),
|
||||
R.start);
|
||||
exit(1);
|
||||
}
|
||||
#if 0
|
||||
|
@ -504,12 +505,14 @@ get_cylindersize(char *dev, int fd, int silent) {
|
|||
R.sectors);
|
||||
if (R.cylinders && B.cylinders != R.cylinders
|
||||
&& B.cylinders < 65536 && R.cylinders < 65536)
|
||||
my_warn(_("Warning: BLKGETSIZE/HDIO_GETGEO says that there are %lu cylinders\n"),
|
||||
my_warn(_
|
||||
("Warning: BLKGETSIZE/HDIO_GETGEO says that there are %lu cylinders\n"),
|
||||
R.cylinders);
|
||||
#endif
|
||||
|
||||
if (B.sectors > 63)
|
||||
my_warn(_("Warning: unlikely number of sectors (%lu) - usually at most 63\n"
|
||||
my_warn(_
|
||||
("Warning: unlikely number of sectors (%lu) - usually at most 63\n"
|
||||
"This will give problems with all software that uses C/H/S addressing.\n"),
|
||||
B.sectors);
|
||||
if (!silent)
|
||||
|
@ -517,10 +520,14 @@ get_cylindersize(char *dev, int fd, int silent) {
|
|||
dev, B.cylinders, B.heads, B.sectors);
|
||||
}
|
||||
|
||||
typedef struct { unsigned char h,s,c; } PACKED chs; /* has some c bits in s */
|
||||
typedef struct {
|
||||
unsigned char h, s, c;
|
||||
} PACKED chs; /* has some c bits in s */
|
||||
chs zero_chs = { 0, 0, 0 };
|
||||
|
||||
typedef struct { unsigned long h,s,c; } longchs;
|
||||
typedef struct {
|
||||
unsigned long h, s, c;
|
||||
} longchs;
|
||||
longchs zero_longchs;
|
||||
|
||||
static chs
|
||||
|
@ -653,8 +660,7 @@ list_types(void) {
|
|||
static int
|
||||
is_extended(unsigned char type) {
|
||||
return (type == EXTENDED_PARTITION
|
||||
|| type == LINUX_EXTENDED
|
||||
|| type == WIN98_EXTENDED);
|
||||
|| type == LINUX_EXTENDED || type == WIN98_EXTENDED);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -692,9 +698,12 @@ copy_to_int(unsigned char *cp) {
|
|||
|
||||
static void
|
||||
copy_from_int(int m, char *cp) {
|
||||
*cp++ = (m & 0xff); m >>= 8;
|
||||
*cp++ = (m & 0xff); m >>= 8;
|
||||
*cp++ = (m & 0xff); m >>= 8;
|
||||
*cp++ = (m & 0xff);
|
||||
m >>= 8;
|
||||
*cp++ = (m & 0xff);
|
||||
m >>= 8;
|
||||
*cp++ = (m & 0xff);
|
||||
m >>= 8;
|
||||
*cp++ = (m & 0xff);
|
||||
}
|
||||
|
||||
|
@ -887,10 +896,18 @@ set_format(char c) {
|
|||
switch (c) {
|
||||
default:
|
||||
do_warn(_("unrecognized format - using sectors\n"));
|
||||
case 'S': specified_format = F_SECTOR; break;
|
||||
case 'B': specified_format = F_BLOCK; break;
|
||||
case 'C': specified_format = F_CYLINDER; break;
|
||||
case 'M': specified_format = F_MEGABYTE; break;
|
||||
case 'S':
|
||||
specified_format = F_SECTOR;
|
||||
break;
|
||||
case 'B':
|
||||
specified_format = F_BLOCK;
|
||||
break;
|
||||
case 'C':
|
||||
specified_format = F_CYLINDER;
|
||||
break;
|
||||
case 'M':
|
||||
specified_format = F_MEGABYTE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -942,9 +959,9 @@ out_partition_header(char *dev, int format, struct geometry G) {
|
|||
case F_CYLINDER:
|
||||
if (G.cylindersize) {
|
||||
printf(_("Units = cylinders of %lu bytes, blocks of 1024 bytes"
|
||||
", counting from %d\n\n"),
|
||||
G.cylindersize<<9, increment);
|
||||
printf(_(" Device Boot Start End #cyls #blocks Id System\n"));
|
||||
", counting from %d\n\n"), G.cylindersize << 9, increment);
|
||||
printf(_
|
||||
(" Device Boot Start End #cyls #blocks Id System\n"));
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
|
@ -961,7 +978,8 @@ out_partition_header(char *dev, int format, struct geometry G) {
|
|||
case F_MEGABYTE:
|
||||
printf(_("Units = mebibytes of 1048576 bytes, blocks of 1024 bytes"
|
||||
", counting from %d\n\n"), increment);
|
||||
printf(_(" Device Boot Start End MiB #blocks Id System\n"));
|
||||
printf(_
|
||||
(" Device Boot Start End MiB #blocks Id System\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1106,8 +1124,7 @@ out_partition(char *dev, int format, struct part_desc *p,
|
|||
break;
|
||||
}
|
||||
if (p->ptype == DOS_TYPE) {
|
||||
printf(" %2x %s\n",
|
||||
p->p.sys_type, sysname(p->p.sys_type));
|
||||
printf(" %2x %s\n", p->p.sys_type, sysname(p->p.sys_type));
|
||||
} else {
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -1121,17 +1138,20 @@ out_partition(char *dev, int format, struct part_desc *p,
|
|||
aa = chs_to_longchs(a);
|
||||
bb = chs_to_longchs(b);
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
do_warn(_("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
do_warn(_
|
||||
("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
a = (size ? ulong_to_chs(end, G) : zero_chs);
|
||||
b = p->p.end_chs;
|
||||
aa = chs_to_longchs(a);
|
||||
bb = chs_to_longchs(b);
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
do_warn(_("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
do_warn(_
|
||||
("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
if (G.cylinders && G.cylinders < 1024 && bb.c > G.cylinders)
|
||||
do_warn(_("partition ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
do_warn(_
|
||||
("partition ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
bb.c);
|
||||
}
|
||||
}
|
||||
|
@ -1144,8 +1164,7 @@ out_partitions(char *dev, struct disk_desc *z) {
|
|||
do_warn(_("No partitions found\n"));
|
||||
else {
|
||||
if (get_fdisk_geometry(z) && !dump) {
|
||||
do_warn(
|
||||
_("Warning: The partition table looks like it was made\n"
|
||||
do_warn(_("Warning: The partition table looks like it was made\n"
|
||||
" for C/H/S=*/%ld/%ld (instead of %ld/%ld/%ld).\n"
|
||||
"For this listing I'll assume that geometry.\n"),
|
||||
F.heads, F.sectors, B.cylinders, B.heads, B.sectors);
|
||||
|
@ -1162,8 +1181,7 @@ out_partitions(char *dev, struct disk_desc *z) {
|
|||
|
||||
static int
|
||||
disj(struct part_desc *p, struct part_desc *q) {
|
||||
return
|
||||
((p->start + p->size <= q->start)
|
||||
return ((p->start + p->size <= q->start)
|
||||
|| (is_extended(p->p.sys_type)
|
||||
&& q->start + q->size <= p->start + p->size));
|
||||
}
|
||||
|
@ -1205,13 +1223,15 @@ partitions_ok(struct disk_desc *z) {
|
|||
for (p = partitions; p - partitions < partno; p++)
|
||||
if (p->size == 0) {
|
||||
if (p->p.sys_type != EMPTY_PARTITION)
|
||||
my_warn(_("Warning: partition %s has size 0 but is not marked Empty\n"),
|
||||
my_warn(_
|
||||
("Warning: partition %s has size 0 but is not marked Empty\n"),
|
||||
PNO(p));
|
||||
else if (p->p.bootable != 0)
|
||||
my_warn(_("Warning: partition %s has size 0 and is bootable\n"),
|
||||
PNO(p));
|
||||
else if (p->p.start_sect != 0)
|
||||
my_warn(_("Warning: partition %s has size 0 and nonzero start\n"),
|
||||
my_warn(_
|
||||
("Warning: partition %s has size 0 and nonzero start\n"),
|
||||
PNO(p));
|
||||
/* all this is probably harmless, no error return */
|
||||
}
|
||||
|
@ -1221,7 +1241,8 @@ partitions_ok(struct disk_desc *z) {
|
|||
if (p->ptype == DOS_TYPE)
|
||||
if (p->size && !is_extended(p->p.sys_type)) {
|
||||
q = p->ep;
|
||||
if (p->start < q->start || p->start + p->size > q->start + q->size) {
|
||||
if (p->start < q->start
|
||||
|| p->start + p->size > q->start + q->size) {
|
||||
my_warn(_("Warning: partition %s "), PNO(p));
|
||||
my_warn(_("is not contained in partition %s\n"), PNO(q));
|
||||
return 0;
|
||||
|
@ -1254,15 +1275,18 @@ partitions_ok(struct disk_desc *z) {
|
|||
}
|
||||
|
||||
/* Do they start past zero and end before end-of-disk? */
|
||||
{ unsigned long ds = get_disksize(F_SECTOR);
|
||||
{
|
||||
unsigned long ds = get_disksize(F_SECTOR);
|
||||
for (p = partitions; p < partitions + partno; p++)
|
||||
if (p->size) {
|
||||
if (p->start == 0) {
|
||||
my_warn(_("Warning: partition %s starts at sector 0\n"), PNO(p));
|
||||
my_warn(_("Warning: partition %s starts at sector 0\n"),
|
||||
PNO(p));
|
||||
return 0;
|
||||
}
|
||||
if (p->size && p->start + p->size > ds) {
|
||||
my_warn(_("Warning: partition %s extends past end of disk\n"),
|
||||
my_warn(_
|
||||
("Warning: partition %s extends past end of disk\n"),
|
||||
PNO(p));
|
||||
return 0;
|
||||
}
|
||||
|
@ -1272,12 +1296,14 @@ partitions_ok(struct disk_desc *z) {
|
|||
/* At most one chain of DOS extended partitions ? */
|
||||
/* It seems that the OS/2 fdisk has the additional requirement
|
||||
that the extended partition must be the fourth one */
|
||||
{ int ect = 0;
|
||||
{
|
||||
int ect = 0;
|
||||
for (p = partitions; p < partitions + 4; p++)
|
||||
if (p->p.sys_type == EXTENDED_PARTITION)
|
||||
ect++;
|
||||
if (ect > 1 && !Linux) {
|
||||
my_warn(_("Among the primary partitions, at most one can be extended\n"
|
||||
my_warn(_
|
||||
("Among the primary partitions, at most one can be extended\n"
|
||||
" (although this is not a problem under Linux)\n"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -1293,7 +1319,9 @@ partitions_ok(struct disk_desc *z) {
|
|||
for (p = partitions; p < partitions + partno; p++)
|
||||
if (p->size) {
|
||||
if (p->start % B.cylindersize != 0
|
||||
&& (!p->ep || p->start / B.cylindersize != p->ep->start / B.cylindersize)
|
||||
&& (!p->ep
|
||||
|| p->start / B.cylindersize !=
|
||||
p->ep->start / B.cylindersize)
|
||||
&& (p->p.start_sect >= B.cylindersize)) {
|
||||
my_warn(_("Warning: partition %s does not start "
|
||||
"at a cylinder boundary\n"), PNO(p));
|
||||
|
@ -1313,26 +1341,30 @@ partitions_ok(struct disk_desc *z) {
|
|||
/* In fact, from a unique one only. */
|
||||
/* do not warn about bootable extended partitions -
|
||||
often LILO is there */
|
||||
{ int pno = -1;
|
||||
{
|
||||
int pno = -1;
|
||||
for (p = partitions; p < partitions + partno; p++)
|
||||
if (p->p.bootable) {
|
||||
if (pno == -1)
|
||||
pno = p - partitions;
|
||||
else if (p - partitions < 4) {
|
||||
my_warn(_("Warning: more than one primary partition is marked "
|
||||
my_warn(_
|
||||
("Warning: more than one primary partition is marked "
|
||||
"bootable (active)\n"
|
||||
"This does not matter for LILO, but the DOS MBR will "
|
||||
"not boot this disk.\n"));
|
||||
break;
|
||||
}
|
||||
if (p - partitions >= 4) {
|
||||
my_warn(_("Warning: usually one can boot from primary partitions "
|
||||
my_warn(_
|
||||
("Warning: usually one can boot from primary partitions "
|
||||
"only\nLILO disregards the `bootable' flag.\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pno == -1 || pno >= 4)
|
||||
my_warn(_("Warning: no primary partition is marked bootable (active)\n"
|
||||
my_warn(_
|
||||
("Warning: no primary partition is marked bootable (active)\n"
|
||||
"This does not matter for LILO, but the DOS MBR will "
|
||||
"not boot this disk.\n"));
|
||||
}
|
||||
|
@ -1349,7 +1381,8 @@ partitions_ok(struct disk_desc *z) {
|
|||
if (!chs_ok(b, PNO(p), _("start")))
|
||||
return 0;
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
my_warn(_("partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
my_warn(_
|
||||
("partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
PNO(p), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
a = p->size ? ulong_to_chs(p->start + p->size - 1, B) : zero_chs;
|
||||
b = p->p.end_chs;
|
||||
|
@ -1358,10 +1391,12 @@ partitions_ok(struct disk_desc *z) {
|
|||
if (!chs_ok(b, PNO(p), _("end")))
|
||||
return 0;
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
my_warn(_("partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
my_warn(_
|
||||
("partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
PNO(p), aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
if (B.cylinders && B.cylinders < 1024 && bb.c > B.cylinders)
|
||||
my_warn(_("partition %s ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
my_warn(_
|
||||
("partition %s ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
PNO(p), bb.c);
|
||||
}
|
||||
|
||||
|
@ -1389,8 +1424,7 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z)
|
|||
do_warn(_("Warning: shifted start of the extd partition "
|
||||
"from %ld to %ld\n"
|
||||
"(For listing purposes only. "
|
||||
"Do not change its contents.)\n"),
|
||||
ep->start, start);
|
||||
"Do not change its contents.)\n"), ep->start, start);
|
||||
} else {
|
||||
do_warn(_("Warning: extended partition does not start at a "
|
||||
"cylinder boundary.\n"
|
||||
|
@ -1536,7 +1570,8 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
|
|||
do_warn(_("detected Disk Manager - unable to handle that\n"));
|
||||
return 0;
|
||||
}
|
||||
{ unsigned int sig = *(unsigned short *)(s->data + 2);
|
||||
{
|
||||
unsigned int sig = *(unsigned short *)(s->data + 2);
|
||||
if (sig <= 0x1ae
|
||||
&& *(unsigned short *)(s->data + sig) == 0x55aa
|
||||
&& (1 & *(unsigned char *)(s->data + sig + 2))) {
|
||||
|
@ -1593,8 +1628,7 @@ static int
|
|||
osf_partition(char *dev __attribute__ ((__unused__)),
|
||||
int fd __attribute__ ((__unused__)),
|
||||
unsigned long start __attribute__ ((__unused__)),
|
||||
struct disk_desc *z __attribute__ ((__unused__)))
|
||||
{
|
||||
struct disk_desc *z __attribute__ ((__unused__))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1602,8 +1636,7 @@ static int
|
|||
sun_partition(char *dev __attribute__ ((__unused__)),
|
||||
int fd __attribute__ ((__unused__)),
|
||||
unsigned long start __attribute__ ((__unused__)),
|
||||
struct disk_desc *z __attribute__ ((__unused__)))
|
||||
{
|
||||
struct disk_desc *z __attribute__ ((__unused__))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1611,8 +1644,7 @@ static int
|
|||
amiga_partition(char *dev __attribute__ ((__unused__)),
|
||||
int fd __attribute__ ((__unused__)),
|
||||
unsigned long start __attribute__ ((__unused__)),
|
||||
struct disk_desc *z __attribute__ ((__unused__)))
|
||||
{
|
||||
struct disk_desc *z __attribute__ ((__unused__))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1642,7 +1674,8 @@ write_partitions(char *dev, int fd, struct disk_desc *z) {
|
|||
|
||||
for (p = partitions; p < partitions + pno; p++) {
|
||||
s = get_sector(dev, fd, p->sector);
|
||||
if (!s) return 0;
|
||||
if (!s)
|
||||
return 0;
|
||||
s->to_be_written = 1;
|
||||
if (p->ptype == DOS_TYPE) {
|
||||
copy_from_part(&(p->p), s->data + p->offset);
|
||||
|
@ -1699,16 +1732,17 @@ struct dumpfld {
|
|||
char *fldname;
|
||||
int is_bool;
|
||||
} dumpflds[] = {
|
||||
{ 0, "start", 0 },
|
||||
{ 1, "size", 0 },
|
||||
{ 2, "Id", 0 },
|
||||
{ 3, "bootable", 1 },
|
||||
{ 4, "bh", 0 },
|
||||
{ 5, "bs", 0 },
|
||||
{ 6, "bc", 0 },
|
||||
{ 7, "eh", 0 },
|
||||
{ 8, "es", 0 },
|
||||
{ 9, "ec", 0 }
|
||||
{
|
||||
0, "start", 0}, {
|
||||
1, "size", 0}, {
|
||||
2, "Id", 0}, {
|
||||
3, "bootable", 1}, {
|
||||
4, "bh", 0}, {
|
||||
5, "bs", 0}, {
|
||||
6, "bc", 0}, {
|
||||
7, "eh", 0}, {
|
||||
8, "es", 0}, {
|
||||
9, "ec", 0}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1782,7 +1816,8 @@ read_stdin(char **fields, char *line, int fieldssize, int linesize) {
|
|||
if (*ip == 0)
|
||||
return fno;
|
||||
if (*ip != ',' && *ip != ';')
|
||||
fatal(_("input error: unexpected character %c after %s field\n"),
|
||||
fatal(_
|
||||
("input error: unexpected character %c after %s field\n"),
|
||||
*ip, d->fldname);
|
||||
*ip = 0;
|
||||
goto nxtfld;
|
||||
|
@ -1795,8 +1830,7 @@ read_stdin(char **fields, char *line, int fieldssize, int linesize) {
|
|||
lp = ip = line + 2;
|
||||
fields[fno++] = lp;
|
||||
while ((c = *ip++) != 0) {
|
||||
if (!lp[-1] && (c == '\t' || c == ' '))
|
||||
;
|
||||
if (!lp[-1] && (c == '\t' || c == ' ')) ;
|
||||
else if (c == '\t' || c == ' ' || c == ',' || c == ';') {
|
||||
*lp++ = 0;
|
||||
if (fno < fieldssize)
|
||||
|
@ -2129,7 +2163,8 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
|
|||
p.size -= (p.size % unitsize(format));
|
||||
}
|
||||
if (p.size > ml1) {
|
||||
my_warn(_("Warning: given size (%lu) exceeds max allowable size (%lu)\n"),
|
||||
my_warn(_
|
||||
("Warning: given size (%lu) exceeds max allowable size (%lu)\n"),
|
||||
(p.size + unitsize(0) - 1) / unitsize(0), ml1 / unitsize(0));
|
||||
if (!force)
|
||||
return 0;
|
||||
|
@ -2170,11 +2205,11 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
|
|||
if (ep && ep->p.sys_type == EMPTY_PARTITION) {
|
||||
if (!build_surrounding_extended(&p, ep, z))
|
||||
return 0;
|
||||
} else
|
||||
if (!compute_start_sect(&p, ep))
|
||||
} else if (!compute_start_sect(&p, ep))
|
||||
return 0;
|
||||
|
||||
{ longchs aa = chs_to_longchs(p.p.begin_chs), bb;
|
||||
{
|
||||
longchs aa = chs_to_longchs(p.p.begin_chs), bb;
|
||||
|
||||
if (fno < 5) {
|
||||
bb = aa;
|
||||
|
@ -2187,7 +2222,8 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
|
|||
return 0;
|
||||
p.p.begin_chs = longchs_to_chs(bb, B);
|
||||
}
|
||||
{ longchs aa = chs_to_longchs(p.p.end_chs), bb;
|
||||
{
|
||||
longchs aa = chs_to_longchs(p.p.end_chs), bb;
|
||||
|
||||
if (fno < 8) {
|
||||
bb = aa;
|
||||
|
@ -2291,7 +2327,8 @@ read_input(char *dev, int interactive, struct disk_desc *z) {
|
|||
z->partno = 0;
|
||||
|
||||
if (interactive)
|
||||
my_warn(_("Input in the following format; absent fields get a default value.\n"
|
||||
my_warn(_
|
||||
("Input in the following format; absent fields get a default value.\n"
|
||||
"<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>\n"
|
||||
"Usually you only need to specify <start> and <size> (and perhaps <type>).\n"));
|
||||
eof = 0;
|
||||
|
@ -2309,8 +2346,8 @@ read_input(char *dev, int interactive, struct disk_desc *z) {
|
|||
/*
|
||||
* G. The command line
|
||||
*/
|
||||
static void usage(FILE * out)
|
||||
{
|
||||
static void
|
||||
usage(FILE * out) {
|
||||
|
||||
fprintf(out, _("\nUsage:\n"
|
||||
" %s [options] device [...]\n"),
|
||||
|
@ -2367,13 +2404,16 @@ static void usage(FILE * out)
|
|||
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
activate_usage(char *progn) {
|
||||
puts(_("Usage:"));
|
||||
printf(_("%s device list active partitions on device\n"), progn);
|
||||
printf(_("%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n"), progn);
|
||||
printf(_("%s -An device activate partition n, inactivate the other ones\n"), PROGNAME);
|
||||
printf(_
|
||||
("%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n"),
|
||||
progn);
|
||||
printf(_
|
||||
("%s -An device activate partition n, inactivate the other ones\n"),
|
||||
PROGNAME);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -2460,8 +2500,7 @@ is_ide_cdrom_or_tape(char *device) {
|
|||
snprintf(buf, sizeof(buf), "/proc/ide/%s/media", device + 5);
|
||||
procf = fopen(buf, "r");
|
||||
if (procf != NULL && fgets(buf, sizeof(buf), procf))
|
||||
is_ide = (!strncmp(buf, "cdrom", 5) ||
|
||||
!strncmp(buf, "tape", 4));
|
||||
is_ide = (!strncmp(buf, "cdrom", 5) || !strncmp(buf, "tape", 4));
|
||||
else
|
||||
/* Now when this proc file does not exist, skip the
|
||||
device when it is read-only. */
|
||||
|
@ -2483,8 +2522,7 @@ nextproc(FILE *procf) {
|
|||
if (procf == NULL)
|
||||
return NULL;
|
||||
while (fgets(line, sizeof(line), procf) != NULL) {
|
||||
if (sscanf (line, " %d %d %llu %128[^\n ]",
|
||||
&ma, &mi, &sz, ptname) != 4)
|
||||
if (sscanf(line, " %d %d %llu %128[^\n ]", &ma, &mi, &sz, ptname) != 4)
|
||||
continue;
|
||||
snprintf(devname, sizeof(devname), "/dev/%s", ptname);
|
||||
if (!is_whole_disk(devname))
|
||||
|
@ -2496,17 +2534,19 @@ nextproc(FILE *procf) {
|
|||
}
|
||||
|
||||
static void
|
||||
gpt_warning(char *dev, int warn_only)
|
||||
{
|
||||
gpt_warning(char *dev, int warn_only) {
|
||||
if (force)
|
||||
warn_only = 1;
|
||||
|
||||
if (dev && gpt_probe_signature_devname(dev)) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, _("\nWARNING: GPT (GUID Partition Table) detected on '%s'! "
|
||||
"The util sfdisk doesn't support GPT. Use GNU Parted.\n\n"), dev);
|
||||
fprintf(stderr,
|
||||
_("\nWARNING: GPT (GUID Partition Table) detected on '%s'! "
|
||||
"The util sfdisk doesn't support GPT. Use GNU Parted.\n\n"),
|
||||
dev);
|
||||
if (!warn_only) {
|
||||
fprintf(stderr, _("Use the --force flag to overrule this check.\n"));
|
||||
fprintf(stderr,
|
||||
_("Use the --force flag to overrule this check.\n"));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -2562,29 +2602,39 @@ main(int argc, char **argv) {
|
|||
while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
force = 1; break; /* does not imply quiet */
|
||||
force = 1;
|
||||
break; /* does not imply quiet */
|
||||
case 'g':
|
||||
opt_out_geom = 1; break;
|
||||
opt_out_geom = 1;
|
||||
break;
|
||||
case 'G':
|
||||
opt_out_pt_geom = 1; break;
|
||||
opt_out_pt_geom = 1;
|
||||
break;
|
||||
case 'i':
|
||||
increment = 1; break;
|
||||
increment = 1;
|
||||
break;
|
||||
case 'c':
|
||||
case 'c' + PRINT_ID:
|
||||
case 'c' + CHANGE_ID:
|
||||
do_id = c; break;
|
||||
do_id = c;
|
||||
break;
|
||||
case 'd':
|
||||
dump = 1; /* fall through */
|
||||
case 'l':
|
||||
opt_list = 1; break;
|
||||
opt_list = 1;
|
||||
break;
|
||||
case 'n':
|
||||
no_write = 1; break;
|
||||
no_write = 1;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1; break;
|
||||
quiet = 1;
|
||||
break;
|
||||
case 's':
|
||||
opt_size = 1; break;
|
||||
opt_size = 1;
|
||||
break;
|
||||
case 'u':
|
||||
set_format(*optarg); break;
|
||||
set_format(*optarg);
|
||||
break;
|
||||
case 'v':
|
||||
printf(_("%s from %s\n"), program_invocation_short_name,
|
||||
PACKAGE_STRING);
|
||||
|
@ -2593,62 +2643,86 @@ main(int argc, char **argv) {
|
|||
usage(stdout);
|
||||
return EXIT_SUCCESS;
|
||||
case 'x':
|
||||
show_extended = 1; break;
|
||||
show_extended = 1;
|
||||
break;
|
||||
case 'A':
|
||||
activatearg = optarg;
|
||||
activate = 1; break;
|
||||
activate = 1;
|
||||
break;
|
||||
case 'C':
|
||||
U.cylinders = atoi(optarg); break;
|
||||
U.cylinders = atoi(optarg);
|
||||
break;
|
||||
case 'D':
|
||||
DOS = 1; break;
|
||||
DOS = 1;
|
||||
break;
|
||||
case 'E':
|
||||
DOS_extended = 1; break;
|
||||
DOS_extended = 1;
|
||||
break;
|
||||
case 'H':
|
||||
U.heads = atoi(optarg); break;
|
||||
U.heads = atoi(optarg);
|
||||
break;
|
||||
case 'L':
|
||||
Linux = 1; break;
|
||||
Linux = 1;
|
||||
break;
|
||||
case 'N':
|
||||
one_only = atoi(optarg); break;
|
||||
one_only = atoi(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
restore_sector_file = optarg; break;
|
||||
restore_sector_file = optarg;
|
||||
break;
|
||||
case 'O':
|
||||
save_sector_file = optarg; break;
|
||||
save_sector_file = optarg;
|
||||
break;
|
||||
case 'R':
|
||||
opt_reread = 1; break;
|
||||
opt_reread = 1;
|
||||
break;
|
||||
case 'S':
|
||||
U.sectors = atoi(optarg); break;
|
||||
U.sectors = atoi(optarg);
|
||||
break;
|
||||
case 'T':
|
||||
list_types();
|
||||
exit(0);
|
||||
case 'U':
|
||||
unhidearg = optarg;
|
||||
unhide = 1; break;
|
||||
unhide = 1;
|
||||
break;
|
||||
case 'V':
|
||||
verify = 1; break;
|
||||
verify = 1;
|
||||
break;
|
||||
default:
|
||||
usage(stderr); break;
|
||||
usage(stderr);
|
||||
break;
|
||||
|
||||
/* dangerous flags */
|
||||
case OPT_IN_ORDER:
|
||||
partitions_in_order = 1; break;
|
||||
partitions_in_order = 1;
|
||||
break;
|
||||
case OPT_NOT_IN_ORDER:
|
||||
partitions_in_order = 0; break;
|
||||
partitions_in_order = 0;
|
||||
break;
|
||||
case OPT_INSIDE_OUTER:
|
||||
all_logicals_inside_outermost_extended = 1; break;
|
||||
all_logicals_inside_outermost_extended = 1;
|
||||
break;
|
||||
case OPT_NOT_INSIDE_OUTER:
|
||||
all_logicals_inside_outermost_extended = 0; break;
|
||||
all_logicals_inside_outermost_extended = 0;
|
||||
break;
|
||||
case OPT_NESTED:
|
||||
boxes = NESTED; break;
|
||||
boxes = NESTED;
|
||||
break;
|
||||
case OPT_CHAINED:
|
||||
boxes = CHAINED; break;
|
||||
boxes = CHAINED;
|
||||
break;
|
||||
case OPT_ONESECTOR:
|
||||
boxes = ONESECTOR; break;
|
||||
boxes = ONESECTOR;
|
||||
break;
|
||||
|
||||
/* more flags */
|
||||
case OPT_NO_REREAD:
|
||||
no_reread = 1; break;
|
||||
no_reread = 1;
|
||||
break;
|
||||
case OPT_LEAVE_LAST:
|
||||
leave_last = 1; break;
|
||||
leave_last = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2835,8 +2909,7 @@ do_pt_geom (char *dev, int silent) {
|
|||
R.heads = F.heads;
|
||||
R.sectors = F.sectors;
|
||||
R.cylindersize = R.heads * R.sectors;
|
||||
R.cylinders = (R.cylindersize == 0) ? 0 :
|
||||
R.total_size / R.cylindersize;
|
||||
R.cylinders = (R.cylindersize == 0) ? 0 : R.total_size / R.cylindersize;
|
||||
}
|
||||
|
||||
if (R.cylinders)
|
||||
|
@ -2952,7 +3025,8 @@ do_activate (char **av, int ac, char *arg) {
|
|||
/* then set where desired */
|
||||
if (ac == 1)
|
||||
set_active(z, arg);
|
||||
else for(i=1; i<ac; i++)
|
||||
else
|
||||
for (i = 1; i < ac; i++)
|
||||
set_active(z, av[i]);
|
||||
|
||||
/* then write to disk */
|
||||
|
@ -2966,8 +3040,10 @@ do_activate (char **av, int ac, char *arg) {
|
|||
if (z->partitions[pno].p.bootable)
|
||||
i++;
|
||||
if (i != 1)
|
||||
my_warn(_("You have %d active primary partitions. This does not matter for LILO,\n"
|
||||
"but the DOS MBR will only boot a disk with 1 active partition.\n"), i);
|
||||
my_warn(_
|
||||
("You have %d active primary partitions. This does not matter for LILO,\n"
|
||||
"but the DOS MBR will only boot a disk with 1 active partition.\n"),
|
||||
i);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
@ -3007,7 +3083,8 @@ do_unhide (char **av, int ac, char *arg) {
|
|||
/* unhide where desired */
|
||||
if (ac == 1)
|
||||
set_unhidden(z, arg);
|
||||
else for(i=1; i<ac; i++)
|
||||
else
|
||||
for (i = 1; i < ac; i++)
|
||||
set_unhidden(z, av[i]);
|
||||
|
||||
/* then write to disk */
|
||||
|
@ -3090,7 +3167,8 @@ do_fdisk(char *dev){
|
|||
if (!no_write && !no_reread) {
|
||||
my_warn(_("Checking that no-one is using this disk right now ...\n"));
|
||||
if (reread_ioctl(fd)) {
|
||||
do_warn(_("\nThis disk is currently in use - repartitioning is probably a bad idea.\n"
|
||||
do_warn(_
|
||||
("\nThis disk is currently in use - repartitioning is probably a bad idea.\n"
|
||||
"Umount all file systems, and swapoff all swap partitions on this disk.\n"
|
||||
"Use the --no-reread flag to suppress this check.\n"));
|
||||
if (!force) {
|
||||
|
@ -3127,7 +3205,8 @@ do_fdisk(char *dev){
|
|||
fatal(_("I don't like these partitions - nothing changed.\n"
|
||||
"(If you really want this, use the --force option.)\n"));
|
||||
else
|
||||
do_warn(_("I don't like this - probably you should answer No\n"));
|
||||
do_warn(_
|
||||
("I don't like this - probably you should answer No\n"));
|
||||
}
|
||||
ask:
|
||||
if (interactive) {
|
||||
|
@ -3162,7 +3241,8 @@ do_fdisk(char *dev){
|
|||
if (!reread_disk_partition(dev, fd))
|
||||
exit_status = 1;
|
||||
|
||||
my_warn(_("If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)\n"
|
||||
my_warn(_
|
||||
("If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)\n"
|
||||
"to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1\n"
|
||||
"(See fdisk(8).)\n"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue