From baa779e2924f0291af7a4f8cb12253a0ce22882c Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Thu, 13 May 2010 07:58:38 +0000 Subject: create devices listed in /proc/partitions with correct major/minor (#57032) --- mdk-stage1/probing.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'mdk-stage1/probing.c') diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index 3f9621705..f2f9fb52c 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -766,12 +766,24 @@ void find_media(enum media_bus bus) log_message("Couldn't open /proc/partitions"); } else { while (fgets(buf, sizeof(buf), f)) { - char name[100]; + char name[100] = "/dev/"; int major, minor, blocks; + struct stat statbuf; + char *ptr; memset(name, 0, sizeof(name)); - sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name); - if (streq(name, tmp_name) && tmp[count].type == DISK && ((blocks == 1048575) || (blocks == 1440))) + sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, &name[5]); + if (streq(&name[5], tmp_name) && tmp[count].type == DISK && ((blocks == 1048575) || (blocks == 1440))) tmp[count].type = FLOPPY; + /* Try to create all devices while we have major/minor */ + if ((ptr = strchr(&name[5], '/'))) { + *ptr = '\0'; + if (stat(name, &statbuf)) + mkdir(name, 0755); + *ptr = '/'; + } + if (stat(name, &statbuf) && mknod(name, S_IFBLK | 0600, makedev(major, minor))) { + log_perror(name); + } } fclose(f); } -- cgit v1.2.1