[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#122738: retitle



> The problem is that even if DevFS is enabled, but not mounted,
> /proc/partitions is in DevFS format, and libfdisk doesn't like it.

Good spotting - devfs was the only thing I could imagine to blame here :-)

> See the function get_part_info in
> boot-floppies/utitlities/libfdisk/fdisk.c.
> 
> I have a function to work around the problem for IDE disks, but it
> doens't handle SCSI at all:
> 
> static void maybe_translate_devfs_name(char *name)

Doesn't this need to be char **name here? Just in case someone changes the
code below to assemble the new name in a different string ... 

> {
>     int is_ide = !strncmp("ide/", name, 4);
>     /* If it's not a DevFS-style IDE or SCSI partition name, ignore it */
>     if (is_ide || !(strncmp("scsi/", name, 5))) {
> 	int host, bus, target, lun;
> 	int len = strlen(name);
> 	int is_disc = len > 4 && !(strcmp(name+len-4, "disc"));
> 	char *partstr = "";
> 	if (is_disc)
> 	    sscanf(name + is_ide ? 4 : 5, "host%d/bus%d/target%d/lun%d",
> 		   &host, &bus, &target, &lun);
> 	else
> 	    sscanf(name + is_ide ? 4 : 5, "host%d/bus%d/target%d/lun%d/part%s",
> 		   &host, &bus, &target, &lun, &partstr);
> 
> 	sprintf(name, "%cd%c%s", is_ide ? 'h' : 's',
> 		97 + bus*2 + target,
> 		is_disc ? "" : partstr);
>     }
> }

It might be easier to change the way the partition table is parsed
altogether - major and minor are also given in /proc/partition so 
instead of going for the name string just use sd(minor/16 + 'a')(minor&15) 
for the device name - hd(minor/64+'a')(minor&63) for IDE. You probably
want to use the macros from linux/blk.h for this if possible.

	Michael




Reply to: