[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] procfs: provide a more meaningful response to fsys_get_optio
From: |
Justus Winter |
Subject: |
[PATCH 6/6] procfs: provide a more meaningful response to fsys_get_options |
Date: |
Fri, 28 Jun 2013 18:37:45 +0200 |
Implement our own netfs_append_args function that provides the
appropriate command line flags if the current values differ from the
default values.
* procfs/main.c (netfs_append_args): New function.
---
procfs/main.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/procfs/main.c b/procfs/main.c
index 3e53307..bcf9590 100644
--- a/procfs/main.c
+++ b/procfs/main.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <error.h>
#include <argp.h>
+#include <argz.h>
#include <hurd/netfs.h>
#include <ps.h>
#include "procfs.h"
@@ -193,6 +194,47 @@ struct argp netfs_runtime_argp_ = {
/* Used by netfs_set_options to handle runtime option parsing. */
struct argp *netfs_runtime_argp = &netfs_runtime_argp_;
+/* Return an argz string describing the current options. Fill *ARGZ
+ with a pointer to newly malloced storage holding the list and *LEN
+ to the length of that storage. */
+error_t
+netfs_append_args (char **argz, size_t *argz_len)
+{
+ char buf[80];
+ error_t err = 0;
+
+#define FOPT(opt, default, fmt, args...) \
+ do { \
+ if (! err && opt != default) \
+ { \
+ snprintf (buf, sizeof buf, fmt, ## args); \
+ err = argz_add (argz, argz_len, buf); \
+ } \
+ } while (0)
+
+ FOPT (opt_clk_tck, OPT_CLK_TCK,
+ "--clk-tck=%d", opt_clk_tck);
+
+ FOPT (opt_stat_mode, OPT_STAT_MODE,
+ "--stat-mode=%o", opt_stat_mode);
+
+ FOPT (opt_fake_self, OPT_FAKE_SELF,
+ "--fake-self=%d", opt_fake_self);
+
+ FOPT (opt_anon_owner, OPT_ANON_OWNER,
+ "--anonymous-owner=%d", opt_anon_owner);
+
+ FOPT (opt_kernel_pid, OPT_KERNEL_PID,
+ "--kernel-process=%d", opt_kernel_pid);
+
+#undef FOPT
+
+ if (! err)
+ err = netfs_append_std_options (argz, argz_len);
+
+ return err;
+}
+
error_t
root_make_node (struct ps_context *pc, struct node **np)
{
--
1.7.10.4
- some work on procfs, Justus Winter, 2013/06/27
- [PATCH 1/6] procfs: fix the error handling in argp_parser, Justus Winter, 2013/06/27
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Emilio Pozuelo Monfort, 2013/06/27
- [PATCH 1/6] procfs: fix the error handling in argp_parser, Justus Winter, 2013/06/28
- [PATCH 3/6] procfs: enable fsys_set_options, Justus Winter, 2013/06/28
- [PATCH 2/6] procfs: keep old config values if the parsing fails, Justus Winter, 2013/06/28
- [PATCH 5/6] procfs: define macros for the default argument values, Justus Winter, 2013/06/28
- [PATCH 4/6] procfs: handle the --update parameter, Justus Winter, 2013/06/28
- [PATCH 6/6] procfs: provide a more meaningful response to fsys_get_options,
Justus Winter <=
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Samuel Thibault, 2013/06/29
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Justus Winter, 2013/06/29
- Re: [PATCH 1/6] procfs: fix the error handling in argp_parser, Samuel Thibault, 2013/06/30
[PATCH 2/6] procfs: keep old config values if the parsing fails, Justus Winter, 2013/06/27
[PATCH 3/6] procfs: enable fsys_set_options, Justus Winter, 2013/06/27
[PATCH 5/6] procfs: define macros for the default argument values, Justus Winter, 2013/06/27
[PATCH 6/6] procfs: provide a more meaningful response to fsys_get_options, Justus Winter, 2013/06/27
[PATCH 4/6] procfs: handle the --update parameter, Justus Winter, 2013/06/27
Re: some work on procfs, Samuel Thibault, 2013/06/29