LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-15-2012, 05:54 AM   #1
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
mounting pendrive (USB) via /sbin/hotplug


A few years ago I've written used a little program to mount my pendrive when kernel-hotplug activates it via /sbin/hotplug interface.
It activated on condition $ACTION="add" and param="scsi_device", used $DEVPATH to determine the USB-informations (vendor, product, serial).

(Example:
DEVPATH: /class/scsi_device/6:0:0:0
sys/$DEVPATH/device pointed to: /sys/devices/pci0000:00/0000:00:1d.3/usb4/4-1/4-1:1.0/host6/target6:0:0:0/6:0:0:0
files idVendor, idProduct and serial can be found in /sys/devices/pci0000:00/0000:00:1d.3/usb4/4-1)

Also there was a symlink called block:sdX in /sys/$DEVPATH/device which told me the device (sdX) to use.

Now I've upgraded my kernel to 3.2.5, which changed a few things:

DEVPATH: /devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host17/target17:0:0/17:0:0:0/scsi_device/17:0:0:0
/sys/$DEVPATH/device points to: /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host17/target17:0:0/17:0:0:0
files idVendor, idProduct and serial still can be found in /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2,

but nothing gives a hint about a the block device to use.

The solution I think of right now is intercepting both scsi_device/add and block/add in /sbin/hotplug, at the first one (whichever it is) only store informations, and at the second actually do the mount.

Last edited by NevemTeve; 02-15-2012 at 03:38 PM.
 
Old 02-15-2012, 03:36 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856

Original Poster
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Well, no, I was wrong, at hotplug-event block/$ACTION=add /sys/$DEVPATH/device is still a symlink (e.g. /sys/block/sdb/device) that points to /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host17/target17:0:0/17:0:0:0 (or something like that), from which /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2 can be deducted, and from that directory USB information can be collected (from files idVendor, idProduct, serial).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting a USB Pendrive Solaris 10 hal8000b Solaris / OpenSolaris 5 04-12-2009 09:35 PM
/sbin/hotplug not being executed when hotplugging usb stick monk576 Linux - Hardware 1 11-26-2008 01:30 AM
Mounting USB pendrive in Zenwalk POW R TOC H Linux - Newbie 9 08-28-2008 09:26 AM
Mounting USB pendrive on Debian malesandro Linux - Newbie 15 10-14-2005 04:19 PM
Mounting USB-Pendrive in Debian Elbryan Linux - Software 4 09-22-2005 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration