summaryrefslogtreecommitdiffstats
path: root/fs/ramfs.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:48 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:48 +0200
commitd7e3f8d227dfb143ed37a51ed31d445964872c99 (patch)
tree752ad87d84fb6646b13e2ce70756130a5db3181e /fs/ramfs.c
parente454ad437a425fa9d654cbf2ba9277b6410606a9 (diff)
downloadbarebox-d7e3f8d227dfb143ed37a51ed31d445964872c99.tar.gz
barebox-d7e3f8d227dfb143ed37a51ed31d445964872c99.tar.xz
svn_rev_378
fix truncate
Diffstat (limited to 'fs/ramfs.c')
-rw-r--r--fs/ramfs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 60bd86a262..65d6a047cb 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -170,8 +170,6 @@ struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const char *fil
n->parent = new_node;
n->child = parent_node->child;
new_node->child->next = n;
- } else {
- new_node->data = ramfs_get_chunk();
}
while (node->next)
@@ -385,9 +383,11 @@ int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
oldchunks = (node->size + CHUNK_SIZE - 1) / CHUNK_SIZE;
if (newchunks < oldchunks) {
+ if (!newchunks)
+ node->data = 0;
while (newchunks--)
data = data->next;
- while (data->next) {
+ while (data) {
struct ramfs_chunk *tmp;
tmp = data->next;
ramfs_put_chunk(data);
@@ -396,6 +396,12 @@ int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
}
if (newchunks > oldchunks) {
+ if (!data) {
+ node->data = ramfs_get_chunk();
+ data = node->data;
+ }
+
+ newchunks--;
while (data->next) {
newchunks--;
data = data->next;