#define EXTENDEDSD_MOUNT_PATH "/opt/extendedsd"
+#define VFAT_NAME "vfat"
#define EXT4_NAME "ext4"
#define LUKS_NAME "crypto_LUKS"
#define EXTENDEDSD_NAME "extendedsd"
get_operation_char(pdata.op),
pdata.bdev, pdata.result);
+ if (pdata.op == BLOCK_LUKS_CLOSE)
+ goto out;
+
if (pdata.op == BLOCK_DEV_MOUNT && pdata.result < 0) {
if (pdata.bdev->data->state == BLOCK_UNMOUNT) {
ret = change_mount_point(pdata.bdev, "");
{
struct udev *udev;
struct udev_device *dev;
+ const char *fs_type;
+ const char *fs_usage;
int r;
int wait;
return -EPERM;
}
- if (!udev_device_get_property_value(dev, "ID_FS_TYPE"))
+ fs_type = udev_device_get_property_value(dev, "ID_FS_TYPE");
+ fs_usage = udev_device_get_property_value(dev, "ID_FS_USAGE");
+ /* fs_usage for crpto_LUKS is crypto */
+ if (!fs_type || (strncmp(fs_type, VFAT_NAME, strlen(VFAT_NAME)) && strncmp(fs_type, EXT4_NAME, strlen(EXT4_NAME))))
+ sleep(1);
+ else if (!fs_usage || strncmp(FILESYSTEM_NAME, fs_usage, strlen(FILESYSTEM_NAME)))
sleep(1);
else
break;
ret = format_block_device(bdev, fdata->fs_type, fdata->option);
if (ret < 0)
- _E("fail to mount block device for %s", bdev->data->devnode);
+ _E("fail to format block device for %s", bdev->data->devnode);
out:
release_format_data(fdata);
pthread_mutex_unlock(&(th_manager[thread_id].mutex));
/* UNLOCK */
- if (operation == BLOCK_DEV_INSERT || operation == BLOCK_DEV_REMOVE) {
+ if (operation == BLOCK_DEV_INSERT || operation == BLOCK_DEV_REMOVE || operation == BLOCK_LUKS_CLOSE) {
if (pipe_trigger(operation, bdev, 0) < 0)
_E("fail to trigger pipe");
}
return -EPERM;
}
+ if (!block_control) {
+ if (!mapper && strncmp(data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
+ _D("Block module is disabled");
+ free_block_data(data);
+ return -EPERM;
+ }
+
+ }
+
bdev = make_block_device(data);
if (!bdev) {
_E("fail to make block device for %s", devnode);
return ret;
}
- ret = add_operation(bdev_extended, BLOCK_DEV_REMOVE, NULL, NULL);
+ ret = add_operation(bdev_extended, BLOCK_LUKS_CLOSE, NULL, NULL);
if (ret < 0) {
- _E("Failed to add operation (remove %s)", devnode);
+ _E("Failed to add operation (luks_close %s)", devnode);
return ret;
}
- ret = add_operation(bdev_extended, BLOCK_LUKS_CLOSE, NULL, NULL);
+ ret = add_operation(bdev_extended, BLOCK_DEV_REMOVE, NULL, NULL);
if (ret < 0) {
- _E("Failed to add operation (luks_close %s)", devnode);
+ _E("Failed to add operation (remove %s)", devnode);
return ret;
}
} else
do {
pthread_mutex_lock(&(th_manager[i].mutex));
DD_LIST_FOREACH_SAFE(th_manager[i].block_dev_list, elem, next, bdev) {
+ if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV ||
+ !strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME)))
+ continue;
if (bdev->removed == false)
break;
}
if (ret < 0)
_E("fail to register block uevent : %d", ret);
+ block_control = true;
/* if there is the attached device, try to mount */
block_init_from_udev_enumerate();
- block_control = true;
block_boot = true;
}
_E("fail to update block data for %s", bdev->data->devnode);
if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME)))
_I("filesystem type is updated: crypto_LUKS");
+ if (bdev->data->fs_usage)
+ _I("fs_usage: %s", bdev->data->fs_usage);
}
}
int id;
int ret = -EBADMSG;
+ if (!block_control) {
+ _D("Block module is disabled");
+ ret = -EPERM;
+ goto out;
+ }
+
if (!reply_handle || !msg)
goto out;
ret = -ENOENT;
goto out;
}
+
+ if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV ||
+ !strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
+ _D("Mount dbus request for extended internal storage is blocked");
+ ret = -EPERM;
+ goto out;
+ }
+
if (bdev->on_private_op != REQ_NORMAL) {
ret = -EPERM;
goto out;
int id;
int ret = -EBADMSG;
+ if (!block_control) {
+ _D("Block module is disabled");
+ ret = -EPERM;
+ goto out;
+ }
+
if (!reply_handle || !msg)
goto out;
goto out;
}
+ /* Unmount dbus call is needed when app proceeds extended internal -> portable storage */
+ if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
+ _D("Unmount dbus request for extended internal storage is blocked");
+ ret = -EPERM;
+ goto out;
+ }
+
if (onprivate) {
pid = get_dbus_method_sender_pid(reply_handle);
if (bdev->on_private_op == REQ_NORMAL || (bdev->on_private_op != REQ_NORMAL && pid != bdev->private_pid)) {
int ret = -EBADMSG;
int prev_state;
+ if (!block_control) {
+ _D("Block module is disabled");
+ ret = -EPERM;
+ goto out;
+ }
+
if (!reply_handle || !msg)
goto out;
goto out;
}
+ if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV ||
+ !strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
+ _D("Format dbus request for extended internal storage is blocked");
+ ret = -EPERM;
+ goto out;
+ }
+
pid = get_dbus_method_sender_pid(reply_handle);
if (bdev->on_private_op != REQ_NORMAL && pid != bdev->private_pid) {
_E("Failed to format on private state");
int ret = -EBADMSG;
int prev_state;
+ if (!block_control) {
+ _D("Block module is disabled");
+ ret = -EPERM;
+ goto out;
+ }
+
if (!reply_handle || !msg)
goto out;
goto out;
}
+ /* FormatwithType dbus call is needed when app proceeds extended internal -> portable storage */
+ if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV) {
+ _D("FormatwithType dbus request for extended internal storage is blocked");
+ ret = -EPERM;
+ goto out;
+ }
+
pid = get_dbus_method_sender_pid(reply_handle);
if (bdev->on_private_op != REQ_NORMAL && pid != bdev->private_pid) {
_E("Failed to format on private state");
static int block_start(void *data)
{
- int ret;
-
if (!block_boot) {
_E("Cannot be started. Booting is not ready");
return -ENODEV;
return 0;
}
- /* register mmc uevent control routine */
- ret = register_udev_uevent_control(&uh);
- if (ret < 0)
- _E("fail to register block uevent : %d", ret);
+ block_control = true;
block_init_from_udev_enumerate();
- block_control = true;
-
_I("start");
return 0;
}
return 0;
}
- /* unregister mmc uevent control routine */
- unregister_udev_uevent_control(&uh);
-
/* remove the existing blocks */
remove_whole_block_device();