Message types for VFS chown

Change-Id: I1dc50772fd28b0c698d85922ad0ad3b41dde006c
This commit is contained in:
Lionel Sambuc 2014-05-01 11:40:33 +02:00
parent fd32afa654
commit a65bf37e3b
5 changed files with 35 additions and 16 deletions

View file

@ -162,6 +162,23 @@ typedef struct {
} mess_fs_vfs_chmod; } mess_fs_vfs_chmod;
_ASSERT_MSG_SIZE(mess_fs_vfs_chmod); _ASSERT_MSG_SIZE(mess_fs_vfs_chmod);
typedef struct {
ino_t inode;
uid_t uid;
gid_t gid;
uint8_t data[40];
} mess_vfs_fs_chown;
_ASSERT_MSG_SIZE(mess_vfs_fs_chown);
typedef struct {
mode_t mode;
uint8_t data[52];
} mess_fs_vfs_chown;
_ASSERT_MSG_SIZE(mess_fs_vfs_chown);
typedef struct { typedef struct {
ino_t inode; ino_t inode;
@ -532,6 +549,8 @@ typedef struct {
mess_fs_vfs_newnode m_fs_vfs_newnode; mess_fs_vfs_newnode m_fs_vfs_newnode;
mess_vfs_fs_chmod m_vfs_fs_chmod; mess_vfs_fs_chmod m_vfs_fs_chmod;
mess_fs_vfs_chmod m_fs_vfs_chmod; mess_fs_vfs_chmod m_fs_vfs_chmod;
mess_vfs_fs_chown m_vfs_fs_chown;
mess_fs_vfs_chown m_fs_vfs_chown;
mess_vfs_fs_create m_vfs_fs_create; mess_vfs_fs_create m_vfs_fs_create;
mess_fs_vfs_create m_fs_vfs_create; mess_fs_vfs_create m_fs_vfs_create;
mess_vfs_fs_flush m_vfs_fs_flush; mess_vfs_fs_flush m_vfs_fs_flush;

View file

@ -54,14 +54,14 @@ int fs_chown(void)
struct vattr va; struct vattr va;
PUFFS_MAKECRED(pcr, &global_kcred); PUFFS_MAKECRED(pcr, &global_kcred);
if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_INODE_NR)) == NULL) if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.m_vfs_fs_chown.inode)) == NULL)
return(EINVAL); return(EINVAL);
/* Not permitted to change the owner of a file on a read-only file sys. */ /* Not permitted to change the owner of a file on a read-only file sys. */
if (!is_readonly_fs) { if (!is_readonly_fs) {
puffs_vattr_null(&va); puffs_vattr_null(&va);
va.va_uid = fs_m_in.REQ_UID; va.va_uid = fs_m_in.m_vfs_fs_chown.uid;
va.va_gid = fs_m_in.REQ_GID; va.va_gid = fs_m_in.m_vfs_fs_chown.gid;
va.va_mode = pn->pn_va.va_mode & ~(I_SET_UID_BIT | I_SET_GID_BIT); va.va_mode = pn->pn_va.va_mode & ~(I_SET_UID_BIT | I_SET_GID_BIT);
va.va_ctime = clock_timespec(); va.va_ctime = clock_timespec();
@ -70,7 +70,7 @@ int fs_chown(void)
} }
/* Update caller on current mode, as it may have changed. */ /* Update caller on current mode, as it may have changed. */
fs_m_out.RES_MODE = pn->pn_va.va_mode; fs_m_out.m_fs_vfs_chown.mode = pn->pn_va.va_mode;
return(OK); return(OK);
} }

View file

@ -48,21 +48,21 @@ int fs_chown()
register int r; register int r;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL) if( (rip = get_inode(fs_dev, fs_m_in.m_vfs_fs_chown.inode)) == NULL)
return(EINVAL); return(EINVAL);
/* Not permitted to change the owner of a file on a read-only file sys. */ /* Not permitted to change the owner of a file on a read-only file sys. */
r = read_only(rip); r = read_only(rip);
if (r == OK) { if (r == OK) {
rip->i_uid = fs_m_in.REQ_UID; rip->i_uid = fs_m_in.m_vfs_fs_chown.uid;
rip->i_gid = fs_m_in.REQ_GID; rip->i_gid = fs_m_in.m_vfs_fs_chown.gid;
rip->i_mode &= ~(I_SET_UID_BIT | I_SET_GID_BIT); rip->i_mode &= ~(I_SET_UID_BIT | I_SET_GID_BIT);
rip->i_update |= CTIME; rip->i_update |= CTIME;
rip->i_dirt = IN_DIRTY; rip->i_dirt = IN_DIRTY;
} }
/* Update caller on current mode, as it may have changed. */ /* Update caller on current mode, as it may have changed. */
fs_m_out.RES_MODE = rip->i_mode; fs_m_out.m_fs_vfs_chown.mode = rip->i_mode;
put_inode(rip); put_inode(rip);
return(r); return(r);

View file

@ -49,21 +49,21 @@ int fs_chown()
register int r; register int r;
/* Temporarily open the file. */ /* Temporarily open the file. */
if( (rip = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL) if( (rip = get_inode(fs_dev, fs_m_in.m_vfs_fs_chown.inode)) == NULL)
return(EINVAL); return(EINVAL);
/* Not permitted to change the owner of a file on a read-only file sys. */ /* Not permitted to change the owner of a file on a read-only file sys. */
r = read_only(rip); r = read_only(rip);
if (r == OK) { if (r == OK) {
rip->i_uid = (uid_t) fs_m_in.REQ_UID; rip->i_uid = fs_m_in.m_vfs_fs_chown.uid;
rip->i_gid = (gid_t) fs_m_in.REQ_GID; rip->i_gid = fs_m_in.m_vfs_fs_chown.gid;
rip->i_mode &= ~(I_SET_UID_BIT | I_SET_GID_BIT); rip->i_mode &= ~(I_SET_UID_BIT | I_SET_GID_BIT);
rip->i_update |= CTIME; rip->i_update |= CTIME;
IN_MARKDIRTY(rip); IN_MARKDIRTY(rip);
} }
/* Update caller on current mode, as it may have changed. */ /* Update caller on current mode, as it may have changed. */
fs_m_out.RES_MODE = rip->i_mode; fs_m_out.m_fs_vfs_chown.mode = rip->i_mode;
put_inode(rip); put_inode(rip);
return(r); return(r);

View file

@ -144,15 +144,15 @@ int req_chown(
/* Fill in request message */ /* Fill in request message */
m.m_type = REQ_CHOWN; m.m_type = REQ_CHOWN;
m.REQ_INODE_NR = (pino_t) inode_nr; m.m_vfs_fs_chown.inode = inode_nr;
m.REQ_UID = (puid_t) newuid; m.m_vfs_fs_chown.uid = newuid;
m.REQ_GID = (pgid_t) newgid; m.m_vfs_fs_chown.gid = newgid;
/* Send/rec request */ /* Send/rec request */
r = fs_sendrec(fs_e, &m); r = fs_sendrec(fs_e, &m);
/* Return new mode to caller. */ /* Return new mode to caller. */
*new_modep = (mode_t) m.RES_MODE; *new_modep = m.m_fs_vfs_chown.mode;
return(r); return(r);
} }