summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisksgilabel.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/fdisksgilabel.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/fdisksgilabel.c')
-rw-r--r--fdisk/fdisksgilabel.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index c2ef06d13..3ef9d69c2 100644
--- a/fdisk/fdisksgilabel.c
+++ b/fdisk/fdisksgilabel.c
@@ -178,7 +178,7 @@ check_sgi_label() {
}
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;
@@ -350,7 +350,7 @@ create_sgiinfo(void) {
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,
@@ -358,9 +358,9 @@ sgi_write_table(void) {
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".
@@ -370,9 +370,9 @@ sgi_write_table(void) {
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);
}
}
@@ -682,7 +682,7 @@ sgi_add_partition(int n, int sys)
}
void
-create_sgilabel(void)
+create_sgilabel(struct fdisk_context *cxt)
{
struct hd_geometry geometry;
struct {