> The option -m is used to specify the regex string. -c is used to
> specify case insensitive matching. -i was already taken.
I guess that's cool if someone really wanted to use the full power of
regexes.
> In order to restore only a single folder somewhere in the btrfs
> tree, it is unfortunately neccessary to construct a slightly
> nontrivial regex, e.g.:
>
> restore -m '^/(|home(|/username(|/Desktop(|/.*))))$' /dev/sdb2 /output
But that example is just bonkers and suggests that we should also
support globs for fnmatch(3). (-g is for glob? :))
> + const char *match_regstr = NULL;
> + int match_cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
> + regex_t match_reg, *mreg = NULL;
> + char reg_err[256];
> + if (match_regstr) {
> + ret = regcomp(&match_reg, match_regstr, match_cflags);
> + if (ret) {
> + regerror(ret, &match_reg, reg_err, sizeof(reg_err));
> + fprintf(stderr, "Regex compile failed: %s\n", reg_err);
> + goto out;
> + }
> + mreg = &match_reg;
> + }
And this should probably be in a helper function. Especially if it also
grows fnmatch() support.
- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html