Re: [RFC] [PATCH 2/3]: ufs: track i_size

From: Andrew Morton
Date: Mon Jun 26 2006 - 14:53:41 EST


On Mon, 26 Jun 2006 17:48:36 +0400
Evgeniy Dushistov <dushistov@xxxxxxx> wrote:

> To make possible proper work of `ufs_truncate'(see the next patch),
> I need to know old size of file in` ufs_truncate',
> but for some unknown for me reason VFS layer doesn't tell
> old size to file system, or at least I don't find way to get
> this information.
> So I have to add per each inode `loff_t' field and update it
> in
> - alloc inode
> - read inode
> - commit write
> - truncate(see the next patch)
> is this right way to know "old size" in truncate method?

You can get this info by implementing inode_operations.setattr(). See the
callsite in fs/attr.c:notify_change(). You'd do something like:

ufs_setattr()
{
loff_t old_i_size = inode->i_size;

/* Stuff copied from notify_change(): */
inode_change_ok()
security_inode_setattr()
inode_setattr()

new_i_size = inode->i_size;
....
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/