You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Add new util function
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/* file.cpp - Contains all files related utilities
|
||||
*/
|
||||
|
||||
#include <sys/sendfile.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/fs.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include <magisk.h>
|
||||
#include <utils.h>
|
||||
@@ -396,3 +396,14 @@ void parse_prop_file(const char *file, const function<bool (string_view, string_
|
||||
return fn(line, eql + 1);
|
||||
}, true);
|
||||
}
|
||||
|
||||
void parse_mnt(const char *file, const function<bool (mntent*)> &fn) {
|
||||
unique_ptr<FILE, decltype(&fclose)> fp(xfopen(file, "rce"), &fclose);
|
||||
if (fp) {
|
||||
mntent *mentry;
|
||||
while ((mentry = getmntent(fp.get())) != nullptr) {
|
||||
if (!fn(mentry))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user