summaryrefslogtreecommitdiffstats
path: root/fdisks/gpt.c
diff options
context:
space:
mode:
authorDavidlohr Bueso2012-10-27 19:23:36 +0200
committerKarel Zak2012-11-02 12:25:47 +0100
commit1961311196cdc290d5e0951f29882d42e01dadd9 (patch)
tree0dfe9b9b7585b4e3baaa1d52e9ad957d050450cb /fdisks/gpt.c
parentbuild-sys: cleanup cpu_set_t usage (diff)
downloadkernel-qcow2-util-linux-1961311196cdc290d5e0951f29882d42e01dadd9.tar.gz
kernel-qcow2-util-linux-1961311196cdc290d5e0951f29882d42e01dadd9.tar.xz
kernel-qcow2-util-linux-1961311196cdc290d5e0951f29882d42e01dadd9.zip
fdisk: gpt: write entire first sector
We were writing only 1 byte in LBA0, and GPT requires dealing with an entire sector. This bug wasn't affecting when dealing with already existing devices with GPT as we weren't writing an important part of the first sector, thus leaving it unchanged. Also use write_all() wrapper from all-io.h Acked-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'fdisks/gpt.c')
-rw-r--r--fdisks/gpt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fdisks/gpt.c b/fdisks/gpt.c
index 40cadb1cd..48397f313 100644
--- a/fdisks/gpt.c
+++ b/fdisks/gpt.c
@@ -44,6 +44,7 @@
#include "blkdev.h"
#include "bitops.h"
#include "strutils.h"
+#include "all-io.h"
#define GPT_HEADER_SIGNATURE 0x5452415020494645LL /* EFI PART */
#define GPT_HEADER_REVISION_V1_02 0x00010200
@@ -1057,8 +1058,10 @@ static int gpt_write_pmbr(struct fdisk_context *cxt)
if (offset != lseek(cxt->dev_fd, offset, SEEK_SET))
goto fail;
- if (1 == write(cxt->dev_fd, pmbr, 1))
- return 0;
+ /* pMBR covers the first sector (LBA) of the disk */
+ if (write_all(cxt->dev_fd, pmbr, cxt->sector_size))
+ goto fail;
+ return 0;
fail:
return -errno;
}