summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-10-09 12:00:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-10-09 12:00:42 +0200
commit2970d7574d1b70a00737626db10221cdedb47b33 (patch)
treebb357ace5df4d75dc43b7e6868ab0ac1cd23668c
parent95788eb4f1f210a2e284d630b5e99aebaf915558 (diff)
parent383b9348d7af2ba9caad23c08fd6553d014457a9 (diff)
downloadbarebox-2970d7574d1b70a00737626db10221cdedb47b33.tar.gz
barebox-2970d7574d1b70a00737626db10221cdedb47b33.tar.xz
Merge branch 'for-next/fs'
-rw-r--r--fs/ramfs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 09dafe02ae..84ecfa0ddb 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -379,24 +379,25 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
}
if (newchunks > oldchunks) {
- if (!data) {
+ if (data) {
+ data = ramfs_find_chunk(node, oldchunks - 1);
+ } else {
node->data = ramfs_get_chunk();
if (!node->data)
return -ENOMEM;
data = node->data;
+ oldchunks = 1;
}
- newchunks--;
- while (data->next) {
- newchunks--;
+ while (data->next)
data = data->next;
- }
- while (newchunks--) {
+ while (newchunks > oldchunks) {
data->next = ramfs_get_chunk();
if (!data->next)
return -ENOMEM;
data = data->next;
+ oldchunks++;
}
}
node->size = size;