return NULL;
if (!fs_type) {
- _D("Not support extended partition");
+ _E("Not support extended partition");
return NULL;
}
data = calloc(1, sizeof(struct block_data));
- if (!data)
+ if (!data) {
+ _E("calloc() failed");
return NULL;
+ }
data->devnode = strdup(devnode);
if (syspath)
} else
th_node = devnode;
- len = strlen(str) + 1;
+ len = strlen(th_node) + 1;
min_num = 1000;
min = -1;
for (i = 0; i < THREAD_MAX; i++) {
DD_LIST_FOREACH(th_manager[i].th_node_list, elem, temp) {
- if (!temp)
- continue;
if (!strncmp(temp, th_node, len))
return i;
}
if (thread_id < 0 || thread_id >= THREAD_MAX) {
_E("Fail to find thread to add");
free_block_data(data);
- free(bdev);
+ free_block_device(bdev);
return -EPERM;
}
bdev->thread_id = thread_id;
ret = add_operation(bdev, BLOCK_DEV_INSERT, NULL, (void *)data);
if (ret < 0) {
- _E("Failed to add operation (mount %s)", devnode);
+ _E("Failed to add operation (insert %s)", devnode);
+ free_block_data(data);
+ free_block_device(bdev);
return ret;
}
ret = add_operation(bdev, BLOCK_DEV_MOUNT, NULL, NULL);
if (ret < 0) {
_E("Failed to add operation (mount %s)", devnode);
+ free_block_data(data);
+ free_block_device(bdev);
return ret;
}
BLOCK_FLAG_SET(bdev->data, UNMOUNT_UNSAFE);
bdev->removed = true;
- if (bdev->on_private_op) {
+ if (bdev->on_private_op != REQ_NORMAL) {
bdev->on_private_op = REQ_NORMAL;
_D("Private operation state: %d", bdev->on_private_op);
}
if (prev_state == BLOCK_MOUNT) {
if (add_operation(bdev, BLOCK_DEV_MOUNT, NULL, NULL) < 0) {
_E("Failed to add operation (mount %s)", bdev->data->devnode);
+ release_format_data(fdata);
goto out;
}
}
if (ret < 0)
_E("Failed to make directory: %d", errno);
} else if (!S_ISDIR(buf.st_mode)) {
- remove(EXTERNAL_STORAGE_PATH);
+ ret = remove(EXTERNAL_STORAGE_PATH);
+ if (ret < 0)
+ _E("Fail to remove %s. errno: %d", EXTERNAL_STORAGE_PATH, errno);
ret = mkdir(EXTERNAL_STORAGE_PATH, 0755);
if (ret < 0)
_E("Failed to make directory: %d", errno);
- } else
- chmod(EXTERNAL_STORAGE_PATH, 644);
+ } else {
+ ret = chmod(EXTERNAL_STORAGE_PATH, 644);
+ if (ret < 0)
+ _E("Fail to change permissions of a file");
+ }
}
static void block_exit(void *data)