Fix for a segfault when resizing files.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Wed, 13 Jan 2010 19:04:27 +0000 (11:04 -0800)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Wed, 13 Jan 2010 19:04:27 +0000 (11:04 -0800)
If we only have a reference to a file block but have not read it in, we
don't actually know the size.  We maybe ought to have a better fix for this
later.

bluesky/file.c

index 09e4805..9b9f916 100644 (file)
@@ -71,7 +71,8 @@ void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size)
                                              inode->blocks->len - 1);
 
             if (b->type != BLUESKY_BLOCK_ZERO
-                    && b->data->len < BLUESKY_BLOCK_SIZE) {
+                    && (b->type == BLUESKY_BLOCK_REF
+                        || b->data->len < BLUESKY_BLOCK_SIZE)) {
                 bluesky_block_touch(inode, inode->blocks->len - 1);
                 gsize old_size = b->data->len;
                 bluesky_string_resize(b->data, BLUESKY_BLOCK_SIZE);