Commit 613f134e authored by Alessandro Rubini's avatar Alessandro Rubini

sdbfs/userspace/lib: bugfix in access.c

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent aa05e0dd
...@@ -21,7 +21,7 @@ int sdbfs_fstat(struct sdbfs *fs, struct sdb_device *record_return) ...@@ -21,7 +21,7 @@ int sdbfs_fstat(struct sdbfs *fs, struct sdb_device *record_return)
int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count) int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count)
{ {
int ret = count; int ret;
if (!fs->currentp) if (!fs->currentp)
return -ENOENT; return -ENOENT;
...@@ -29,6 +29,7 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count) ...@@ -29,6 +29,7 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count)
offset = fs->read_offset; offset = fs->read_offset;
if (offset + count > fs->f_len) if (offset + count > fs->f_len)
count = fs->f_len - offset; count = fs->f_len - offset;
ret = count;
if (fs->data) if (fs->data)
memcpy(buf, fs->data + fs->f_offset + offset, count); memcpy(buf, fs->data + fs->f_offset + offset, count);
else else
...@@ -40,7 +41,7 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count) ...@@ -40,7 +41,7 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count)
int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count) int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count)
{ {
int ret = count; int ret;
if (!fs->currentp) if (!fs->currentp)
return -ENOENT; return -ENOENT;
...@@ -48,6 +49,7 @@ int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count) ...@@ -48,6 +49,7 @@ int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count)
offset = fs->read_offset; offset = fs->read_offset;
if (offset + count > fs->f_len) if (offset + count > fs->f_len)
count = fs->f_len - offset; count = fs->f_len - offset;
ret = count;
if (fs->data) if (fs->data)
memcpy(buf, fs->data + fs->f_offset + offset, count); memcpy(buf, fs->data + fs->f_offset + offset, count);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment