From d6fa78a1b05a5e03ef51fbab321529c9a52e2ef6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 10 Oct 2015 15:26:07 -0600 Subject: [PATCH] TMPFS: Fixes several bugs --- configs | 2 +- fs/tmpfs/fs_tmpfs.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configs b/configs index b16519ea24..20921ccad2 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit b16519ea24e26d50c61202ea80802a0417daeb11 +Subproject commit 20921ccad2cf456d6828d5d9f4ec8763a5f31f1f diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c index 5e7641d0a5..9984cc5d65 100644 --- a/fs/tmpfs/fs_tmpfs.c +++ b/fs/tmpfs/fs_tmpfs.c @@ -409,7 +409,7 @@ static int tmpfs_realloc_file(FAR struct tmpfs_file_s **tfo, /* Realloc the file object */ - newtfo = (FAR struct tmpfs_file_s *)kmm_realloc(oldtfo, objsize); + newtfo = (FAR struct tmpfs_file_s *)kmm_realloc(oldtfo, allocsize); if (newtfo == NULL) { return -ENOMEM; @@ -423,7 +423,7 @@ static int tmpfs_realloc_file(FAR struct tmpfs_file_s **tfo, /* Return the new address of the reallocated file object */ newtfo->tfo_alloc = allocsize; - newtfo->tfo_size = objsize; + newtfo->tfo_size = newsize; *tfo = newtfo; return OK; } @@ -1558,7 +1558,7 @@ static ssize_t tmpfs_read(FAR struct file *filep, FAR char *buffer, /* Copy data from the memory object to the user buffer */ - memcpy(buffer, &tfo->tfo_data, nread); + memcpy(buffer, &tfo->tfo_data[startpos], nread); filep->f_pos += nread; /* Release the lock on the file */ @@ -1613,7 +1613,7 @@ static ssize_t tmpfs_write(FAR struct file *filep, FAR const char *buffer, /* Copy data from the memory object to the user buffer */ - memcpy(&tfo->tfo_data, buffer, nwritten); + memcpy(&tfo->tfo_data[startpos], buffer, nwritten); filep->f_pos += nwritten; /* Release the lock on the file */