LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how can i create a device like /dev/zero? (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-create-a-device-like-dev-zero-4175411032/)

noone234 06-12-2012 09:19 AM

how can i create a device like /dev/zero?
 
Hello,
how can write a device like /dev/zero that willl output instead of zeroes ones and will be /dev/one.
Also where can i find /dev/zero source code?
thans.

pan64 06-12-2012 11:20 AM

have you heard about the program called yes?










__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.

273 06-12-2012 11:49 AM

I was under the impression that /dev/zero, like /dev/null, was an output-only thing?

noone234 06-12-2012 11:59 AM

what is the program Yes? and yeah they are an output devices.. what it has to do wuth the question?
edit: yes doesnt work out for me.. i want to create an actual device

pan64 06-12-2012 12:40 PM

yes is not a device, but a simple program.
Here is a tutorial on creating a basic char device: http://learninglinuxkernel.com/Basic...Driver_07.html






__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.

noone234 06-12-2012 02:49 PM

"yes" doesnt workout for me i want to create a device similliar to /dev/zero that will output 1's

noone234 06-14-2012 10:01 AM

does anyone knows where /dev/zero source code is located?

pan64 06-14-2012 11:38 AM

I gave you a link about how to create a simple device. Have you tried?

2ck 06-14-2012 11:39 AM

Quote:

Originally Posted by 273 (Post 4701573)
I was under the impression that /dev/zero, like /dev/null, was an output-only thing?

Well, you can write to them--they're just no-error data sinks. /dev/null doesn't do output though which is kinda why we like /dev/zero which you can read null bytes from.


noone234, what you want is to create a character device as pan64 indicated. A complete test program is provided at the end of the linked page.

Please mark this thread as solved if you are satisfied with that answer.

Edit:
Realized input/output might be confusing. By output I mean "read-from".


All times are GMT -5. The time now is 02:58 PM.