Message types for VFS rdlink
Change-Id: Ic077e99fb140a3a1de849f7f761fdfd90961f5d8
This commit is contained in:
parent
591227dc38
commit
111969b623
6 changed files with 41 additions and 22 deletions
|
@ -281,6 +281,23 @@ typedef struct {
|
||||||
} mess_fs_vfs_newnode;
|
} mess_fs_vfs_newnode;
|
||||||
_ASSERT_MSG_SIZE(mess_fs_vfs_newnode);
|
_ASSERT_MSG_SIZE(mess_fs_vfs_newnode);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ino_t inode;
|
||||||
|
|
||||||
|
cp_grant_id_t grant;
|
||||||
|
size_t mem_size;
|
||||||
|
|
||||||
|
uint8_t data[40];
|
||||||
|
} mess_vfs_fs_rdlink;
|
||||||
|
_ASSERT_MSG_SIZE(mess_vfs_fs_rdlink);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t nbytes;
|
||||||
|
|
||||||
|
uint8_t data[52];
|
||||||
|
} mess_fs_vfs_rdlink;
|
||||||
|
_ASSERT_MSG_SIZE(mess_fs_vfs_rdlink);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dev_t device;
|
dev_t device;
|
||||||
|
|
||||||
|
@ -428,6 +445,8 @@ typedef struct {
|
||||||
mess_fs_vfs_lookup m_fs_vfs_lookup;
|
mess_fs_vfs_lookup m_fs_vfs_lookup;
|
||||||
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
|
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
|
||||||
mess_vfs_fs_new_driver m_vfs_fs_new_driver;
|
mess_vfs_fs_new_driver m_vfs_fs_new_driver;
|
||||||
|
mess_vfs_fs_rdlink m_vfs_fs_rdlink;
|
||||||
|
mess_fs_vfs_rdlink m_fs_vfs_rdlink;
|
||||||
mess_vfs_fs_readsuper m_vfs_fs_readsuper;
|
mess_vfs_fs_readsuper m_vfs_fs_readsuper;
|
||||||
mess_fs_vfs_readsuper m_fs_vfs_readsuper;
|
mess_fs_vfs_readsuper m_fs_vfs_readsuper;
|
||||||
mess_vfs_fs_rename m_vfs_fs_rename;
|
mess_vfs_fs_rename m_vfs_fs_rename;
|
||||||
|
|
|
@ -160,12 +160,12 @@ int fs_rdlink(void)
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
PUFFS_MAKECRED(pcr, &global_kcred);
|
PUFFS_MAKECRED(pcr, &global_kcred);
|
||||||
|
|
||||||
copylen = (size_t) fs_m_in.REQ_MEM_SIZE < UMAX_FILE_POS ?
|
copylen = fs_m_in.m_vfs_fs_rdlink.mem_size < UMAX_FILE_POS ?
|
||||||
(size_t) fs_m_in.REQ_MEM_SIZE : UMAX_FILE_POS;
|
fs_m_in.m_vfs_fs_rdlink.mem_size : UMAX_FILE_POS;
|
||||||
|
|
||||||
assert(copylen <= PATH_MAX);
|
assert(copylen <= PATH_MAX);
|
||||||
|
|
||||||
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_rdlink.inode)) == NULL)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
|
|
||||||
if (!S_ISLNK(pn->pn_va.va_mode))
|
if (!S_ISLNK(pn->pn_va.va_mode))
|
||||||
|
@ -181,10 +181,10 @@ int fs_rdlink(void)
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
r = sys_safecopyto(VFS_PROC_NR, fs_m_in.m_vfs_fs_rdlink.grant,
|
||||||
(vir_bytes) 0, (vir_bytes) path, (size_t) copylen);
|
(vir_bytes) 0, (vir_bytes) path, (size_t) copylen);
|
||||||
if (r == OK)
|
if (r == OK)
|
||||||
fs_m_out.RES_NBYTES = copylen;
|
fs_m_out.m_fs_vfs_rdlink.nbytes = copylen;
|
||||||
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ int fs_rdlink(void)
|
||||||
size_t len;
|
size_t len;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL)
|
if ((node = find_inode(fs_m_in.m_vfs_fs_rdlink.inode)) == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
/* Call the rdlink hook. */
|
/* Call the rdlink hook. */
|
||||||
|
@ -28,14 +28,14 @@ int fs_rdlink(void)
|
||||||
len = strlen(path);
|
len = strlen(path);
|
||||||
assert(len > 0 && len < sizeof(path));
|
assert(len > 0 && len < sizeof(path));
|
||||||
|
|
||||||
if (len > fs_m_in.REQ_MEM_SIZE)
|
if (len > fs_m_in.m_vfs_fs_rdlink.mem_size)
|
||||||
len = fs_m_in.REQ_MEM_SIZE;
|
len = fs_m_in.m_vfs_fs_rdlink.mem_size;
|
||||||
|
|
||||||
/* Copy out the result. */
|
/* Copy out the result. */
|
||||||
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,
|
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.m_vfs_fs_rdlink.grant, 0,
|
||||||
(vir_bytes) path, len);
|
(vir_bytes) path, len);
|
||||||
if (r != OK) return r;
|
if (r != OK) return r;
|
||||||
|
|
||||||
fs_m_out.RES_NBYTES = len;
|
fs_m_out.m_fs_vfs_rdlink.nbytes = len;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,10 +188,10 @@ int fs_rdlink()
|
||||||
register int r; /* return value */
|
register int r; /* return value */
|
||||||
size_t copylen;
|
size_t copylen;
|
||||||
|
|
||||||
copylen = min( (size_t) fs_m_in.REQ_MEM_SIZE, UMAX_FILE_POS);
|
copylen = min(fs_m_in.m_vfs_fs_rdlink.mem_size, UMAX_FILE_POS);
|
||||||
|
|
||||||
/* 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_rdlink.inode)) == NULL)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
|
|
||||||
if (rip->i_size >= MAX_FAST_SYMLINK_LENGTH) {
|
if (rip->i_size >= MAX_FAST_SYMLINK_LENGTH) {
|
||||||
|
@ -212,12 +212,12 @@ int fs_rdlink()
|
||||||
/* We can safely cast to unsigned, because copylen is guaranteed to be
|
/* We can safely cast to unsigned, because copylen is guaranteed to be
|
||||||
below max file size */
|
below max file size */
|
||||||
copylen = min( copylen, (unsigned) rip->i_size);
|
copylen = min( copylen, (unsigned) rip->i_size);
|
||||||
r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
r = sys_safecopyto(VFS_PROC_NR, fs_m_in.m_vfs_fs_rdlink.grant,
|
||||||
(vir_bytes) 0, (vir_bytes) link_text,
|
(vir_bytes) 0, (vir_bytes) link_text,
|
||||||
(size_t) copylen);
|
(size_t) copylen);
|
||||||
put_block(bp, DIRECTORY_BLOCK);
|
put_block(bp, DIRECTORY_BLOCK);
|
||||||
if (r == OK)
|
if (r == OK)
|
||||||
fs_m_out.RES_NBYTES = copylen;
|
fs_m_out.m_fs_vfs_rdlink.nbytes = copylen;
|
||||||
}
|
}
|
||||||
|
|
||||||
put_inode(rip);
|
put_inode(rip);
|
||||||
|
|
|
@ -178,10 +178,10 @@ int fs_rdlink()
|
||||||
register int r; /* return value */
|
register int r; /* return value */
|
||||||
size_t copylen;
|
size_t copylen;
|
||||||
|
|
||||||
copylen = min( (size_t) fs_m_in.REQ_MEM_SIZE, UMAX_FILE_POS);
|
copylen = min(fs_m_in.m_vfs_fs_rdlink.mem_size, UMAX_FILE_POS);
|
||||||
|
|
||||||
/* 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_rdlink.inode)) == NULL)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
|
|
||||||
if(!S_ISLNK(rip->i_mode))
|
if(!S_ISLNK(rip->i_mode))
|
||||||
|
@ -193,12 +193,12 @@ int fs_rdlink()
|
||||||
/* We can safely cast to unsigned, because copylen is guaranteed to be
|
/* We can safely cast to unsigned, because copylen is guaranteed to be
|
||||||
below max file size */
|
below max file size */
|
||||||
copylen = min( copylen, (unsigned) rip->i_size);
|
copylen = min( copylen, (unsigned) rip->i_size);
|
||||||
r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
r = sys_safecopyto(VFS_PROC_NR, fs_m_in.m_vfs_fs_rdlink.grant,
|
||||||
(vir_bytes) 0, (vir_bytes) b_data(bp),
|
(vir_bytes) 0, (vir_bytes) b_data(bp),
|
||||||
(size_t) copylen);
|
(size_t) copylen);
|
||||||
put_block(bp, DIRECTORY_BLOCK);
|
put_block(bp, DIRECTORY_BLOCK);
|
||||||
if (r == OK)
|
if (r == OK)
|
||||||
fs_m_out.RES_NBYTES = copylen;
|
fs_m_out.m_fs_vfs_rdlink.nbytes = copylen;
|
||||||
}
|
}
|
||||||
|
|
||||||
put_inode(rip);
|
put_inode(rip);
|
||||||
|
|
|
@ -731,15 +731,15 @@ static int req_rdlink_actual(endpoint_t fs_e, ino_t inode_nr,
|
||||||
|
|
||||||
/* Fill in request message */
|
/* Fill in request message */
|
||||||
m.m_type = REQ_RDLINK;
|
m.m_type = REQ_RDLINK;
|
||||||
m.REQ_INODE_NR = (pino_t) inode_nr;
|
m.m_vfs_fs_rdlink.inode = inode_nr;
|
||||||
m.REQ_GRANT = grant_id;
|
m.m_vfs_fs_rdlink.grant = grant_id;
|
||||||
m.REQ_MEM_SIZE = len;
|
m.m_vfs_fs_rdlink.mem_size = len;
|
||||||
|
|
||||||
/* Send/rec request */
|
/* Send/rec request */
|
||||||
r = fs_sendrec(fs_e, &m);
|
r = fs_sendrec(fs_e, &m);
|
||||||
cpf_revoke(grant_id);
|
cpf_revoke(grant_id);
|
||||||
|
|
||||||
if (r == OK) r = m.RES_NBYTES;
|
if (r == OK) r = m.m_fs_vfs_rdlink.nbytes;
|
||||||
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue