*
* <informalexample>
* <programlisting>
- * while((blkid_do_probe(pr) == 0)
+ * while((blkid_do_probe(pr) == BLKID_PROBE_OK)
* ... use result ...
* </programlisting>
* </informalexample>
* <example>
* <title>basic case - use the first result only</title>
* <programlisting>
- * if (blkid_do_probe(pr) == 0) {
+ * if (blkid_do_probe(pr) == BLKID_PROBE_OK) {
* int nvals = blkid_probe_numof_values(pr);
* for (n = 0; n < nvals; n++) {
* if (blkid_probe_get_value(pr, n, &name, &data, &len) == 0)
* <example>
* <title>advanced case - probe for all signatures</title>
* <programlisting>
- * while (blkid_do_probe(pr) == 0) {
+ * while (blkid_do_probe(pr) == BLKID_PROBE_OK) {
* int nvals = blkid_probe_numof_values(pr);
* ...
* }
int rc = 1;
if (pr->flags & BLKID_FL_NOSCAN_DEV)
- return 1;
+ return BLKID_PROBE_NONE;
do {
struct blkid_chain *chn = pr->cur_chain;
chn = pr->cur_chain = &pr->chains[idx];
else {
blkid_probe_end(pr);
- return 1; /* all chains already probed */
+ return BLKID_PROBE_NONE; /* all chains already probed */
}
}
/* rc: -1 = error, 0 = success, 1 = no result */
rc = chn->driver->probe(pr, chn);
- } while (rc == 1);
+ } while (rc == BLKID_PROBE_NONE);
+
+ if (rc < 0)
+ return BLKID_PROBE_ERROR;
return rc;
}
chn = pr->cur_chain;
if (!chn)
- return -1;
+ return BLKID_PROBE_ERROR;
switch (chn->driver->id) {
case BLKID_CHAIN_SUBLKS:
rc = blkid_probe_lookup_value(pr, "PTMAGIC", NULL, &len);
break;
default:
- return 0;
+ return BLKID_PROBE_OK;
}
if (rc || len == 0 || off == NULL)
- return 0;
+ return BLKID_PROBE_OK;
errno = 0;
magoff = strtoumax(off, NULL, 10);
if (errno)
- return 0;
+ return BLKID_PROBE_OK;
offset = magoff + pr->off;
fd = blkid_probe_get_fd(pr);
if (fd < 0)
- return -1;
+ return BLKID_PROBE_ERROR;
if (len > sizeof(buf))
len = sizeof(buf);
rc = is_conventional(pr, offset);
if (rc < 0)
- return rc;
+ return BLKID_PROBE_ERROR;
conventional = rc == 1;
DBG(LOWPROBE, ul_debug(
offset, offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
+ return BLKID_PROBE_ERROR;
if (!dryrun && len) {
if (conventional) {
/* wipen on device */
if (write_all(fd, buf, len))
- return -1;
+ return BLKID_PROBE_ERROR;
if (fsync(fd) != 0)
- return -1;
+ return BLKID_PROBE_ERROR;
} else {
#ifdef HAVE_LINUX_BLKZONED_H
uint64_t zone_mask = ~(pr->zone_size - 1);
rc = ioctl(fd, BLKRESETZONE, &range);
if (rc < 0)
- return -1;
+ return BLKID_PROBE_ERROR;
#else
/* Should not reach here */
assert(0);
return blkid_probe_step_back(pr);
}
- return 0;
+ return BLKID_PROBE_OK;
}
/**
* blkid_probe_enable_partitions(pr, 1);
* blkid_probe_set_partitions_flags(pr, BLKID_PARTS_MAGIC);
*
- * while (blkid_do_probe(pr) == 0) {
+ * while (blkid_do_probe(pr) == BLKID_PROBE_OK) {
* const char *ostr = NULL;
* size_t len = 0;
*
int i, count = 0, rc = 0;
if (pr->flags & BLKID_FL_NOSCAN_DEV)
- return 1;
+ return BLKID_PROBE_NONE;
blkid_probe_start(pr);
done:
blkid_probe_end(pr);
if (rc < 0)
- return rc;
- return count ? 0 : 1;
+ return BLKID_PROBE_ERROR;
+
+ return count == 0 ? BLKID_PROBE_NONE : BLKID_PROBE_OK;
}
/**
int i, count = 0, rc = 0;
if (pr->flags & BLKID_FL_NOSCAN_DEV)
- return 1;
+ return BLKID_PROBE_NONE;
blkid_probe_start(pr);
done:
blkid_probe_end(pr);
if (rc < 0)
- return rc;
- return count ? 0 : 1;
+ return BLKID_PROBE_ERROR;
+
+ return count == 0 ? BLKID_PROBE_NONE : BLKID_PROBE_OK;
}
/* same sa blkid_probe_get_buffer() but works with 512-sectors */