Some questions about function usage

Ching-Hung Lin billlin at wshlab2.ee.kuas.edu.tw
Mon Jun 12 11:48:59 UTC 2006


Hello,
Recently, I am coding a program about read and write control.
And there are some questions confusing me.
1.
In info libext2fs:
Function: errcode_t ext2fs_get_blocks (ext2_filsys FS, ext2_ino_t
	INO, blk_t *BLOCKS)
Returns an array of blocks corresponding to the direct, indirect,
doubly indirect, and triply indirect blocks as stored in the inode
structure.

So I wrote some codes like following:
blk_t target_blks[EXT_N_BLOCKS];
retval = ext2fs_get_blocks(fs, ino, target_blks);
printf("[percentage]u [percentage]u [percentage]u", 
	*target_blks, target_blks[1], target_blks[2]);
P.S. [percentage] is "shift+5"
The output of printf is strange.
*target_blks is the actul block number of the first block of target inode.
But target_blks[1] and target_blks[2] always 0(zero).
Why and how I get the correct an array of blocks?

2.
I get a "Attempt to write block from filesystem resulted in short write" 
when I calling io_channel_write_byte( ).
Why?
My code:
unsigned char write_buf[4096];
retval = io_channel_write_byte(fs->io, 100581, -4096, write_buf);
if (retval) {
          com_err (program_name, retval, "while callng io_channel_write_byte");
          printf ("Failure: Calling function io_channel_write_byte.\n");
          exit (1);
}

3.
I can using io_channel_write_blk to write data in the desired block.
But the changed content of block must readed by io_channel_read_blk( ).
(for example: 'a' is overwrite by 'b', and the editor still read 'a', but
io_channel_read_blk read 'b);
But I do have call io_channel_flush(fs->io) before ext2fs_close(fs).
Is there anything more I should do(like sync or something else)?
Finally, please let me know if this letter shouldn't appears in this 
mailing list.

Thank you for reading such boring and stupid letter.
Thanks for any reply message.

Ching-Hung Lin



林慶鴻 敬上
Ching-Hung Lin, CNPAL, EE, KUAS, R.O.C.(Twiwan)
07-3814526#5566




More information about the Ext3-users mailing list