diff options
author | Karel Zak | 2013-06-25 15:58:36 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-16 16:47:04 +0200 |
commit | c37ebc12a5d7fd9c824a727215ceeb7f0243d9c3 (patch) | |
tree | 6aedf7d74a2c75902405d389a197d8c58c3e550a /fdisks/fdiskdoslabel.c | |
parent | fdisk: (dos) add dos menu callback (diff) | |
download | kernel-qcow2-util-linux-c37ebc12a5d7fd9c824a727215ceeb7f0243d9c3.tar.gz kernel-qcow2-util-linux-c37ebc12a5d7fd9c824a727215ceeb7f0243d9c3.tar.xz kernel-qcow2-util-linux-c37ebc12a5d7fd9c824a727215ceeb7f0243d9c3.zip |
fdisk: cleanup header file
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdiskdoslabel.c')
-rw-r--r-- | fdisks/fdiskdoslabel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index 84c4a3431..67199eaea 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -175,6 +175,24 @@ static int get_partition_unused_primary(struct fdisk_context *cxt) } } +static int seek_sector(struct fdisk_context *cxt, sector_t secno) +{ + off_t offset = (off_t) secno * cxt->sector_size; + + return lseek(cxt->dev_fd, offset, SEEK_SET) == (off_t) -1 ? -errno : 0; +} + +static int read_sector(struct fdisk_context *cxt, sector_t secno, + unsigned char *buf) +{ + int rc = seek_sector(cxt, secno); + + if (rc < 0) + return rc; + + return read(cxt->dev_fd, buf, cxt->sector_size) != + (ssize_t) cxt->sector_size ? -errno : 0; +} /* Allocate a buffer and read a partition table sector */ static int read_pte(struct fdisk_context *cxt, int pno, sector_t offset) |