mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 10:45:02 +00:00
cgpt_wrapper: Resolve the path to "cgpt" command
Because we do not use "execvp", "cgpt.bin" is not resolved to the same directory as "cgpt". So we need to resolve the original command to its absolute path first, then append ".bin" to it. BUG=None BRANCH=None TEST="cgpt" no longer fails. Change-Id: Id22c2d97616867125e9744c00bbf527f8a176df4 Reviewed-on: https://chromium-review.googlesource.com/242294 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@google.com>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
c67b061cb5
commit
9fa6afce26
@@ -140,6 +140,23 @@ cleanup:
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
char resolved_cgpt[PATH_MAX];
|
||||
pid_t pid = getpid();
|
||||
char exe_link[40];
|
||||
|
||||
if (argc < 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(exe_link, sizeof(exe_link), "/proc/%d/exe", pid);
|
||||
memset(resolved_cgpt, 0, sizeof(resolved_cgpt));
|
||||
if (readlink(exe_link, resolved_cgpt, sizeof(resolved_cgpt) - 1) == -1) {
|
||||
perror("readlink");
|
||||
return -1;
|
||||
}
|
||||
|
||||
argv[0] = resolved_cgpt;
|
||||
|
||||
if (argc > 2 && !has_dash_D(argc, argv)) {
|
||||
const char *mtd_device = find_mtd_device(argc, argv);
|
||||
if (mtd_device) {
|
||||
|
||||
Reference in New Issue
Block a user