summaryrefslogtreecommitdiffstats
path: root/freebsd/sbin/nvmecontrol/comnd.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sbin/nvmecontrol/comnd.c')
-rw-r--r--freebsd/sbin/nvmecontrol/comnd.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/freebsd/sbin/nvmecontrol/comnd.c b/freebsd/sbin/nvmecontrol/comnd.c
index 47572401..0b74574b 100644
--- a/freebsd/sbin/nvmecontrol/comnd.c
+++ b/freebsd/sbin/nvmecontrol/comnd.c
@@ -27,6 +27,11 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include <getopt.h>
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -182,6 +187,16 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
char *shortopts, *p;
const struct opts *opts = f->opts;
const struct args *args = f->args;
+#ifdef __rtems__
+ struct getopt_data getopt_data;
+ memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt_long(argc, argv, shortopts, longopts, longind) \
+ getopt_long_r(argc, argv, shortopts, longopts, longind, &getopt_data)
+#endif /* __rtems__ */
if (opts == NULL)
n = 0;
@@ -194,6 +209,9 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
p = shortopts = malloc((2 * n + 3) * sizeof(char));
if (shortopts == NULL)
err(1, "shortopts memory");
+#ifdef __rtems__
+ *p++ = '+';
+#endif /* __rtems__ */
idx = 0;
for (i = 0; i < n; i++) {
lopts[i].name = opts[i].long_arg;
@@ -284,6 +302,7 @@ bad_arg:
exit(1);
}
+#ifndef __rtems__
/*
* Loads all the .so's from the specified directory.
*/
@@ -315,6 +334,7 @@ cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __u
}
closedir(d);
}
+#endif /* __rtems__ */
void
cmd_register(struct cmd *up, struct cmd *cmd)