* Re: How to find mounted path from usb hotplug?
2007-05-16 23:20 How to find mounted path from usb hotplug? Greg
@ 2007-05-17 2:48 ` Andrey Borzenkov
2007-05-17 4:23 ` Greg
2007-05-17 11:07 ` Bryan Kadzban
2 siblings, 0 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2007-05-17 2:48 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 1709 bytes --]
On Thursday 17 May 2007, Greg wrote:
> How can I find out where my USB stick was mounted using /sbin/
> hotplug? I have a simple script in /etc/hotplug.d/usb/ that is run
> when the key is attached, but I need to know the full path of where
> the USB key is mounted to, and I can't seem to figure out how the
> environment variables can tell me that:
>
Because at this stage it is not known yet. What makes you believe it will be
mounted at all?
Once upon a time there were mount/umount events but I believe they are gone
now.
To not depend on the method of mounting just poll /proc/mounts. If you are
sure your system is using HAL to mount, you can just watch for
PropertyChanged for correspsonding device (and check mounted state).
HTH
-andrey
> SUBSYSTEM=usb
> DEVPATH=/devices/pci0000:00/0000:00:10.4/usb1/1-5/1-5:1.0
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> ACTION=add
> MODALIAS=usb:v0457p0150d0100dc00dsc00dp00ic08isc06ip50
> PWD=/
> HOME=/
> SHLVL=2
> DEVICE=/proc/bus/usb/001/004
> INTERFACE=8/6/80
> PRODUCT=457/150/100
> TYPE=0/0/0
> PHYSDEVBUS=usb
>
> Any help would be greatly appreciated!
>
> - Greg
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
> Linux-hotplug-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to find mounted path from usb hotplug?
2007-05-16 23:20 How to find mounted path from usb hotplug? Greg
2007-05-17 2:48 ` Andrey Borzenkov
@ 2007-05-17 4:23 ` Greg
2007-05-17 11:07 ` Bryan Kadzban
2 siblings, 0 replies; 4+ messages in thread
From: Greg @ 2007-05-17 4:23 UTC (permalink / raw)
To: linux-hotplug
Thanks for the response Andrey. Indeed after sending the email I
realized that this was the problem, and that because of this I could
not (in my hotplug.d script) figure out the mount point by reading
the /proc/mounts file. So now I've decided that the best thing to do
is to wait a while until that file has been updated and then read the
last entry in it (or perhaps find the different line between an old
version and an updated version), is this a safe way of doing it or is
there a better/safer way?
I do not know how to use HAL's PropertyChanged event (again, I know
little of this side of Linux), all I'm looking for is a quick and
dirty way of doing this. So far it seems /proc/mounts is my best bet.
The machines that I'm working on have Fedora Core installed on them
(versions 3 and 6, depending on the machine) with a 2.6 kernel. When
you stick a USB key into them it is automagically mounted at /media/
DEVICENAME, how this is done I do not know. I did not set these
machines up so that is about all I know, but perhaps you (or someone)
could tell me what program is ultimately responsible for mounting the
device? Perhaps if I knew this then I might somehow have the program
notify me when it does this?
- Greg
On May 16, 2007, at 10:48 PM, Andrey Borzenkov wrote:
> On Thursday 17 May 2007, Greg wrote:
>> How can I find out where my USB stick was mounted using /sbin/
>> hotplug? I have a simple script in /etc/hotplug.d/usb/ that is run
>> when the key is attached, but I need to know the full path of where
>> the USB key is mounted to, and I can't seem to figure out how the
>> environment variables can tell me that:
>>
>
> Because at this stage it is not known yet. What makes you believe
> it will be
> mounted at all?
>
> Once upon a time there were mount/umount events but I believe they
> are gone
> now.
>
> To not depend on the method of mounting just poll /proc/mounts. If
> you are
> sure your system is using HAL to mount, you can just watch for
> PropertyChanged for correspsonding device (and check mounted state).
>
> HTH
>
> -andrey
>
>> SUBSYSTEM=usb
>> DEVPATH=/devices/pci0000:00/0000:00:10.4/usb1/1-5/1-5:1.0
>> PATH=/sbin:/bin:/usr/sbin:/usr/bin
>> ACTIONd
>> MODALIAS=usb:v0457p0150d0100dc00dsc00dp00ic08isc06ip50
>> PWD=/
>> HOME=/
>> SHLVL=2
>> DEVICE=/proc/bus/usb/001/004
>> INTERFACE=8/6/80
>> PRODUCTE7/150/100
>> TYPE=0/0/0
>> PHYSDEVBUS=usb
>>
>> Any help would be greatly appreciated!
>>
>> - Greg
>>
>> ---------------------------------------------------------------------
>> ----
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Linux-hotplug-devel mailing list http://linux-
>> hotplug.sourceforge.net
>> Linux-hotplug-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to find mounted path from usb hotplug?
2007-05-16 23:20 How to find mounted path from usb hotplug? Greg
2007-05-17 2:48 ` Andrey Borzenkov
2007-05-17 4:23 ` Greg
@ 2007-05-17 11:07 ` Bryan Kadzban
2 siblings, 0 replies; 4+ messages in thread
From: Bryan Kadzban @ 2007-05-17 11:07 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 1267 bytes --]
Greg wrote:
> The machines that I'm working on have Fedora Core installed on them
> (versions 3 and 6, depending on the machine) with a 2.6 kernel. When
> you stick a USB key into them it is automagically mounted at /media/
> DEVICENAME, how this is done I do not know. I did not set these
> machines up so that is about all I know, but perhaps you (or someone)
> could tell me what program is ultimately responsible for mounting
> the device? Perhaps if I knew this then I might somehow have the
> program notify me when it does this?
The "correct" way to do this is to do it in HAL. That's why HAL was
suggested before: the program that's doing the mount already has a way
to notify you when the mount happens. ;-)
To listen, you'd have to learn at least dbus. I believe Python has some
usable dbus bindings; otherwise C or C++ should work too.
It's also possible to do mounts directly from udev rules, but this isn't
the Right Way to do it. I'm not quite sure why, but I think it has
something to do with the fact that HAL knows a lot more about the system
state (including possible mount points) than udev alone does. Or maybe
it's the fact that HAL has a piece that runs as each logged-on user, so
user mounts can be done.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread