[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/1] Add support for SD/MMC storage cards on Linux
From: |
Harald Welte |
Subject: |
[PATCH 1/1] Add support for SD/MMC storage cards on Linux |
Date: |
Sun, 5 Oct 2008 15:11:03 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
This patch adds a new SDMMC device type to represent SD/MMC
cards. There is nothing special about handling those devices,
they are just standard block devices with different names.
They use device major ID 179 and are usually called
/dev/mmcblkN (where N is the card number) and the individual partitions
/dev/mmcblkNpM (where M is the partition number).
This patch was developed as part of an effort to make debian-installer
support installation of Debian GNU/Linux on SD/MMC cards, as boot-from-SD
is becoming a feature seen in mobile x86 devices.
---
AUTHORS | 3 +++
include/parted/device.h | 3 ++-
libparted/arch/linux.c | 36 ++++++++++++++++++++++++++++++++++++
parted/parted.c | 4 ++--
4 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index e955e6f..568e019 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -231,3 +231,6 @@ Debarshi Ray <address@hidden>
* Introduce 'print devices' and alias 'print list' to 'print all'.
* Alias 'mktable' to 'mklabel'.
* Code and API clean-up, bug fixes, and other miscellaneous stuff.
+
+Harald Welte <address@hidden>
+ * SD/MMC Storage card support on Linux
diff --git a/include/parted/device.h b/include/parted/device.h
index fdfcb1f..2a3421f 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -44,7 +44,8 @@ typedef enum {
PED_DEVICE_VIODASD = 10,
PED_DEVICE_SX8 = 11,
PED_DEVICE_DM = 12,
- PED_DEVICE_XVD = 13
+ PED_DEVICE_XVD = 13,
+ PED_DEVICE_SDMMC = 14
} PedDeviceType;
typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 333f818..83e24c8 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -255,6 +255,7 @@ struct blkdev_ioctl_param {
#define SX8_MAJOR1 160
#define SX8_MAJOR2 161
#define XVD_MAJOR 202
+#define SDMMC_MAJOR 179
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -537,6 +538,8 @@ _device_probe_type (PedDevice* dev)
#endif
} else if (dev_major == XVD_MAJOR && (dev_minor % 0x10 == 0)) {
dev->type = PED_DEVICE_XVD;
+ } else if (dev_major == SDMMC_MAJOR && (dev_minor % 0x08 == 0)) {
+ dev->type = PED_DEVICE_SDMMC;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1147,6 +1150,34 @@ error:
return 0;
}
+static int
+sdmmc_get_product_info (PedDevice* dev, char **type, char **name)
+{
+ *type = read_device_sysfs_file (dev, "type");
+ *name = read_device_sysfs_file (dev, "name");
+ if (*type && *name)
+ return 1;
+
+ return 0;
+}
+
+static int
+init_sdmmc (PedDevice* dev)
+{
+ char id[128];
+ char *type, *name;
+
+ if (sdmmc_get_product_info (dev, &type, &name)) {
+ snprintf (id, sizeof(id) - 1, "%s %s", type, name);
+ free (type);
+ free (name);
+ } else {
+ snprintf (id, sizeof(id) - 1, "%s",
+ _("Generic SD/MMC Storage Card"));
+ }
+ return init_generic(dev, id);
+}
+
static PedDevice*
linux_new (const char* path)
{
@@ -1259,6 +1290,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_SDMMC:
+ if (!init_sdmmc (dev))
+ goto error_free_arch_specific;
+ break;
+
default:
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
diff --git a/parted/parted.c b/parted/parted.c
index 5e67584..d7c0292 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1268,10 +1268,10 @@ do_print (PedDevice** dev)
int has_free_arg = 0;
int has_list_arg = 0;
int has_num_arg = 0;
- const char *const transport[14] = {"unknown", "scsi", "ide", "dac960",
+ const char *const transport[15] = {"unknown", "scsi", "ide", "dac960",
"cpqarray", "file", "ataraid", "i2o",
"ubd", "dasd", "viodasd", "sx8",
"dm",
- "xvd"};
+ "xvd", "sd/mmc"};
char* peek_word;
char* start;
char* end;
--
1.5.6.5
- [PATCH 1/1] Add support for SD/MMC storage cards on Linux,
Harald Welte <=