Merge "Use hasmntopt(3) rather than reinventing the wheel." am: 769a5a1962
am: 8656ed109b
Change-Id: Ied4c404b0d0f957bfe0e9ff3841173b52147b21b
This commit is contained in:
commit
5dd53bf466
1 changed files with 2 additions and 22 deletions
|
|
@ -42,24 +42,6 @@ typedef struct {
|
||||||
struct mntent entry;
|
struct mntent entry;
|
||||||
} mntent_list;
|
} mntent_list;
|
||||||
|
|
||||||
static bool has_mount_option(const char* opts, const char* opt_to_find)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
char* copy = NULL;
|
|
||||||
char* opt;
|
|
||||||
char* rem;
|
|
||||||
|
|
||||||
while ((opt = strtok_r(copy ? NULL : (copy = strdup(opts)), ",", &rem))) {
|
|
||||||
if (!strcmp(opt, opt_to_find)) {
|
|
||||||
ret = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(copy);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_block_device(const char* fsname)
|
static bool is_block_device(const char* fsname)
|
||||||
{
|
{
|
||||||
return !strncmp(fsname, "/dev/block", 10);
|
return !strncmp(fsname, "/dev/block", 10);
|
||||||
|
|
@ -78,8 +60,7 @@ static void find_rw(struct listnode* rw_entries)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while ((mentry = getmntent(fp)) != NULL) {
|
while ((mentry = getmntent(fp)) != NULL) {
|
||||||
if (is_block_device(mentry->mnt_fsname) &&
|
if (is_block_device(mentry->mnt_fsname) && hasmntopt(mentry, "rw")) {
|
||||||
has_mount_option(mentry->mnt_opts, "rw")) {
|
|
||||||
mntent_list* item = (mntent_list*)calloc(1, sizeof(mntent_list));
|
mntent_list* item = (mntent_list*)calloc(1, sizeof(mntent_list));
|
||||||
item->entry = *mentry;
|
item->entry = *mentry;
|
||||||
item->entry.mnt_fsname = strdup(mentry->mnt_fsname);
|
item->entry.mnt_fsname = strdup(mentry->mnt_fsname);
|
||||||
|
|
@ -170,8 +151,7 @@ static void remount_ro(void (*cb_on_remount)(const struct mntent*))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
while ((mentry = getmntent(fp)) != NULL) {
|
while ((mentry = getmntent(fp)) != NULL) {
|
||||||
if (!is_block_device(mentry->mnt_fsname) ||
|
if (!is_block_device(mentry->mnt_fsname) || !hasmntopt(mentry, "ro")) {
|
||||||
!has_mount_option(mentry->mnt_opts, "ro")) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mntent_list* item = find_item(&rw_entries, mentry->mnt_fsname);
|
mntent_list* item = find_item(&rw_entries, mentry->mnt_fsname);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue