-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
utils: unpack kheaders.tar.xz if necessary #768
Conversation
When CONFIG_IKHEADERS is enabled, a tarball containing the kernel headers is available in /sys/kernel, allowing the kernel type definitions to be used even if the headers have not been separately distributed to /lib on the target. This is akin to [how bcc handles it][1], but with the new path in /sys after [2]. Notably, use the same path in /tmp, so that the tarball will be unpacked only once between the two tools. [1]: iovisor/bcc@ae92f3d [2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f7b101d33046a837c2aa4526cef28a3c785d7af2
Thanks for doing this. Could you read the /tmp directory path from $TMPDIR if it exists? If it doesn't then default to /tmp. |
Sounds reasonable. |
I added the functionality to use Without $TMPDIR set, this does:
and with
The behavior when
This codepath is only hit if none of |
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.
Mostly LGTM, couple nits
src/utils.cpp
Outdated
|
||
KernelHeaderTmpDir tmpdir{path_prefix}; | ||
|
||
FILE* tar = popen(("tar xf /sys/kernel/kheaders.tar.xz -C " + tmpdir.path).c_str(), "w"); |
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.
FILE* tar = popen(("tar xf /sys/kernel/kheaders.tar.xz -C " + tmpdir.path).c_str(), "w"); | |
FILE* tar = ::popen(("tar xf /sys/kernel/kheaders.tar.xz -C " + tmpdir.path).c_str(), "w"); |
src/utils.cpp
Outdated
return ""; | ||
} | ||
|
||
int rc = pclose(tar); |
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.
int rc = pclose(tar); | |
int rc = ::pclose(tar); |
src/utils.cpp
Outdated
|
||
std::string path; | ||
|
||
friend std::string unpack_kheaders_tar_xz(const struct utsname&); |
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.
Any reason not to instead make everything public?
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.
Yeah, I wondered that one myself when I went back to post v2 yesterday :) That should shave off a few lines of weirdness.
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.
LGTM, thanks!
When CONFIG_IKHEADERS is enabled, a tarball containing the kernel
headers is available in /sys/kernel, allowing the kernel type
definitions to be used even if the headers have not been separately
distributed to /lib on the target.
This is akin to how bcc handles it, but with the new path in /sys
after 2. Notably, use the same path in /tmp, so that the tarball will
be unpacked only once between the two tools.