nshlib: Fix write buffer position in nsh cp command
The iobuffer for write buffer position need to be update if write API cannot write data at once.
This commit is contained in:
parent
1c3d08a738
commit
8e0892b2f2
@ -587,10 +587,11 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
int nbytesread;
|
||||
int nbyteswritten;
|
||||
char *iobuffer = vtbl->iobuffer;
|
||||
|
||||
do
|
||||
{
|
||||
nbytesread = read(rdfd, vtbl->iobuffer, IOBUFFERSIZE);
|
||||
nbytesread = read(rdfd, iobuffer, IOBUFFERSIZE);
|
||||
if (nbytesread == 0)
|
||||
{
|
||||
/* End of file */
|
||||
@ -621,10 +622,11 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
|
||||
do
|
||||
{
|
||||
nbyteswritten = write(wrfd, vtbl->iobuffer, nbytesread);
|
||||
nbyteswritten = write(wrfd, iobuffer, nbytesread);
|
||||
if (nbyteswritten >= 0)
|
||||
{
|
||||
nbytesread -= nbyteswritten;
|
||||
iobuffer += nbyteswritten;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user