int is_root_path_mounted(const char *root_path) { const RootInfo *info = get_root_info_for_path(root_path); if (info == NULL) { return -1; } return internal_root_mounted(info) >= 0; }
int ensure_root_path_mounted(const char *root_path) { const RootInfo *info = get_root_info_for_path(root_path); if (info == NULL) { return -1; } int ret = internal_root_mounted(info); if (ret >= 0) { /* It's already mounted. */ return 0; } /* It's not mounted. */ if (info->device == g_mtd_device) { if (info->partition_name == NULL) { return -1; } //TODO: make the mtd stuff scan once when it needs to mtd_scan_partitions(); const MtdPartition *partition; partition = mtd_find_partition_by_name(info->partition_name); if (partition == NULL) { return -1; } return mtd_mount_partition(partition, info->mount_point, info->filesystem, 0); } if (info->device == NULL || info->mount_point == NULL || info->filesystem == NULL || info->filesystem == g_raw || info->filesystem == g_package_file) { return -1; } mkdir(info->mount_point, 0755); // in case it doesn't already exist if (mount_internal(info->device, info->mount_point, info->filesystem, info->filesystem_options)) { if (info->device2 == NULL) { LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno)); return -1; } else if (mount(info->device2, info->mount_point, info->filesystem, MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) { LOGE("Can't mount %s (or %s)\n(%s)\n", info->device, info->device2, strerror(errno)); return -1; } } return 0; }