From: Thomas Weißschuh Date: Mon, 2 Oct 2023 20:24:21 +0000 (+0200) Subject: libblkid: reset errno before calling probefuncs X-Git-Tag: v2.40-rc1~213^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1a5ad691239a8840ee8c8da003d6cdbe80d0444;p=thirdparty%2Futil-linux.git libblkid: reset errno before calling probefuncs The probers optionally use errno to communicate error details. When a leftover errno is set from libblkid internally this can confuse the probers. Signed-off-by: Thomas Weißschuh --- diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 6a11c50698..e096cf8f72 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -555,6 +555,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id, if (id->probefunc) { DBG(LOWPROBE, ul_debug( "%s: ---> call probefunc()", id->name)); + errno = 0; rc = id->probefunc(pr, mag); blkid_probe_prune_buffers(pr); if (rc < 0) { diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index e89af1b629..f64b19aef1 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -417,6 +417,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) /* final check by probing function */ if (id->probefunc) { DBG(LOWPROBE, ul_debug("\tcall probefunc()")); + errno = 0; rc = id->probefunc(pr, mag); blkid_probe_prune_buffers(pr); if (rc != BLKID_PROBE_OK) { diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c index 1fe7c63943..f19a4f2be5 100644 --- a/libblkid/src/topology/topology.c +++ b/libblkid/src/topology/topology.c @@ -183,6 +183,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn) if (id->probefunc) { DBG(LOWPROBE, ul_debug("%s: call probefunc()", id->name)); + errno = 0; rc = id->probefunc(pr, NULL); blkid_probe_prune_buffers(pr); if (rc != 0)