mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-07 11:32:06 +00:00
Don't use getmntent_r from system's libc
Fix #5354 Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
@@ -53,32 +53,6 @@ ssize_t getline(char **buf, size_t *bufsiz, FILE *fp) {
|
||||
return getdelim(buf, bufsiz, '\n', fp);
|
||||
}
|
||||
|
||||
// Original source: https://android.googlesource.com/platform/bionic/+/master/libc/bionic/mntent.cpp
|
||||
// License: AOSP, full copyright notice please check original source
|
||||
|
||||
struct mntent *getmntent_r(FILE *fp, struct mntent *e, char *buf, int buf_len) {
|
||||
memset(e, 0, sizeof(*e));
|
||||
while (fgets(buf, buf_len, fp) != nullptr) {
|
||||
// Entries look like "proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0".
|
||||
// That is: mnt_fsname mnt_dir mnt_type mnt_opts 0 0.
|
||||
int fsname0, fsname1, dir0, dir1, type0, type1, opts0, opts1;
|
||||
if (sscanf(buf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d",
|
||||
&fsname0, &fsname1, &dir0, &dir1, &type0, &type1, &opts0, &opts1,
|
||||
&e->mnt_freq, &e->mnt_passno) == 2) {
|
||||
e->mnt_fsname = &buf[fsname0];
|
||||
buf[fsname1] = '\0';
|
||||
e->mnt_dir = &buf[dir0];
|
||||
buf[dir1] = '\0';
|
||||
e->mnt_type = &buf[type0];
|
||||
buf[type1] = '\0';
|
||||
e->mnt_opts = &buf[opts0];
|
||||
buf[opts1] = '\0';
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FILE *setmntent(const char *path, const char *mode) {
|
||||
return fopen(path, mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user