mmc-utils: improve lsmmc usability
Subsystems (2)
cover mmc-utils: improve lsmmc usability
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
This adds external manufacturer ID files, accepts /dev and /sys/block paths for register reads, adds an mmc list command, and installs bash completion for mmc-utils.
Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completion
Makefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode 100644 completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
Signature · 1 line
2.53.0
PATCH 1/4 mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
Similar to pci.ids and usb.ids, move the statically defined manufacturer ID arrays out of the source and into external sdcard.ids and multimediacard.ids files. This allows other programs to use the same database without an API, ABI, or cmd interface.
Make the program able to read from the base directory to test without installing.
Make it possible from the Makefile to change the install directory of the database.
--- Makefile | 8 +- lsmmc.c | 225 ++++++++++++--------------------------------- multimediacard.ids | 16 ++++ sdcard.ids | 23 +++++ 4 files changed, 104 insertions(+), 168 deletions(-) create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
Makefile +7 -1
@@ -1,7 +1,9 @@ CC ?= gcc GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)" AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \ - -DVERSION=\"$(GIT_VERSION)\" + -DVERSION=\"$(GIT_VERSION)\" \ + -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \ + -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\" CFLAGS ?= -g -O2 objects = \ mmc.o \
@@ -19,6 +21,7 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS) INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin +idsdir ?= /usr/share/misc LIBS= RESTORE_LIBS= mandir = /usr/share/man
@@ -55,6 +58,9 @@ install: $(progs) $(INSTALL) $(progs) $(DESTDIR)$(bindir) $(INSTALL) -m755 -d $(DESTDIR)$(mandir)/man1 $(INSTALL) -m 644 mmc.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m755 -d $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir) -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
lsmmc.c +58 -167
290 lines not on this page · raw message
multimediacard.ids new file +16 -0
@@ -0,0 +1,16 @@ +# MMC manufacturer IDs +# This file is maintained at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x00 SanDisk +0x02 Kingston/SanDisk +0x03 Toshiba +0x05 Unknown +0x06 Unknown +0x11 Toshiba +0x13 Micron +0x15 Samsung/SanDisk/LG +0x37 KingMax +0x44 ATP +0x45 SanDisk Corporation +0x2c Kingston +0x70 Kingston +0xfe Micron
sdcard.ids new file +23 -0
@@ -0,0 +1,23 @@ +# SD card (secure digital) manufacturer IDs +# This file is maintained at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x01 Panasonic +0x02 Toshiba/Kingston/Viking +0x03 SanDisk +0x08 Silicon Power +0x18 Infineon +0x1b Transcend/Samsung +0x1c Transcend +0x1d Corsair/AData +0x1e Transcend +0x1f Kingston +0x27 Delkin/Phison +0x28 Lexar +0x30 SanDisk +0x31 Silicon Power +0x33 STMicroelectronics +0x41 Kingston +0x6f STMicroelectronics +0x74 Transcend +0x76 Patriot +0x82 Gobe/Sony +0x89 Unknown
Signature · 1 line
2.53.0
RE: [PATCH 1/4] mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
Quoted 240 lines
Similar to pci.ids and usb.ids, move the statically defined manufacturer ID arrays out of the source and into external sdcard.ids and multimediacard.ids files. This allows other programs to use the same database without an API, ABI, or cmd interface.
Make the program able to read from the base directory to test without installing.
Make it possible from the
Makefileto change the install directory of the database.Signed-off-by Torstein Eide <[email protected]>--- Makefile | 8 +- lsmmc.c | 225 ++++++++++++--------------------------------- multimediacard.ids | 16 ++++ sdcard.ids | 23 +++++ 4 files changed, 104 insertions(+), 168 deletions(-) create mode 100644multimediacard.ids create mode 100644 sdcard.ids
Makefile +3
-1@@ -1,7 +1,9 @@ CC ?= gcc GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)" AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \ - -DVERSION=\"$(GIT_VERSION)\" + -DVERSION=\"$(GIT_VERSION)\" \ + -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \ + -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\" CFLAGS ?= -g -O2 objects = \ mmc.o \@@ -19,6 +21,7 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS)$(CFLAGS) INSTALL = install prefix ?=
/usr/localbindir = $(prefix)/binMakefile +4
-0+idsdir ?= /usr/share/misc LIBS= RESTORE_LIBS= mandir = /usr/share/man@@ -55,6 +58,9 @@ install: $(progs) $(INSTALL) $(progs) $(DESTDIR)$(bindir) $(INSTALL) -m755 -d $(DESTDIR)$(mandir)/man1 $(INSTALL) -m 644 mmc.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m755 -d $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir) -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)lsmmc.c +8
-152@@ -56,6 +56,13 @@#define IDS_MAX 256#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) +#ifndef SD_IDS_PATH +#define SD_IDS_PATH "/usr/share/misc/sdcard.ids" +#endif +#ifndef MMC_IDS_PATH +#define MMC_IDS_PATH "/usr/share/misc/multimediacard.ids" +#endif +enum bus_type {MMC =1 ,SD ,@@ -63,6 +70,7 @@ enum bus_type {struct config {char *dir; +char *ids_dir;bool verbose;enum bus_type bus;@@ -75,157 +83,6 @@ enum REG_TYPE { SCR, }; -struct ids_database { -int id; -char *manufacturer; -}; - -static struct ids_database sd_database[] = { - { - .id =0x01 , - .manufacturer ="Panasonic" , - }, - { - .id =0x02 , - .manufacturer ="Toshiba/Kingston/Viking" , - }, - { - .id =0x03 , - .manufacturer ="SanDisk" , - }, - { - .id =0x08 , - .manufacturer ="Silicon Power" , - }, - { - .id =0x18 , - .manufacturer ="Infineon" , - }, - { - .id =0x1b , - .manufacturer ="Transcend/Samsung" , - }, - { - .id =0x1c , - .manufacturer ="Transcend" , - }, - { - .id =0x1d , - .manufacturer ="Corsair/AData" , - }, - { - .id =0x1e , - .manufacturer ="Transcend" , - }, - { - .id =0x1f , - .manufacturer ="Kingston" , - }, - { - .id =0x27 , - .manufacturer ="Delkin/Phison" , - }, - { - .id =0x28 , - .manufacturer ="Lexar" , - }, - { - .id =0x30 , - .manufacturer ="SanDisk" , - }, - { - .id =0x31 , - .manufacturer ="Silicon Power" , - }, - { - .id =0x33 , - .manufacturer ="STMicroelectronics" , - }, - { - .id =0x41 , - .manufacturer ="Kingston" , - }, - { - .id =0x6f , - .manufacturer ="STMicroelectronics" , - }, - { - .id =0x74 , - .manufacturer ="Transcend" , - }, - { - .id =0x76 , - .manufacturer ="Patriot" , - }, - { - .id =0x82 , - .manufacturer ="Gobe/Sony" , - }, - { - .id =0x89 , - .manufacturer ="Unknown" , - }, -}; - -static struct ids_database mmc_database[] = { - { - .id =0x00 , - .manufacturer ="SanDisk" , - }, - { - .id =0x02 , - .manufacturer ="Kingston/SanDisk" , - }, - { - .id =0x03 , - .manufacturer ="Toshiba" , - }, - { - .id =0x05 , - .manufacturer ="Unknown" , - }, - { - .id =0x06 , - .manufacturer ="Unknown" , - }, - { - .id =0x11 , - .manufacturer ="Toshiba" , - }, - { - .id =0x13 , - .manufacturer ="Micron" , - }, - { - .id =0x15 , - .manufacturer ="Samsung/SanDisk/LG" , - }, - { - .id =0x37 , - .manufacturer ="KingMax" , - }, - { - .id =0x44 , - .manufacturer ="ATP" , - }, - { - .id =0x45 , - .manufacturer ="SanDisk Corporation" , - }, - { - .id =0x2c , - .manufacturer ="Kingston" , - }, - { - .id =0x70 , - .manufacturer ="Kingston" , - }, - { - .id =0xfe , - .manufacturer ="Micron" , - }, -}; -/* Command line parsing functions */ static void usage (char *progname) {@@ -319,25 +176,53 @@ static int parse_opts(int argc, char **argv, struct config *config)return 0 ; } -static char *get_manufacturer (struct config *config,unsigned int manid)
lsmmc.c static int parse_opts(int argc, char **argv, struct config · line 187
Quoted 10 lines
lsmmc.c +6
-2+static const char *get_manufacturer (struct config *config,unsigned int +manid) { -struct ids_database *db; -unsigned int ids_cnt; +const char *paths[] = {NULL ,NULL }; +char local_path[PATH_MAX ];int i; +FILE *f; +static char name[256 ];
I guess you are preparing here to iterate over several devices.
The static buffer will work here only if the result is printed before the next call. Maybe use strdup() instead?
Quoted 11 lines
lsmmc.c +10
-0+char line[256 ]; +const char *local_name; + + local_name = (config->bus ==MMC ) ?"multimediacard.ids" :"sdcard.ids" ; +/* check local directory first, then fall back to system path */ +if (config->ids_dir) +snprintf (local_path,sizeof (local_path),"%s/%s" , config->ids_dir, local_name); +else +snprintf (local_path,sizeof (local_path),"%s" , local_name); + paths[0 ] = local_path;
lsmmc.c static int parse_opts(int argc, char **argv, struct config *config) · line 199
Quoted 10 lines
lsmmc.c +3
-6+ paths[1 ] = (config->bus ==MMC ) ?MMC_IDS_PATH :SD_IDS_PATH ; -if (config->bus ==MMC ) { - db = mmc_database; - ids_cnt =ARRAY_SIZE (mmc_database); - }else { - db = sd_database; - ids_cnt =ARRAY_SIZE (sd_database); +for (i =0 ; i <2 ; i++) { + f =fopen (paths[i],"r" );
Maybe just:
f = fopen(local_path, "r");
if (!f)
f = fopen(system_path, "r");
lsmmc.c static int parse_opts(int argc, char **argv, struct config *config) · line 204
Quoted 5 lines
lsmmc.c +4
-0+if (f) +break ; } +if (!f) +return NULL ;
A warning that the ids files are missing?
Quoted 47 lines
lsmmc.c +21
-5-for (i =0 ; i < ids_cnt; i++) { -if (db[i].id == manid) -return db[i].manufacturer; +while (fgets (line,sizeof (line), f)) { +unsigned int id; +char *nl; + + nl =strchr (line,'\n' ); +if (nl) + *nl ='\0' ; + +if (line[0 ] =='#' || line[0 ] =='\0' ) +continue ; + +if (sscanf (line,"0x%x %255[^\n]" , &id, name) ==2 ) { +if (id == manid) { +fclose (f); +return name; + } + } } +fclose (f);return NULL ; }@@ -526,7 +411,7 @@ static void print_sd_cid(struct config *config, char *cid)unsigned int mdt_month;unsigned int mdt_year;unsigned int crc; -char *manufacturer =NULL ; +const char *manufacturer =NULL ;parse_bin (cid,"8u16a40a4u4u32u4r8u4u7u1r" , &mid, &oid[0], &pnm[0], &prv_major, &prv_minor, &psn, @@ -585,7 +470,7 @@ static void print_mmc_cid(struct config *config, char *cid) unsigned int mdt_month;unsigned int mdt_year;unsigned int crc; - char *manufacturer = NULL; +const char *manufacturer =NULL ; parse_bin(cid, "8u6r2u8u48a4u4u32u4u4u7u1r", &mid, &cbx, &oid, &pnm[0], &prv_major, &prv_minor, &psn, @@ -2220,11 +2105,14 @@ static int
process_dir(struct config *config, enum REG_TYPE reg)
Quoted 4 lines
char *type = NULL; int ret = 0;+
config->ids_dir=getcwd(NULL, 0);
I think it's an opportunity to replace the chdir()/getcwd() pattern with reading via full paths (e.g., a read_file_at(dir, name) helper)? That would eliminate the need for ids_dir entirely - get_manufacturer() could just open the .ids files directly since the working directory wouldn't change. Your code is fine, if you decided to do that, it should be a cleanup first patch.
Thanks,
Avri
Quoted 85 lines
lsmmc.c +5
-2+if (chdir (config->dir) <0 ) {fprintf (stderr,"MMC/SD information directory '%s' does not exist.\n" , config->dir); -return -1 ; + ret =-1 ; + goto err; } type =read_file ("type" );@@ -2232,7 +2120,8 @@ static int process_dir(struct config *config, enum REG_TYPE reg) fprintf(stderr,"Could not read card interface type in directory '%s'.\n" , config->dir); -return -1 ; + ret =-1 ; + goto err; }if (strcmp(type, "MMC") && strcmp(type, "SD")) { @@ -2247,6 +2136,8 @@static int
process_dir(struct config *config, enum REG_TYPE reg)err:
free(type);lsmmc.c +2
-0+free (config->ids_dir); + config->ids_dir =NULL ;return ret; }multimediacard.ids new file mode 100644 index renamed from multimediacard.ids +0
-00000000..0c91118
multimediacard.ids new file +17
-0@@ -0,0 +1,16 @@ +# MMC manufacturer IDs +# This file is maintained at: +https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x00 SanDisk +0x02 Kingston/SanDisk +0x03 Toshiba +0x05 Unknown +0x06 Unknown +0x11 Toshiba +0x13 Micron +0x15 Samsung/SanDisk/LG +0x37 KingMax +0x44 ATP +0x45 SanDisk Corporation +0x2c Kingston +0x70 Kingston +0xfe Micronsdcard.ids new file +23
-1@@ -0,0 +1,23 @@ +# SD card (secure digital) manufacturer IDs # This file is maintained +at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x01 Panasonic +0x02 Toshiba/Kingston/Viking +0x03 SanDisk +0x08 Silicon Power +0x18 Infineon +0x1b Transcend/Samsung +0x1c Transcend +0x1d Corsair/AData +0x1e Transcend +0x1f Kingston +0x27 Delkin/Phison +0x28 Lexar +0x30 SanDisk +0x31 Silicon Power +0x33 STMicroelectronics +0x41 Kingston +0x6f STMicroelectronics +0x74 Transcend +0x76 Patriot +0x82 Gobe/Sony +0x89 Unknown --2.53.0
Re: [PATCH 1/4] mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
fre. 15. mai 2026 kl. 17:05 skrev Avri Altman <[email protected]>:
Quoted 240 lines
Quoted 240 lines
Similar to pci.ids and usb.ids, move the statically defined manufacturer ID arrays out of the source and into external sdcard.ids and multimediacard.ids files. This allows other programs to use the same database without an API, ABI, or cmd interface.
Make the program able to read from the base directory to test without installing.
Make it possible from the
Makefileto change the install directory of the database.Signed-off-by Torstein Eide <[email protected]>--- Makefile | 8 +- lsmmc.c | 225 ++++++++++++--------------------------------- multimediacard.ids | 16 ++++ sdcard.ids | 23 +++++ 4 files changed, 104 insertions(+), 168 deletions(-) create mode 100644multimediacard.ids create mode 100644 sdcard.ids
Makefile +3
-1@@ -1,7 +1,9 @@ CC ?= gcc GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)" AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \ - -DVERSION=\"$(GIT_VERSION)\" + -DVERSION=\"$(GIT_VERSION)\" \ + -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \ + -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\" CFLAGS ?= -g -O2 objects = \ mmc.o \@@ -19,6 +21,7 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS)$(CFLAGS) INSTALL = install prefix ?=
/usr/localbindir = $(prefix)/binMakefile +4
-0+idsdir ?= /usr/share/misc LIBS= RESTORE_LIBS= mandir = /usr/share/man@@ -55,6 +58,9 @@ install: $(progs) $(INSTALL) $(progs) $(DESTDIR)$(bindir) $(INSTALL) -m755 -d $(DESTDIR)$(mandir)/man1 $(INSTALL) -m 644 mmc.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m755 -d $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir) + $(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir) -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)lsmmc.c +8
-151@@ -56,6 +56,13 @@#define IDS_MAX 256#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) +#ifndef SD_IDS_PATH +#define SD_IDS_PATH "/usr/share/misc/sdcard.ids" +#endif +#ifndef MMC_IDS_PATH +#define MMC_IDS_PATH "/usr/share/misc/multimediacard.ids" +#endif +enum bus_type {MMC =1 ,SD ,@@ -63,6 +70,7 @@ enum bus_type {struct config {char *dir; +char *ids_dir;bool verbose;enum bus_type bus;@@ -75,157 +83,6 @@ enum REG_TYPE { SCR, }; -struct ids_database { -int id; -char *manufacturer; -}; - -static struct ids_database sd_database[] = { - { - .id =0x01 , - .manufacturer ="Panasonic" , - }, - { - .id =0x02 , - .manufacturer ="Toshiba/Kingston/Viking" , - }, - { - .id =0x03 , - .manufacturer ="SanDisk" , - }, - { - .id =0x08 , - .manufacturer ="Silicon Power" , - }, - { - .id =0x18 , - .manufacturer ="Infineon" , - }, - { - .id =0x1b , - .manufacturer ="Transcend/Samsung" , - }, - { - .id =0x1c , - .manufacturer ="Transcend" , - }, - { - .id =0x1d , - .manufacturer ="Corsair/AData" , - }, - { - .id =0x1e , - .manufacturer ="Transcend" , - }, - { - .id =0x1f , - .manufacturer ="Kingston" , - }, - { - .id =0x27 , - .manufacturer ="Delkin/Phison" , - }, - { - .id =0x28 , - .manufacturer ="Lexar" , - }, - { - .id =0x30 , - .manufacturer ="SanDisk" , - }, - { - .id =0x31 , - .manufacturer ="Silicon Power" , - }, - { - .id =0x33 , - .manufacturer ="STMicroelectronics" , - }, - { - .id =0x41 , - .manufacturer ="Kingston" , - }, - { - .id =0x6f , - .manufacturer ="STMicroelectronics" , - }, - { - .id =0x74 , - .manufacturer ="Transcend" , - }, - { - .id =0x76 , - .manufacturer ="Patriot" , - }, - { - .id =0x82 , - .manufacturer ="Gobe/Sony" , - }, - { - .id =0x89 , - .manufacturer ="Unknown" , - }, -}; - -static struct ids_database mmc_database[] = { - { - .id =0x00 , - .manufacturer ="SanDisk" , - }, - { - .id =0x02 , - .manufacturer ="Kingston/SanDisk" , - }, - { - .id =0x03 , - .manufacturer ="Toshiba" , - }, - { - .id =0x05 , - .manufacturer ="Unknown" , - }, - { - .id =0x06 , - .manufacturer ="Unknown" , - }, - { - .id =0x11 , - .manufacturer ="Toshiba" , - }, - { - .id =0x13 , - .manufacturer ="Micron" , - }, - { - .id =0x15 , - .manufacturer ="Samsung/SanDisk/LG" , - }, - { - .id =0x37 , - .manufacturer ="KingMax" , - }, - { - .id =0x44 , - .manufacturer ="ATP" , - }, - { - .id =0x45 , - .manufacturer ="SanDisk Corporation" , - }, - { - .id =0x2c , - .manufacturer ="Kingston" , - }, - { - .id =0x70 , - .manufacturer ="Kingston" , - }, - { - .id =0xfe , - .manufacturer ="Micron" , - }, -}; -/* Command line parsing functions */ static void usage (char *progname) {@@ -319,25 +176,53 @@ static int parse_opts(int argc, char **argv, struct config *config)return 0 ; }
Quoted 15 lines
lsmmc.c static int parse_opts(int argc, char **argv, struct config *config) · line 185
Quoted 11 lines
lsmmc.c +6
-3-static char *get_manufacturer (struct config *config,unsigned int manid) +static const char *get_manufacturer (struct config *config,unsigned int +manid) { -struct ids_database *db; -unsigned int ids_cnt; +const char *paths[] = {NULL ,NULL }; +char local_path[PATH_MAX ];int i; +FILE *f; +static char name[256 ];I guess you are preparing here to iterate over several devices.
The static buffer will work here only if the result is printed before the next call. Maybe usestrdup()instead?
Good catch will repalce it.
Quoted 24 lines
Quoted 11 lines
lsmmc.c +10
-0+char line[256 ]; +const char *local_name; + + local_name = (config->bus ==MMC ) ?"multimediacard.ids" :"sdcard.ids" ; +/* check local directory first, then fall back to system path */ +if (config->ids_dir) +snprintf (local_path,sizeof (local_path),"%s/%s" , config->ids_dir, local_name); +else +snprintf (local_path,sizeof (local_path),"%s" , local_name); + paths[0 ] = local_path;lsmmc.c static int parse_opts(int argc, char **argv, struct config *config) · line 199
Quoted 10 lines
lsmmc.c +3
-6+ paths[1 ] = (config->bus ==MMC ) ?MMC_IDS_PATH :SD_IDS_PATH ; -if (config->bus ==MMC ) { - db = mmc_database; - ids_cnt =ARRAY_SIZE (mmc_database); - }else { - db = sd_database; - ids_cnt =ARRAY_SIZE (sd_database); +for (i =0 ; i <2 ; i++) { + f =fopen (paths[i],"r" );Maybe just:
f =fopen(local_path, "r");
if (!f)
Quoted 9 lines
f = fopen(system_path, "r");lsmmc.c static int parse_opts(int argc, char **argv, struct config *config) · line 204
Quoted 5 lines
lsmmc.c +4
-0+if (f) +break ; } +if (!f) +return NULL ;A warning that the ids files are missing?
I agree, i will also add a flag to check that we printer a error.
Quoted 50 lines
Quoted 50 lines
lsmmc.c +21
-5-for (i =0 ; i < ids_cnt; i++) { -if (db[i].id == manid) -return db[i].manufacturer; +while (fgets (line,sizeof (line), f)) { +unsigned int id; +char *nl; + + nl =strchr (line,'\n' ); +if (nl) + *nl ='\0' ; + +if (line[0 ] =='#' || line[0 ] =='\0' ) +continue ; + +if (sscanf (line,"0x%x %255[^\n]" , &id, name) ==2 ) { +if (id == manid) { +fclose (f); +return name; + } + } } +fclose (f);return NULL ; }@@ -526,7 +411,7 @@ static void print_sd_cid(struct config *config, char *cid)unsigned int mdt_month;unsigned int mdt_year;unsigned int crc; -char *manufacturer =NULL ; +const char *manufacturer =NULL ;parse_bin (cid,"8u16a40a4u4u32u4r8u4u7u1r" , &mid, &oid[0], &pnm[0], &prv_major, &prv_minor, &psn, @@ -585,7 +470,7 @@ static void print_mmc_cid(struct config *config, char *cid) unsigned int mdt_month;unsigned int mdt_year;unsigned int crc; - char *manufacturer = NULL; +const char *manufacturer =NULL ; parse_bin(cid, "8u6r2u8u48a4u4u32u4u4u7u1r", &mid, &cbx, &oid, &pnm[0], &prv_major, &prv_minor, &psn, @@ -2220,11 +2105,14 @@ static int
process_dir(struct config *config, enum REG_TYPE reg)char *type = NULL; int ret = 0;
Quoted 7 lines
Quoted 1 line
+
config->ids_dir=getcwd(NULL, 0);I think it's an opportunity to replace the
chdir()/getcwd()pattern with reading via full paths (e.g., aread_file_at(dir, name)helper)? That would eliminate the need forids_direntirely -get_manufacturer()could just open the.idsfiles directly since the working directory wouldn't change. Your code is fine, if you decided to do that, it should be a cleanup first patch.Thanks,
Avri
I agree the chdir is unnecessary.
I will make a V2 patch.
Quoted 87 lines
Quoted 86 lines
lsmmc.c +5
-2+if (chdir (config->dir) <0 ) {fprintf (stderr,"MMC/SD information directory '%s' does not exist.\n" , config->dir); -return -1 ; + ret =-1 ; + goto err; } type =read_file ("type" );@@ -2232,7 +2120,8 @@ static int process_dir(struct config *config, enum REG_TYPE reg) fprintf(stderr,"Could not read card interface type in directory '%s'.\n" , config->dir); -return -1 ; + ret =-1 ; + goto err; }if (strcmp(type, "MMC") && strcmp(type, "SD")) { @@ -2247,6 +2136,8 @@static int
process_dir(struct config *config, enum REG_TYPE reg)err:
free(type);lsmmc.c +2
-0+free (config->ids_dir); + config->ids_dir =NULL ;return ret; }multimediacard.ids new file mode 100644 index renamed from multimediacard.ids +0
-00000000..0c91118
multimediacard.ids new file +17
-0@@ -0,0 +1,16 @@ +# MMC manufacturer IDs +# This file is maintained at: +https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x00 SanDisk +0x02 Kingston/SanDisk +0x03 Toshiba +0x05 Unknown +0x06 Unknown +0x11 Toshiba +0x13 Micron +0x15 Samsung/SanDisk/LG +0x37 KingMax +0x44 ATP +0x45 SanDisk Corporation +0x2c Kingston +0x70 Kingston +0xfe Micronsdcard.ids new file +23
-1@@ -0,0 +1,23 @@ +# SD card (secure digital) manufacturer IDs # This file is maintained +at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git +0x01 Panasonic +0x02 Toshiba/Kingston/Viking +0x03 SanDisk +0x08 Silicon Power +0x18 Infineon +0x1b Transcend/Samsung +0x1c Transcend +0x1d Corsair/AData +0x1e Transcend +0x1f Kingston +0x27 Delkin/Phison +0x28 Lexar +0x30 SanDisk +0x31 Silicon Power +0x33 STMicroelectronics +0x41 Kingston +0x6f STMicroelectronics +0x74 Transcend +0x76 Patriot +0x82 Gobe/Sony +0x89 Unknown --2.53.0
PATCH 2/4 mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads
In reply to Torstein EideCommands like 'cid read' previously required a raw sysfs device path such as /sys/bus/mmc/devices/mmc0:0001/. Most users know their block device as /dev/mmcblk0 or /sys/block/mmcblk0.
Add resolve_dev_path() which follows /sys/class/block/<dev>/device via realpath() to reach the canonical sysfs device directory. Paths that start with /dev/ or /sys/block/ are resolved automatically in do_read_reg() before processing, and the resolved sysfs path is printed so the caller can see which device was matched.
--- docs/HOWTO.rst | 59 ++++++++++++++++++++++++++++++++++++++++++-------- lsmmc.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 9 deletions(-)
docs/HOWTO.rst +50 -9
@@ -35,19 +35,60 @@ Running mmc-utils Set user area write protection. ``csd read [-h] [-v] [-b bus_type] [-r register] <device path>`` - Print CSD data from <device path>. The device path should specify the csd sysfs file directory. - if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path. - it is useful for cases we are getting the register value without having the actual platform. + Print CSD data from <device path>. The device path may be one of the following: + - sysfs device directory (/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001) + - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc csd read /dev/mmcblk0 + sysfs: /sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001 + CSD Register: 00000000... ``cid read <device path>`` - Print CID data from <device path>. The device path should specify the cid sysfs file directory. - if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path. - it is useful for cases we are getting the register value without having the actual platform. + Print CID data from <device path>. The device path may be one of the following: + - sysfs device directory (/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001) + - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc cid read /dev/mmcblk0 + sysfs: /sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001 + Manufacturer ID: 0x15 + OEM ID: 0x0100 + Product name: MAG4FA + Product revision: 1.0 + Serial number: 0x1a2b3c4d + Manufacturing date: 01/2021 ``scr read <device path>`` - Print SCR data from <device path>. The device path should specify the scr sysfs file directory. - if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path. - it is useful for cases we are getting the register value without having the actual platform. + Print SCR data from <device path>. The device path may be one of the following: + - sysfs device directory (/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa) + - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc scr read /dev/mmcblk1 + sysfs: /sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa + SCR Register: 0235800000000000 ``ffu <image name> <device> [chunk-bytes]`` Default mode. Run Field Firmware Update with `<image name>` on `<device>`. `[chunk-bytes]` is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.
lsmmc.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.53.0
RE: [PATCH 2/4] mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads
Quoted 115 lines
Commands like 'cid read' previously required a raw sysfs device path such as /sys/bus/mmc/devices/mmc0:0001/. Most users know their block device as
/dev/mmcblk0or/sys/block/mmcblk0.Add
resolve_dev_path()which follows /sys/class/block/<dev>/device viarealpath()to reach the canonical sysfs device directory. Paths that start with/dev/or/sys/block/are resolved automatically indo_read_reg()before processing, and the resolved sysfs path is printed so the caller can see which device was matched.Signed-off-by Torstein Eide <[email protected]>--- docs/HOWTO.rst | 59 ++++++++++++++++++++++++++++++++++++++++++-------(quoted diff) +0
-1- lsmmc.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 9 deletions(-)docs/HOWTO.rst +0
-1@@ -35,19 +35,60 @@ Running mmc-utils Set user area write protection. ``csd read [-h] [-v] [-b bus_type] [-r register] <device path>`` - Print CSD data from <device path>. The device path should specify the csdsysfs file directory.
- if [bus_type] is passed (mmc or sd) the [register] content must be passed as
well, and no need for device path.
- it is useful for cases we are getting the register value without having the
actual platform.
+ Print CSD data from <device path>. The device path may be one of the
following:
+ - sysfs device directory
(/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001)docs/HOWTO.rst +12
-0+ - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc csd read /dev/mmcblk0 + sysfs:
/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001docs/HOWTO.rst +1
-1+ CSD Register: 00000000... ``cid read <device path>`` - Print CID data from <device path>. The device path should specify the cidsysfs file directory.
- if [bus_type] is passed (mmc or sd) the [register] content must be passed as
well, and no need for device path.
- it is useful for cases we are getting the register value without having the
actual platform.
+ Print CID data from <device path>. The device path may be one of the
following:
+ - sysfs device directory
(/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001)docs/HOWTO.rst +12
-0+ - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc cid read /dev/mmcblk0 + sysfs:
/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001docs/HOWTO.rst +6
-1+ Manufacturer ID: 0x15 + OEM ID: 0x0100 + Product name: MAG4FA + Product revision: 1.0 + Serial number: 0x1a2b3c4d + Manufacturing date: 01/2021 ``scr read <device path>`` - Print SCR data from <device path>. The device path should specify the scrsysfs file directory.
- if [bus_type] is passed (mmc or sd) the [register] content must be passed as
well, and no need for device path.
- it is useful for cases we are getting the register value without having the
actual platform.
+ Print SCR data from <device path>. The device path may be one of the
following:
+ - sysfs device directory
(/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa)docs/HOWTO.rst +12
-0+ - device node (/dev/mmcblkN) + - sysfs block device entry (/sys/block/mmcblkN) + /dev/ and /sys/block/ paths are resolved to the sysfs device + directory automatically and the resolved path is printed. + If [-b bus_type] is passed (mmc or sd) the [-r register] content must + be passed as well, and no device path is required. Useful when the + register value is known without access to the actual hardware. + + Example:: + + $ mmc scr read /dev/mmcblk1 + sysfs:/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa
+ SCR Register: 0235800000000000``ffu <image name> <device> [chunk-bytes]``
Default mode. Run Field Firmware Update with<image name>on<device>.[chunk-bytes]is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.lsmmc.c +0
-0
lsmmc.c static const char *get_manufacturer(struct config · line 233
Quoted 8 lines
lsmmc.c +4
-0@@ -226,6 +226,33 @@ static const char *get_manufacturer(struct config *config, unsigned int manid)return NULL ; } +static char *resolve_dev_path (const char *path) { +const char *devname =strrchr (path,'/' ); +char syspath[PATH_MAX ]; +char *resolved;
Maybe:
char resolved[PATH_MAX]
And at the end:
return strdup(resolved);
lsmmc.c static const char *get_manufacturer(struct config *config, unsigned int manid) · line 235
Quoted 2 lines
lsmmc.c +2
-0+ + devname = devname ? devname +1 : path;
What happens is a partition e.g. /dev/mmcblk0p1 is passed?
Quoted 8 lines
lsmmc.c +8
-0+if (*devname =='\0' ) +return NULL ; + +if (snprintf (syspath,sizeof (syspath),"/sys/class/block/%s/device" , + devname) >=PATH_MAX ) +return NULL ; + + resolved =malloc (PATH_MAX );
lsmmc.c static const char *get_manufacturer(struct config *config, unsigned int manid) · line 253
Quoted 10 lines
lsmmc.c +10
-0+if (!resolved) +return NULL ; + +if (realpath (syspath, resolved) ==NULL ) { +fprintf (stderr,"Cannot resolve '%s': %s\n" , path,strerror (errno)); +free (resolved); +return NULL ; + } + +return resolved;
Shouldn't we validate that the resolved path is actually an MMC/SD device ? E.g. the sysfs dir has fwrev in it or read the type entry etc.
Thanks,
Avri
Quoted 31 lines
lsmmc.c +17
-0+} +/* MMC/SD file parsing functions */ static char *read_file (char *name) {@@ -2151,6 +2178,21 @@ static int do_read_reg(int argc, char **argv, enum REG_TYPE reg)if (ret)return ret; +if (cfg.dir && + (strncmp (cfg.dir,"/dev/" ,5 ) ==0 || +strncmp (cfg.dir,"/sys/block/" ,11 ) ==0 )) { +char *sysfs =resolve_dev_path (cfg.dir); + +if (!sysfs) { +free (cfg.dir); +return -1 ; + } + +free (cfg.dir); + cfg.dir = sysfs; +printf ("sysfs: %s\n" , cfg.dir); + } +if (cfg.dir) { ret =process_dir (&cfg, reg);free(cfg.dir);--
2.53.0
PATCH 3/4 mmc-utils: lsmmc: Add mmc list command
In reply to Torstein EideAdd a 'mmc list' command that scans /sys/bus/mmc/devices/, resolves each card's sysfs path, and prints a one-line summary per device.
find_block_devname() maps a sysfs device path back to its mmcblkN name by scanning /sys/class/block/mmcblkN/device symlinks.
print_list_entry() parses the CID register and formats a fixed-width table row with device name, /dev path, bus type, manufacturer, product, revision, serial number, and manufacturing date.
The header is printed once before the first result. Devices without a readable cid file are skipped silently via access() so unrelated sysfs entries do not produce spurious error messages.
--- docs/HOWTO.rst | 12 ++++ lsmmc.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++ mmc.c | 6 +- mmc_cmds.h | 1 + 4 files changed, 185 insertions(+), 1 deletion(-)
docs/HOWTO.rst +12 -0
@@ -90,6 +90,18 @@ Running mmc-utils sysfs: /sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa SCR Register: 0235800000000000 + ``list`` + List all MMC/SD devices present on the system. Output is a table with + columns: DEVICE (sysfs name), DEV (/dev path), TYPE (MMC or SD), + MANUFACTURER, PRODUCT, REV, SERIAL, and DATE. + + Example:: + + $ mmc list + DEVICE DEV TYPE MANUFACTURER PRODUCT REV SERIAL DATE + mmc0:0001 /dev/mmcblk0 MMC Samsung MAG4FA 1.0 0x1a2b3c4d 2021-jan + mmc1:aaaa /dev/mmcblk1 SD SanDisk SP32G 8.0 0x5e6f7a8b 2020-mar + ``ffu <image name> <device> [chunk-bytes]`` Default mode. Run Field Firmware Update with `<image name>` on `<device>`. `[chunk-bytes]` is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.
lsmmc.c +167 -0
179 lines not on this page · raw message
mmc.c +5 -1
@@ -292,6 +292,11 @@ static struct Command commands[] = { "4. The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.\n", NULL }, + { do_list,0 , +"list" ,"\n" +"List all MMC/SD devices with their /dev path and CID info." , +NULL + }, { NULL, 0, NULL, NULL } };
@@ -567,4 +572,3 @@ int main(int ac, char **av )exit (func (nargs, args)); } -
mmc_cmds.h +1 -0
@@ -49,6 +49,7 @@ int do_opt_ffu4(int nargs, char **argv);int do_read_scr (int argc,char **argv);int do_read_cid (int argc,char **argv);int do_read_csd (int argc,char **argv); +int do_list (int nargs,char **argv);int do_erase (int nargs,char **argv);int do_general_cmd_read (int nargs,char **argv);int do_softreset (int nargs,char **argv);
Signature · 1 line
2.53.0
RE: [PATCH 3/4] mmc-utils: lsmmc: Add mmc list command
Quoted 93 lines
Add a 'mmc list' command that scans
/sys/bus/mmc/devices/, resolves each card's sysfs path, and prints a one-line summary per device.
find_block_devname()maps a sysfs device path back to its mmcblkN name by scanning/sys/class/block/mmcblkN/devicesymlinks.
print_list_entry()parses the CID register and formats a fixed-width table row with device name, /dev path, bus type, manufacturer, product, revision, serial number, and manufacturing date.The header is printed once before the first result. Devices without a readable cid file are skipped silently via
access()so unrelated sysfs entries do not produce spurious error messages.Signed-off-by Torstein Eide <[email protected]>--- docs/HOWTO.rst | 12 ++++ lsmmc.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++ mmc.c | 6 +- mmc_cmds.h | 1 + 4 files changed, 185 insertions(+), 1 deletion(-)docs/HOWTO.rst +0
-0@@ -90,6 +90,18 @@ Running mmc-utils sysfs:/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa
SCR Register: 0235800000000000docs/HOWTO.rst +9
-0+ ``list`` + List all MMC/SD devices present on the system. Output is a table with + columns: DEVICE (sysfs name), DEV (/dev path), TYPE (MMC or SD), + MANUFACTURER, PRODUCT, REV, SERIAL, and DATE. + + Example:: + + $ mmc list + DEVICE DEV TYPE MANUFACTURER PRODUCT REVSERIAL DATE
+ mmc0:0001/dev/mmcblk0MMC Samsung MAG4FA 1.00x1a2b3c4d2021-jan
+ mmc1:aaaa/dev/mmcblk1SD SanDisk SP32G 8.00x5e6f7a8b2020-mar
+
``ffu <image name> <device> [chunk-bytes]``
Default mode. Run Field Firmware Update with<image name>on<device>.[chunk-bytes]is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.lsmmc.c +31
-0@@ -253,6 +253,38 @@ static char *resolve_dev_path(const char *path)return resolved; } +static char *find_block_devname (const char *sysfs_devpath) { +DIR *d; +struct dirent *ent; + + d =opendir ("/sys/class/block" ); +if (!d) +return NULL ; + +while ((ent =readdir (d)) !=NULL ) { +char linkpath[PATH_MAX ]; +char resolved[PATH_MAX ]; + +if (strncmp (ent->d_name,"mmcblk" ,6 ) !=0 ) +continue ; +if (strchr (ent->d_name +6 ,'p' )) +continue ; + +snprintf (linkpath,sizeof (linkpath), +"/sys/class/block/%s/device" , ent->d_name); +if (realpath (linkpath, resolved) ==NULL ) +continue ; +if (strcmp (resolved, sysfs_devpath) ==0 ) { +closedir (d); +return strdup (ent->d_name); + } + } + +closedir (d); +return NULL ; +} +/* MMC/SD file parsing functions */ static char *read_file (char *name) {
lsmmc.c static int do_read_reg(int argc, char **argv, enum · line 2243
Quoted 9 lines
lsmmc.c +5
-0@@ -2203,6 +2235,141 @@ static int do_read_reg(int argc, char **argv, enum REG_TYPE reg)return ret; } +static const char *month_name (unsigned int month) { +static const char *months[] = { +"???" ,"jan" ,"feb" ,"mar" ,"apr" ,"may" ,"jun" , +"jul" ,"aug" ,"sep" ,"oct" ,"nov" ,"dec" , + };
Maybe maintain consistency with the month's arrays in print_sd_cid() / print_mmc_cid()`
Quoted 35 lines
lsmmc.c +35
-0+ +if (month >=ARRAY_SIZE (months)) +return "???" ; + +return months[month]; +} + +static void print_list_entry (struct config *cfg,const char *devname, +const char *blkdev,char *cid) { +const char *mfr; +char devnode[32 ]; + +snprintf (devnode,sizeof (devnode),"/dev/%s" , blkdev ? blkdev : +"?" ); + +if (cfg->bus ==SD ) { +unsigned int mid, prv_major, prv_minor, psn, mdt_year; +unsigned int mdt_month, crc; +char oid[3 ], pnm[6 ]; + +parse_bin (cid,"8u16a40a4u4u32u4r8u4u7u1r" , + &mid, &oid[0 ], &pnm[0 ], &prv_major, &prv_minor, + &psn, &mdt_year, &mdt_month, &crc); + oid[2 ] ='\0' ; + pnm[5 ] ='\0' ; + + mfr =get_manufacturer (cfg, mid); +printf ("%-14s %-14s SD %-20s %-10s %u.%u 0x%08x %u-%s\n" , + devname, devnode, mfr ? mfr :"Unlisted" , pnm, + prv_major, prv_minor, psn,2000 + mdt_year, +month_name (mdt_month)); + }else { +unsigned int mid, cbx, oid, prv_major, prv_minor, psn; +unsigned int mdt_year, mdt_month, crc; +char pnm[7 ];
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2288
Quoted 10 lines
lsmmc.c +10
-0+ +parse_bin (cid,"8u6r2u8u48a4u4u32u4u4u7u1r" , + &mid, &cbx, &oid, &pnm[0 ], &prv_major, &prv_minor, + &psn, &mdt_year, &mdt_month, &crc); + pnm[6 ] ='\0' ; + + mfr =get_manufacturer (cfg, mid); + printf("%-14s %-14s MMC %-20s %-10s %u.%u 0x%08x %u-%s\n", + devname, devnode, mfr ? mfr : "Unlisted", pnm, + prv_major, prv_minor, psn, 1997 + mdt_year,
The existing print_mmc_cid() has logic to adjust the base year based on ext_csd_rev (2013 for rev > 4, 2029 for rev > 8). See if you can use it as well.
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2301
Quoted 13 lines
lsmmc.c +13
-0+ month_name(mdt_month)); + } +} + +int do_list (int nargs,char **argv) +{ +const char *bus_path ="/sys/bus/mmc/devices" ; +char orig_cwd[PATH_MAX ]; +DIR *d; +struct dirent *ent; +bool header_printed = false; + +if (!getcwd (orig_cwd,sizeof (orig_cwd))) {
If you decide to replace getcwd/chdir (comment in patch 1) - use here read_file_at as well...
Quoted 5 lines
lsmmc.c +5
-0+fprintf (stderr,"Cannot get current directory.\n" ); +return -1 ; + } + + d =opendir (bus_path);
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2316
Quoted 10 lines
lsmmc.c +10
-0+if (!d) { +fprintf (stderr,"Cannot open %s\n" , bus_path); +return -1 ; + } + +while ((ent =readdir (d)) !=NULL ) { +char devpath[PATH_MAX ]; +char resolved[PATH_MAX ]; +char *type, *cid, *blkdev; +struct config cfg = {};
re-initializing cfg every iteration is wasteful but harmless - consider moving it out of the loop.
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2325
Quoted 9 lines
lsmmc.c +9
-0+ +if (!strchr (ent->d_name,':' )) +continue ; + +snprintf (devpath,sizeof (devpath),"%s/%s" , bus_path, ent->d_name); +if (realpath (devpath, resolved) ==NULL ) +continue ; + +if (chdir (resolved) <0 )
silently skip devices with no diagnostics ?
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2328
Quoted 3 lines
lsmmc.c +3
-0+continue ; + +if (access ("cid" ,R_OK ) !=0 ) {
Isn't read_file() does fopen() which checks the same thing as access()?
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2331
Quoted 3 lines
lsmmc.c +3
-0+if (chdir (orig_cwd) <0 ) +break ; +continue ;
silently skip devices with no diagnostics ?
Quoted 24 lines
lsmmc.c +24
-0+ } + + type =read_file ("type" ); +if (!type) { +if (chdir (orig_cwd) <0 ) +break ; +continue ; + } + + cid =read_file ("cid" ); +if (!cid) { +free (type); +if (chdir (orig_cwd) <0 ) +break ; +continue ; + } + + blkdev =find_block_devname (resolved); + cfg.bus =strcmp (type,"MMC" ) ?SD :MMC ; + cfg.ids_dir = orig_cwd; + +if (!header_printed) { + printf("%-14s %-14s %-5s%-20s %-10s %-5s %-12s %s\n", + "DEVICE", "DEV", "TYPE", "MANUFACTURER", "PRODUCT",
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2365
Quoted 10 lines
lsmmc.c +10
-0+ "REV", "SERIAL", "DATE"); + header_printed = true; + } + +print_list_entry (&cfg, ent->d_name, blkdev, cid); + +free (blkdev); +free (cid); +free (type); +if (chdir (orig_cwd) <0 )
We fail here but returns 0?
Thanks,
Avri
Quoted 45 lines
lsmmc.c +7
-0+break ; + } + +closedir (d); +return 0 ; +} +int do_read_csd (int argc,char **argv) { return do_read_reg(argc, argv, CSD); diff --git a/mmc.c b/mmc.c index077e901..01ad181 100644
mmc.c +5
-1@@ -292,6 +292,11 @@ static struct Command commands[] = { "4. The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.\n", NULL }, + { do_list, 0, + "list", "\n" + "List all MMC/SD devices with their /dev path and CID info.", + NULL + }, { NULL, 0, NULL, NULL } };@@ -567,4 +572,3 @@ int main(int ac, char **av )exit (func (nargs, args)); } -mmc_cmds.h +0
-0@@ -49,6 +49,7 @@ int do_opt_ffu4(int nargs, char **argv); int do_read_scr(intargc, char **argv); int
do_read_cid(int argc, char **argv); intdo_read_csd(int argc, char **argv);
+intdo_list(int nargs, char **argv);
intdo_erase(int nargs, char **argv);
intdo_general_cmd_read(int nargs, char **argv); int do_softreset(int nargs,
char **argv);
--
2.53.0
Re: [PATCH 3/4] mmc-utils: lsmmc: Add mmc list command
fre. 15. mai 2026 kl. 18:38 skrev Avri Altman <[email protected]>:
Quoted 98 lines
Quoted 98 lines
Add a 'mmc list' command that scans
/sys/bus/mmc/devices/, resolves each card's sysfs path, and prints a one-line summary per device.
find_block_devname()maps a sysfs device path back to its mmcblkN name by scanning/sys/class/block/mmcblkN/devicesymlinks.
print_list_entry()parses the CID register and formats a fixed-width table row with device name, /dev path, bus type, manufacturer, product, revision, serial number, and manufacturing date.The header is printed once before the first result. Devices without a readable cid file are skipped silently via
access()so unrelated sysfs entries do not produce spurious error messages.Signed-off-by Torstein Eide <[email protected]>--- docs/HOWTO.rst | 12 ++++ lsmmc.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++ mmc.c | 6 +- mmc_cmds.h | 1 + 4 files changed, 185 insertions(+), 1 deletion(-)docs/HOWTO.rst +0
-0@@ -90,6 +90,18 @@ Running mmc-utils sysfs:/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa
SCR Register: 0235800000000000docs/HOWTO.rst +9
-0+ ``list`` + List all MMC/SD devices present on the system. Output is a table with + columns: DEVICE (sysfs name), DEV (/dev path), TYPE (MMC or SD), + MANUFACTURER, PRODUCT, REV, SERIAL, and DATE. + + Example:: + + $ mmc list + DEVICE DEV TYPE MANUFACTURER PRODUCT REVSERIAL DATE
+ mmc0:0001/dev/mmcblk0MMC Samsung MAG4FA 1.00x1a2b3c4d2021-jan
+ mmc1:aaaa/dev/mmcblk1SD SanDisk SP32G 8.00x5e6f7a8b2020-mar
+
``ffu <image name> <device> [chunk-bytes]``
Default mode. Run Field Firmware Update with<image name>on<device>.[chunk-bytes]is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.lsmmc.c +31
-0@@ -253,6 +253,38 @@ static char *resolve_dev_path(const char *path)return resolved; } +static char *find_block_devname (const char *sysfs_devpath) { +DIR *d; +struct dirent *ent; + + d =opendir ("/sys/class/block" ); +if (!d) +return NULL ; + +while ((ent =readdir (d)) !=NULL ) { +char linkpath[PATH_MAX ]; +char resolved[PATH_MAX ]; + +if (strncmp (ent->d_name,"mmcblk" ,6 ) !=0 ) +continue ; +if (strchr (ent->d_name +6 ,'p' )) +continue ; + +snprintf (linkpath,sizeof (linkpath), +"/sys/class/block/%s/device" , ent->d_name); +if (realpath (linkpath, resolved) ==NULL ) +continue ; +if (strcmp (resolved, sysfs_devpath) ==0 ) { +closedir (d); +return strdup (ent->d_name); + } + } + +closedir (d); +return NULL ; +} +/* MMC/SD file parsing functions */ static char *read_file (char *name) {@@ -2203,6 +2235,141 @@ static int do_read_reg(int argc, char **argv, enum REG_TYPE reg)return ret; }
Quoted 6 lines
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2243
Quoted 5 lines
lsmmc.c +5
-0+static const char *month_name (unsigned int month) { +static const char *months[] = { +"???" ,"jan" ,"feb" ,"mar" ,"apr" ,"may" ,"jun" , +"jul" ,"aug" ,"sep" ,"oct" ,"nov" ,"dec" , + };Maybe maintain consistency with the month's arrays in
print_sd_cid()/print_mmc_cid()`
good poiint ill fix.
Quoted 49 lines
Quoted 36 lines
lsmmc.c +35
-0+ +if (month >=ARRAY_SIZE (months)) +return "???" ; + +return months[month]; +} + +static void print_list_entry (struct config *cfg,const char *devname, +const char *blkdev,char *cid) { +const char *mfr; +char devnode[32 ]; + +snprintf (devnode,sizeof (devnode),"/dev/%s" , blkdev ? blkdev : +"?" ); + +if (cfg->bus ==SD ) { +unsigned int mid, prv_major, prv_minor, psn, mdt_year; +unsigned int mdt_month, crc; +char oid[3 ], pnm[6 ]; + +parse_bin (cid,"8u16a40a4u4u32u4r8u4u7u1r" , + &mid, &oid[0 ], &pnm[0 ], &prv_major, &prv_minor, + &psn, &mdt_year, &mdt_month, &crc); + oid[2 ] ='\0' ; + pnm[5 ] ='\0' ; + + mfr =get_manufacturer (cfg, mid); +printf ("%-14s %-14s SD %-20s %-10s %u.%u 0x%08x %u-%s\n" , + devname, devnode, mfr ? mfr :"Unlisted" , pnm, + prv_major, prv_minor, psn,2000 + mdt_year, +month_name (mdt_month)); + }else { +unsigned int mid, cbx, oid, prv_major, prv_minor, psn; +unsigned int mdt_year, mdt_month, crc; +char pnm[7 ];lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2288
Quoted 10 lines
lsmmc.c +10
-0+ +parse_bin (cid,"8u6r2u8u48a4u4u32u4u4u7u1r" , + &mid, &cbx, &oid, &pnm[0 ], &prv_major, &prv_minor, + &psn, &mdt_year, &mdt_month, &crc); + pnm[6 ] ='\0' ; + + mfr =get_manufacturer (cfg, mid); + printf("%-14s %-14s MMC %-20s %-10s %u.%u 0x%08x %u-%s\n", + devname, devnode, mfr ? mfr : "Unlisted", pnm, + prv_major, prv_minor, psn, 1997 + mdt_year,The existing
print_mmc_cid()has logic to adjust the base year based onext_csd_rev(2013 for rev > 4, 2029 for rev > 8). See if you can use it as well.
Quoted 15 lines
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2301
Quoted 13 lines
lsmmc.c +13
-0+ month_name(mdt_month)); + } +} + +int do_list (int nargs,char **argv) +{ +const char *bus_path ="/sys/bus/mmc/devices" ; +char orig_cwd[PATH_MAX ]; +DIR *d; +struct dirent *ent; +bool header_printed = false; + +if (!getcwd (orig_cwd,sizeof (orig_cwd))) {If you decide to replace getcwd/chdir (comment in patch 1) - use here
read_file_atas well...
Yes i will.
Quoted 8 lines
Quoted 8 lines
lsmmc.c +8
-0+fprintf (stderr,"Cannot get current directory.\n" ); +return -1 ; + } + + d =opendir (bus_path); +if (!d) { +fprintf (stderr,"Cannot open %s\n" , bus_path); +return -1 ;
Quoted 9 lines
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2316
Quoted 7 lines
lsmmc.c +7
-0+ } + +while ((ent =readdir (d)) !=NULL ) { +char devpath[PATH_MAX ]; +char resolved[PATH_MAX ]; +char *type, *cid, *blkdev; +struct config cfg = {};re-initializing cfg every iteration is wasteful but harmless - consider moving it out of the loop.
Ill move it out of loop.
Quoted 14 lines
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2325
Quoted 9 lines
lsmmc.c +9
-0+ +if (!strchr (ent->d_name,':' )) +continue ; + +snprintf (devpath,sizeof (devpath),"%s/%s" , bus_path, ent->d_name); +if (realpath (devpath, resolved) ==NULL ) +continue ; + +if (chdir (resolved) <0 )silently skip devices with no diagnostics ?
lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2328
Quoted 3 lines
lsmmc.c +3
-0+continue ; + +if (access ("cid" ,R_OK ) !=0 ) {
Quoted 7 lines
Isn't
read_file()doesfopen()which checks the same thing asaccess()?lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2331
Quoted 3 lines
lsmmc.c +3
-0+if (chdir (orig_cwd) <0 ) +break ; +continue ;silently skip devices with no diagnostics ?
this will be removed with removal of chdir.
Quoted 37 lines
Quoted 24 lines
lsmmc.c +24
-0+ } + + type =read_file ("type" ); +if (!type) { +if (chdir (orig_cwd) <0 ) +break ; +continue ; + } + + cid =read_file ("cid" ); +if (!cid) { +free (type); +if (chdir (orig_cwd) <0 ) +break ; +continue ; + } + + blkdev =find_block_devname (resolved); + cfg.bus =strcmp (type,"MMC" ) ?SD :MMC ; + cfg.ids_dir = orig_cwd; + +if (!header_printed) { + printf("%-14s %-14s %-5s%-20s %-10s %-5s %-12s %s\n", + "DEVICE", "DEV", "TYPE", "MANUFACTURER", "PRODUCT",lsmmc.c static int do_read_reg(int argc, char **argv, enum REG_TYPE reg) · line 2365
Quoted 10 lines
lsmmc.c +10
-0+ "REV", "SERIAL", "DATE"); + header_printed = true; + } + +print_list_entry (&cfg, ent->d_name, blkdev, cid); + +free (blkdev); +free (cid); +free (type); +if (chdir (orig_cwd) <0 )We fail here but returns 0?
Quoted 2 lines
Thanks,
Avri
This will also be removed.
Torstein.
Quoted 46 lines
Quoted 45 lines
lsmmc.c +7
-0+break ; + } + +closedir (d); +return 0 ; +} +int do_read_csd (int argc,char **argv) { return do_read_reg(argc, argv, CSD); diff --git a/mmc.c b/mmc.c index077e901..01ad181 100644
mmc.c +5
-1@@ -292,6 +292,11 @@ static struct Command commands[] = { "4. The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.\n", NULL }, + { do_list, 0, + "list", "\n" + "List all MMC/SD devices with their /dev path and CID info.", + NULL + }, { NULL, 0, NULL, NULL } };@@ -567,4 +572,3 @@ int main(int ac, char **av )exit (func (nargs, args)); } -mmc_cmds.h +0
-0@@ -49,6 +49,7 @@ int do_opt_ffu4(int nargs, char **argv); int do_read_scr(intargc, char **argv); int
do_read_cid(int argc, char **argv); intdo_read_csd(int argc, char **argv);
+intdo_list(int nargs, char **argv);
intdo_erase(int nargs, char **argv);
intdo_general_cmd_read(int nargs, char **argv); int do_softreset(int nargs,
char **argv);
--
2.53.0
PATCH 4/4 mmc-utils: Add bash completion
In reply to Torstein EideAdd a bash completion script in completion/mmc that completes subcommands and /dev/mmcblkN device paths for all mmc commands.
The completion directory is named 'completion/' rather than 'bash-completion/' so shell-specific scripts for other shells (zsh, fish, etc.) can be placed alongside it without renaming.
Add bashcompletiondir variable to the Makefile (defaulting to the standard /usr/share/bash-completion/completions) and install the script as part of 'make install'. The install path can be overridden at build time with make bashcompletiondir=<path>.
--- Makefile | 5 +++- completion/mmc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/HOWTO.rst | 6 +++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 completion/mmc
Makefile +4 -1
@@ -5,6 +5,8 @@ AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \ -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \ -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\" CFLAGS ?= -g -O2 +idsdir = /usr/share/misc +bashcompletiondir = /usr/share/bash-completion/completions objects = \ mmc.o \ mmc_cmds.o \
@@ -21,7 +23,6 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS) INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin -idsdir ?= /usr/share/misc LIBS= RESTORE_LIBS= mandir = /usr/share/man
@@ -61,6 +62,8 @@ install: $(progs) $(INSTALL) -m755 -d $(DESTDIR)$(idsdir) $(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir) $(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir) + $(INSTALL) -m755 -d $(DESTDIR)$(bashcompletiondir) + $(INSTALL) -m 644 completion/mmc $(DESTDIR)$(bashcompletiondir)/mmc -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
completion/mmc new file +62 -0
62 lines not on this page · raw message
docs/HOWTO.rst +6 -0
@@ -2,6 +2,12 @@ Running mmc-utils ----------------- +**Bash completion** + Source ``completion/mmc`` to enable tab-completion for all subcommands and + device paths. When installed via ``make install``, the file is placed in + ``$(bashcompletiondir)`` (default: ``/usr/share/bash-completion/completions/mmc``) + and loaded automatically by bash-completion. + **Name** mmc - a tool for configuring MMC storage devices **Synopsis**
Signature · 1 line
2.53.0
Quoted 3 lines
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
Thanks. Still having some troubles applying it cleanly. Please make sure you are rebasing it on recent master. Will review your series anyway.
Thanks,
Avri
Quoted 24 lines
This adds external manufacturer ID files, accepts /dev and
/sys/blockpaths for register reads, adds an mmc list command, and installs bash completion for mmc- utils.Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and/sys/blockpaths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completionMakefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode 100644completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
--
2.53.0
fre. 15. mai 2026 kl. 16:29 skrev Avri Altman <[email protected]>:
Quoted 11 lines
Quoted 4 lines
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
Thanks. Still having some troubles applying it cleanly. Please make sure you are rebasing it on recent master. Will review your series anyway.
Thanks,
Avri
The first patch serie i modified after git format-patch master and did also fail locally,
in the new export i only changed the subject and description in cover letter, I let notice it was not happy when i try to apply the cover letter, but locally to a new branch the all apply without issue. I am unsure what i did wrong.
Quoted 25 lines
Quoted 24 lines
This adds external manufacturer ID files, accepts /dev and
/sys/blockpaths for register reads, adds an mmc list command, and installs bash completion for mmc- utils.Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and/sys/blockpaths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completionMakefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode 100644completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
--
2.53.0
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
Thanks. Still having some troubles applying it cleanly. Please make sure you are rebasing it on recent master. Will review your series anyway.
Thanks,
Avri
Quoted 7 lines
The first patch serie i modified after
git format-patch masterand did also fail locally,in the new export i only changed the subject and description in cover letter, I let notice it was not happy when i try to apply the cover letter, but locally to a new branch the all apply without issue.
I am unsure what i did wrong.
Your local master seems to be behind upstream. The patches conflict with the CID date-fix series that landed recently (commits 6f6b6e1..2364dc6).
Please do:
git fetch origin
git rebase origin/master
Then re-export with git format-patch.
Thanks,
Avri
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
This adds external manufacturer ID files, accepts /dev and
/sys/blockpaths for register reads, adds an mmc list command, and installs bash completion for mmc- utils.Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and/sys/blockpaths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completionMakefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode100644 completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
--
2.53.0
fre. 15. mai 2026 kl. 18:46 skrev Avri Altman <[email protected]>:
Quoted 22 lines
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
Thanks. Still having some troubles applying it cleanly. Please make sure you are rebasing it on recent master. Will review your series anyway.
Thanks,
AvriQuoted 7 lines
The first patch serie i modified after
git format-patch masterand did also fail locally,in the new export i only changed the subject and description in cover letter, I let notice it was not happy when i try to apply the cover letter, but locally to a new branch the all apply without issue.
I am unsure what i did wrong.Your local master seems to be behind upstream. The patches conflict with the CID date-fix series that landed recently (commits 6f6b6e1..2364dc6).
Quoted 8 lines
Please do:
git fetch origin
git rebase origin/masterThen re-export with git format-patch.
Thanks,
Avri
That makes sense that you have conflict, but not a other errors.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
This adds external manufacturer ID files, accepts /dev and
/sys/blockpaths for register reads, adds an mmc list command, and installs bash completion for mmc- utils.Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and/sys/blockpaths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completionMakefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode100644 completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
--
2.53.0
The current master is on https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/
is 5 months old. can it be a possibility that your local master is a head?
fre. 15. mai 2026 kl. 22:28 skrev Torstein Eide <[email protected]>:
Quoted 60 lines
fre. 15. mai 2026 kl. 18:46 skrev Avri Altman <[email protected]>:
Quoted 22 lines
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
Resend the lsmmc usability updates as an ordered series after the previous submission could not be applied cleanly from patchwork or b4.
Thanks. Still having some troubles applying it cleanly. Please make sure you are rebasing it on recent master. Will review your series anyway.
Thanks,
AvriQuoted 7 lines
The first patch serie i modified after
git format-patch masterand did also fail locally,in the new export i only changed the subject and description in cover letter, I let notice it was not happy when i try to apply the cover letter, but locally to a new branch the all apply without issue.
I am unsure what i did wrong.Your local master seems to be behind upstream. The patches conflict with the CID date-fix series that landed recently (commits 6f6b6e1..2364dc6).
Quoted 8 lines
Please do:
git fetch origin
git rebase origin/masterThen re-export with git format-patch.
Thanks,
AvriThat makes sense that you have conflict, but not a other errors.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
This adds external manufacturer ID files, accepts /dev and
/sys/blockpaths for register reads, adds an mmc list command, and installs bash completion for mmc- utils.Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and/sys/blockpaths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completionMakefile | 11 +- completion/mmc | 62 +++++++ docs/HOWTO.rst | 77 +++++++- lsmmc.c | 434 ++++++++++++++++++++++++++++----------------- mmc.c | 6 +- mmc_cmds.h | 1 + multimediacard.ids | 16 ++ sdcard.ids | 23 +++ 8 files changed, 452 insertions(+), 178 deletions(-) create mode100644 completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids
--
2.53.0