util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Uzel <petr.uzel@suse.cz>
To: Davidlohr Bueso <dave@gnu.org>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH 1/2] fdisk: gpt: write entire first sector
Date: Thu, 1 Nov 2012 09:49:07 +0100	[thread overview]
Message-ID: <20121101084906.GG3979@foxbat.suse.cz> (raw)
In-Reply-To: <1351358616.2842.2.camel@offbook>

[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]

On Sat, Oct 27, 2012 at 07:23:36PM +0200, Davidlohr Bueso wrote:
> 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
> 
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>

Acked-by: Petr Uzel <petr.uzel@suse.cz>

> ---
>  fdisks/gpt.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fdisks/gpt.c b/fdisks/gpt.c
> index 40cadb1..48397f3 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;
>  }
> -- 
> 1.7.9.5
> 
> 
> 
> 

Petr

-- 
Petr Uzel
IRC: ptr_uzl @ freenode

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2012-11-01  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-27 17:23 [PATCH 1/2] fdisk: gpt: write entire first sector Davidlohr Bueso
2012-11-01  8:49 ` Petr Uzel [this message]
2012-11-02 11:30 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121101084906.GG3979@foxbat.suse.cz \
    --to=petr.uzel@suse.cz \
    --cc=dave@gnu.org \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).