usb-drives and device mapping
Hello all,
I have an embedded Linux system with 2.4.21 kernel running on a
StrongARM SA-1110 CPU. The System has an USB-Host on which I use an usb
memory stick. Normaly I can mount the stick on the device /dev/sda1.
but if I take another usbstick, then this one is mapped to /dev/sdb. In
/proc/scsi/ there are then the directories usb-storage-0,
usb-storage-1,...
the USB subsystem and the usb-storage is compiled into the kernel. How
can I tell the kernel to remove the entries in /proc/scsi/ when I
unplug the USB memory stick. Unfortunatly I can't compile my own kernel
to include the usb-storge driver as module, because the manufactor of
this device does not allow to modify the systemimage with costum
kernels /modules.
The system I'm talking about is found on the following URL
[url]http://www.icpdas.com/products/PAC/lincon-8000/introduction.htm[/url]
thanks for any help and hints
Mike Lawson
Re: usb-drives and device mapping
Hi Mike,[color=blue]
> I have an embedded Linux system with 2.4.21 kernel running on a
> StrongARM SA-1110 CPU. The System has an USB-Host on which I use an usb
> memory stick. Normaly I can mount the stick on the device /dev/sda1.
> but if I take another usbstick, then this one is mapped to /dev/sdb. In
> /proc/scsi/ there are then the directories usb-storage-0,
> usb-storage-1,...
> the USB subsystem and the usb-storage is compiled into the kernel. How
> can I tell the kernel to remove the entries in /proc/scsi/ when I
> unplug the USB memory stick.[/color]
I don't think you can tell it to remove those. the usb-storage driver
tries to remember devices so if you remove and re-insert them, they will
re-appear in the same place.
Removing the usb-storage module, or using a 2.6.x kernel would alleviate
this problem, but you've said you aren't able to do either.
regards,
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Damion de Soto --------------------------------------------------
| Software Engineer email: [email]Damion_deSoto@au.securecomputing.com[/email]
| Secure Computing Corporation web: [url]http://www.securecomputing.com[/url]
| fax: +61 7 3891 3630 ph: +61 7 3435 2809
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---- Free Embedded Linux Distro at [url]http://www.snapgear.org[/url] ----
Re: usb-drives and device mapping
Panther (golum@wolke7.net) wrote at Tuesday 10. October 2006 11:06 in
comp.os.linux.embedded:
[color=blue]
> Hello all,
>
> I have an embedded Linux system with 2.4.21 kernel running on a
> StrongARM SA-1110 CPU. The System has an USB-Host on which I use an usb
> memory stick. Normaly I can mount the stick on the device /dev/sda1.
> but if I take another usbstick, then this one is mapped to /dev/sdb. In
> /proc/scsi/ there are then the directories usb-storage-0,
> usb-storage-1,...
> the USB subsystem and the usb-storage is compiled into the kernel. How
> can I tell the kernel to remove the entries in /proc/scsi/ when I
> unplug the USB memory stick. Unfortunatly I can't compile my own kernel
> to include the usb-storge driver as module, because the manufactor of
> this device does not allow to modify the systemimage with costum
> kernels /modules.
>
> The system I'm talking about is found on the following URL
> [url]http://www.icpdas.com/products/PAC/lincon-8000/introduction.htm[/url]
>
> thanks for any help and hints
> Mike Lawson[/color]
Hi Mike,
I don't know how to achieve this but can't you automatically detect as what
device this stick appers to your system?
I have done this by scanning /etc/fstab for a HOTPLUG entry:
chat name[50] = "", mntpoint[50] = "";
FILE * fstab = fopen("/etc/fstab", "r");
if (! fstab)
{ perror("open fstab");
goto error;
}
for(;;)
{ char line[200]
if (! fgets(line, sizeof(line)-1, fstab))
{ perror("read fstab");
fclose(fstab);
goto error;
}
if (strstr(line, "#HOTPLUG"))
{ strcpy(name, strtok(line, " \t\n"));
strcpy(mntpoint, strtok(0, " \t\n"));
break;
}
}
fclose(fstab);
cout << "fstab: name=<" << name << "> mnt=<" << mntpoint << ">" << endl;
if (strlen(name) == 0 || strlen(mntpoint) == 0)
{ cout << "No USB stick" << endl;
goto error;
}
rc = mount(name, mntpoint, "vfat", 0xc0ed << 16 | MS_RDONLY, "");
if (rc)
{ perror("UsbStick: mount");
return EXIT_FAILURE;
}
--
Reinhardt Behm, Bodenheim, Germany, [email]reinhardt.behm@t-online.de[/email]