Re: [PATCH] partx: support loop devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux