* [PATCH] ksmbd-tools: add missing long option in adduser/addshare/control
@ 2022-06-02 1:14 Namjae Jeon
2022-06-02 5:07 ` Hyunchul Lee
0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2022-06-02 1:14 UTC (permalink / raw)
To: linux-cifs
Cc: hyc.lee, sfrench, senozhatsky, smfrench, Namjae Jeon, David Howells
Add missing long option in adduser/addshare/control.
Reported-by: David Howells <dhowells@redhat.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
addshare/addshare.c | 11 ++++++++++-
adduser/adduser.c | 12 +++++++++++-
control/control.c | 9 ++++++++-
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/addshare/addshare.c b/addshare/addshare.c
index 4d25047..a8ba71a 100644
--- a/addshare/addshare.c
+++ b/addshare/addshare.c
@@ -54,6 +54,15 @@ static void usage(void)
exit(EXIT_FAILURE);
}
+static const struct option opts[] = {
+ {"add-share", required_argument, NULL, 'a' },
+ {"del-share", required_argument, NULL, 'd' },
+ {"update-share", required_argument, NULL, 'u' },
+ {"options", required_argument, NULL, 'o' },
+ {"version", no_argument, NULL, 'V' },
+ {"verbose", no_argument, NULL, 'v' },
+};
+
static void show_version(void)
{
printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -102,7 +111,7 @@ int main(int argc, char *argv[])
set_logger_app_name("ksmbd.addshare");
opterr = 0;
- while ((c = getopt(argc, argv, "c:a:d:u:p:o:Vvh")) != EOF)
+ while ((c = getopt_long(argc, argv, "c:a:d:u:p:o:Vvh", opts, NULL)) != EOF)
switch (c) {
case 'a':
arg_name = g_ascii_strdown(optarg, strlen(optarg));
diff --git a/adduser/adduser.c b/adduser/adduser.c
index 88b12db..60a059d 100644
--- a/adduser/adduser.c
+++ b/adduser/adduser.c
@@ -50,6 +50,16 @@ static void usage(void)
exit(EXIT_FAILURE);
}
+static const struct option opts[] = {
+ {"add-user", required_argument, NULL, 'a' },
+ {"del-user", required_argument, NULL, 'd' },
+ {"update-user", required_argument, NULL, 'u' },
+ {"password", required_argument, NULL, 'p' },
+ {"import-users", required_argument, NULL, 'i' },
+ {"version", no_argument, NULL, 'V' },
+ {"verbose", no_argument, NULL, 'v' },
+};
+
static void show_version(void)
{
printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -102,7 +112,7 @@ int main(int argc, char *argv[])
set_logger_app_name("ksmbd.adduser");
opterr = 0;
- while ((c = getopt(argc, argv, "c:i:a:d:u:p:Vvh")) != EOF)
+ while ((c = getopt_long(argc, argv, "c:i:a:d:u:p:Vvh", opts, NULL)) != EOF)
switch (c) {
case 'a':
arg_account = g_strdup(optarg);
diff --git a/control/control.c b/control/control.c
index 780a48a..3dc8c7e 100644
--- a/control/control.c
+++ b/control/control.c
@@ -23,6 +23,13 @@ static void usage(void)
exit(EXIT_FAILURE);
}
+static const struct option opts[] = {
+ {"shutdown", no_argument, NULL, 's' },
+ {"debug", required_argument, NULL, 'd' },
+ {"ksmbd-version", no_argument, NULL, 'c' },
+ {"version", no_argument, NULL, 'V' },
+};
+
static void show_version(void)
{
printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -101,7 +108,7 @@ int main(int argc, char *argv[])
}
opterr = 0;
- while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
+ while ((c = getopt_long(argc, argv, "sd:cVh", opts, NULL)) != EOF)
switch (c) {
case 's':
ret = ksmbd_control_shutdown();
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ksmbd-tools: add missing long option in adduser/addshare/control
2022-06-02 1:14 [PATCH] ksmbd-tools: add missing long option in adduser/addshare/control Namjae Jeon
@ 2022-06-02 5:07 ` Hyunchul Lee
2022-06-02 5:20 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Hyunchul Lee @ 2022-06-02 5:07 UTC (permalink / raw)
To: Namjae Jeon
Cc: linux-cifs, Steve French, Sergey Senozhatsky, Steve French,
David Howells
Hi Namjae,
2022년 6월 2일 (목) 오전 10:14, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> Add missing long option in adduser/addshare/control.
>
> Reported-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> ---
> addshare/addshare.c | 11 ++++++++++-
> adduser/adduser.c | 12 +++++++++++-
> control/control.c | 9 ++++++++-
> 3 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/addshare/addshare.c b/addshare/addshare.c
> index 4d25047..a8ba71a 100644
> --- a/addshare/addshare.c
> +++ b/addshare/addshare.c
> @@ -54,6 +54,15 @@ static void usage(void)
> exit(EXIT_FAILURE);
> }
>
> +static const struct option opts[] = {
> + {"add-share", required_argument, NULL, 'a' },
> + {"del-share", required_argument, NULL, 'd' },
> + {"update-share", required_argument, NULL, 'u' },
> + {"options", required_argument, NULL, 'o' },
> + {"version", no_argument, NULL, 'V' },
> + {"verbose", no_argument, NULL, 'v' },
> +};
We have to add the last element, {NULL, 0, NULL, 0} to avoid
Segment Fault. otherwise Looks good to me.
> +
> static void show_version(void)
> {
> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -102,7 +111,7 @@ int main(int argc, char *argv[])
> set_logger_app_name("ksmbd.addshare");
>
> opterr = 0;
> - while ((c = getopt(argc, argv, "c:a:d:u:p:o:Vvh")) != EOF)
> + while ((c = getopt_long(argc, argv, "c:a:d:u:p:o:Vvh", opts, NULL)) != EOF)
> switch (c) {
> case 'a':
> arg_name = g_ascii_strdown(optarg, strlen(optarg));
> diff --git a/adduser/adduser.c b/adduser/adduser.c
> index 88b12db..60a059d 100644
> --- a/adduser/adduser.c
> +++ b/adduser/adduser.c
> @@ -50,6 +50,16 @@ static void usage(void)
> exit(EXIT_FAILURE);
> }
>
> +static const struct option opts[] = {
> + {"add-user", required_argument, NULL, 'a' },
> + {"del-user", required_argument, NULL, 'd' },
> + {"update-user", required_argument, NULL, 'u' },
> + {"password", required_argument, NULL, 'p' },
> + {"import-users", required_argument, NULL, 'i' },
> + {"version", no_argument, NULL, 'V' },
> + {"verbose", no_argument, NULL, 'v' },
> +};
> +
> static void show_version(void)
> {
> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -102,7 +112,7 @@ int main(int argc, char *argv[])
> set_logger_app_name("ksmbd.adduser");
>
> opterr = 0;
> - while ((c = getopt(argc, argv, "c:i:a:d:u:p:Vvh")) != EOF)
> + while ((c = getopt_long(argc, argv, "c:i:a:d:u:p:Vvh", opts, NULL)) != EOF)
> switch (c) {
> case 'a':
> arg_account = g_strdup(optarg);
> diff --git a/control/control.c b/control/control.c
> index 780a48a..3dc8c7e 100644
> --- a/control/control.c
> +++ b/control/control.c
> @@ -23,6 +23,13 @@ static void usage(void)
> exit(EXIT_FAILURE);
> }
>
> +static const struct option opts[] = {
> + {"shutdown", no_argument, NULL, 's' },
> + {"debug", required_argument, NULL, 'd' },
> + {"ksmbd-version", no_argument, NULL, 'c' },
> + {"version", no_argument, NULL, 'V' },
> +};
> +
> static void show_version(void)
> {
> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -101,7 +108,7 @@ int main(int argc, char *argv[])
> }
>
> opterr = 0;
> - while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
> + while ((c = getopt_long(argc, argv, "sd:cVh", opts, NULL)) != EOF)
> switch (c) {
> case 's':
> ret = ksmbd_control_shutdown();
> --
> 2.25.1
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ksmbd-tools: add missing long option in adduser/addshare/control
2022-06-02 5:07 ` Hyunchul Lee
@ 2022-06-02 5:20 ` Namjae Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2022-06-02 5:20 UTC (permalink / raw)
To: Hyunchul Lee
Cc: linux-cifs, Steve French, Sergey Senozhatsky, Steve French,
David Howells
2022-06-02 14:07 GMT+09:00, Hyunchul Lee <hyc.lee@gmail.com>:
> Hi Namjae,
>
> 2022년 6월 2일 (목) 오전 10:14, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>>
>> Add missing long option in adduser/addshare/control.
>>
>> Reported-by: David Howells <dhowells@redhat.com>
>> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
>> ---
>> addshare/addshare.c | 11 ++++++++++-
>> adduser/adduser.c | 12 +++++++++++-
>> control/control.c | 9 ++++++++-
>> 3 files changed, 29 insertions(+), 3 deletions(-)
>>
>> diff --git a/addshare/addshare.c b/addshare/addshare.c
>> index 4d25047..a8ba71a 100644
>> --- a/addshare/addshare.c
>> +++ b/addshare/addshare.c
>> @@ -54,6 +54,15 @@ static void usage(void)
>> exit(EXIT_FAILURE);
>> }
>>
>> +static const struct option opts[] = {
>> + {"add-share", required_argument, NULL, 'a' },
>> + {"del-share", required_argument, NULL, 'd' },
>> + {"update-share", required_argument, NULL, 'u' },
>> + {"options", required_argument, NULL, 'o' },
>> + {"version", no_argument, NULL, 'V' },
>> + {"verbose", no_argument, NULL, 'v' },
>> +};
>
> We have to add the last element, {NULL, 0, NULL, 0} to avoid
> Segment Fault. otherwise Looks good to me.
Good catch. fixed it on v2.
Thanks!
>
>> +
>> static void show_version(void)
>> {
>> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
>> @@ -102,7 +111,7 @@ int main(int argc, char *argv[])
>> set_logger_app_name("ksmbd.addshare");
>>
>> opterr = 0;
>> - while ((c = getopt(argc, argv, "c:a:d:u:p:o:Vvh")) != EOF)
>> + while ((c = getopt_long(argc, argv, "c:a:d:u:p:o:Vvh", opts,
>> NULL)) != EOF)
>> switch (c) {
>> case 'a':
>> arg_name = g_ascii_strdown(optarg,
>> strlen(optarg));
>> diff --git a/adduser/adduser.c b/adduser/adduser.c
>> index 88b12db..60a059d 100644
>> --- a/adduser/adduser.c
>> +++ b/adduser/adduser.c
>> @@ -50,6 +50,16 @@ static void usage(void)
>> exit(EXIT_FAILURE);
>> }
>>
>> +static const struct option opts[] = {
>> + {"add-user", required_argument, NULL, 'a' },
>> + {"del-user", required_argument, NULL, 'd' },
>> + {"update-user", required_argument, NULL, 'u' },
>> + {"password", required_argument, NULL, 'p' },
>> + {"import-users", required_argument, NULL, 'i' },
>> + {"version", no_argument, NULL, 'V' },
>> + {"verbose", no_argument, NULL, 'v' },
>> +};
>> +
>> static void show_version(void)
>> {
>> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
>> @@ -102,7 +112,7 @@ int main(int argc, char *argv[])
>> set_logger_app_name("ksmbd.adduser");
>>
>> opterr = 0;
>> - while ((c = getopt(argc, argv, "c:i:a:d:u:p:Vvh")) != EOF)
>> + while ((c = getopt_long(argc, argv, "c:i:a:d:u:p:Vvh", opts,
>> NULL)) != EOF)
>> switch (c) {
>> case 'a':
>> arg_account = g_strdup(optarg);
>> diff --git a/control/control.c b/control/control.c
>> index 780a48a..3dc8c7e 100644
>> --- a/control/control.c
>> +++ b/control/control.c
>> @@ -23,6 +23,13 @@ static void usage(void)
>> exit(EXIT_FAILURE);
>> }
>>
>> +static const struct option opts[] = {
>> + {"shutdown", no_argument, NULL, 's' },
>> + {"debug", required_argument, NULL, 'd' },
>> + {"ksmbd-version", no_argument, NULL, 'c' },
>> + {"version", no_argument, NULL, 'V' },
>> +};
>> +
>> static void show_version(void)
>> {
>> printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
>> @@ -101,7 +108,7 @@ int main(int argc, char *argv[])
>> }
>>
>> opterr = 0;
>> - while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
>> + while ((c = getopt_long(argc, argv, "sd:cVh", opts, NULL)) !=
>> EOF)
>> switch (c) {
>> case 's':
>> ret = ksmbd_control_shutdown();
>> --
>> 2.25.1
>>
>
>
> --
> Thanks,
> Hyunchul
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-02 5:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 1:14 [PATCH] ksmbd-tools: add missing long option in adduser/addshare/control Namjae Jeon
2022-06-02 5:07 ` Hyunchul Lee
2022-06-02 5:20 ` Namjae Jeon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.