Merge "NetBpfLoad - log Tethering Apex version" into main
This commit is contained in:
commit
2fe0abc95c
1 changed files with 56 additions and 1 deletions
|
|
@ -169,9 +169,62 @@ int writeProcSysFile(const char *filename, const char *value) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define APEX_MOUNT_POINT "/apex/com.android.tethering"
|
||||
const char * const platformBpfLoader = "/system/bin/bpfloader";
|
||||
const char * const platformNetBpfLoad = "/system/bin/netbpfload";
|
||||
const char * const apexNetBpfLoad = "/apex/com.android.tethering/bin/netbpfload";
|
||||
const char * const apexNetBpfLoad = APEX_MOUNT_POINT "/bin/netbpfload";
|
||||
|
||||
int logTetheringApexVersion(void) {
|
||||
char * found_blockdev = NULL;
|
||||
FILE * f = NULL;
|
||||
char buf[4096];
|
||||
|
||||
f = fopen("/proc/mounts", "re");
|
||||
if (!f) return 1;
|
||||
|
||||
// /proc/mounts format: block_device [space] mount_point [space] other stuff... newline
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
char * blockdev = buf;
|
||||
char * space = strchr(blockdev, ' ');
|
||||
if (!space) continue;
|
||||
*space = '\0';
|
||||
char * mntpath = space + 1;
|
||||
space = strchr(mntpath, ' ');
|
||||
if (!space) continue;
|
||||
*space = '\0';
|
||||
if (strcmp(mntpath, APEX_MOUNT_POINT)) continue;
|
||||
found_blockdev = strdup(blockdev);
|
||||
break;
|
||||
}
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
||||
if (!found_blockdev) return 2;
|
||||
ALOGD("Found Tethering Apex mounted from blockdev %s", found_blockdev);
|
||||
|
||||
f = fopen("/proc/mounts", "re");
|
||||
if (!f) { free(found_blockdev); return 3; }
|
||||
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
char * blockdev = buf;
|
||||
char * space = strchr(blockdev, ' ');
|
||||
if (!space) continue;
|
||||
*space = '\0';
|
||||
char * mntpath = space + 1;
|
||||
space = strchr(mntpath, ' ');
|
||||
if (!space) continue;
|
||||
*space = '\0';
|
||||
if (strcmp(blockdev, found_blockdev)) continue;
|
||||
if (strncmp(mntpath, APEX_MOUNT_POINT "@", strlen(APEX_MOUNT_POINT "@"))) continue;
|
||||
char * at = strchr(mntpath, '@');
|
||||
if (!at) continue;
|
||||
char * ver = at + 1;
|
||||
ALOGI("Tethering APEX version %s", ver);
|
||||
}
|
||||
fclose(f);
|
||||
free(found_blockdev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv, char * const envp[]) {
|
||||
(void)argc;
|
||||
|
|
@ -205,6 +258,8 @@ int main(int argc, char** argv, char * const envp[]) {
|
|||
ALOGW("exec '%s' fail: %d[%s]", apexNetBpfLoad, errno, strerror(errno));
|
||||
}
|
||||
|
||||
logTetheringApexVersion();
|
||||
|
||||
if (isAtLeastT && !android::bpf::isAtLeastKernelVersion(4, 9, 0)) {
|
||||
ALOGE("Android T requires kernel 4.9.");
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue