[comp.os.minix] Bug reading block special devices

Leisner.Henr@xerox.com (Marty) (10/08/87)

In between lines 9834 and 9835 in the Minix book, some code was inserted
for the 1.1 release.

This appears to be why I'm having the problem with block special
devices.

I changed
  if (mode_word == I_BLOCK_SPECIAL && f_size == 0) f_size = MAX_P_LONG;
  
  to
  
  if(mode_word == I_BLOCK_SPECIAL) f_size = MAX_P_LONG;


I'm not sure where f_size would come from for a block special device,
but if its
not 0, read won't allow read's beyond the limit of f_size.  Why bother
checking f_size at all (which comes out of the inode's i_size field).

I assume for block special devices, all read requests should issue a
request to the device driver and let the driver tell the file system if
there is an error.

Its interesting that write had no problem.


marty
ARPA:	leisner.henr@xerox.com
GV:  leisner.henr
NS:  martin leisner:henr801c:xerox
UUCP: martyl@rocksvax.uucp

 

ast@cs.vu.nl (Andy Tanenbaum) (10/12/87)

In article <569@louie.udel.EDU> Leisner.Henr@xerox.com (Marty) writes:
>I'm not sure where f_size would come from for a block special device,

Block devices have sizes in MINIX, unlike UNIX.  The sizes are inserted by
mkfs when the file systems are made.  The reason for this is that the 360K
and 1.2M disk drivers are one and the same.  If you insert a 360K diskette
in an AT drive and ask for block 361, it hangs.  As a partial attempt to
solve this problem, I made special files /dev/fd0 and /dev/at0.  The former
has a size of 360K and the latter 1.2M.  If you try to access block 361 on
/dev/fd0, the file system sees that the block is beyond the maximum file
size and returns EOF without even calling the driver.

Andy Tanenbaum (ast@cs.vu.nl)

Leisner.Henr@xerox.com (marty) (10/14/87)

Andy,

I agree with you about floppy disks -- but what about hard disks
partitions?

This become a problem when I tried to run mkfs on a hard disk partition,
the initial write on the end of the file system worked, then the read
failed (never getting into the device driver).

The reason for the change was mkfs was able to make a file system the
size of the hard disk partition.  It seemed like a catch22 situation --
mkfs can't make the file system because it can't read the end of it, and
it can't read the end of it until it makes the file system.

Is there a way to find out the size of hard disk partitions which the
file can access?  I don't see any except doing a read and seeing if it
fails.

I suppose mkfs could be modified to only abort on write errors (which
the driver will pass back).

marty
ARPA:	leisner.henr@xerox.com
GV:  leisner.henr
NS:  martin leisner:henr801c:xerox
UUCP: martyl@rocksvax.uucp