Workaround seccomp on MagiskBoot

Close #1150
This commit is contained in:
topjohnwu 2019-03-02 05:45:55 -05:00
parent d8cd2031c7
commit dee3c3e7ba

View File

@ -358,9 +358,13 @@ void full_read_at(int dirfd, const char *filename, void **buf, size_t *size) {
}
void write_zero(int fd, size_t size) {
size_t pos = lseek(fd, 0, SEEK_CUR);
ftruncate(fd, pos + size);
lseek(fd, pos + size, SEEK_SET);
char buf[4096] = {0};
size_t len;
while (size > 0) {
len = sizeof(buf) > size ? size : sizeof(buf);
write(fd, buf, len);
size -= len;
}
}
void file_readline(const char *filename, const function<bool (string_view&)> &fn, bool trim) {