From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bryan Kadzban Date: Fri, 20 Aug 2010 16:32:18 +0000 Subject: Re: cold-plugged usb flash drive not handled correctly in embedded system Message-Id: <20100820163218.GA4847@kadzban.is-a-geek.net> List-Id: References: <20100820144236.GD10027@debian-wegner1.datadisplay.de> In-Reply-To: <20100820144236.GD10027@debian-wegner1.datadisplay.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Fri, Aug 20, 2010 at 04:42:36PM +0200, Wolfgang Wegner wrote: > ACTION="remove", KERNEL="sd[a-z][0-9]", RUN+="/bin/umount -l /mnt/usbdisk" Hmm. You are aware that this won't save you, right? :-) If someone writes a file into /mnt/usbdisk/... somewhere, and then unplugs the USB device, this umount call will *not* flush the write out to disk, and the file will most likely be either lost, or corrupt. The remove event gets handed to udev *after* the device is already gone. (And for that matter, the USB hub doesn't provide an event to the host system until the device is already gone. Once it's gone, you can't delay its removal, or start any USB transactions, or anything like that: there's no way to cleanly unmount the FS, or flush out writes, unless the user tells you beforehand that they're going to be removing the device.)