== uso delle procedure post add/remove ==

Sotto /etc/mon-usdbdisks, nelle directories add.d e remove.d,
possono essere inseriti scripts che verranno eseguiti, rispettivamente,
dopo l'operazione di inserimento (add, solo se e dopo il mount andato
a buon fine), e di rimozione (remove, prima di un eventuale umount).

Gli scripts possono essere in qualsiasi linguaggio, devono essere files
ed eseguibili.

L'environment e` quello esportato dal daemon udev (vedi esempi dopo),
piu` queste variabili impostate dal nostro script che gestisce le
operazioni:

 * MON_USBDISKS_MOUNTDIR: impostata in caso di action=add, la directory
 dove e` stata eventualmente montata la partizione

 * MON_USBDISKS_MOUNTDIR: impostato in caso di action=remove, se il
 comando di umount della partizione e` andato a buon fine o meno
 (true/false)

<!> notare che non e` possibile sapere direttamente, durante il remove,
su quale directory e` stata montata la partizione; anche memorizzanddone
il nome sfruttando uno script durante la fase di "add", non e` detto che
successive operazioni manuali di umount/mount/remount non cambino le
carte in tavola, la cosa migliore e` eseguire una scansione di /proc/mounts
e cercare la partizione interessata

<!> notare che, indipendemente che il comando umount sia andato a buon
fine o meno, l'azione di remove viene eseguita '''dopo''' la rimozione fisica
di un dispositivo, e che quindi questo non e` piu` disponibile per alcuna
operazione fisica!


== environment from udev ==

Durante operazioni di ''add'' (inserimento chiavetta USB):
{{{
ID_USB_DRIVER=usb-storage
ID_MODEL=USB_FLASH_DRIVE
ID_MODEL_ENC=USB\x20FLASH\x20DRIVE\x20
ID_REVISION=PMAP
DEVTYPE=partition
ID_FS_LABEL=USB-PK008
ID_BUS=usb
ID_FS_LABEL_ENC=USB-PK008
SUBSYSTEM=block
ID_SERIAL=_USB_FLASH_DRIVE_198A10240A50-0:0
ID_FS_UUID=98FD-D52F
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host9/target9:0:0/9:0:0:0/block/sdf/sdf1
ID_MODEL_ID=b113
ID_VENDOR_ENC=\x20\x20\x20\x20\x20\x20\x20\x20
ID_FS_VERSION=FAT32
MINOR=81
ACTION=add
PWD=/
UDEV_LOG=3
ID_FS_TYPE=vfat
MAJOR=8
DEVLINKS=/dev/block/8:81 /dev/disk/by-id/usb-_USB_FLASH_DRIVE_198A10240A50-0:0-part1 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:5:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/98FD-D52F /dev/disk/by-label/USB-PK008
DEVNAME=/dev/sdf1
ID_VENDOR_ID=1005
SHLVL=1
ID_FS_USAGE=filesystem
ID_TYPE=disk
ID_FS_UUID_ENC=98FD-D52F
ID_INSTANCE=0:0
ID_USB_INTERFACE_NUM=00
ID_SERIAL_SHORT=198A10240A50
ID_PATH=pci-0000:00:1d.7-usb-0:5:1.0-scsi-0:0:0:0
ID_USB_INTERFACES=:080650:
SEQNUM=1742
}}}


Durante operazioni di ''remote'' (rimozione chiavetta USB):
{{{
ID_USB_DRIVER=usb-storage
ID_MODEL=USB_FLASH_DRIVE
ID_MODEL_ENC=USB\x20FLASH\x20DRIVE\x20
ID_REVISION=PMAP
DEVTYPE=partition
ID_FS_LABEL=USB-PK008
ID_BUS=usb
ID_FS_LABEL_ENC=USB-PK008
SUBSYSTEM=block
ID_SERIAL=_USB_FLASH_DRIVE_198A10240A50-0:0
ID_FS_UUID=98FD-D52F
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host9/target9:0:0/9:0:0:0/block/sdf/sdf1
ID_MODEL_ID=b113
ID_VENDOR_ENC=\x20\x20\x20\x20\x20\x20\x20\x20
ID_FS_VERSION=FAT32
MINOR=81
ACTION=remove
PWD=/
UDEV_LOG=3
ID_FS_TYPE=vfat
MAJOR=8
DEVLINKS=/dev/block/8:81 /dev/disk/by-id/usb-_USB_FLASH_DRIVE_198A10240A50-0:0-part1 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:5:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/98FD-D52F /dev/disk/by-label/USB-PK008
ID_VENDOR_ID=1005
DEVNAME=/dev/sdf1
SHLVL=1
ID_FS_USAGE=filesystem
ID_TYPE=disk
ID_FS_UUID_ENC=98FD-D52F
ID_INSTANCE=0:0
ID_USB_INTERFACE_NUM=00
ID_SERIAL_SHORT=198A10240A50
ID_PATH=pci-0000:00:1d.7-usb-0:5:1.0-scsi-0:0:0:0
ID_USB_INTERFACES=:080650:
SEQNUM=1751
}}}
