[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add support for SD/MMC storage cards on Linux
From: |
Harald Welte |
Subject: |
Re: [PATCH] Add support for SD/MMC storage cards on Linux |
Date: |
Wed, 17 Sep 2008 09:23:38 +0800 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Wed, Sep 17, 2008 at 08:52:22AM +0800, Harald Welte wrote:
> Can you please review (and possibly apply) the following patch?
Here is an incremental patch to add support for the SD/MMC card type and name
from sysfs to the parted device name.
The output of 'parted -l' now looks like:
Model: SD SD02G (sd/mmc)
Disk /dev/mmcblk0: 2013MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 131kB 2013MB 2013MB primary fat16
------------------------------------------------------
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 983f232..017e3f4 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1150,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)
{
@@ -1263,7 +1291,7 @@ linux_new (const char* path)
break;
case PED_DEVICE_SDMMC:
- if (!init_generic (dev, _("SD/MMC Storage Card")))
+ if (!init_sdmmc (dev))
goto error_free_arch_specific;
break;
--
- Harald Welte <address@hidden> http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)