summaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/tpax_driver_ctx.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c
index b43d129..675d836 100644
--- a/src/driver/tpax_driver_ctx.c
+++ b/src/driver/tpax_driver_ctx.c
@@ -23,6 +23,12 @@
| TPAX_DRIVER_EXEC_MODE_WRITE \
| TPAX_DRIVER_EXEC_MODE_COPY)
+#define TPAX_DRIVER_WRITE_FORMAT_MASK \
+ (TPAX_DRIVER_WRITE_FORMAT_PAX \
+ | TPAX_DRIVER_WRITE_FORMAT_CPIO \
+ | TPAX_DRIVER_WRITE_FORMAT_USTAR \
+ | TPAX_DRIVER_WRITE_FORMAT_RUSTAR)
+
/* package info */
static const struct tpax_source_version tpax_src_version = {
TPAX_TAG_VER_MAJOR,
@@ -78,7 +84,7 @@ static int tpax_driver_usage(
"Synopsis:\n"
" %s\n"
" %s -r\n"
- " %s -w\n"
+ " %s -w [−x format]\n"
" %s -r -w\n\n"
"Options:\n",
program,program,program,program,program);
@@ -167,6 +173,25 @@ static int tpax_driver_usage_copy_mode(
return TPAX_USAGE;
}
+static int tpax_driver_usage_write_format(
+ int fdout,
+ const char * program,
+ const char * arg,
+ const struct argv_option ** optv,
+ struct argv_meta * meta)
+{
+ tpax_driver_usage(
+ fdout,program,
+ arg,optv,meta);
+
+ tpax_dprintf(
+ fdout,
+ "\nArchive format may only be specified "
+ "in write mode.\n");
+
+ return TPAX_USAGE;
+}
+
static int tpax_driver_error_not_implemented(
int fdout,
const char * program,
@@ -295,6 +320,20 @@ int tpax_get_driver_ctx(
case TAG_COPY:
cctx.drvflags |= TPAX_DRIVER_EXEC_MODE_COPY;
break;
+
+ case TAG_FORMAT:
+ cctx.drvflags &= ~(uint64_t)(TPAX_DRIVER_WRITE_FORMAT_MASK);
+
+ if (!strcmp(entry->arg,"pax"))
+ cctx.drvflags |= TPAX_DRIVER_WRITE_FORMAT_PAX;
+ else if (!strcmp(entry->arg,"cpio"))
+ cctx.drvflags |= TPAX_DRIVER_WRITE_FORMAT_CPIO;
+ else if (!strcmp(entry->arg,"ustar"))
+ cctx.drvflags |= TPAX_DRIVER_WRITE_FORMAT_USTAR;
+ else if (!strcmp(entry->arg,"rustar"))
+ cctx.drvflags |= TPAX_DRIVER_WRITE_FORMAT_RUSTAR;
+
+ break;
}
} else {
operand = entry;
@@ -372,6 +411,35 @@ int tpax_get_driver_ctx(
break;
}
+ /* archive format vs. execution mode*/
+ switch (cctx.drvflags & TPAX_DRIVER_EXEC_MODE_MASK) {
+ case TPAX_DRIVER_EXEC_MODE_WRITE:
+ if (!(cctx.drvflags & TPAX_DRIVER_WRITE_FORMAT_MASK))
+ cctx.drvflags |= TPAX_DRIVER_WRITE_FORMAT_USTAR;
+ break;
+
+ default:
+ if (cctx.drvflags & TPAX_DRIVER_WRITE_FORMAT_MASK)
+ return tpax_driver_usage_write_format(
+ fdctx->fderr,program,
+ entry->arg,optv,meta);
+ }
+
+ /* not implemented archive format(s) */
+ switch (cctx.drvflags & TPAX_DRIVER_WRITE_FORMAT_MASK) {
+ case TPAX_DRIVER_WRITE_FORMAT_PAX:
+ return tpax_driver_error_not_implemented(
+ fdctx->fderr,program,"the pax format",meta);
+
+ case TPAX_DRIVER_WRITE_FORMAT_CPIO:
+ return tpax_driver_error_not_implemented(
+ fdctx->fderr,program,"the cpio format",meta);
+
+ default:
+ break;
+ }
+
+ /* driver ctx */
if (!(ctx = tpax_driver_ctx_alloc(meta,fdctx,&cctx,nunits))) {
if (cctx.drvflags & TPAX_DRIVER_EXEC_MODE_COPY)
close(fddst);