summaryrefslogtreecommitdiff
path: root/storeio
diff options
context:
space:
mode:
authorLuca Dariz <luca.dariz@gmail.com>2017-01-26 22:36:16 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-22 23:59:28 +0200
commit6d3b4cea78b22a6562eef4256cfcc40a8d372194 (patch)
treee788d824c27d299fdc20eceefa64d910591adc95 /storeio
parent4f653341476e7bd81475ea29316d59254d8b957e (diff)
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>
Diffstat (limited to 'storeio')
-rw-r--r--storeio/storeio.c46
1 files changed, 37 insertions, 9 deletions
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 <argp.h>
#include <argz.h>
#include <sys/sysmacros.h>
+#include <stdbool.h>
#include <hurd.h>
#include <hurd/ports.h>
@@ -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, &params);
- 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;