Conversation
|
This pull request introduces 2 alerts when merging 90b4063 into 949082a - view on LGTM.com new alerts:
Comment posted by LGTM.com |
90b4063 to
3f52e8b
Compare
|
Force-pushed to fix the two issues pointed out by LGTM. |
|
You're right about the unescaping. I remember this was discussed when the current code was being merged, but for some reason the unescaping was left in, even though it shouldn't. Did maybe libmount behave differently in the past? Anyway, I added a patch to remove the unescaping in all places it was done, and adjusted the new patches to not do it. PTAL. |
3f52e8b to
d6e8280
Compare
| @@ -11,7 +11,6 @@ | |||
| #include "dbus-mount.h" | |||
| #include "dbus-unit.h" | |||
There was a problem hiding this comment.
this commit should probably be added to v242 still?
There was a problem hiding this comment.
Maybe the first three (refactoring, test, and cunescape removal)? I can submit separate PR.
src/shared/mount-util.c
Outdated
| iter = mnt_new_iter(MNT_ITER_FORWARD); | ||
| if (!table || !iter) | ||
| return log_oom(); | ||
|
|
There was a problem hiding this comment.
still logs at non-debug level
There was a problem hiding this comment.
This one is different, it was logging at non-debug level before, I just kept the behaviour.
There was a problem hiding this comment.
but please. let's fix this when touching that
There was a problem hiding this comment.
It seems you were right, and I added logging here, but then removed it in one of the later commits. I now fixed this during the rebase to have return -ENOMEM.
| continue; | ||
| if (!set_contains(done, path)) { | ||
| r = set_put_strdup(todo, path); | ||
| if (r < 0) |
There was a problem hiding this comment.
needs to handle EEXIST gracefully, as before
There was a problem hiding this comment.
set_put_strdup return 0 if the entry exists.
src/mount/mount-tool.c
Outdated
| for (;;) { | ||
| _cleanup_free_ char *path = NULL, *where = NULL, *dev = NULL; | ||
| int r; | ||
| r = mnt_table_parse_mtab(table, NULL); |
There was a problem hiding this comment.
maybe we should add a helper for this to libmount-util:
int mnt_table_proc_self_mount_info(struct libmnt_table **ret);which allocates the table and opens it in one go. and maybe even go one step further and also allocate an iter at the same time and return that. After all we currently always do these three steps separately, always the same way
d6e8280 to
92f1194
Compare
|
Force pushed with a bugfix (wrong return value on error), and the suggested change to add a helper function. I also added one more commit to relax the test case which fails in CI. |
92f1194 to
a3eddfd
Compare
|
I think the CI failure is again caused by old libmount version. I hope it'll pass now. |
| DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table); | ||
| DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter); | ||
|
|
||
| static inline int libmount_parse( |
There was a problem hiding this comment.
hmm, static inline? I think this should just be a regular function, it's complicated enough to warrant that.
There was a problem hiding this comment.
This was explained in the commit message that adds the function. I'll repush for the other things, and then I'll try to make the explanation clearer.
src/shared/libmount-util.h
Outdated
|
|
||
| if (source) | ||
| /* Older libmount seems to require this. */ | ||
| assert(path); |
src/test/test-libmount.c
Outdated
|
|
||
| assert_se(mnt_table_next_fs(table, iter, &fs) == 0); | ||
| r = mnt_table_next_fs(table, iter, &fs); | ||
| if (r < 0 && may_fail) { |
There was a problem hiding this comment.
can you add a comment here maybe, that says "we allow this to fail in some tests, see below", or so?
a3eddfd to
ab57b19
Compare
ab57b19 to
79d8329
Compare
|
Updated:
|
79d8329 to
8cab8c6
Compare
|
bionic-i386 fails in two places: test/TEST-29-UDEV-ID_RENAMING test/TEST-30-ONCLOCKCHANGE. |
8cab8c6 to
75b9abc
Compare
|
The Travis CI integration is having an aneurysm, so I triggered it manually: https://travis-ci.org/systemd/systemd/builds/517648222 ✅ |
| rewind(proc_self_mountinfo); | ||
|
|
||
| r = mnt_table_parse_stream(table, proc_self_mountinfo, "/proc/self/mountinfo"); | ||
| r = libmount_parse("/proc/self/mountinfo", proc_self_mountinfo, &table, &iter); |
There was a problem hiding this comment.
hmm, so i wonder about the two uses in bind_remount_recursive_with_mountinfo() and umount_recursive(). We use this when setting up a namespace environment for a service. i.e. we operate on a different root than the real one. libmount is unlikely to understand that though and will merge data from /run/mount/utab into what is read here, but that's data about host mounts, not about mounts in the little namespaced environment we are setting up. Hence, we should somehow massage libmount into not loading utab meta info here if we want to use it in an entirely generic function like these two that should make no assumptions on the context they are called in.
@karelzak can you comment on this maybe? is there a way we can use the libmount mnt_table_xyz API without it reading utab for such namespaced environments?
There was a problem hiding this comment.
@karelzak can you comment on this maybe? is there a way we can use the libmount mnt_table_xyz API without it reading utab for such namespaced environments?
Only mnt_table_parse_mtab() reads utab userspace junk.
So, all you need is to use mnt_table_parse_file(), mnt_new_table_from_file() or mnt_table_parse_stream() with "/proc/self/mountinfo" as path to the table.
And for libmount_monitor API -- the utab is enabled only if explicitly requested by mnt_monitor_enable_userspace().
There was a problem hiding this comment.
Thanks. So it seems only umount_recursive() needs changing. bind_remount_recursive_with_mountinfo() already uses mnt_table_parse_stream(). I pushed one more commit to do this.
It seems better to use just a single parsing algorithm for /proc/self/mountinfo. Also, unify the naming of variables in all places that use mnt_table_next_fs(). It makes it easier to compare the different call sites.
Same motivation as in other places: let's use a single logic to parse this. Use path_equal() to compare the path. A bug in error handling is fixed: if we failed after the GREEDY_REALLOC but before the line that sets the last item to NULL, we would jump to _cleanup_strv_free_ with the strv unterminated. Let's use GREEDY_REALLOC0 to avoid the issue.
This wraps a few common steps. It is defined as inline function instead of in a .c file to avoid having a .c file. With a .c file, we would have three choices: - either link it into libshared, but then then libshared would have to be linked to libmount. - or compile the .c file into each target separately. This has the disdvantage that configuration of every target has to be updated and stuff will be compiled multiple times anyway, which is not too different from keeping this in the header file. - or create a new convenience library just for this. This also has the disadvantage that the every target would have to be updated, and a separate library for a 10 line function seems overkill. By keeping everything in a header file, we compile this a few times, but otherwise it's the least painful option. The compiler can optimize most of the function away, because it knows if 'source' is set or not.
75b9abc to
2f2d81d
Compare
This might be a solution for #12018, once util-linux/util-linux#780 is resolved.