Arm9 hotplug

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 15:57, 26 December 2007 by Georg (Talk | contribs)

Jump to: navigation, search

Hotplug on ARM9 This article explains (very short) how the hot plug system on the Linkstation Pro (also Live and Terasation Pro/Live - on the ARM9 series)works and shows a simple way to alter it in order to perform custom actions upon hot plugging.

The hotplug system

When plugging in a new usb device /sbin/hotplug is called. Before the call a number of environment variables are set (see http://linux-hotplug.sourceforge.net/?selected=hotplug). For this article the most important are:

$PRODUCT   the product ID of the device
$ACTION    "add"/"remove" depending on if the device is plugged or unplugged
$PATH      /sbin:/bin:/usr/sbin:/usr/bin

Further a parameter $1 is passed to /sbin/hotplug, that depends on the device. Depending on this parameter scripts in /etc/hotplug.d/$1/*.hotplug are called. On the linkstation pro only one script for handling external usb disks exists /etc/hotplug.d/scsi_device/usb-buffalo.hotplug.

Customizing

The idea was brought to me by an article in the German IT magazine c't (16/2007). The idea in short: If you plug in a device you usually want to perform a certain action. For a camera you want to copy the images from the camera to the hard disc, if it's a mp3 player you might to put new music on it...

The mentioned article used udev and hal (hardware abstraction layer). Due to the different mechanism implemented on the arm9 stock firmware it can not be transfered directly. So we adapt the idea using the hotplug.d concept.

All we have to do is to add a user script e.g /etc/hotplug.d/usb/mydevice.hotplug and make it executable.

This is explained in the following for a Canon powershot. We download the images, rotate them according to the exif flags and store them into a date dependent folder.

Example image downloading

To come...