Re: [PATCH 1/2] blkid: stop scanning on I/O error

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

 



On Wed, Mar 19, 2014 at 02:50:55PM +0100, Hannes Reinecke wrote:
> @@ -794,6 +801,8 @@ int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
>  		off = (mag->kboff + (mag->sboff >> 10)) << 10;
>  		buf = blkid_probe_get_buffer(pr, off, 1024);
>  
> +		if (!buf && errno)
> +			return -1;

            return -errno;

>  		if (buf && !memcmp(mag->magic,
>  				buf + (mag->sboff & 0x3ff), mag->len)) {
>  			DBG(LOWPROBE, blkid_debug("\tmagic sboff=%u, kboff=%ld",
> diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
> index c6394c4..35cfd50 100644
> --- a/libblkid/src/superblocks/superblocks.c
> +++ b/libblkid/src/superblocks/superblocks.c
> @@ -379,15 +379,22 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
>  
>  		DBG(LOWPROBE, blkid_debug("[%zd] %s:", i, id->name));
>  
> -		if (blkid_probe_get_idmag(pr, id, &off, &mag))
> +		rc = blkid_probe_get_idmag(pr, id, &off, &mag);
> +		if (rc < 0)
> +			break;
> +		if (rc > 0)
>  			continue;
>  
>  		/* final check by probing function */
>  		if (id->probefunc) {
>  			DBG(LOWPROBE, blkid_debug("\tcall probefunc()"));
> -			if (id->probefunc(pr, mag) != 0) {
> +			rc = id->probefunc(pr, mag);
> +			if (rc != 0) {
>  				blkid_probe_chain_reset_vals(pr, chn);
> -				continue;
> +				if (rc < 0)
> +					break;
> +				else
> +					continue;
>  			}
>  		}

The function superblocks_probe() has to return 'rc' (now after the
loop break it returns 1), otherwise the errors will be invisible for
superblocks_safeprobe().

The errors has to be propagated to top level function (probe.c
blkid_do_probe(), blkid_do_safeprobe(), etc).

    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