You are not logged in.

#1 2014-03-02 23:32:11

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,346

FUSE and pseudo dev nodes

I have been playing around with FUSE.  It is kind of cute, but I have run into a barrier.  I am looking for either direction, or for someone to tell me I've my head up and locked.

What I want to do is create is a 'file' using FUSE that behaves like a device node -- kind of like /dev/urandom.  The idea is to create an arbitrary function generator that can be piped through something like aplay, or a graphing program, or a FFT analyzer.   I want to create a file that, when you read a value from it (byte, int, whatever) you get the next value in the sequence.

I can get this to work if I define the file size as being ludicrously large (like -1) but that is an ugly, ugly hack.  Is it possible to define a file that behaves like a device node using FUSE?, or do I need to do that in kernel space. (Hint: For a weekend project, that aint gonna happen)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#2 2014-03-03 13:22:28

Rexilion
Member
Registered: 2013-12-23
Posts: 784

Re: FUSE and pseudo dev nodes

So you want something like urandom, but that outputs sequential data as a result from an arbitrary function?

Why not create a program that generates the data and pipe that into a (named) fifo (mkfifo) and read from that?

Or do you want a combination of urandom and a function? I'm not able to connect all the information to a consistent and coherent question. I might have interperted it incorrectly.


fs/super.c : "Self-destruct in 5 seconds.  Have a nice day...\n",

Offline

#3 2014-03-04 05:36:48

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,346

Re: FUSE and pseudo dev nodes

Thanks.  The real answer is because that was not where my brain had been smile

I learned a bit about named pipes today.  I need a file that can be opened from inside a program.  I realize now that that is something named pipes do very well.
What I did not realize was that named pipes don't buffer the input.  What I thought they would do would be to act like a FIFO, where they would accept data from the source as long as the source belched it out, would buffer it indefinitely (or until some limit was reached), and would un-buffer them later as they were read.  I see I was wrong.  Named pipes will probably do what I need.

The other need for FUSE is a bit unrelated to Arch.  It is more what FUSE was probably designed for.  I am dealing with an embedded Linux that copies an image from flash to RAM, and then runs from a RAM disk -- there is no physical disk.  There are some data I need to be persistent, I have an unused Flash segment I can use, but no good way to implement a Flash controller in my image.  At this point, I plan to do raw I/O to the unused flash sector in user space, and implement a FUSE file system to allow file system access to that bulk space. 

Going back to my original problem, it too will ultimately be implemented in this embedded system, but as I now realize that the buffering is not deep (a byte or two), named pipes should work just fine.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB