summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisksunlabel.c
diff options
context:
space:
mode:
authorDavidlohr Bueso2012-05-27 21:44:04 +0200
committerKarel Zak2012-06-06 10:11:41 +0200
commit7737f698508a9ad3b6aa0ee7e02cbaa646e815b6 (patch)
treef65d64499351fdfa0154489f6641079e20edf602 /fdisk/fdisksunlabel.c
parentfdisk: stop buffering welcome message (diff)
downloadkernel-qcow2-util-linux-7737f698508a9ad3b6aa0ee7e02cbaa646e815b6.tar.gz
kernel-qcow2-util-linux-7737f698508a9ad3b6aa0ee7e02cbaa646e815b6.tar.xz
kernel-qcow2-util-linux-7737f698508a9ad3b6aa0ee7e02cbaa646e815b6.zip
fdisk: use context as a parameter
This program heavily uses global variables, which isn't very elegant and can lead to nasty bugs. Modify functions that use fdisk's context current features (descriptor and path), to receive the context as a parameter instead of globally. This includes DOS, SUN, SGI and BSD label code. Another benefit that comes with this is that as the API grows all the information regarding fdisk will be accessible from this structure so we can reduce even more global variables and simply code. This patch passed: - building - regression tests - local dos/sun/bsd partition changes Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'fdisk/fdisksunlabel.c')
-rw-r--r--fdisk/fdisksunlabel.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c
index 6944824db..e94b652a6 100644
--- a/fdisk/fdisksunlabel.c
+++ b/fdisk/fdisksunlabel.c
@@ -149,7 +149,7 @@ int check_sun_label(void)
return 1;
}
-void create_sunlabel(void)
+void create_sunlabel(struct fdisk_context *cxt)
{
struct hd_geometry geometry;
unsigned long long llsectors, llcyls;
@@ -533,7 +533,7 @@ int sun_change_sysid(int i, uint16_t sys)
return 1;
}
-void sun_list_table(int xtra)
+void sun_list_table(struct fdisk_context *cxt, int xtra)
{
int i, w;
char *type;
@@ -626,7 +626,7 @@ void sun_set_pcylcount(void)
_("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;
@@ -635,9 +635,9 @@ void sun_write_table(void)
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)