summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaeyoung Kim <ty317.kim@samsung.com>2016-04-18 12:18:46 +0900
committerTaeyoung Kim <ty317.kim@samsung.com>2016-04-19 09:19:54 +0900
commit732c8d9350877b0b3b98e8ea3e806eb563907dd5 (patch)
tree5e9ea1aa104aa315c1535aaf95301f30e70dc09c
parent4507f10a17ec2a056d21fee6309563683c6088dd (diff)
downloaddeviced-732c8d9350877b0b3b98e8ea3e806eb563907dd5.tar.gz
deviced-732c8d9350877b0b3b98e8ea3e806eb563907dd5.tar.bz2
deviced-732c8d9350877b0b3b98e8ea3e806eb563907dd5.zip
block: change name of mount nodes
- The mount node of MMC devices are changed to SdcardA1, Sdcard A2, Sdcard B1, and so on - The mount node of SCSI devices are changed to UsbDriveA1, UsbDriveA2, UsbDriveB1, and so on Change-Id: Ic8fefb326d7c9cb5d830257d64cf5ecb985a467c Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
-rw-r--r--src/block/block.c82
1 files changed, 72 insertions, 10 deletions
diff --git a/src/block/block.c b/src/block/block.c
index ccda958b..1ac724e2 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -35,6 +35,7 @@
#include <time.h>
#include <assert.h>
#include <vconf.h>
+#include <ctype.h>
#include <tzplatform_config.h>
#include "core/log.h"
@@ -308,27 +309,88 @@ static void signal_device_changed(struct block_device *bdev,
"issssssisibi", arr);
}
+static int get_mmc_mount_node(char *devnode, char *node, size_t len)
+{
+ char *name = devnode;
+ char *pt;
+ int dev = -1, part = -1;
+
+ if (!name)
+ return -EINVAL;
+
+ sscanf(name, "mmcblk%dp%d", &dev, &part);
+ if (dev < 0)
+ return -EINVAL;
+
+ if (part < 0)
+ snprintf(node, len, "Sdcard%c", dev + 'A' - 1);
+ else
+ snprintf(node, len, "Sdcard%c%d", dev + 'A' - 1, part);
+
+ return 0;
+}
+
+static int get_scsi_mount_node(char *devnode, char *node, size_t len)
+{
+ char dev[64], *name;
+ int i;
+
+ if (!devnode)
+ return -EINVAL;
+
+ snprintf(dev, sizeof(dev), "%s", devnode);
+
+ if (!strstr(dev, "sd"))
+ return -EINVAL;
+
+ name = dev;
+ name += strlen("sd");
+ if (!name)
+ return -EINVAL;
+
+ for (i = 0 ; i < strlen(name) ; i++)
+ name[i] = toupper(name[i]);
+ snprintf(node, len, "UsbDrive%s", name);
+
+ return 0;
+}
+
static char *generate_mount_path(struct block_data *data)
{
- const char *str, *node;
+ const char *str;
+ char *name, node[64];
+ int ret;
- if (!data)
+ if (!data || !data->devnode)
return NULL;
- /* For libstorage API
- * If it's a primary partition and mmc device,
- * use 'sdcard' node as mount point. */
- if (data->primary && data->block_type == BLOCK_MMC_DEV)
- node = "sdcard";
- else if (data->fs_uuid_enc)
- node = data->fs_uuid_enc;
- else
+ name = strrchr(data->devnode, '/');
+ if (!name)
+ goto out;
+ name++;
+
+ switch (data->block_type) {
+ case BLOCK_MMC_DEV:
+ ret = get_mmc_mount_node(name, node, sizeof(node));
+ break;
+ case BLOCK_SCSI_DEV:
+ ret = get_scsi_mount_node(name, node, sizeof(node));
+ break;
+ default:
+ _E("Invalid block type (%d)", data->block_type);
return NULL;
+ }
+ if (ret < 0)
+ goto out;
str = tzplatform_mkpath(TZ_SYS_MEDIA, node);
if (!str)
return NULL;
return strdup(str);
+
+out:
+ _E("Invalid devnode (%s)", data->devnode ? data->devnode : "NULL");
+ return NULL;
}
static bool check_primary_partition(const char *devnode)