Folks, I'd like to be able to queue read/write request to my Zip drive and bypass the buffering that goes on in the kernel. From what I've read, you can do this by binding the raw device (/dev/raw) to /dev/hdc1 for example. When I do that, I get a message that /dev/raw/raw1 has ben bound to char major 22 1. When I try open("/dev/raw/raw1",O_RDWR|O_CREAT,S_IREAD|S_IWRITE); it fails. Can someone tell me how to do this please? Thanks, Skip
Just a quick suggestion; open() sets perror(). try calling perror after your open() call, it might give you (and us) some insite to why you can't open the device. On Fri, Nov 09, 2001 at 03:08:50PM -0500, Skip Gaede wrote:
Folks,
I'd like to be able to queue read/write request to my Zip drive and bypass the buffering that goes on in the kernel. From what I've read, you can do this by binding the raw device (/dev/raw) to /dev/hdc1 for example.
When I do that, I get a message that /dev/raw/raw1 has ben bound to char major 22 1. When I try
open("/dev/raw/raw1",O_RDWR|O_CREAT,S_IREAD|S_IWRITE);
it fails. Can someone tell me how to do this please?
Thanks, Skip
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
On Friday 09 November 2001 04:05 pm, Brad Noyes wrote:
Just a quick suggestion; open() sets perror(). try calling perror after your open() call, it might give you (and us) some insite to why you can't open the device.
Sorry about that! I get "No such file or device", which I also get if I do "ls /dev/raw/raw1" I have in /dev/{raw1,raw2...} If I change the code to open /dev/raw1, the open succeeds but the reads and writes then fail. Should I be able to see this mythical device in the /proc filesystem somewhere, cause I can't seem to find it... Thanks, Skip
On Fri, Nov 09, 2001 at 03:08:50PM -0500, Skip Gaede wrote:
Folks,
I'd like to be able to queue read/write request to my Zip drive and bypass the buffering that goes on in the kernel. From what I've read, you can do this by binding the raw device (/dev/raw) to /dev/hdc1 for example.
When I do that, I get a message that /dev/raw/raw1 has ben bound to char major 22 1. When I try
open("/dev/raw/raw1",O_RDWR|O_CREAT,S_IREAD|S_IWRITE);
it fails. Can someone tell me how to do this please?
Thanks, Skip
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
Can you do a bash$raw -qa as root and post the output. I assume that you used the "raw" command to bind the block device for raw I/O such as bash$raw /dev/raw/raw1 /dev/hdc1 On another note you may also want to check the permissions on the device file(s). This would cause the open to fail! Skip Gaede wrote:
On Friday 09 November 2001 04:05 pm, Brad Noyes wrote:
Just a quick suggestion; open() sets perror(). try calling perror after your open() call, it might give you (and us) some insite to why you can't open the device.
Sorry about that!
I get "No such file or device", which I also get if I do "ls /dev/raw/raw1"
I have in /dev/{raw1,raw2...}
If I change the code to open /dev/raw1, the open succeeds but the reads and writes then fail.
Should I be able to see this mythical device in the /proc filesystem somewhere, cause I can't seem to find it...
Thanks, Skip
On Fri, Nov 09, 2001 at 03:08:50PM -0500, Skip Gaede wrote:
Folks,
I'd like to be able to queue read/write request to my Zip drive and bypass the buffering that goes on in the kernel. From what I've read, you can do this by binding the raw device (/dev/raw) to /dev/hdc1 for example.
When I do that, I get a message that /dev/raw/raw1 has ben bound to char major 22 1. When I try
open("/dev/raw/raw1",O_RDWR|O_CREAT,S_IREAD|S_IWRITE);
it fails. Can someone tell me how to do this please?
Thanks, Skip
On Friday 09 November 2001 10:31 pm, you wrote:
Can you do a
bash$raw -qa
as root and post the output.
root:/usr/src/linux# raw /dev/raw1 /dev/hdc1 /dev/raw/raw1: bound to major 22, minor 1 root:/usr/src/linux# raw -qa /dev/raw/raw1: bound to major 22, minor 1 I don't understand why the output says /dev/*raw*/raw1 is bound when I said /dev/raw1? NOTE: root:/usr/src/linux# ls -R /dev/raw* /dev/raw1 /dev/raw2 /dev/raw3 /dev/raw4 /dev/raw5 /dev/rawctl (There's nothing there that looks like /dev/raw/raw1!)
I assume that you used the "raw" command to bind the block device for raw I/O such as
bash$raw /dev/raw/raw1 /dev/hdc1
Is it necessary to use the devfs for this to work?
On another note you may also want to check the permissions on the device file(s). This would cause the open to fail!
I'm doing this as root. Permissions shouldn't be an issue, should they?
Skip Gaede wrote:
On Friday 09 November 2001 04:05 pm, Brad Noyes wrote:
Just a quick suggestion; open() sets perror(). try calling perror after your open() call, it might give you (and us) some insite to why you can't open the device.
Sorry about that!
I get "No such file or device", which I also get if I do "ls /dev/raw/raw1"
I have in /dev/{raw1,raw2...}
If I change the code to open /dev/raw1, the open succeeds but the reads and writes then fail.
Should I be able to see this mythical device in the /proc filesystem somewhere, cause I can't seem to find it...
Thanks, Skip
On Fri, Nov 09, 2001 at 03:08:50PM -0500, Skip Gaede wrote:
Folks,
I'd like to be able to queue read/write request to my Zip drive and bypass the buffering that goes on in the kernel. From what I've read, you can do this by binding the raw device (/dev/raw) to /dev/hdc1 for example.
When I do that, I get a message that /dev/raw/raw1 has ben bound to char major 22 1. When I try
open("/dev/raw/raw1",O_RDWR|O_CREAT,S_IREAD|S_IWRITE);
it fails. Can someone tell me how to do this please?
Thanks, Skip
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 ==> Regarding Re: [Wlug] Raw IO Howto; Skip Gaede <sgaede@mediaone.net> adds: sgaede> On Friday 09 November 2001 10:31 pm, you wrote:
Can you do a
bash$raw -qa
as root and post the output.
root> /usr/src/linux# raw /dev/raw1 /dev/hdc1 sgaede> /dev/raw/raw1: bound to major 22, minor 1 ok. root> /usr/src/linux# raw -qa sgaede> /dev/raw/raw1: bound to major 22, minor 1 sgaede> I don't understand why the output says /dev/*raw*/raw1 is bound sgaede> when I said /dev/raw1? buggy error message. Open /dev/raw1 in your case. Also, when doing IO to a raw device, the buffer you pass in needs to be aligned on an 512 byte boundary. Most likely this is your problem. If you would like I can send you some sample code to align your buffs. - -Jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard <http://www.gnupg.org/> iEYEARECAAYFAjvurPgACgkQH/inyh944bRjywCggJWGfycPznp7f8iLgdqBk5E1 AHoAn2ZaNqbhRs5ouatx08qoPVkpTZVN =/FIf -----END PGP SIGNATURE-----
On Sunday 11 November 2001 11:53 am, Jeff Moyer wrote:
sgaede> I don't understand why the output says /dev/*raw*/raw1 is bound sgaede> when I said /dev/raw1?
buggy error message. Open /dev/raw1 in your case. Also, when doing IO to a raw device, the buffer you pass in needs to be aligned on an 512 byte boundary. Most likely this is your problem. If you would like I can send you some sample code to align your buffs.
- -Jeff
Folks, It works, and in case someone else wants to try it out ... NOTE: this is to an IOMEGA ATAPI ZIP 100 drive, not a "real" disk! --Skip /* * a simple program showing how to do raw character-based IO to a device, * bypassing the kernel's queueing algorithm. The data is not copied to * kernel space. Instead, the user pages are mapped instead. root:/home/skip# gcc -o rwtest rwtest.c root:/home/skip# time ./rwtest (/dev/hdc1, O_SYNC) real 0m25.084s user 0m0.000s sys 0m0.000s root:/home/skip# gcc -o rwtest rwtest.c root:/home/skip# time ./rwtest (/dev/raw1) real 0m20.558s // 20% performance boost user 0m0.000s sys 0m0.050s root:/home/skip# root:/home/skip# gcc -o rwtest rwtest.c root:/home/skip# time ./rwtest (/dev/hdc1, no O_SYNC) real 0m0.112s // this really helps measure performance, no! user 0m0.010s sys 0m0.000s root:/home/skip# Thanks to Jeff Moyer <moyer@missioncriticallinux.com> for pointing out the need to have the buffer page alligned. */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <time.h> int main (void) { int fd1,fd2; static unsigned char block[8192]; void *bp = (void *)((long) &block & 0xfffff000); // allign on page boundary int reads=0, writes=0; int k; time_t ticks; fd1 = open("/dev/raw1",O_CREAT|O_RDWR); if (fd1 < 0) { printf("Can't open /dev/raw1\n"); perror("rwtest: "); return 1; } for(k=0;k<1000;k++) { int count; if (k) { lseek( fd1, 0, SEEK_SET); } if (k % 2) { /* write */ count = write( fd1, bp, 1024); } else { /* read */ count = read( fd1, bp, 1024); } if (count != 1024) { printf("k = %d, Count = %d\n", k, count); return 2; } } close(fd1); return 0; }
participants (4)
-
Brad Noyes
-
Jeff Moyer
-
Skip Gaede
-
Tom Guilderson