((type *) blkid_probe_get_buffer((_pr),\
(_mag)->kboff << 10, sizeof(type)))
+
+extern void blkid_probe_chain_reset_vals(blkid_probe pr, struct blkid_chain *chn);
+extern int blkid_probe_chain_copy_vals(blkid_probe pr, struct blkid_chain *chn,
+ struct blkid_prval *vals, int nvals);
+extern struct blkid_prval *blkid_probe_assign_value(blkid_probe pr, const char *name);
+extern void blkid_probe_append_vals(blkid_probe pr, struct blkid_prval *vals, int nvals);
+
+
extern int blkid_probe_set_value(blkid_probe pr, const char *name,
unsigned char *data, size_t len);
extern int blkid_probe_vsprintf_value(blkid_probe pr, const char *name,
free(pr);
}
+/*
+ * Removes chain values from probing result.
+ */
+void blkid_probe_chain_reset_vals(blkid_probe pr, struct blkid_chain *chn)
+{
+ int nvals = pr->nvals;
+ int i, x;
+
+ for (x = 0, i = 0; i < pr->nvals; i++) {
+ struct blkid_prval *v = &pr->vals[i];
+
+ if (v->chain != chn && x == i) {
+ x++;
+ continue;
+ }
+ if (v->chain == chn) {
+ --nvals;
+ continue;
+ }
+ memcpy(&pr->vals[x++], v, sizeof(struct blkid_prval));
+ }
+ pr->nvals = nvals;
+}
+
+/*
+ * Copies chain values from probing result to @vals, the max size of @vals is
+ * @nvals and returns real number of values.
+ */
+int blkid_probe_chain_copy_vals(blkid_probe pr, struct blkid_chain *chn,
+ struct blkid_prval *vals, int nvals)
+{
+ int i, x;
+
+ for (x = 0, i = 0; i < pr->nvals && x < nvals; i++) {
+ struct blkid_prval *v = &pr->vals[i];
+
+ if (v->chain != chn)
+ continue;
+ memcpy(&vals[x++], v, sizeof(struct blkid_prval));
+ }
+ return x;
+}
+
+/*
+ * Appends values from @vals to the probing result
+ */
+void blkid_probe_append_vals(blkid_probe pr, struct blkid_prval *vals, int nvals)
+{
+ int i = 0;
+
+ while (i < nvals && pr->nvals < BLKID_NVALS) {
+ memcpy(&pr->vals[pr->nvals++], &vals[i++],
+ sizeof(struct blkid_prval));
+ }
+}
+
+
static void blkid_probe_reset_vals(blkid_probe pr)
{
memset(pr->vals, 0, sizeof(pr->vals));
return pr->nvals;
}
-
-static struct blkid_prval *blkid_probe_assign_value(
+struct blkid_prval *blkid_probe_assign_value(
blkid_probe pr, const char *name)
{
struct blkid_prval *v;
v = &pr->vals[pr->nvals];
v->name = name;
+ v->chain = pr->cur_chain;
pr->nvals++;
- DBG(DEBUG_LOWPROBE, printf("assigning %s\n", name));
+ DBG(DEBUG_LOWPROBE,
+ printf("assigning %s [%s]\n", name, v->chain->driver->name));
return v;
}