i may be wrong here...just random bombing:
On Wed, Aug 27, 2008 at 6:54 PM, pradeep singh <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> If i look at the file linux/fs.h for definition of struct inode i
> notice that following fields-
>
>
> struct timespec i_atime;
> struct timespec i_mtime;
> struct timespec i_ctime;
> umode_t i_mode;
> uid_t i_uid;
> gid_t i_gid;
>
> are also present in the struct iattr defined in the same file, though
> with a slightly modified name, viz -
>
> umode_t ia_mode;
> uid_t ia_uid;
> gid_t ia_gid;
> struct timespec ia_atime;
> struct timespec ia_mtime;
> struct timespec ia_ctime;
>
> Why keep then both? Why can't we make struct iattr a member of inode
> itself, maybe via a pointer?
> is there a reason not to do so?
>
> Thanks,
> --Pradeep
>
>
Reading the comments (doubly arrowed):
/*
* This is the Inode Attributes structure, used for notify_change(). It
* uses the above definitions as flags, to know which values have changed.
* Also, in this manner, a Filesystem can look at only the values it cares
>>>>> * about. Basically, these are the attributes that the VFS layer can
>>>>> * request to change from the FS layer.
*
* Derek Atkins <[EMAIL PROTECTED]> 94-10-20
*/
struct iattr {
unsigned int ia_valid;
umode_t ia_mode;
uid_t ia_uid;
gid_t ia_gid;
loff_t ia_size;
struct timespec ia_atime;
struct timespec ia_mtime;
struct timespec ia_ctime;
/*
* Not an attribute, but an auxilary info for filesystems wanting to
* implement an ftruncate() like method. NOTE: filesystem should
* check for (ia_valid & ATTR_FILE), and not for (ia_file != NULL).
*/
struct file *ia_file;
};
It seemed to imply that the inode's definition of i_atime (etc etc) is
for the generic VFS layer, and iatttr (ia_atime etc etc) is for the
individual FS layer which can be notified for changes. So their
value need not be the same at some point in time, before/after the
notification function is executed?
To elaborate this with example:
looking at fs/attr.c (we noticed how it processed the iattr - upon
notification values - and the current values - inode):
/* POSIX UID/GID verification for setting inode attributes. */
int inode_change_ok(struct inode *inode, struct iattr *attr)
{
int retval = -EPERM;
unsigned int ia_valid = attr->ia_valid;
/* If force is set do it anyway. */
if (ia_valid & ATTR_FORCE)
goto fine;
/* Make sure a caller can chown. */
if ((ia_valid & ATTR_UID) &&
(current->fsuid != inode->i_uid ||
attr->ia_uid != inode->i_uid) && !capable(CAP_CHOWN))
goto error;
/* Make sure caller can chgrp. */
if ((ia_valid & ATTR_GID) &&
(current->fsuid != inode->i_uid ||
(!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid)) &&
!capable(CAP_CHOWN))
goto error;
/* Make sure a caller can chmod. */
if (ia_valid & ATTR_MODE) {
if (!is_owner_or_cap(inode))
goto error;
/* Also check the setgid bit! */
if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
inode->i_gid) && !capable(CAP_FSETID))
attr->ia_mode &= ~S_ISGID;
}
/* Check for setting the inode time. */
if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
if (!is_owner_or_cap(inode))
goto error;
}
fine:
retval = 0;
error:
return retval;
}
Make sense?
--
Regards,
Peter Teoh
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ