diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-05 12:45:35 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-05 12:45:35 +0000 |
commit | 8870a08597a5dc66b762f1badd7fbc11f2fe3241 (patch) | |
tree | 55457b1185f375e365bcdb6feba4000e025c2973 /nuttx/lib | |
parent | bdd2c5b28836a80e3a79be23bfe45fd159203d8a (diff) | |
download | px4-firmware-8870a08597a5dc66b762f1badd7fbc11f2fe3241.tar.gz px4-firmware-8870a08597a5dc66b762f1badd7fbc11f2fe3241.tar.bz2 px4-firmware-8870a08597a5dc66b762f1badd7fbc11f2fe3241.zip |
Refactor serial configuratin; AVR teensy Kconfig now builds
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5092 7fd9a85b-ad96-42d3-883c-3090e2eb8679
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; } |