Skip to content

Truncate #26

@dhalsimax

Description

@dhalsimax

Hi,
Nice work, I never user FUSE before, anyway the truncate function in vmram.cpp does:

file->size(size);

And it it's just nice for this function to delegate the class, anyway the file function size() in file class:

    void file_t::size(size_t new_size) {
        if (new_size < _size) {
            free_blocks(new_size);
        }

        _size = new_size;

        mtime(util::time());
    }

Suppose you are using the standard shell command truncate on a new file or to increase the size of any existing one, as you only check the new size is less the _size member field you will finally get the new or bigger "truncated" file without the correct blocks allocated. So then, when using the file again, you will get a segfault. Try by yourself.
Is it solution writing a while loop to allocate all the blocks needed with alloc_block function?

Regards Massimo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions