Skip to content
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: use /data/local/tmp as temprary dir on Android #2828

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

simpleton
Copy link
Contributor

/tmp does not exist on Android and cannot be created by regular applications.
Use /data/local/tmp as an alternate tmpDir.

Test Plan

before

Test bfptrace on Android device. bpftrace raises runtime_error due to the /tmp is not available and creatable.

$ ./bpftrace  -e 't:timer:hrtimer_start { @[ksym(args->function)] = count(); }'
terminating with uncaught exception of type std::runtime_error: creating temporary path for kheaders.tar.xz failed
Aborted

after

runtime_error got migrated.

$ bpftrace  -e 't:timer:hrtimer_start { @[ksym(args->function)] = count(); }'
Attaching 1 probe...
[..]

src/utils.cpp Show resolved Hide resolved
Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a CHANGELOG entry (see https://github.com/iovisor/bpftrace/blob/master/docs/developers.md#changelog) but lgtm otherwise

@tnovak
Copy link
Contributor

tnovak commented Nov 15, 2023

FYI bpftrace will use the TMPDIR env variable if it exists, which is normally[*] set to /data/local/tmp on Android:

$ adb shell echo \$TMPDIR
/data/local/tmp

[*] It's set by adbd here, so this applies to adb shell but may not if, say, invoking bpftrace from another process or clearing the environment.

@danobi danobi merged commit 3e368fa into bpftrace:master Nov 15, 2023
21 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants