From: Karel Zak Date: Tue, 15 Sep 2009 20:02:20 +0000 (+0200) Subject: libblkid: use superblock filter functions X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=305ad2237bd713e17a9712b30d35c8622e2f3bb7;p=util-linux libblkid: use superblock filter functions Signed-off-by: Karel Zak --- diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 0dc70ebc..529a283c 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -452,125 +452,6 @@ int blkid_probe_set_device(blkid_probe pr, int fd, return 0; } -int blkid_probe_set_request(blkid_probe pr, int flags) -{ - if (!pr) - return -1; - pr->probreq = flags; - return 0; -} - -int blkid_probe_reset_filter(blkid_probe pr) -{ - if (!pr) - return -1; - if (pr->fltr) - memset(pr->fltr, 0, BLKID_FLTR_SIZE * sizeof(unsigned long)); - blkid_probe_reset_idx(pr); - return 0; -} - -/* - * flag: - * - * BLKID_FLTR_NOTIN - probe all filesystems which are NOT IN names[] - * - * BLKID_FLTR_ONLYIN - probe filesystem which are IN names[] - */ -int blkid_probe_filter_types(blkid_probe pr, int flag, char *names[]) -{ - int i; - - if (!pr || !names) - return -1; - if (!pr->fltr) { - pr->fltr = calloc(BLKID_FLTR_SIZE, sizeof(unsigned long)); - blkid_probe_reset_idx(pr); - } else - blkid_probe_reset_filter(pr); - - if (!pr->fltr) - return -1; - - for (i = 0; i < ARRAY_SIZE(idinfos); i++) { - int has = 0; - const struct blkid_idinfo *id = idinfos[i]; - char **n; - - for (n = names; *n; n++) { - if (!strcmp(id->name, *n)) { - has = 1; - break; - } - } - /* The default is enable all filesystems, - * set relevant bitmap bit means disable the filesystem. - */ - if (flag & BLKID_FLTR_ONLYIN) { - if (!has) - blkid_bmp_set_item(pr->fltr, i); - } else if (flag & BLKID_FLTR_NOTIN) { - if (has) - blkid_bmp_set_item(pr->fltr, i); - } - } - DBG(DEBUG_LOWPROBE, printf("a new probing type-filter initialized\n")); - return 0; -} - -/* - * flag: - * - * BLKID_FLTR_NOTIN - probe all filesystems which are NOT IN "usage" - * - * BLKID_FLTR_ONLYIN - probe filesystem which are IN "usage" - * - * where the "usage" is a set of filesystem according the usage flag (crypto, - * raid, filesystem, ...) - */ -int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage) -{ - int i; - - if (!pr || !usage) - return -1; - if (!pr->fltr) { - pr->fltr = calloc(BLKID_FLTR_SIZE, sizeof(unsigned long)); - blkid_probe_reset_idx(pr); - } else - blkid_probe_reset_filter(pr); - - if (!pr->fltr) - return -1; - - for (i = 0; i < ARRAY_SIZE(idinfos); i++) { - const struct blkid_idinfo *id = idinfos[i]; - - if (id->usage & usage) { - if (flag & BLKID_FLTR_NOTIN) - blkid_bmp_set_item(pr->fltr, i); - } else if (flag & BLKID_FLTR_ONLYIN) - blkid_bmp_set_item(pr->fltr, i); - } - DBG(DEBUG_LOWPROBE, printf("a new probing usage-filter initialized\n")); - return 0; -} - - -int blkid_probe_invert_filter(blkid_probe pr) -{ - int i; - - if (!pr || !pr->fltr) - return -1; - for (i = 0; i < BLKID_FLTR_SIZE; i++) - pr->fltr[i] = ~pr->fltr[i]; - - blkid_probe_reset_idx(pr); - DBG(DEBUG_LOWPROBE, printf("probing filter inverted\n")); - return 0; -} - /* * The blkid_do_probe() calls the probe functions. This routine could be used * in a loop when you need to probe for all possible filesystems/raids. diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c index 4ad73d37..61c1bff3 100644 --- a/shlibs/blkid/src/superblocks/superblocks.c +++ b/shlibs/blkid/src/superblocks/superblocks.c @@ -437,3 +437,79 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage) return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1); } + + +/* + * DEPRECATED FUNCTIONS + */ + +/** + * blkid_probe_set_request: + * @pr: probe + * @flags: BLKID_PROBREQ_* (deprecated) or BLKID_SUBLKS_* flags + * + * Returns: 0 on success, or -1 in case of error. + * + * Deprecated: Use blkid_probe_set_superblocks_flags(). + */ +int blkid_probe_set_request(blkid_probe pr, int flags) +{ + return blkid_probe_set_superblocks_flags(pr, flags); +} + +/** + * blkid_probe_reset_filter: + * @pr: prober + * + * Returns: 0 on success, or -1 in case of error. + * + * Deprecated: Use blkid_probe_reset_superblocks_filter(). + */ +int blkid_probe_reset_filter(blkid_probe pr) +{ + return __blkid_probe_reset_filter(pr, BLKID_CHAIN_SUBLKS); +} + +/** + * blkid_probe_invert_filter: + * @pr: prober + * + * Returns: 0 on success, or -1 in case of error. + * + * Deprecated: Use blkid_probe_invert_superblocks_filter(). + */ +int blkid_probe_invert_filter(blkid_probe pr) +{ + return __blkid_probe_invert_filter(pr, BLKID_CHAIN_SUBLKS); +} + +/** + * blkid_probe_filter_types + * @pr: prober + * @flag: filter BLKID_FLTR_{NOTIN,ONLYIN} flag + * @names: NULL terminated array of probing function names (e.g. "vfat"). + * + * Returns: 0 on success, or -1 in case of error. + * + * Deprecated: Use blkid_probe_filter_superblocks_types(). + */ +int blkid_probe_filter_types(blkid_probe pr, int flag, char *names[]) +{ + return __blkid_probe_filter_types(pr, BLKID_CHAIN_SUBLKS, flag, names); +} + +/** + * blkid_probe_filter_usage + * @pr: prober + * @flag: filter BLKID_FLTR_{NOTIN,ONLYIN} flag + * @usage: BLKID_USAGE_* flags + * + * Returns: 0 on success, or -1 in case of error. + * + * Deprecated: Use blkid_probe_filter_superblocks_usage(). + */ +int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage) +{ + return blkid_probe_filter_superblocks_usage(pr, flag, usage); +} +