-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: share internal API symbols #2437
Conversation
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
This pull request didn't trigger Jenkins as its author isn't in the whitelist. An organization member must perform one of the following:
Those commands are simple Github comments of the format: "jenkins: COMMAND" |
jenkins: test this please |
1 similar comment
jenkins: test this please |
@2xsec, just ping me when you think this branch is ready to be merged. :) |
OK^^ |
Note, that we should keep symbols that are only used by the tools restricted to the tools, i.e. they should not appear in the dependency list or files for the shared library itself. :) |
Also, in case you're at OSS NA or OSS EU, or Linux Plumbers you've earned a drink. :) |
Dear Mr.Brauner, All works are finished. Some tools have still issues related logs. But I think it is not critical issue. I'll fix them later. And some apis are still duplicated like lxc_tool_monitord_spawn, lxc_tool_check_inherited in lxc_monitor.c. Please let us know your opinion. Thanks^^ |
Please, no Mr. necessary I'm far away from that. :) |
Hm, |
I'll check it. |
@2xsec, can you merge the last commit into the other |
@brauner, I didn't understand. How do I for that? |
@2xsec, |
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
@brauner It's done. But, push is failed. guybrush@nt900x5t:~/Project/github/lxc$ git push origin bugfix |
@2xsec use |
@brauner Thanks^^ |
apparmor-mount TC is failed. I'll check it again. FAIL: lxc-tests: /usr/bin/lxc-test-apparmor-mount |
No, you can ignore that error. It's caused by:
|
@brauner ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically just nits and questions. Otherwise lgtm. Once those things are addressed I'll merge.
src/lxc/tools/lxc_autostart.c
Outdated
if (! p1 && ! str_ptr) | ||
return 1; | ||
if (! p1 && ! *str_ptr) | ||
if (!p1 && !str_ptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're trying to replace the logic exactly shouldn't this be:
if (!p1 && !str_ptr || !p1 && !*str_ptr)
or
if (!p1 && (!str_ptr || !*str_ptr))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I fixed it.
src/lxc/tools/lxc_autostart.c
Outdated
if (strcmp(it1->elem, it2->elem) == 0) | ||
return 1; | ||
} | ||
if (!strncmp(it1->elem, str_ptr, strlen(it1->elem))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use strncmp() == 0
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
src/lxc/tools/lxc_autostart.c
Outdated
@@ -372,7 +361,7 @@ int main(int argc, char *argv[]) | |||
qsort(&containers[0], count, sizeof(struct lxc_container *), cmporder); | |||
|
|||
if (cmd_groups_list && my_args.all) | |||
fprintf(stderr, "Specifying -a (all) with -g (groups) doesn't make sense. All option overrides.\n"); | |||
ERROR("Specifying -a (all) with -g (groups) doesn't make sense. All option overrides."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the trailing .
while you're at it. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
src/lxc/tools/lxc_autostart.c
Outdated
@@ -404,27 +393,28 @@ int main(int argc, char *argv[]) | |||
/* We're done with this container */ | |||
if ( lxc_container_put(c) > 0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the unnecessary spaces here as well. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
src/lxc/tools/lxc_config.c
Outdated
@@ -60,21 +61,25 @@ int main(int argc, char *argv[]) | |||
struct lxc_config_items *i; | |||
const char *value; | |||
|
|||
if (argc < 2 || strcmp(argv[1], "-h") == 0 || | |||
strcmp(argv[1], "--help") == 0) | |||
if (argc < 2 || !strncmp(argv[1], "-h", strlen(argv[1])) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== 0
syntax, please. It's in our coding style. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
src/lxc/tools/lxc_create.c
Outdated
if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype)) && | ||
strncmp(a->bdevtype, "loop", strlen(a->bdevtype)) && | ||
strncmp(a->bdevtype, "rbd", strlen(a->bdevtype))) { | ||
ERROR("Filesystem type and size are only valid with block devices"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!= 0
syntax, please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
src/lxc/tools/lxc_create.c
Outdated
if (!my_args.bdevtype) | ||
my_args.bdevtype = "_unset"; | ||
|
||
if (!validate_bdev_args(&my_args)) | ||
exit(EXIT_FAILURE); | ||
|
||
if (strcmp(my_args.bdevtype, "none") == 0) | ||
if (!strncmp(my_args.bdevtype, "none", strlen(my_args.bdevtype))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm note sure those are necessary, strcmp()
should be sufficient and safe and spares us a strlen()
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using strncmp instead of strcmp to prevent bof attack habitually. But input validation and checking length for input are valid, there is no problem. In case of this, it is sufficient and safe. You are right.
src/lxc/tools/lxc_device.c
Outdated
if (p < 0) { | ||
fprintf(stderr, "failed to fork task.\n"); | ||
ERROR("Failed to fork task."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, can you remove the trailing .
as well :)
@@ -1290,3 +1323,51 @@ static void ls_field_width(const struct ls *l, const size_t size, | |||
} | |||
} | |||
} | |||
|
|||
static int rm_r(char *dirname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, you could also move static int recursive_destroy(char *dirname)
from cgroups/cgfsng.c
to utils.{c,h}
and call it rm_r()
and use it in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it you mentioned after tools are merged.
src/lxc/tools/lxc_snapshot.c
Outdated
@@ -218,13 +221,13 @@ static int do_snapshot_destroy(struct lxc_container *c, char *snapname) | |||
{ | |||
bool ret; | |||
|
|||
if (strcmp(snapname, "ALL") == 0) | |||
if (!strncmp(snapname, "ALL", strlen(snapname))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== 0
syntax, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.
…ncmp Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
jenkins: test this please |
Thanks! :) |
Thanks for your review. |
Hello,
I'm working to share internal API symbols to tools.
I'll add commit for other tools to this pull request.
Before that, if you have any opinion for that, Please let us know.
Thanks.