public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Carlos Maiolino <cmaiolino@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] mkfs: Refuse to initialize a misaligned device if not forced using libblkid
Date: Fri, 2 Dec 2011 06:27:54 -0500	[thread overview]
Message-ID: <20111202112754.GB17319@infradead.org> (raw)
In-Reply-To: <1322743465-17175-1-git-send-email-cmaiolino@redhat.com>

On Thu, Dec 01, 2011 at 10:44:25AM -0200, Carlos Maiolino wrote:
> This is the first patch proposal to fix the problem about the usage of
> 4k sector devices when the device is not properly aligned
> 
> The patch make mkfs to refuse to initialize a xfs filesystem if the -f
> option is not passed at the command line, and forces a 512b sector size
> if the user opt to force the device initialization
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>  mkfs/xfs_mkfs.c |   24 ++++++++++++++++++------
>  1 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index f527f3d..495c70d 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -369,8 +369,14 @@ out:
>  	return ret;
>  }
>  
> -static void blkid_get_topology(const char *device, int *sunit, int *swidth, int *sectorsize)
> +static void blkid_get_topology(
> +	const char *device,
> +	int *sunit,
> +	int *swidth,
> +	int *sectorsize,
> +	int force_overwrite)
>  {
> +
>  	blkid_topology tp;
>  	blkid_probe pr;
>  	unsigned long val;
> @@ -409,6 +415,12 @@ static void blkid_get_topology(const char *device, int *sunit, int *swidth, int
>  		fprintf(stderr,
>  			_("warning: device is not properly aligned %s\n"),
>  			device);
> +
> +		if(!force_overwrite){
> +			fprintf(stderr, _("Use -f to force usage of a misaligned device\n"));
> +			exit(EXIT_FAILURE);
> +		}
> +	*sectorsize = BBSIZE;  /* Force a 512b sector size if the device is misaligned*/
>  	}

style issues:

	- always use whitespaces beforew and after braces, except in
	  function calls e.g.

		if (!force_overwrite) {

avoid 80 character lines if possible, e.g.


		fprintf(stderr,
	_("Use -f to force usage of a misaligned device\n"));

and

	/* Force a 512b sector size if the device is misaligned */
	*sectorsize = BBSIZE;

> -		blkid_get_topology(xi->rtname, &dummy, &ft->rtswidth, &dummy);
> +		blkid_get_topology(xi->rtname, &dummy, &ft->rtswidth, &dummy, force_overwrite);

needs linebreak, too.

>  	}
>  }
>  #else /* ENABLE_BLKID */
> @@ -460,7 +472,7 @@ check_overwrite(
>  	return 0;
>  }
>  
> -static void get_topology(libxfs_init_t *xi, struct fs_topology *ft)
> +static void get_topology(libxfs_init_t *xi, struct fs_topology *ft, int force_overwrite)

same here

otherwise this looks good to me.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2011-12-02 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01 12:44 [PATCH] mkfs: Refuse to initialize a misaligned device if not forced using libblkid Carlos Maiolino
2011-12-02 11:27 ` Christoph Hellwig [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-12-02 12:14 Carlos Maiolino
2011-12-13  5:01 ` Eric Sandeen

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=20111202112754.GB17319@infradead.org \
    --to=hch@infradead.org \
    --cc=cmaiolino@redhat.com \
    --cc=xfs@oss.sgi.com \
    /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