From: Robert Read Date: 2000-12-16T10:53:14+09:00 Subject: [ruby-talk:7370] BUG? IO.seek conflicts with IO.sysread I'm writing a simple tool to test a disk driver. I want to write lots of blocks and then read them back to verify them. When I use seek and sysread like this, it fails after 3 or four reads. Sample code: class DCheck def initialize(dev, blk_size, blk_count) @dev = dev @blk_size = blk_size @blk_count = blk_count end def verifyBlocks() disk = File.new(@dev) disk.sync = true begin for i in 0..@blk_count disk.seek(i*@blk_size) block = disk.sysread(@blk_size) end rescue $stderr.print "IO failed: " + $! + "\n" disk.close raise end end end I realize that in this simple case the seek is not needed, but the final version will need to do more random io. The error comes from io.c:rb_io_sysread around line 1157: if (READ_DATA_PENDING(fptr->f)) { rb_raise(rb_eIOError, "sysread for buffered IO"); } READ_DATA_PENDING seems to be confused by the seek. I'm new to Ruby, so I'm not sure if this is my fault or a real bug. thanks, robert