diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-05 12:45:35 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-05 12:45:35 +0000 |
commit | f10e9d9af26b805cf842bf0f3898684c76133fdd (patch) | |
tree | 55457b1185f375e365bcdb6feba4000e025c2973 /nuttx/lib | |
parent | 26ee5f5668ab205c940feaed71f1ba159a3b85b0 (diff) | |
download | px4-nuttx-f10e9d9af26b805cf842bf0f3898684c76133fdd.tar.gz px4-nuttx-f10e9d9af26b805cf842bf0f3898684c76133fdd.tar.bz2 px4-nuttx-f10e9d9af26b805cf842bf0f3898684c76133fdd.zip |
Refactor serial configuratin; AVR teensy Kconfig now builds
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5092 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-rw-r--r-- | nuttx/lib/misc/lib_sendfile.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/nuttx/lib/misc/lib_sendfile.c b/nuttx/lib/misc/lib_sendfile.c index b7959482e..e4b53d8c8 100644 --- a/nuttx/lib/misc/lib_sendfile.c +++ b/nuttx/lib/misc/lib_sendfile.c @@ -125,7 +125,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) if (offset) { - /* Use lseek to get the current position */ + /* Use lseek to get the current file position */ startpos = lseek(infd, 0, SEEK_CUR); if (startpos == (off_t)-1) @@ -133,7 +133,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) return ERROR; } - /* Use lseek again to set the new position */ + /* Use lseek again to set the new file position */ if (lseek(infd, *offset, SEEK_SET) == (off_t)-1) { @@ -209,9 +209,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) wrbuffer = iobuffer; do { + /* Write the buffer of data to the outfd */ + nbyteswritten = write(outfd, wrbuffer, nbytesread); - /* Check for a complete (or parial write). write() should not + /* Check for a complete (or parial) write. write() should not * return zero. */ @@ -261,11 +263,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) free(iobuffer); - /* Get the current file position */ + /* Return the current file position */ if (offset) { - /* Use lseek to get the current position */ + /* Use lseek to get the current file position */ off_t curpos = lseek(infd, 0, SEEK_CUR); if (curpos == (off_t)-1) @@ -277,7 +279,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) *offset = curpos; - /* Use lseek again to restore the original position */ + /* Use lseek again to restore the original file position */ if (lseek(infd, startpos, SEEK_SET) == (off_t)-1) { @@ -285,6 +287,10 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) } } + /* Finally return the number of bytes actually transferred (or ERROR + * if any failure occurred). + */ + return ntransferred; } |