-
Notifications
You must be signed in to change notification settings - Fork 1.2k
lsns: minor refactoring #3006
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
lsns: minor refactoring #3006
Conversation
Functions taking LSNS_ID_ as arguments have .*_lsns_type_.* or .*_type_.* as parts of their name. This implies the prefix LSNS_TYPE_ is more consistent than LSNS_ID_. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…umerators Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…rts of get_ns_ino() get_ns_ino() returns three inode numbers. The code for the two of three, inodes for PARENT and USERNS, is moved to the new functions. So we can reuse the code in other places in lsns. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…_nsfd Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The function gets three inode numbers. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
read_related_namespaces() itself doesn't read names of new namespaces. Connecting namespaces for making a tree is the the main job the function. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…stent Signed-off-by: Masatake YAMATO <yamato@redhat.com>
In read_open_ns_inos(), a namespace is added to the list without verifying its uniqueness in the list. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
|
||
*ino = 0; | ||
if (ul_path_stat(pc, &st, 0, path) != 0) | ||
return -errno; |
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.
It seems we need to add
ul_path_statf(struct path_cxt *pc, struct stat *sb, int flags, const char *path, ...)
to lib/path.c to avoid snprintf() and the path[]. And then we can use ul_path_statf(PC, &st, 0, "ns/%s", nsname);
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.
Implemented (but not tested yet): #3007
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 chrry-pick'ed #3007 to this pull request.
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 apply the openf and statf to lsfd in another pull request.
Looks good, thanks! |
Signed-off-by: Karel Zak <kzak@redhat.com> (cherry picked from commit 9b47899)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
While inspecting #2982 and #2987, I found some areas where I could improve the readability of the source code.
Here is a figure I used during the inspection and refactoring.
