Thread: Trickiness while trying to implement an automounter ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Cape Town, S.A.

    Trickiness while trying to implement an automounter ...

    Hi all,

    So, I'm busy using inotify to implement a kind of automounter for linux. Essentially it watches /dev for the creation of any 'files' matching a pattern (e.g. 'sd*'). when such a file appears, it creates a new mount point (e.g. /mnt/myautomount/volume0) and simulates an automount subprocess on that mount point, i.e. whenever files are accessed in that mount point, the created device is mounted on that mount point, and then once every second, the process tries to unmount it. Once successfully unmounted, the subprocess watches for further file access in the mount point, and repeats the process. The main process also picks up when the device s removed (e.g. /dev/sda1 goes away) and kills the appropriate subprocess.

    So in theory this seems all hunky dory, except that the sub process catches the file access attempt after it has happened, and mounts the device post facto. Meaning an ls in the mount point reveals an empty directory, and I must change up and back down again to get 'into' the mounted file system.

    So I've thought of two solutions here

    a) use automount proper as a sub process, using the executable as map function, to determine the mount point name. To do this I need some way of accessing the table of mount point/device pairs in my main process from another program, i.e. shared memory. I've never done this before, so some pointers to good docs on using shared mem in linux would be of great help

    b) I need to somehow detect and hook into the file access of the mount point directory and complete the mount before the access is complete, which is I think how automount does it. I've googled, I've sworn, I've looked at code from things like submount, I've perused the kernel filesystem code briefly, I've cried... Any suggestions on how one might go about this are most welcome...

    Oh, and before anyone jumps down my throat and screams 'DON'T REINVENT THE WHEEL', this is as much an academic exercise as it is practical. Yes I know about HAL, and ivman, etc... just want to try my hand at something similar...


  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-20-2007, 07:55 PM
  2. how do i implement IOleCommandTarget
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 06-24-2007, 10:33 PM
  3. Implement "Whats This" using Win32
    By hemanth.balaji in forum Windows Programming
    Replies: 1
    Last Post: 05-29-2005, 06:03 AM
  4. Can't Implement Tabbing
    By Invincible in forum Windows Programming
    Replies: 10
    Last Post: 02-27-2002, 05:09 AM
  5. How to implement several source files?
    By Gades in forum C Programming
    Replies: 3
    Last Post: 11-21-2001, 02:44 PM