More complete support for fstab in dt

This commit is contained in:
topjohnwu
2020-05-03 22:49:54 -07:00
parent 8ab045331b
commit 0c99c4d93f
7 changed files with 151 additions and 116 deletions

View File

@@ -302,11 +302,10 @@ void full_read(const char *filename, void **buf, size_t *size) {
}
string fd_full_read(int fd) {
char buf[4096];
string str;
auto len = lseek(fd, 0, SEEK_END);
str.resize(len);
lseek(fd, 0, SEEK_SET);
xxread(fd, str.data(), len);
for (ssize_t len; (len = xread(fd, buf, sizeof(buf))) > 0;)
str.insert(str.end(), buf, buf + len);
return str;
}

View File

@@ -164,14 +164,6 @@ bool ends_with(const std::string_view &s1, const std::string_view &s2) {
return l1 < l2 ? false : s1.compare(l1 - l2, l2, s2) == 0;
}
char *rtrim(char *str) {
int len = strlen(str);
while (len > 0 && str[len - 1] == ' ')
--len;
str[len] = '\0';
return str;
}
/*
* Bionic's atoi runs through strtol().
* Use our own implementation for faster conversion.

View File

@@ -97,7 +97,6 @@ bool ends_with(const std::string_view &s1, const std::string_view &s2);
int fork_dont_care();
int fork_no_zombie();
int strend(const char *s1, const char *s2);
char *rtrim(char *str);
void init_argv0(int argc, char **argv);
void set_nice_name(const char *name);
uint32_t binary_gcd(uint32_t u, uint32_t v);