On Thu, 25 May 2000, Erez Zadok wrote:
> For now we're ok, but I think we should consider passing a struct file to
> ->truncate, and maybe even move ->truncate from inode ops to as-ops. Here
> are a brief list of reasons:
>
> (1) truncate is fundamentally an operation that is asked to operate on a
> file without being given a file to operate on. Truncating or enlarging
> a file implies munging data pages.
It's _not_ a VFS method. Just a convenient callback - convenient for many
filesystems. Not all of them have it and actually _none_ of them need it.
> (3) if we pass a struct file to ->truncate instead of a dentry, very little
> change will be required to actual file systems. The changes to the VFS
> may not be simple however. My quick inspections showed that
> notify_change and friends don't have an easy access to a struct file.
Except that struct file may not exist. Period.
> Comments?
You are doing something _very_ wrong. Notice that ->truncate() is actually
a helper - we shouldn't have it in inode_operations at all and that's on
a hitlist. ->setattr() _is_ a method, all right, but there is no struct
file around the bloody thing. Moreover, for stuff like devices ->setattr()
is fundamentally _non_-file animal - file_operations are from the
device driver, inode_operations are from the hosting fs. ->setattr()
belongs to the latter.