linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Finding sysfs mount point
@ 2005-04-28 22:08 Ian Pilcher
  2005-04-29  4:48 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ian Pilcher @ 2005-04-28 22:08 UTC (permalink / raw)
  To: linux-hotplug

I'm trying to write a script (invoked via a PROGRAM key) to find the
interface number of a USB serial port.  (See my post in the "udev: rules
using multiple sysfs directories" thread for the reason why.)

To do this I need to look as sysfs.  What's the best way to figure out
where it's mounted?

Also, is it safe to rely on the contents of DEVPATH to find a symbolic
link to the device?

Thanks!

-- 
====================================
Ian Pilcher                                        i.pilcher@comcast.net
====================================



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id\x105hix
_______________________________________________
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: Finding sysfs mount point
  2005-04-28 22:08 Finding sysfs mount point Ian Pilcher
@ 2005-04-29  4:48 ` Greg KH
  2005-04-29  7:09 ` Christian Bornträger
  2005-05-04 17:51 ` Nico -telmich- Schottelius
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2005-04-29  4:48 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Apr 28, 2005 at 05:08:02PM -0500, Ian Pilcher wrote:
> I'm trying to write a script (invoked via a PROGRAM key) to find the
> interface number of a USB serial port.  (See my post in the "udev: rules
> using multiple sysfs directories" thread for the reason why.)
> 
> To do this I need to look as sysfs.  What's the best way to figure out
> where it's mounted?

cat /proc/mounts | grep sysfs | cut -f 2 -d " "

works for me.  I think there's a glibc function to retrieve this too.

> Also, is it safe to rely on the contents of DEVPATH to find a symbolic
> link to the device?

Yes, that's what it is there for :)

thanks,

greg k-h


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id\x105hix
_______________________________________________
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: Finding sysfs mount point
  2005-04-28 22:08 Finding sysfs mount point Ian Pilcher
  2005-04-29  4:48 ` Greg KH
@ 2005-04-29  7:09 ` Christian Bornträger
  2005-05-04 17:51 ` Nico -telmich- Schottelius
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Bornträger @ 2005-04-29  7:09 UTC (permalink / raw)
  To: linux-hotplug

On Friday 29 April 2005 06:48, Greg KH wrote:
> cat /proc/mounts | grep sysfs | cut -f 2 -d " "

if sysfs is mounted several times, this results in a non useful value for 
scripting. what about

cat /proc/mounts | grep -m 1 sysfs | cut -f 2 -d " "

to get the first available mountpoint?

cheers

Christian


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id\x105hix
_______________________________________________
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: Finding sysfs mount point
  2005-04-28 22:08 Finding sysfs mount point Ian Pilcher
  2005-04-29  4:48 ` Greg KH
  2005-04-29  7:09 ` Christian Bornträger
@ 2005-05-04 17:51 ` Nico -telmich- Schottelius
  2 siblings, 0 replies; 4+ messages in thread
From: Nico -telmich- Schottelius @ 2005-05-04 17:51 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

Christian Borntr?ger [Fri, Apr 29, 2005 at 09:09:47AM +0200]:
> On Friday 29 April 2005 06:48, Greg KH wrote:
> > cat /proc/mounts | grep sysfs | cut -f 2 -d " "
> 
> if sysfs is mounted several times, this results in a non useful value for 
> scripting. what about
> 
> cat /proc/mounts | grep -m 1 sysfs | cut -f 2 -d " "
> 
> to get the first available mountpoint?

None of those expamples is reliable, when other paths contain
'sysfs'.

Simply use awk for it, it's build for such things:

   awk '$3 ~ /sysfs/ { print $2; exit }' /proc/mounts

This will catch wrong sysfs mounts and also display only the first
match.

Nico

-- 
Keep it simple & stupid, use what's available.
Please use pgp encryption: 8D0E 27A4 is my id.
http://nico.schotteli.us | http://linux.schottelius.org

[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-04 17:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-28 22:08 Finding sysfs mount point Ian Pilcher
2005-04-29  4:48 ` Greg KH
2005-04-29  7:09 ` Christian Bornträger
2005-05-04 17:51 ` Nico -telmich- Schottelius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).