while (1) {
static struct option long_options[] = {
- {"localdb", 1, 0, 0}, // 0
- {"exclude", 1, 0, 0}, // 1
+ {"localdb", 1, 0, 0}, // 0
+ {"exclude", 1, 0, 0}, // 1
+ {"filter", 1, 0, 0}, // 2
+ {"filter-extension", 1, 0, 0}, // 3
{NULL, 0, 0, 0},
};
case 1: // --exclude
excludes.push_back(optarg);
break;
+ case 2: // --filter
+ filter_program = optarg;
+ break;
+ case 3: // --filter-extension
+ filter_extension = optarg;
+ break;
default:
fprintf(stderr, "Unhandled long option!\n");
return 1;
using std::set;
using std::string;
-static char *const filter_program[] = {"bzip2", "-c", NULL};
+/* Default filter program is bzip2 */
+const char *filter_program = "bzip2 -c";
+const char *filter_extension = ".bz2";
static void cloexec(int fd)
{
close(fd_out);
/* Exec the filter program. */
- execvp(filter_program[0], filter_program);
+ execlp("/bin/sh", "/bin/sh", "-c", filter_program, NULL);
/* Should not reach here except for error cases. */
fprintf(stderr, "Could not exec filter: %m\n");
segment->name = generate_uuid();
- string filename = path + "/" + segment->name + ".tar.bz2";
+ string filename = path + "/" + segment->name + ".tar";
+ filename += filter_extension;
segment->file = new Tarfile(filename, segment->name);
segment->count = 0;
ObjectReference ref;
};
+/* Program through which segment data is piped before being written to file. */
+extern const char *filter_program;
+
+/* Extension which should be appended to segments written out (.tar is already
+ * included; this adds to it) */
+extern const char *filter_extension;
+
#endif // _LBS_STORE_H