diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-10 20:00:04 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-10 20:00:04 +0000 |
commit | c0e51eccc5bc5ce6743572f97cfc9d13fc13ceab (patch) | |
tree | 416516f21abef14bf01587a6f93c6b02ac369255 /nuttx/fs | |
parent | 4f03177a72a65beeca2e40185d2e2fa97f24bc11 (diff) | |
download | px4-nuttx-c0e51eccc5bc5ce6743572f97cfc9d13fc13ceab.tar.gz px4-nuttx-c0e51eccc5bc5ce6743572f97cfc9d13fc13ceab.tar.bz2 px4-nuttx-c0e51eccc5bc5ce6743572f97cfc9d13fc13ceab.zip |
More M3 Wildfire logic; mmap-related bug fixes from Kate
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5124 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r-- | nuttx/fs/mmap/fs_rammap.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/nuttx/fs/mmap/fs_rammap.c b/nuttx/fs/mmap/fs_rammap.c index 0eaf313b5..d2bda4fb5 100644 --- a/nuttx/fs/mmap/fs_rammap.c +++ b/nuttx/fs/mmap/fs_rammap.c @@ -165,7 +165,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) */ fdbg("Seek to position %d failed\n", (int)offset); - err = ENOMEM; + err = EINVAL; goto errout_with_region; } @@ -181,28 +181,35 @@ FAR void *rammap(int fd, size_t length, off_t offset) * signal. */ - if (nread != EINTR) + err = get_errno(); + if (err != EINTR) { /* All other read errors are bad. errno is already set. - * (but maybe should be forced to EINVAL?) + * (but maybe should be forced to EINVAL?). NOTE that if + * FS DEBUG is enabled, then the following fdbg() macro will + * destroy the errno value. */ - fdbg("Read failed: %d\n", (int)offset); + fdbg("Read failed: offset=%d errno=%d\n", (int)offset, err); +#ifdef CONFIG_DEBUG_FS + goto errout_with_region; +#else goto errout_with_errno; +#endif } + } - /* Check for end of file. */ + /* Check for end of file. */ - if (nread == 0) - { - break; - } + if (nread == 0) + { + break; + } - /* Increment number of bytes read */ + /* Increment number of bytes read */ - rdbuffer += nread; - length -= nread; - } + rdbuffer += nread; + length -= nread; } /* Zero any memory beyond the amount read from the file */ @@ -227,7 +234,7 @@ FAR void *rammap(int fd, size_t length, off_t offset) errout_with_region: kfree(alloc); errout: - errno = err; + set_errno(err); return MAP_FAILED; errout_with_errno: |