From mboxrd@z Thu Jan 1 00:00:00 1970 From: apawar.linux@gmail.com (Abhijit Pawar) Date: Tue, 14 Feb 2012 17:08:00 +0530 Subject: Get USB Device Class Type and Mount point In-Reply-To: <20120213150219.GA7328@kroah.com> References: <20120209122348.GB16651@kroah.com> <4F33CEC5.7000900@gmail.com> <20120209144717.GA19643@kroah.com> <4F38FEC0.8050505@gmail.com> <20120213150219.GA7328@kroah.com> Message-ID: <1329219480.18211.8.camel@abhijit-linux.cybage.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Mon, 2012-02-13 at 07:02 -0800, Greg KH wrote: > On Mon, Feb 13, 2012 at 05:44:56PM +0530, Abhijit Pawar wrote: > > The reason I went for kernel module is to get the device add > > notification. However once I get the notification, I can have > > netlink socket pass the device data to my user space application. > > Like others pointed out, use libudev for this, that's the only way you > can properly do it. I am getting the device node from libudev and witht his devnode I would be traversing the mnttab to get the actual mount path for this device.struct mntent* has helped me lot here. > > > Here the tricky part is I can get the device info, but not able to > > figure out how can I get the mount path from this device. > > Within the kernel you can not. Think of namespaces, and all that fun > stuff, it will not work properly within the kernel. > > Again, if you are using an encrypted filesystem, just use what Linux > provides for this today. Is there something there that does not meet > your needs? There isnt any special filesystem need for my app. I am planning to use ecryptfs module (with its overlay capability) which is available today. Or is there any other module i should look into for this? > greg k-h If I am using the monitor capabilities of libudev then I may need to write a daemon process to run this in background. There is always a chance that user with root access can kill this application. I read about call_usermodehelper_exec API which can launch a user application from kernel mode which can prove useful. However still writing a kernel module and making it compatible for each kerne is time consuming. As everyone is saying, I will go with user mode app for this functionality. Thanks, Abhijit Pawar