nfsclient: POSIX conformance

According to POSIX the read() call should return the maximum number of
bytes available for regular files.
This commit is contained in:
Sebastian Huber
2012-04-23 15:46:07 +02:00
parent c24d98236f
commit e384438b9c

View File

@@ -2200,20 +2200,17 @@ static int nfs_dir_close(
return 0;
}
static ssize_t nfs_file_read(
rtems_libio_t *iop,
void *buffer,
size_t count
static ssize_t nfs_file_read_chunk(
NfsNode node,
uint32_t offset,
void *buffer,
size_t count
)
{
readres rr;
NfsNode node = iop->pathinfo.node_access;
Nfs nfs = node->nfs;
if (count > NFS_MAXDATA)
count = NFS_MAXDATA;
SERP_ARGS(node).readarg.offset = iop->offset;
SERP_ARGS(node).readarg.offset = offset;
SERP_ARGS(node).readarg.count = count;
SERP_ARGS(node).readarg.totalcount = UINT32_C(0xdeadbeef);
@@ -2244,6 +2241,37 @@ Nfs nfs = node->nfs;
return rr.readres_u.reply.data.data_len;
}
static ssize_t nfs_file_read(
rtems_libio_t *iop,
void *buffer,
size_t count
)
{
ssize_t rv = 0;
NfsNode node = iop->pathinfo.node_access;
uint32_t offset = iop->offset;
char *in = buffer;
do {
size_t chunk = count <= NFS_MAXDATA ? count : NFS_MAXDATA;
ssize_t done = nfs_file_read_chunk(node, offset, in, chunk);
if (done > 0) {
offset += (uint32_t) done;
in += done;
count -= (size_t) done;
rv += done;
} else {
count = 0;
if (done < 0) {
rv = -1;
}
}
} while (count > 0);
return rv;
}
/* this is called by readdir() / getdents() */
static ssize_t nfs_dir_read(
rtems_libio_t *iop,