本文整理汇总了C++中scan_mounted_volumes函数的典型用法代码示例。如果您正苦于以下问题:C++ scan_mounted_volumes函数的具体用法?C++ scan_mounted_volumes怎么用?C++ scan_mounted_volumes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scan_mounted_volumes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ensure_path_mounted
int ensure_path_mounted(const char* path) {
Volume* v = volume_for_path(path);
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted.
return 0;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv) {
// volume is already mounted
return 0;
}
mkdir("/mnt", 0755); // in case it doesn't already exist
mkdir(v->mount_point, 0755); // in case it doesn't already exist
if (strcmp(v->fs_type, "yaffs2") == 0) {
// mount an MTD partition as a YAFFS2 filesystem.
mtd_scan_partitions();
const MtdPartition* partition;
partition = mtd_find_partition_by_name(v->device);
if (partition == NULL) {
LOGE("failed to find \"%s\" partition to mount at \"%s\"\n",
v->device, v->mount_point);
return -1;
}
return mtd_mount_partition(partition, v->mount_point, v->fs_type, 0);
} else if (strcmp(v->fs_type, "ext4") == 0 ||
strcmp(v->fs_type, "vfat") == 0) {
result = mount(v->device, v->mount_point, v->fs_type,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result == 0) return 0;
if (v->device2) {
LOGW("failed to mount %s (%s); trying %s\n",
v->device, strerror(errno), v->device2);
result = mount(v->device2, v->mount_point, v->fs_type,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result == 0) return 0;
}
LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno));
return -1;
}
LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, v->mount_point);
return -1;
}
示例2: ensure_path_unmounted
int ensure_path_unmounted(const char* path) {
// if we are using /data/media, do not ever unmount volumes /data or /sdcard
if (strstr(path, "/data") == path && is_data_media()) {
return 0;
}
Volume* v = volume_for_path(path);
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
if (is_data_media_volume_path(path)) {
return ensure_path_unmounted("/data");
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted; you can't unmount it.
return -1;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv == NULL) {
// volume is already unmounted
return 0;
}
return unmount_mounted_volume(mv);
}
示例3: is_path_mounted
int is_path_mounted(const char* path) {
Volume* v = volume_for_path(path);
if (v == NULL) {
return 0;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted.
return 1;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return 0;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv) {
// volume is already mounted
return 1;
}
return 0;
}
示例4: get_restore_handler
static nandroid_restore_handler get_restore_handler(const char *backup_path) {
Volume *v = volume_for_path(backup_path);
if (v == NULL) {
ui_print("Unable to find volume.\n");
return NULL;
}
scan_mounted_volumes();
const MountedVolume *mv = find_mounted_volume_by_mount_point(v->mount_point);
if (mv == NULL) {
ui_print("Unable to find mounted volume: %s\n", v->mount_point);
return NULL;
}
if (strcmp(backup_path, "/data") == 0 && is_data_media()) {
return tar_extract_wrapper;
}
// Disable tar backups of yaffs2 by default
char prefer_tar[PROPERTY_VALUE_MAX];
property_get("ro.cwm.prefer_tar", prefer_tar, "false");
if (strcmp("yaffs2", mv->filesystem) == 0 && strcmp("false", prefer_tar) == 0) {
return unyaffs_wrapper;
}
return tar_extract_wrapper;
}
示例5: ensure_path_mounted
int ensure_path_mounted(const char* path) {
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
const MountedVolume* mv = find_mounted_volume_by_mount_point("/data");
const MountedVolume* m_v = find_mounted_volume_by_mount_point("/cache");
if (mv && m_v) {
// volume is already mounted
return 0;
}
if (!mv) {
result = mount("/[email protected]", "/data", "ext4",
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result < 0) {
LOGE("failed to mount /data (%s)\n", strerror(errno));
return -1;
}
}
if (!m_v) {
result = mount("/[email protected]", "/cache", "ext4",
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result < 0) {
LOGE("failed to mount /cache (%s)\n", strerror(errno));
return -1;
}
}
if (result == 0)
return 0;
}
示例6: check_root_path_mounted
static int check_root_path_mounted(const char* root_path)
{
const MountedVolume *volume;
LOGD(TAG "%s: Start\n", __FUNCTION__);
/* scan the volumes already mounted */
int ret = scan_mounted_volumes();
if (ret < 0)
{
return ret;
}
/* Find if the path is already mounted */
volume = find_mounted_volume_by_mount_point(root_path);
if (volume == NULL)
{
/* It's not mounted. */
return -1;
}
return 0;
}
示例7: internal_root_mounted
static int
internal_root_mounted(const RootInfo *info)
{
if (info->mount_point == NULL) {
return -1;
}
if(info->device == NULL)
return 0;
//xxx if TMP: (or similar) just say "yes"
/* See if this root is already mounted.
*/
int ret = scan_mounted_volumes();
if (ret < 0) {
return ret;
}
const MountedVolume *volume;
volume = find_mounted_volume_by_mount_point(info->mount_point);
if (volume != NULL) {
/* It's already mounted.
*/
return 0;
}
return -1;
}
示例8: UnmountFn
Value* UnmountFn(const char* name, State* state, int argc, Expr* argv[]) {
char* result = NULL;
if (argc != 1) {
return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
}
char* mount_point;
if (ReadArgs(state, argv, 1, &mount_point) < 0) {
return NULL;
}
if (strlen(mount_point) == 0) {
ErrorAbort(state, "mount_point argument to unmount() can't be empty");
goto done;
}
scan_mounted_volumes();
const MountedVolume* vol = find_mounted_volume_by_mount_point(mount_point);
if (vol == NULL) {
fprintf(stderr, "unmount of %s failed; no such volume\n", mount_point);
result = strdup("");
} else {
unmount_mounted_volume(vol);
result = mount_point;
}
done:
if (result != mount_point) free(mount_point);
return StringValue(result);
}
示例9: ensure_path_unmounted
int ensure_path_unmounted(const char* path) {
Volume* v = volume_for_path(path);
#if defined(CACHE_MERGE_SUPPORT)
if (strncmp(path, "/cache", 6) == 0) {
unlink(path);
return 0;
}
#endif
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted; you can't unmount it.
return -1;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv == NULL) {
// volume is already unmounted
return 0;
}
return unmount_mounted_volume(mv);
}
示例10: get_restore_handler
static nandroid_restore_handler get_restore_handler(const char *backup_path) {
Volume *v = volume_for_path(backup_path);
if (v == NULL) {
ui_print("Unable to find volume.\n");
return NULL;
}
scan_mounted_volumes();
MountedVolume *mv = find_mounted_volume_by_mount_point(v->mount_point);
if (mv == NULL) {
ui_print("Unable to find mounted volume: %s\n", v->mount_point);
return NULL;
}
if (strcmp(backup_path, "/data") == 0 && is_data_media()) {
return tar_extract_wrapper;
}
// cwr 5, we prefer tar for everything unless it is yaffs2
char str[255];
char* partition;
property_get("ro.cwm.prefer_tar", str, "false");
if (strcmp("true", str) != 0) {
return unyaffs_wrapper;
}
if (strcmp("yaffs2", mv->filesystem) == 0) {
return unyaffs_wrapper;
}
return tar_extract_wrapper;
}
示例11: ensure_path_unmounted
int ensure_path_unmounted(const char* path) {
if (PartitionManager.UnMount_By_Path(path, true))
return 0;
else
return -1;
Volume* v = volume_for_path(path);
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted; you can't unmount it.
return -1;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv == NULL) {
// volume is already unmounted
return 0;
}
return unmount_mounted_volume(mv);
}
示例12: ensure_root_path_unmounted
int
ensure_root_path_unmounted(const char *root_path)
{
const RootInfo *info = get_root_info_for_path(root_path);
if (info == NULL) {
return -1;
}
if (info->mount_point == NULL) {
/* This root can't be mounted, so by definition it isn't.
*/
return 0;
}
//xxx if TMP: (or similar) just return error
/* See if this root is already mounted.
*/
int ret = scan_mounted_volumes();
if (ret < 0) {
return ret;
}
const MountedVolume *volume;
volume = find_mounted_volume_by_mount_point(info->mount_point);
if (volume == NULL) {
/* It's not mounted.
*/
return 0;
}
return unmount_mounted_volume(volume);
}
示例13: ensure_volume_mounted
int ensure_volume_mounted(fstab_rec* v) {
if (v == NULL) {
LOGE("cannot mount unknown volume\n");
return -1;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted.
return 0;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
if (!fs_mgr_is_voldmanaged(v)) {
const MountedVolume* mv =
find_mounted_volume_by_mount_point(v->mount_point);
if (mv) {
// volume is already mounted
return 0;
}
}
mkdir_p(v->mount_point, 0755); // in case it doesn't already exist
if (fs_mgr_is_voldmanaged(v)) {
if (!strcmp(v->mount_point, "auto")) {
return vold_mount_auto_volume(v->label, 1);
}
return vold_mount_volume(v->mount_point, 1);
} else if (strcmp(v->fs_type, "yaffs2") == 0) {
// mount an MTD partition as a YAFFS2 filesystem.
mtd_scan_partitions();
const MtdPartition* partition;
partition = mtd_find_partition_by_name(v->blk_device);
if (partition == NULL) {
LOGE("failed to find \"%s\" partition to mount at \"%s\"\n",
v->blk_device, v->mount_point);
return -1;
}
return mtd_mount_partition(partition, v->mount_point, v->fs_type, 0);
} else if (strcmp(v->fs_type, "ext4") == 0 ||
strcmp(v->fs_type, "f2fs") == 0 ||
strcmp(v->fs_type, "vfat") == 0) {
result = mount(v->blk_device, v->mount_point, v->fs_type,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result == 0) return 0;
LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno));
return -1;
}
LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, v->mount_point);
return -1;
}
示例14: ensure_path_mounted_at
// Mount the volume specified by path at the given mount_point.
int ensure_path_mounted_at(const char* path, const char* mount_point) {
Volume* v = volume_for_path(path);
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
// the ramdisk is always mounted.
return 0;
}
int result;
result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
if (!mount_point) {
mount_point = v->mount_point;
}
const MountedVolume* mv =
find_mounted_volume_by_mount_point(mount_point);
if (mv) {
// volume is already mounted
return 0;
}
mkdir(mount_point, 0755); // in case it doesn't already exist
if (strcmp(v->fs_type, "yaffs2") == 0) {
// mount an MTD partition as a YAFFS2 filesystem.
mtd_scan_partitions();
const MtdPartition* partition;
partition = mtd_find_partition_by_name(v->blk_device);
if (partition == NULL) {
LOGE("failed to find \"%s\" partition to mount at \"%s\"\n",
v->blk_device, mount_point);
return -1;
}
return mtd_mount_partition(partition, mount_point, v->fs_type, 0);
} else if (strcmp(v->fs_type, "ext4") == 0 ||
strcmp(v->fs_type, "squashfs") == 0 ||
strcmp(v->fs_type, "vfat") == 0) {
result = mount(v->blk_device, mount_point, v->fs_type,
v->flags, v->fs_options);
if (result == 0) return 0;
LOGE("failed to mount %s (%s)\n", mount_point, strerror(errno));
return -1;
}
LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, mount_point);
return -1;
}
示例15: device_truedualboot_mount
int device_truedualboot_mount(const char* path, const char* mount_point) {
if(strcmp(path, "/data") != 0)
return 1;
else if(mount_point!=NULL && strcmp(mount_point, MOUNTPOINT_DATAROOT)==0)
return 1;
if(!dualboot_is_tdb_enabled())
return 1;
ensure_path_mounted_at_mount_point("/data", MOUNTPOINT_DATAROOT);
Volume* v = volume_for_path(path);
if (v == NULL) {
LOGE("unknown volume for path [%s]\n", path);
return -1;
}
int result = scan_mounted_volumes();
if (result < 0) {
LOGE("failed to scan mounted volumes\n");
return -1;
}
if (NULL == mount_point)
mount_point = v->mount_point;
const MountedVolume* mv =
find_mounted_volume_by_mount_point(mount_point);
if (mv) {
// volume is already mounted
return 0;
}
char* bind_path;
if(get_selected_system()==SYSTEM1)
bind_path = MOUNTPOINT_DATAROOT "/system0";
else if(get_selected_system()==SYSTEM2)
bind_path = MOUNTPOINT_DATAROOT "/system1";
else return -1;
mkdir(mount_point, 0755); // in case it doesn't already exist
mkdir(bind_path, 0755);
char mount_cmd[PATH_MAX];
sprintf(mount_cmd, "mount -o bind %s %s", bind_path, mount_point);
int ret = __system(mount_cmd);
if(ret!=0) return ret>0?-ret:ret;
return 0;
}