aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_inode.c
diff options
context:
space:
mode:
authorSripathi Kodi <sripathik@in.ibm.com>2010-06-18 02:20:10 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2010-08-02 15:25:10 -0400
commit87d7845aa0b157a62448dd3e339856f28befe1f4 (patch)
treebae5a5449f4bdb5ccfd1edcb99b285708c123e9f /fs/9p/vfs_inode.c
parentf085312204f384a0277a66c3c48ba8f9edcd58f2 (diff)
9p: Implement client side of setattr for 9P2000.L protocol.
SYNOPSIS size[4] Tsetattr tag[2] attr[n] size[4] Rsetattr tag[2] DESCRIPTION The setattr command changes some of the file status information. attr resembles the iattr structure used in Linux kernel. It specifies which status parameter is to be changed and to what value. It is laid out as follows: valid[4] specifies which status information is to be changed. Possible values are: ATTR_MODE (1 << 0) ATTR_UID (1 << 1) ATTR_GID (1 << 2) ATTR_SIZE (1 << 3) ATTR_ATIME (1 << 4) ATTR_MTIME (1 << 5) ATTR_ATIME_SET (1 << 7) ATTR_MTIME_SET (1 << 8) The last two bits represent whether the time information is being sent by the client's user space. In the absense of these bits the server always uses server's time. mode[4] File permission bits uid[4] Owner id of file gid[4] Group id of the file size[8] File size atime_sec[8] Time of last file access, seconds atime_nsec[8] Time of last file access, nanoseconds mtime_sec[8] Time of last file modification, seconds mtime_nsec[8] Time of last file modification, nanoseconds Explanation of the patches: -------------------------- *) The kernel just copies relevent contents of iattr structure to p9_iattr_dotl structure and passes it down to the client. The only check it has is calling inode_change_ok() *) The p9_iattr_dotl structure does not have ctime and ia_file parameters because I don't think these are needed in our case. The client user space can request updating just ctime by calling chown(fd, -1, -1). This is handled on server side without a need for putting ctime on the wire. *) The server currently supports changing mode, time, ownership and size of the file. *) 9P RFC says "Either all the changes in wstat request happen, or none of them does: if the request succeeds, all changes were made; if it fails, none were." I have not done anything to implement this specifically because I don't see a reason. Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r--fs/9p/vfs_inode.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index afcb8d889382..a90324f4546a 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -977,6 +977,49 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
977} 977}
978 978
979/** 979/**
980 * v9fs_vfs_setattr_dotl - set file metadata
981 * @dentry: file whose metadata to set
982 * @iattr: metadata assignment structure
983 *
984 */
985
986static int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
987{
988 int retval;
989 struct v9fs_session_info *v9ses;
990 struct p9_fid *fid;
991 struct p9_iattr_dotl p9attr;
992
993 P9_DPRINTK(P9_DEBUG_VFS, "\n");
994
995 retval = inode_change_ok(dentry->d_inode, iattr);
996 if (retval)
997 return retval;
998
999 p9attr.valid = iattr->ia_valid;
1000 p9attr.mode = iattr->ia_mode;
1001 p9attr.uid = iattr->ia_uid;
1002 p9attr.gid = iattr->ia_gid;
1003 p9attr.size = iattr->ia_size;
1004 p9attr.atime_sec = iattr->ia_atime.tv_sec;
1005 p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
1006 p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
1007 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
1008
1009 retval = -EPERM;
1010 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1011 fid = v9fs_fid_lookup(dentry);
1012 if (IS_ERR(fid))
1013 return PTR_ERR(fid);
1014
1015 retval = p9_client_setattr(fid, &p9attr);
1016 if (retval >= 0)
1017 retval = inode_setattr(dentry->d_inode, iattr);
1018
1019 return retval;
1020}
1021
1022/**
980 * v9fs_stat2inode - populate an inode structure with mistat info 1023 * v9fs_stat2inode - populate an inode structure with mistat info
981 * @stat: Plan 9 metadata (mistat) structure 1024 * @stat: Plan 9 metadata (mistat) structure
982 * @inode: inode to populate 1025 * @inode: inode to populate
@@ -1400,7 +1443,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotl = {
1400 .mknod = v9fs_vfs_mknod, 1443 .mknod = v9fs_vfs_mknod,
1401 .rename = v9fs_vfs_rename, 1444 .rename = v9fs_vfs_rename,
1402 .getattr = v9fs_vfs_getattr_dotl, 1445 .getattr = v9fs_vfs_getattr_dotl,
1403 .setattr = v9fs_vfs_setattr, 1446 .setattr = v9fs_vfs_setattr_dotl,
1404}; 1447};
1405 1448
1406static const struct inode_operations v9fs_dir_inode_operations = { 1449static const struct inode_operations v9fs_dir_inode_operations = {
@@ -1422,7 +1465,7 @@ static const struct inode_operations v9fs_file_inode_operations = {
1422 1465
1423static const struct inode_operations v9fs_file_inode_operations_dotl = { 1466static const struct inode_operations v9fs_file_inode_operations_dotl = {
1424 .getattr = v9fs_vfs_getattr_dotl, 1467 .getattr = v9fs_vfs_getattr_dotl,
1425 .setattr = v9fs_vfs_setattr, 1468 .setattr = v9fs_vfs_setattr_dotl,
1426}; 1469};
1427 1470
1428static const struct inode_operations v9fs_symlink_inode_operations = { 1471static const struct inode_operations v9fs_symlink_inode_operations = {
@@ -1438,5 +1481,5 @@ static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
1438 .follow_link = v9fs_vfs_follow_link, 1481 .follow_link = v9fs_vfs_follow_link,
1439 .put_link = v9fs_vfs_put_link, 1482 .put_link = v9fs_vfs_put_link,
1440 .getattr = v9fs_vfs_getattr_dotl, 1483 .getattr = v9fs_vfs_getattr_dotl,
1441 .setattr = v9fs_vfs_setattr, 1484 .setattr = v9fs_vfs_setattr_dotl,
1442}; 1485};