sunxfancy / whefs

Automatically exported from code.google.com/p/whefs
Other
0 stars 0 forks source link

update file content error #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.whefs_mkfs ,new one file ABC 
2.open fs and write content to the file ABC 
3.open fs and open the file,cat ABC file content
4.keep 2. and 3. 

What is the expected output? What do you see instead?
after loop (fsopts.block_count - 1), get empty file content.
open the fs file,I found every time write the file content , it aband the old 
block,and write file content to the next block.So after (fsopts.block_count - 
1) loop,there will have no block left.

What version of the product are you using? On what operating system?
version 20111103

Please provide any additional information below.
here is the test code

int  test_update()
{
    char const * fname = "one.whefs";

    whefs_fs * fs;

    if( whefs_rc.OK != whefs_openfs( fname, &fs, true ) )
    {
        ("openfs(%s) failed!\n",fname);
        return 1;
    }

whio_stream * dest = whio_stream_for_FILE( stdout, true );
    cat_file( fs, fname, dest);

    whio_stream * out = whefs_stream_open( fs, fname, true, false );
    assert(out);
    char const * str = "555555555555!";
    size_t slen = strlen(str);
    out->api->write( out, str, slen );
    out->api->flush(out);
    out->api->finalize(out);

    whefs_fs_finalize( fs );

    MARKER("ending test\n");

}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    ThisApp.fsopts = whefs_fs_options_default;

     ThisApp.fsopts.inode_count = 16;
     ThisApp.fsopts.block_count = 32;
     ThisApp.fsopts.filename_length = 64;
     ThisApp.fsopts.block_size = 1024 ;

     ForEachDataInit.pos = 0;

     test_update();

    return a.exec();
}

Original issue reported on code.google.com by yunjie....@gmail.com on 8 Nov 2012 at 8:08