LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-12-2012, 09:19 AM   #1
noone234
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
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.
 
Old 06-12-2012, 11:20 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,779

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
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.
 
Old 06-12-2012, 11:49 AM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I was under the impression that /dev/zero, like /dev/null, was an output-only thing?
 
Old 06-12-2012, 11:59 AM   #4
noone234
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
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

Last edited by noone234; 06-12-2012 at 12:13 PM.
 
Old 06-12-2012, 12:40 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,779

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
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.
 
Old 06-12-2012, 02:49 PM   #6
noone234
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
"yes" doesnt workout for me i want to create a device similliar to /dev/zero that will output 1's
 
Old 06-14-2012, 10:01 AM   #7
noone234
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
does anyone knows where /dev/zero source code is located?
 
Old 06-14-2012, 11:38 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,779

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
I gave you a link about how to create a simple device. Have you tried?
 
Old 06-14-2012, 11:39 AM   #9
2ck
Member
 
Registered: Mar 2010
Location: /home/twock
Distribution: Debian
Posts: 74
Blog Entries: 9

Rep: Reputation: 21
Quote:
Originally Posted by 273 View Post
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".

Last edited by 2ck; 06-14-2012 at 11:41 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot create /dev/md1 using mdadm after /dev/md0 is created dwong05 Linux - Newbie 1 05-04-2009 02:37 AM
using flash drive changes device /dev/sr0 to /dev/sr1 for mapping to /dev/pktcdvd/0? lugoteehalt Linux - Software 3 10-24-2007 10:27 AM
/dev/tty0, /dev/tty1, /dev/tty10...and so on...which should be used for a device ??? b0nd Slackware 2 04-02-2006 08:14 AM
USB CDRW: sg won't create sg* device in /dev sugapablo Linux - Hardware 3 05-06-2005 08:07 PM
I can`t create a device node in /dev gcasados Slackware 8 02-21-2005 05:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration