From 6d3b4cea78b22a6562eef4256cfcc40a8d372194 Mon Sep 17 00:00:00 2001 From: Luca Dariz Date: Thu, 26 Jan 2017 22:36:16 +0100 Subject: Add trivfs_startup_debug() for easier translator development Basically it is an automation of this: http://walfield.org/pub/people/neal/papers/hurd-misc/manual-bootstrap.txt To launch a storeio translator on FILE: $ storeio -d FILE -T TYPE ARG Message-Id: <20170126213616.26846-1-luca.dariz@gmail.com> --- storeio/storeio.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'storeio') diff --git a/storeio/storeio.c b/storeio/storeio.c index 872b388f..5b8db0d3 100644 --- a/storeio/storeio.c +++ b/storeio/storeio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,8 @@ static struct argp_option options[] = {"no-file-io", 'F', 0, 0,"Never perform io via plain file io RPCs"}, {"no-fileio", 0, 0, OPTION_ALIAS | OPTION_HIDDEN}, {"enforced", 'e', 0, 0,"Never reveal underlying devices, even to root"}, + {"debug", 'd', "PATH", 0, + "Launch a standalone translator, for debug purposes"}, {"rdev", 'n', "ID", 0, "The stat rdev number for this node; may be either a" " single integer, or of the form MAJOR,MINOR"}, @@ -50,7 +53,10 @@ static struct argp_option options[] = static const char doc[] = "Translator for devices and other stores"; const char *argp_program_version = STANDARD_HURD_VERSION (storeio); - + +static bool debug=false; +static char *debug_fname=NULL; + /* Desired store parameters specified by the user. */ struct storeio_argp_params { @@ -97,6 +103,16 @@ parse_opt (int key, char *arg, struct argp_state *state) } break; + case 'd': + { + debug=true; + char *new = strdup (arg); + if (new == NULL) + return ENOMEM; + debug_fname = new; + } + break; + case ARGP_KEY_INIT: /* Now store_argp's parser will get to initialize its state. The default_type member is our input parameter to it. */ @@ -135,14 +151,26 @@ main (int argc, char *argv[]) params.dev = &device; argp_parse (&argp, argc, argv, 0, 0, ¶ms); - task_get_bootstrap_port (mach_task_self (), &bootstrap); - if (bootstrap == MACH_PORT_NULL) - error (2, 0, "Must be started as a translator"); - - /* Reply to our parent */ - err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &storeio_fsys); - if (err) - error (3, err, "trivfs_startup"); + if (debug) + { + if (debug_fname) + err = trivfs_startup_debug (debug_fname, 0, 0, 0, 0, &storeio_fsys); + else + error (3, err, "missing translated node"); + if (err) + error (3, err, "trivfs_startup_debug failed"); + } + else + { + task_get_bootstrap_port (mach_task_self (), &bootstrap); + if (bootstrap == MACH_PORT_NULL) + error (2, 0, "Must be started as a translator"); + + /* Reply to our parent */ + err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &storeio_fsys); + if (err) + error (3, err, "trivfs_startup"); + } storeio_fsys->hook = &device; -- cgit v1.2.3