gtfs: Remove the EOF optimization Turns out this is wrong for directories (and often device files). The ufs server reports a directory size of 4096, which is what Linux tells it. We'd read 4096 bytes worth of records, and then stop. The 9p man page says: The length records the number of bytes in the file. Directories and most files representing devices have a conventional length of 0. Instead of mucking around, we'll just issue the RPC for whatever offset we're asked for. Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/drivers/dev/gtfs.c b/kern/drivers/dev/gtfs.c index a7284ba..bd375a0 100644 --- a/kern/drivers/dev/gtfs.c +++ b/kern/drivers/dev/gtfs.c
@@ -46,7 +46,10 @@ * be_{length,mode,mtime} should be what the remote server thinks they are - * especially for length and mode. The invariant is that e.g. the file's length * == be_length, and the qlock protects that invariant. We don't care as much - * about mtime, since some 9p servers just change that on their own. */ + * about mtime, since some 9p servers just change that on their own. + * + * Also note that you can't trust be_length for directories. You'll often get + * 4096 or 0, depending on the 9p server you're talking to. */ struct gtfs_priv { struct chan *be_walk; /* never opened */ struct chan *be_read; @@ -323,10 +326,6 @@ { struct gtfs_priv *gp = fsf_to_gtfs_priv(f); - if (off >= gp->be_length) { - /* We can skip the RPC, since we know it will return zero (EOF). */ - return 0; - } if (!gp->be_read) gp->be_read = cclone_and_open(gp->be_walk, O_READ); return devtab[gp->be_read->type].read(gp->be_read, ubuf, n, off);