Util-Linux package development
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Davidlohr Bueso <dave@gnu.org>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH] partx: support loop devices
Date: Mon, 15 Aug 2011 13:58:55 +0200	[thread overview]
Message-ID: <20110815115855.GE1843@nb.net.home> (raw)
In-Reply-To: <1313381477.2509.1.camel@offbook>

On Mon, Aug 15, 2011 at 12:11:17AM -0400, Davidlohr Bueso wrote:
> @@ -800,14 +857,23 @@ int main(int argc, char **argv)
>  	if (what == ACT_ADD || what == ACT_DELETE) {
>  		struct stat x;
>  
> -		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode))
> -			errx(EXIT_FAILURE, _("%s: not a block device"), wholedisk);
> +		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode)) {

  && S_ISREG() :-)

> +			/* not a blkdev, try to associate it to a loop device */

            if (what == ACT_DELETE)
                errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);

> +			if (!loopmod_supports_parts())
> +				errx(EXIT_FAILURE, _("%s: does not support loop device partitions"), 
> +				     wholedisk);
> +			assoc_loopdev(wholedisk);
> +			wholedisk = xstrdup(lc.device);
> +		}
>  	}
>  	if ((fd = open(wholedisk, O_RDONLY)) == -1)
>  		err(EXIT_FAILURE, _("%s: open failed"), wholedisk);
>  
> -	if (what == ACT_DELETE)
> +	if (what == ACT_DELETE) {
> +		if (loopdev)
> +			errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
>  		rc = del_parts(fd, wholedisk, disk_devno, lower, upper);
> +	}

 Does it make sense to initialize loop device if ACT_DELETE is requested?

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2011-08-15 11:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-15  4:11 [PATCH] partx: support loop devices Davidlohr Bueso
2011-08-15 11:58 ` Karel Zak [this message]
2011-08-16 13:20   ` Davidlohr Bueso
2011-08-16 15:03     ` Karel Zak
2011-08-31 14:56     ` 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=20110815115855.GE1843@nb.net.home \
    --to=kzak@redhat.com \
    --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