Read/Write function callback in user space for a file

This is a discussion on Read/Write function callback in user space for a file within the C Programming forums, part of the General Programming Boards category; Hi;I am looking for 'proc fs' type of solution in User space.In Linux Kernel space, we can register read/write function ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    2

    Question Read/Write function callback in user space for a file

    Hi;I am looking for 'proc fs' type of solution in User space.In Linux Kernel space, we can register read/write function for a proc file and those got called while doing respective operation on that file.Is there same kind of mechansim availabel in C library for user space. Can we crate a file and register read/write callback functions for that file in User space application?So that when "cat " is exectued, the read callback function of that file for called.Please let know if there any mechansim exist for this in User space.Thanks in advance.

  2. #2
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Talking about a Linux solution, I assume?

    Read up on inotify and the various utilities built off it that do just what you want. On Windows? I'm not aware of a solution that doesn't hook every filesystem access and filter as appropriate but it's not my area.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    You want to use Fuse.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    2
    Yeah, it is for Linux system. Can you elaborate little more about those?

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Fuse is a system for implementing filesystems in user space. From your analogy to /proc, I assume you are trying to create "virtual files" or something like that, where the content of the file is generated by a program instead of being stored on disk. Fuse would be perfect for that. I cannot describe it all myself, Google it. The docs are very good. I used it a couple years ago to implement a PDF filesystem (mount a PDF and browse around inside it using shell commands, cool stuff)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a proc file in user space
    By Fillis52 in forum C Programming
    Replies: 3
    Last Post: 12-06-2010, 10:03 AM
  2. Replies: 6
    Last Post: 04-17-2009, 04:41 PM
  3. Read space from the file
    By Ken JS in forum C++ Programming
    Replies: 9
    Last Post: 08-05-2007, 03:13 AM
  4. Member Function Callback - No User Supplied Args
    By Tonto in forum C++ Programming
    Replies: 3
    Last Post: 01-01-2007, 09:26 PM
  5. How to write file .txt which can read-only.
    By ooosawaddee3 in forum C++ Programming
    Replies: 6
    Last Post: 06-21-2002, 01:13 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21