pmount & safe removal of USB device

I am new to Linux (still discovering Arch inside a VM for now) and lately I've been looking into working with USB devices. I found out about pmount, great tool, but I wanted a little more. So also as part of me trying to learn C as well, I decided to make some changes.

First of all, as the title indicates, I added something to safely remove devices. After searching, it seemed that a lot of people simply unmount whatever file system they have mounted before unplugging their USB devices. That just didn't seem like completely enough to me, and I eventually found this post where it seems that there are, indeed, a few more steps to do before one can safely unplug an USB device.

So I did put those into a new option (-D) of pumount, which will try also try to unmount all partitions of a given device before. Similarly, the same option can be used with pmount to mount all partitions of a device at once.

Additionally, I also added support for a configuration file (/etc/pmount.conf) where one can predefined, for some devices, a few options. Some are new, others will overwrite any command-line options:- fs to define the file system (overwrites option -t)- charset to define the I/O character set (overwrites option -c)- passphrase to define the file to read passphrase from (overwrites options -p/--passphrase)- mntpt to define the mount point. Overwrites the usual way (e.g. specified label), can be anywhere (not restricted to /media/)- options to defines the mounting options. That is, this allows you to overwrite the defaut options, as defined in fs.c No checks are done here, so make sure not to include non-existing options, as well as not to include any options auto-added by pmount (that is, things based on command-line options, such as atime/noatime, exec/noexec, etc)

In the end, with a simple call to pmount I can now have my LUKS encrypted partitions mounted automatically; and when I’m done one call to pumount will have them all unmounted, and the device be prepared for safe removal. I think I now have everything I was looking for.

The modified source code is available on this BitBucket repository. You can also find a PKGBUILD in the AUR, which uses the official source code and a patch to get there, simply because I figured it would allow people to check the changes more easily.

I've also made a blog post where I described changes I made a little more, if anyone's interested.

Maybe that might be useful to others; And any bug reports, suggestions or any other form of constructive criticism is very much welcome.-jacky

Re: pmount & safe removal of USB device

I've just found this and it looks interesting. Have you tried to push (some of) your changes upstream? Especially the safe removal bits (might be good to split to two patches for that)?I'm still trying to work out how to sort out my working but unsatisfactory removable drives situation, and it may well involve this or main pmount.

"...one cannot be angry when one looks at a penguin." - John Ruskin"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Re: pmount & safe removal of USB device

I haven't submitted anything upstream, no. I might try and do that at some point, but as you said it would require splitting it in a few patches, and while I use this version of pmount I haven't looked at this code in a while...