Re: help with ext3 reserved inode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Donato,

On Wed, Jul 8, 2009 at 1:14 PM, Donato Capitella<d.capitella@xxxxxx> wrote:
> Hi there,
> I wrote a dummy function to write to the reserved inode. This is as far
> as I got and I have a few questions:
>
> /**************************************************************/
> void dummy_write_to_inode(struct inode *ino)
> {
>        struct buffer_head *bh;
>        handle_t *handle;
>        int err, blk;
>        char dummy_text[] = "The crazy fox jumps over the lazy dog!";
>
>        handle = ext3_start_journal(inode, 2);
>        if (IS_ERR(handle))
>                goto err;
>
>        /* allocate a block */
>        blk = ext3_new_block(handle, inode, 1, &err);
>        if (err)
>                goto err;
>
>        EXT3_I(inode)->i_data[0] = blk
>
>        /* write something to the block */
>        bh = sb_bread(ino->sb, blk);
>        if (IS_ERR(bh))
>                goto err;
>
>        memcpy(bh->b_data, dummy_text, sizeof(dummy_text));
>        mark_buffer_dirty(bh);
>        brelse(bh);
>
>        i_size_write(inode, sizeof(dummy_text));
>        mark_inode_dirty(inode);
>
ext3_sync_inode(handle, ino);

>        ext3_journal_stop(handle);
>
>
> err:
>        /* ... error handling code ... */
> }
> /**************************************************************/
>
> For some reason, this code doesn't work as I expected. The block is
> actually written and at the end contains "The lazy fox jumps over the
> lazy dog". The problem is with the inode: it just gets partially
> updated. The block pointer to the first block is updated but the size
> stays zero. How is it possibile that half of the inode gets updated and
> the other half doesn't? What am I missing here?
>

try syncing the inode. This should probably help.

> Thanks,
> Donato
>
> p.s.: I'd also like to know if there is a "smarter" way to write to an
> inode that automatically allocates blocks when needed and the like...
>

>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Sandeep.





 	
“To learn is to change. Education is a process that changes the learner.”

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux