partitions = 4; /* maximum partition + 1 */
unsigned int user_cylinders, user_heads, user_sectors;
-unsigned int units_per_sector = 1, display_in_cyl_units = 0;
static void __attribute__ ((__noreturn__)) usage(FILE *out)
{
return 1;
}
-void update_units(struct fdisk_context *cxt)
-{
- int cyl_units = cxt->geom.heads * cxt->geom.sectors;
-
- if (display_in_cyl_units && cyl_units)
- units_per_sector = cyl_units;
- else
- units_per_sector = 1; /* in sectors */
-}
-
void warn_limits(struct fdisk_context *cxt)
{
if (cxt->total_sectors > UINT_MAX && !nowarn) {
}
}
-void warn_alignment(struct fdisk_context *cxt)
-{
- if (nowarn)
- return;
-
- if (cxt->sector_size != cxt->phy_sector_size)
- fprintf(stderr, _("\n"
-"The device presents a logical sector size that is smaller than\n"
-"the physical sector size. Aligning to a physical sector (or optimal\n"
-"I/O) size boundary is recommended, or performance may be impacted.\n"));
-
- if (dos_compatible_flag)
- fprintf(stderr, _("\n"
-"WARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n"
-" switch off the mode (with command 'c')."));
-
- if (display_in_cyl_units)
- fprintf(stderr, _("\n"
-"WARNING: cylinders as display units are deprecated. Use command 'u' to\n"
-" change units to sectors.\n"));
-
-}
-
static int is_partition_table_changed(void)
{
int i;
return P_("sector", "sectors", n);
}
-void change_units(struct fdisk_context *cxt)
-{
- display_in_cyl_units = !display_in_cyl_units;
- update_units(cxt);
-
- if (display_in_cyl_units)
- printf(_("Changing display/entry units to cylinders (DEPRECATED!)\n"));
- else
- printf(_("Changing display/entry units to sectors\n"));
-}
-
static void
toggle_active(int i) {
struct pte *pe = &ptes[i];
user_heads = read_int(cxt, 1, cxt->geom.heads, 256, 0,
_("Number of heads"));
fdisk_context_set_user_geometry(cxt, user_cylinders, user_heads, user_sectors);
- update_units(cxt);
break;
case 'i':
if (fdisk_is_disklabel(cxt, SUN))
"sector offset for DOS "
"compatibility\n"));
fdisk_context_set_user_geometry(cxt, user_cylinders, user_heads, user_sectors);
- update_units(cxt);
break;
case 'v':
verify(cxt);
/*
* Try BSD -- TODO: move to list_table() too
*/
+ update_units(cxt);
list_disk_geometry(cxt);
if (!fdisk_is_disklabel(cxt, AIX) &&
!fdisk_is_disklabel(cxt, MAC))
cxt->sector_size, DEFAULT_SECTOR_SIZE);
if (!fdisk_dev_has_disklabel(cxt)) {
+ update_units(cxt); /* to provide compatible 'p'rint output */
fprintf(stderr,
_("Device does not contain a recognized partition table\n"));
fdisk_create_disklabel(cxt, NULL);
extern void check_alignment(struct fdisk_context *cxt, sector_t lba, int partition);
extern void check(struct fdisk_context *cxt, int n, unsigned int h, unsigned int s, unsigned int c, unsigned int start);
-extern void change_units(struct fdisk_context *cxt);
extern void fatal(struct fdisk_context *cxt, enum failure why);
extern int get_partition(struct fdisk_context *cxt, int warn, int max);
extern void list_partition_types(struct fdisk_context *cxt);
extern void fill_bounds(sector_t *first, sector_t *last);
extern char *partition_type(struct fdisk_context *cxt, unsigned char type);
-extern void update_units(struct fdisk_context *cxt);
extern char read_chars(char *mesg);
extern void set_changed(int);
extern void set_all_unchanged(void);
extern int warn_geometry(struct fdisk_context *cxt);
extern void warn_limits(struct fdisk_context *cxt);
-extern void warn_alignment(struct fdisk_context *cxt);
extern unsigned int read_int_with_suffix(struct fdisk_context *cxt,
unsigned int low, unsigned int dflt, unsigned int high,
unsigned int base, char *mesg, int *is_suffix_used);
extern sector_t get_nr_sects(struct partition *p);
+extern int nowarn;
extern int MBRbuffer_changed;
/* start_sect and nr_sects are stored little endian on all machines */
#define NETBSD_PARTITION 0xa9
#define DKTYPENAMES
#include "fdiskbsdlabel.h"
+#include "fdiskdoslabel.h"
static int xbsd_delete_part (struct fdisk_context *cxt, int partnum);
static void xbsd_edit_disklabel (void);
sector_t extended_offset;
int ext_index;
+unsigned int units_per_sector = 1, display_in_cyl_units = 0;
+
+void update_units(struct fdisk_context *cxt)
+{
+ int cyl_units = cxt->geom.heads * cxt->geom.sectors;
+
+ if (display_in_cyl_units && cyl_units)
+ units_per_sector = cyl_units;
+ else
+ units_per_sector = 1; /* in sectors */
+}
+
+void change_units(struct fdisk_context *cxt)
+{
+ display_in_cyl_units = !display_in_cyl_units;
+ update_units(cxt);
+
+ if (display_in_cyl_units)
+ printf(_("Changing display/entry units to cylinders (DEPRECATED!)\n"));
+ else
+ printf(_("Changing display/entry units to sectors\n"));
+}
+
+
+static void warn_alignment(struct fdisk_context *cxt)
+{
+ if (nowarn)
+ return;
+
+ if (cxt->sector_size != cxt->phy_sector_size)
+ fprintf(stderr, _("\n"
+"The device presents a logical sector size that is smaller than\n"
+"the physical sector size. Aligning to a physical sector (or optimal\n"
+"I/O) size boundary is recommended, or performance may be impacted.\n"));
+
+ if (dos_compatible_flag)
+ fprintf(stderr, _("\n"
+"WARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n"
+" switch off the mode (with command 'c')."));
+
+ if (display_in_cyl_units)
+ fprintf(stderr, _("\n"
+"WARNING: cylinders as display units are deprecated. Use command 'u' to\n"
+" change units to sectors.\n"));
+
+}
+
static int get_nonexisting_partition(struct fdisk_context *cxt, int warn, int max)
{
int pno = -1;
extern int mbr_is_valid_magic(unsigned char *b);
+extern void change_units(struct fdisk_context *cxt);
+extern void update_units(struct fdisk_context *cxt); /* called from sunlabel too */
+
#endif
#include "common.h"
#include "fdisk.h"
#include "fdisksunlabel.h"
+#include "fdiskdoslabel.h"
static int other_endian = 0;
set_changed(0);
}
}
- update_units(cxt);
return 1;
}
return 0;
}
+
+static int sun_reset_alignment(struct fdisk_context *cxt)
+{
+ /* this is shared with DOS ... */
+ update_units(cxt);
+ return 0;
+}
+
const struct fdisk_label sun_label =
{
.name = "sun",
.part_delete = sun_delete_partition,
.part_get_type = sun_get_parttype,
.part_set_type = sun_set_parttype,
-
+ .reset_alignment = sun_reset_alignment,
};
size_t i;
cxt->disklabel = FDISK_DISKLABEL_ANY;
- update_units(cxt);
for (i = 0; i < ARRAY_SIZE(labels); i++) {
if (!labels[i]->probe || labels[i]->probe(cxt) != 1)