unsigned char *MBRbuffer;
int MBRbuffer_changed;
-struct fdisk_context *cxt = NULL;
#define hex_val(c) ({ \
char _c = (c); \
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
-void fatal(enum failure why)
+void fatal(struct fdisk_context *cxt, enum failure why)
{
close(cxt->dev_fd);
switch (why) {
}
static void
-get_topology(int fd) {
+get_topology(struct fdisk_context *cxt) {
int arg;
#ifdef HAVE_LIBBLKID
blkid_probe pr;
}
void
-get_geometry(int fd, struct geom *g) {
+get_geometry(struct fdisk_context *cxt, struct geom *g) {
unsigned long long llcyls, nsects = 0;
unsigned int kern_heads = 0, kern_sectors = 0;
- get_topology(fd);
+ get_topology(cxt);
heads = cylinders = sectors = 0;
pt_heads = pt_sectors = 0;
- blkdev_get_geometry(fd, &kern_heads, &kern_sectors);
+ blkdev_get_geometry(cxt->dev_fd, &kern_heads, &kern_sectors);
get_partition_table_geometry();
heads = user_heads ? user_heads :
kern_sectors ? kern_sectors : 63;
/* get number of 512-byte sectors, and convert it the real sectors */
- if (blkdev_get_sectors(fd, &nsects) == 0)
+ if (blkdev_get_sectors(cxt->dev_fd, &nsects) == 0)
total_number_of_sectors = (nsects / (sector_size >> 9));
update_sector_offset();
* 0: found or created label
* 1: I/O error
*/
-static int get_boot(int try_only) {
+static int get_boot(struct fdisk_context *cxt, int try_only) {
disklabel = ANY_LABEL;
memset(MBRbuffer, 0, 512);
if (512 != read(cxt->dev_fd, MBRbuffer, 512)) {
if (try_only)
return 1;
- fatal(unable_to_read);
+ fatal(cxt, unable_to_read);
}
- get_geometry(cxt->dev_fd, NULL);
+ get_geometry(cxt, NULL);
update_units();
- if (!check_dos_label())
+ if (!check_dos_label(cxt))
if (check_sun_label() || check_sgi_label() || check_aix_label() || check_mac_label())
return 0;
- if (check_osf_label()) {
+ if (check_osf_label(cxt)) {
/* intialize partitions for BSD as well */
dos_init();
if (!valid_part_table_flag(MBRbuffer)) {
fprintf(stderr,
_("Device does not contain a recognized partition table\n"));
#ifdef __sparc__
- create_sunlabel();
+ create_sunlabel(cxt);
#else
create_doslabel();
#endif
}
static void
-list_disk_geometry(void) {
+list_disk_geometry(struct fdisk_context *cxt) {
unsigned long long bytes = total_number_of_sectors * sector_size;
long megabytes = bytes/1000000;
}
static void
-list_table(int xtra) {
+list_table(struct fdisk_context *cxt, int xtra) {
struct partition *p;
char *type;
int i, w;
if (disklabel == SUN_LABEL) {
- sun_list_table(xtra);
+ sun_list_table(cxt, xtra);
return;
}
if (disklabel == SGI_LABEL) {
- sgi_list_table(xtra);
+ sgi_list_table(cxt, xtra);
return;
}
- list_disk_geometry();
+ list_disk_geometry(cxt);
if (disklabel == OSF_LABEL) {
- xbsd_print_disklabel(xtra);
+ xbsd_print_disklabel(cxt, xtra);
return;
}
}
static void
-x_list_table(int extend) {
+x_list_table(struct fdisk_context *cxt, int extend) {
struct pte *pe;
struct partition *p;
int i;
}
static void
-write_table(void) {
+write_table(struct fdisk_context *cxt) {
int i;
if (disklabel == DOS_LABEL)
- dos_write_table();
+ dos_write_table(cxt);
else if (disklabel == SGI_LABEL)
/* no test on change? the printf below might be mistaken */
- sgi_write_table();
+ sgi_write_table(cxt);
else if (disklabel == SUN_LABEL) {
int needw = 0;
if (ptes[i].changed)
needw = 1;
if (needw)
- sun_write_table();
+ sun_write_table(cxt);
}
printf(_("The partition table has been altered!\n\n"));
- reread_partition_table(1);
+ reread_partition_table(cxt, 1);
}
void
-reread_partition_table(int leave) {
+reread_partition_table(struct fdisk_context *cxt, int leave) {
int i;
struct stat statbuf;
}
static void
-print_raw(void) {
+print_raw(char *dev) {
int i;
- printf(_("Device: %s\n"), cxt->dev_path);
+ printf(_("Device: %s\n"), dev);
if (disklabel == SUN_LABEL || disklabel == SGI_LABEL)
print_buffer(MBRbuffer);
else for (i = 3; i < partitions; i++)
}
static void
-expert_command_prompt(void)
+expert_command_prompt(struct fdisk_context *cxt)
{
char c;
sun_set_ncyl(cylinders);
break;
case 'd':
- print_raw();
+ print_raw(cxt->dev_path);
break;
case 'e':
if (disklabel == SGI_LABEL)
sun_set_xcyl();
else
if (disklabel == DOS_LABEL)
- x_list_table(1);
+ x_list_table(cxt, 1);
break;
case 'f':
if (disklabel == DOS_LABEL)
fix_partition_table_order();
break;
case 'g':
- create_sgilabel();
+ create_sgilabel(cxt);
break;
case 'h':
user_heads = heads = read_int(1, heads, 256, 0,
break;
case 'p':
if (disklabel == SUN_LABEL)
- list_table(1);
+ list_table(cxt, 1);
else
- x_list_table(0);
+ x_list_table(cxt, 0);
break;
case 'q':
handle_quit(cxt);
verify();
break;
case 'w':
- write_table(); /* does not return */
+ write_table(cxt); /* does not return */
break;
case 'y':
if (disklabel == SUN_LABEL)
{
int gb;
- cxt = fdisk_new_context_from_filename(device, 1); /* read-only */
+ struct fdisk_context *cxt = fdisk_new_context_from_filename(device, 1); /* read-only */
if (!cxt)
err(EXIT_FAILURE, _("unable to open %s"), device);
gpt_warning(device);
- gb = get_boot(1);
+ gb = get_boot(cxt, 1);
if (gb < 0) { /* no DOS signature */
- list_disk_geometry();
+ list_disk_geometry(cxt);
if (disklabel != AIX_LABEL && disklabel != MAC_LABEL)
- btrydev(device);
+ btrydev(cxt);
}
else if (!gb)
- list_table(0);
+ list_table(cxt, 0);
fdisk_free_context(cxt);
cxt = NULL;
}
fflush(stdout);
}
-static void command_prompt(void)
+static void command_prompt(struct fdisk_context *cxt)
{
int c;
printf(_("Detected an OSF/1 disklabel on %s, entering "
"disklabel mode.\n"),
cxt->dev_path);
- bsd_command_prompt();
+ bsd_command_prompt(cxt);
/* If we return we may want to make an empty DOS label? */
disklabel = DOS_LABEL;
}
sgi_set_bootfile();
else if (disklabel == DOS_LABEL) {
disklabel = OSF_LABEL;
- bsd_command_prompt();
+ bsd_command_prompt(cxt);
disklabel = DOS_LABEL;
} else
unknown_command(c);
create_doslabel();
break;
case 'p':
- list_table(0);
+ list_table(cxt, 0);
break;
case 'q':
handle_quit(cxt);
case 's':
- create_sunlabel();
+ create_sunlabel(cxt);
break;
case 't':
change_sysid();
verify();
break;
case 'w':
- write_table(); /* does not return */
+ write_table(cxt); /* does not return */
break;
case 'x':
- expert_command_prompt();
+ expert_command_prompt(cxt);
break;
default:
unknown_command(c);
if ((fd = open(dev, O_RDONLY)) < 0)
err(EXIT_FAILURE, _("unable to open %s"), dev);
- if (blkdev_get_sectors(fd, &size) == -1)
- fatal(ioctl_error);
+ if (blkdev_get_sectors(fd, &size) == -1) {
+ close(fd);
+ err(EXIT_FAILURE, _("BLKGETSIZE ioctl failed on %s"), dev);
+ }
close(fd);
return size/2;
}
int main(int argc, char **argv)
{
int c, optl = 0, opts = 0;
+ struct fdisk_context *cxt = NULL;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
print_welcome();
gpt_warning(cxt->dev_path);
- get_boot(0);
+ get_boot(cxt, 0);
- command_prompt();
+ command_prompt(cxt);
return 0;
}
char *dev_path; /* device path */
};
-extern struct fdisk_context *cxt;
-
extern struct fdisk_context *fdisk_new_context_from_filename(const char *fname, int readonly);
extern void fdisk_free_context(struct fdisk_context *cxt);
extern int fd, partitions;
extern unsigned int display_in_cyl_units, units_per_sector;
extern void change_units(void);
-extern void fatal(enum failure why);
-extern void get_geometry(int fd, struct geom *);
+extern void fatal(struct fdisk_context *cxt, enum failure why);
+extern void get_geometry(struct fdisk_context *, struct geom *);
extern int get_partition(int warn, int max);
extern void list_types(struct systypes *sys);
extern int read_line (int *asked);
extern char read_char(char *mesg);
extern int read_hex(struct systypes *sys);
-extern void reread_partition_table(int leave);
+extern void reread_partition_table(struct fdisk_context *cxt, int leave);
extern struct partition *get_part_table(int);
extern int valid_part_table_flag(unsigned char *b);
extern unsigned int read_int(unsigned int low, unsigned int dflt,
store4_little_endian(p->start4, start_sect);
}
-static inline void seek_sector(int fd, unsigned long long secno)
+static inline void seek_sector(struct fdisk_context *cxt, unsigned long long secno)
{
off_t offset = (off_t) secno * sector_size;
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- fatal(unable_to_seek);
+ if (lseek(cxt->dev_fd, offset, SEEK_SET) == (off_t) -1)
+ fatal(cxt, unable_to_seek);
}
-static inline void read_sector(int fd, unsigned long long secno, unsigned char *buf)
+static inline void read_sector(struct fdisk_context *cxt, unsigned long long secno, unsigned char *buf)
{
- seek_sector(fd, secno);
- if (read(fd, buf, sector_size) != sector_size)
- fatal(unable_to_read);
+ seek_sector(cxt, secno);
+ if (read(cxt->dev_fd, buf, sector_size) != sector_size)
+ fatal(cxt, unable_to_read);
}
-static inline void write_sector(int fd, unsigned long long secno, unsigned char *buf)
+static inline void write_sector(struct fdisk_context *cxt, unsigned long long secno, unsigned char *buf)
{
- seek_sector(fd, secno);
- if (write(fd, buf, sector_size) != sector_size)
- fatal(unable_to_write);
+ seek_sector(cxt, secno);
+ if (write(cxt->dev_fd, buf, sector_size) != sector_size)
+ fatal(cxt, unable_to_write);
}
static inline unsigned long long get_start_sect(struct partition *p)
static void xbsd_delete_part (void);
static void xbsd_new_part (void);
-static void xbsd_write_disklabel (void);
-static int xbsd_create_disklabel (void);
+static void xbsd_write_disklabel (struct fdisk_context *cxt);
+static int xbsd_create_disklabel (struct fdisk_context *cxt);
static void xbsd_edit_disklabel (void);
-static void xbsd_write_bootstrap (void);
+static void xbsd_write_bootstrap (struct fdisk_context *cxt);
static void xbsd_change_fstype (void);
static int xbsd_get_part_index (int max);
static int xbsd_check_new_partition (int *i);
static void xbsd_list_types (void);
static unsigned short xbsd_dkcksum (struct xbsd_disklabel *lp);
-static int xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d,
+static int xbsd_initlabel (struct fdisk_context *cxt,
+ struct partition *p, struct xbsd_disklabel *d,
int pindex);
-static int xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d);
-static int xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d);
+static int xbsd_readlabel (struct fdisk_context *cxt,
+ struct partition *p, struct xbsd_disklabel *d);
+static int xbsd_writelabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d);
static void sync_disks (void);
#if defined (__alpha__)
* so this does not mean that there is a BSD disk label.
*/
int
-check_osf_label(void) {
- if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0)
+check_osf_label(struct fdisk_context *cxt) {
+ if (xbsd_readlabel (cxt, NULL, &xbsd_dlabel) == 0)
return 0;
return 1;
}
int
-btrydev (char * dev) {
- if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0)
+btrydev (struct fdisk_context *cxt) {
+ if (xbsd_readlabel (cxt, NULL, &xbsd_dlabel) == 0)
return -1;
- printf(_("\nBSD label for device: %s\n"), dev);
- xbsd_print_disklabel (0);
+ printf(_("\nBSD label for device: %s\n"), cxt->dev_path);
+ xbsd_print_disklabel (cxt, 0);
return 0;
}
#endif
void
-bsd_command_prompt (void)
+bsd_command_prompt (struct fdisk_context *cxt)
{
#if !defined (__alpha__)
int t, ss;
}
printf (_("Reading disklabel of %s at sector %d.\n"),
partname(cxt->dev_path, t+1, 0), ss + BSD_LABELSECTOR);
- if (xbsd_readlabel (xbsd_part, &xbsd_dlabel) == 0)
- if (xbsd_create_disklabel () == 0)
+ if (xbsd_readlabel (cxt, xbsd_part, &xbsd_dlabel) == 0)
+ if (xbsd_create_disklabel (cxt) == 0)
return;
break;
}
#elif defined (__alpha__)
- if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0)
- if (xbsd_create_disklabel () == 0)
+ if (xbsd_readlabel (cxt, NULL, &xbsd_dlabel) == 0)
+ if (xbsd_create_disklabel (cxt) == 0)
exit ( EXIT_SUCCESS );
#endif
xbsd_edit_disklabel ();
break;
case 'i':
- xbsd_write_bootstrap ();
+ xbsd_write_bootstrap (cxt);
break;
case 'l':
xbsd_list_types ();
xbsd_new_part ();
break;
case 'p':
- xbsd_print_disklabel (0);
+ xbsd_print_disklabel (cxt, 0);
break;
case 'q':
close (cxt->dev_fd);
case 'r':
return;
case 's':
- xbsd_print_disklabel (1);
+ xbsd_print_disklabel (cxt, 1);
break;
case 't':
xbsd_change_fstype ();
change_units();
break;
case 'w':
- xbsd_write_disklabel ();
+ xbsd_write_disklabel (cxt);
break;
#if !defined (__alpha__)
case 'x':
}
void
-xbsd_print_disklabel (int show_all) {
+xbsd_print_disklabel (struct fdisk_context *cxt, int show_all) {
struct xbsd_disklabel *lp = &xbsd_dlabel;
struct xbsd_partition *pp;
FILE *f = stdout;
}
static void
-xbsd_write_disklabel (void) {
+xbsd_write_disklabel (struct fdisk_context *cxt) {
#if defined (__alpha__)
printf (_("Writing disklabel to %s.\n"), cxt->dev_path);
- xbsd_writelabel (NULL, &xbsd_dlabel);
+ xbsd_writelabel (cxt, NULL, &xbsd_dlabel);
#else
printf (_("Writing disklabel to %s.\n"),
partname(cxt->dev_path, xbsd_part_index+1, 0));
- xbsd_writelabel (xbsd_part, &xbsd_dlabel);
+ xbsd_writelabel (cxt, xbsd_part, &xbsd_dlabel);
#endif
- reread_partition_table(0); /* no exit yet */
+ reread_partition_table(cxt, 0); /* no exit yet */
}
static int
-xbsd_create_disklabel (void) {
+xbsd_create_disklabel (struct fdisk_context *cxt) {
char c;
#if defined (__alpha__)
while (1) {
c = read_char (_("Do you want to create a disklabel? (y/n) "));
if (tolower(c) == 'y') {
- if (xbsd_initlabel (
+ if (xbsd_initlabel (cxt,
#if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) || \
defined (__s390__) || defined (__s390x__)
NULL, &xbsd_dlabel, 0
xbsd_part, &xbsd_dlabel, xbsd_part_index
#endif
) == 1) {
- xbsd_print_disklabel (1);
+ xbsd_print_disklabel (cxt, 1);
return 1;
} else
return 0;
}
static void
-xbsd_write_bootstrap (void)
+xbsd_write_bootstrap (struct fdisk_context *cxt)
{
char *bootdir = BSD_LINUX_BOOTDIR;
char path[sizeof(BSD_LINUX_BOOTDIR) + 1 + 2 + 4]; /* BSD_LINUX_BOOTDIR + / + {sd,wd} + boot */
#endif
if (lseek (cxt->dev_fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
- fatal (unable_to_seek);
+ fatal (cxt, unable_to_seek);
if (BSD_BBSIZE != write (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
- fatal (unable_to_write);
+ fatal (cxt, unable_to_write);
#if defined (__alpha__)
printf (_("Bootstrap installed on %s.\n"), cxt->dev_path);
}
static int
-xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d,
+xbsd_initlabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d,
int pindex __attribute__((__unused__))) {
struct xbsd_partition *pp;
struct geom g;
- get_geometry (cxt->dev_fd, &g);
+ get_geometry (cxt, &g);
memset (d, 0, sizeof (struct xbsd_disklabel));
d -> d_magic = BSD_DISKMAGIC;
* If it has the right magic, return 1.
*/
static int
-xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
+xbsd_readlabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d)
{
int t, sector;
#endif
if (lseek (cxt->dev_fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
- fatal (unable_to_seek);
+ fatal (cxt, unable_to_seek);
if (BSD_BBSIZE != read (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
- fatal (unable_to_read);
+ fatal (cxt, unable_to_read);
memmove (d,
&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
}
static int
-xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
+xbsd_writelabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d)
{
unsigned int sector;
#if defined (__alpha__) && BSD_LABELSECTOR == 0
alpha_bootblock_checksum (disklabelbuffer);
if (lseek (cxt->dev_fd, (off_t) 0, SEEK_SET) == -1)
- fatal (unable_to_seek);
+ fatal (cxt, unable_to_seek);
if (BSD_BBSIZE != write (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
- fatal (unable_to_write);
+ fatal (cxt, unable_to_write);
#else
if (lseek (cxt->dev_fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
SEEK_SET) == -1)
- fatal (unable_to_seek);
+ fatal (cxt, unable_to_seek);
if (sizeof (struct xbsd_disklabel) != write (cxt->dev_fd, d, sizeof (struct xbsd_disklabel)))
- fatal (unable_to_write);
+ fatal (cxt, unable_to_write);
#endif
sync_disks ();
#define BSD_D_CHAIN 0x10 /* can do back-back transfers */
#define BSD_D_DOSPART 0x20 /* within MSDOS partition */
-extern void bsd_command_prompt(void);
-extern int check_osf_label(void);
-extern int btrydev(char * dev);
-extern void xbsd_print_disklabel(int);
+extern void bsd_command_prompt(struct fdisk_context *cxt);
+extern int check_osf_label(struct fdisk_context *cxt);
+extern int btrydev(struct fdisk_context *cxt);
+extern void xbsd_print_disklabel(struct fdisk_context *cxt, int);
#endif /* FDISK_BSD_LABEL_H */
/* Allocate a buffer and read a partition table sector */
-static void read_pte(int fd, int pno, unsigned long long offset)
+static void read_pte(struct fdisk_context *cxt, int pno, unsigned long long offset)
{
struct pte *pe = &ptes[pno];
pe->offset = offset;
pe->sectorbuffer = xmalloc(sector_size);
- read_sector(fd, offset, pe->sectorbuffer);
+ read_sector(cxt, offset, pe->sectorbuffer);
pe->changed = 0;
pe->part_table = pe->ext_pointer = NULL;
}
warn_alignment();
}
-static void read_extended(int ext)
+static void read_extended(struct fdisk_context *cxt, int ext)
{
int i;
struct pte *pex;
return;
}
- read_pte(cxt->dev_fd, partitions, extended_offset + get_start_sect(p));
+ read_pte(cxt, partitions, extended_offset + get_start_sect(p));
if (!extended_offset)
extended_offset = get_start_sect(p);
}
}
-int check_dos_label(void)
+int check_dos_label(struct fdisk_context *cxt)
{
int i;
fprintf(stderr, _("Ignoring extra extended "
"partition %d\n"), i + 1);
else
- read_extended(i);
+ read_extended(cxt, i);
}
}
}
}
-void dos_write_table(void)
+void dos_write_table(struct fdisk_context *cxt)
{
int i;
}
if (MBRbuffer_changed) {
write_part_table_flag(MBRbuffer);
- write_sector(cxt->dev_fd, 0, MBRbuffer);
+ write_sector(cxt, 0, MBRbuffer);
}
/* EBR (logical partitions) */
for (i = 4; i < partitions; i++) {
if (pe->changed) {
write_part_table_flag(pe->sectorbuffer);
- write_sector(cxt->dev_fd, pe->offset, pe->sectorbuffer);
+ write_sector(cxt, pe->offset, pe->sectorbuffer);
}
}
}
extern void dos_print_mbr_id(void);
extern void dos_set_mbr_id(void);
extern void dos_delete_partition(int i);
-extern int check_dos_label(void);
+extern int check_dos_label(struct fdisk_context *cxt);
extern int is_dos_partition(int t);
extern void dos_init(void);
extern void dos_add_partition(int n, int sys);
extern void dos_new_partition(void);
-extern void dos_write_table(void);
+extern void dos_write_table(struct fdisk_context *cxt);
#endif
}
void
-sgi_list_table(int xtra) {
+sgi_list_table(struct fdisk_context *cxt, int xtra) {
int i, w;
int kpi = 0; /* kernel partition ID */
char *type;
sgiinfo *fill_sgiinfo(void);
void
-sgi_write_table(void) {
+sgi_write_table(struct fdisk_context *cxt) {
sgilabel->csum = 0;
sgilabel->csum = SSWAP32(two_s_complement_32bit_sum(
(unsigned int*)sgilabel,
assert(two_s_complement_32bit_sum(
(unsigned int*)sgilabel, sizeof(*sgilabel)) == 0);
if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0)
- fatal(unable_to_seek);
+ fatal(cxt, unable_to_seek);
if (write(cxt->dev_fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE)
- fatal(unable_to_write);
+ fatal(cxt, unable_to_write);
if (! strncmp((char *) sgilabel->directory[0].vol_file_name, "sgilabel", 8)) {
/*
* keep this habit of first writing the "sgilabel".
int infostartblock = SSWAP32(sgilabel->directory[0].vol_file_start);
if (lseek(cxt->dev_fd, (off_t) infostartblock*
SECTOR_SIZE, SEEK_SET) < 0)
- fatal(unable_to_seek);
+ fatal(cxt, unable_to_seek);
if (write(cxt->dev_fd, info, SECTOR_SIZE) != SECTOR_SIZE)
- fatal(unable_to_write);
+ fatal(cxt, unable_to_write);
free(info);
}
}
}
void
-create_sgilabel(void)
+create_sgilabel(struct fdisk_context *cxt)
{
struct hd_geometry geometry;
struct {
extern struct systypes sgi_sys_types[];
extern void sgi_nolabel( void );
extern int check_sgi_label( void );
-extern void sgi_list_table( int xtra );
+extern void sgi_list_table( struct fdisk_context *cxt, int xtra );
extern int sgi_change_sysid( int i, int sys );
extern unsigned int sgi_get_start_sector( int i );
extern unsigned int sgi_get_num_sectors( int i );
extern int sgi_get_sysid( int i );
extern void sgi_delete_partition( int i );
extern void sgi_add_partition( int n, int sys );
-extern void create_sgilabel( void );
+extern void create_sgilabel( struct fdisk_context *cxt );
extern void create_sgiinfo( void );
extern int verify_sgi( int verbose );
-extern void sgi_write_table( void );
+extern void sgi_write_table( struct fdisk_context *cxt );
extern void sgi_set_ilfact( void );
extern void sgi_set_rspeed( void );
extern void sgi_set_pcylcount( void );
return 1;
}
-void create_sunlabel(void)
+void create_sunlabel(struct fdisk_context *cxt)
{
struct hd_geometry geometry;
unsigned long long llsectors, llcyls;
return 1;
}
-void sun_list_table(int xtra)
+void sun_list_table(struct fdisk_context *cxt, int xtra)
{
int i, w;
char *type;
_("Number of physical cylinders")));
}
-void sun_write_table(void)
+void sun_write_table(struct fdisk_context *cxt)
{
unsigned short *ush = (unsigned short *)sunlabel;
unsigned short csum = 0;
csum ^= *ush++;
sunlabel->cksum = csum;
if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0)
- fatal(unable_to_seek);
+ fatal(cxt, unable_to_seek);
if (write(cxt->dev_fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE)
- fatal(unable_to_write);
+ fatal(cxt, unable_to_write);
}
int sun_get_sysid(int i)
extern struct systypes sun_sys_types[];
extern int check_sun_label(void);
extern void sun_nolabel(void);
-extern void create_sunlabel(void);
+extern void create_sunlabel(struct fdisk_context *cxt);
extern void sun_delete_partition(int i);
extern int sun_change_sysid(int i, uint16_t sys);
-extern void sun_list_table(int xtra);
+extern void sun_list_table(struct fdisk_context *cxt, int xtra);
extern void verify_sun(void);
extern void add_sun_partition(int n, int sys);
-extern void sun_write_table(void);
+extern void sun_write_table(struct fdisk_context *cxt);
extern void sun_set_alt_cyl(void);
extern void sun_set_ncyl(int cyl);
extern void sun_set_xcyl(void);