Commit c93be5b1 authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman

staging: usbip: userspace: usbip.c: add log option

Add option for logging with syslog, and default to use stderr for
error and info messages.
Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f2fb62b3
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <getopt.h> #include <getopt.h>
#include <syslog.h>
#include "usbip_common.h" #include "usbip_common.h"
#include "usbip.h" #include "usbip.h"
...@@ -33,7 +34,7 @@ static int usbip_version(int argc, char *argv[]); ...@@ -33,7 +34,7 @@ static int usbip_version(int argc, char *argv[]);
static const char usbip_version_string[] = PACKAGE_STRING; static const char usbip_version_string[] = PACKAGE_STRING;
static const char usbip_usage_string[] = static const char usbip_usage_string[] =
"usbip [--debug] [version]\n" "usbip [--debug] [--log] [version]\n"
" [help] <command> <args>\n"; " [help] <command> <args>\n";
static void usbip_usage(void) static void usbip_usage(void)
...@@ -138,12 +139,15 @@ int main(int argc, char *argv[]) ...@@ -138,12 +139,15 @@ int main(int argc, char *argv[])
{ {
static const struct option opts[] = { static const struct option opts[] = {
{ "debug", no_argument, NULL, 'd' }, { "debug", no_argument, NULL, 'd' },
{ NULL, 0, NULL, 0 } { "log", no_argument, NULL, 'l' },
{ NULL, 0, NULL, 0 }
}; };
char *cmd; char *cmd;
int opt; int opt;
int i, rc = -1; int i, rc = -1;
usbip_use_stderr = 1;
opterr = 0; opterr = 0;
for (;;) { for (;;) {
opt = getopt_long(argc, argv, "+d", opts, NULL); opt = getopt_long(argc, argv, "+d", opts, NULL);
...@@ -154,7 +158,10 @@ int main(int argc, char *argv[]) ...@@ -154,7 +158,10 @@ int main(int argc, char *argv[])
switch (opt) { switch (opt) {
case 'd': case 'd':
usbip_use_debug = 1; usbip_use_debug = 1;
usbip_use_stderr = 1; break;
case 'l':
usbip_use_syslog = 1;
openlog("", LOG_PID, LOG_USER);
break; break;
default: default:
goto err_out; goto err_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment