Message types for VFS getdents
Change-Id: I7474d7547f1fd52f4da54754ccfe984ba1a2baa8
This commit is contained in:
parent
5fb3a3e7d3
commit
591227dc38
8 changed files with 69 additions and 47 deletions
|
@ -187,6 +187,26 @@ typedef struct {
|
|||
} mess_vfs_fs_ftrunc;
|
||||
_ASSERT_MSG_SIZE(mess_vfs_fs_ftrunc);
|
||||
|
||||
typedef struct {
|
||||
ino_t inode;
|
||||
off_t seek_pos;
|
||||
|
||||
cp_grant_id_t grant;
|
||||
size_t mem_size;
|
||||
|
||||
uint8_t data[32];
|
||||
} mess_vfs_fs_getdents;
|
||||
_ASSERT_MSG_SIZE(mess_vfs_fs_getdents);
|
||||
|
||||
typedef struct {
|
||||
off_t seek_pos;
|
||||
|
||||
size_t nbytes;
|
||||
|
||||
uint8_t data[44];
|
||||
} mess_fs_vfs_getdents;
|
||||
_ASSERT_MSG_SIZE(mess_fs_vfs_getdents);
|
||||
|
||||
typedef struct {
|
||||
ino_t dir_ino;
|
||||
ino_t root_ino;
|
||||
|
@ -402,6 +422,8 @@ typedef struct {
|
|||
mess_fs_vfs_create m_fs_vfs_create;
|
||||
mess_vfs_fs_flush m_vfs_fs_flush;
|
||||
mess_vfs_fs_ftrunc m_vfs_fs_ftrunc;
|
||||
mess_vfs_fs_getdents m_vfs_fs_getdents;
|
||||
mess_fs_vfs_getdents m_fs_vfs_getdents;
|
||||
mess_vfs_fs_lookup m_vfs_fs_lookup;
|
||||
mess_fs_vfs_lookup m_fs_vfs_lookup;
|
||||
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
|
||||
|
|
|
@ -123,7 +123,7 @@ int fs_getdents(void)
|
|||
{
|
||||
int r;
|
||||
register struct puffs_node *pn;
|
||||
pino_t ino;
|
||||
ino_t ino;
|
||||
cp_grant_id_t gid;
|
||||
size_t size, buf_left;
|
||||
off_t pos;
|
||||
|
@ -132,10 +132,10 @@ int fs_getdents(void)
|
|||
size_t written;
|
||||
PUFFS_MAKECRED(pcr, &global_kcred);
|
||||
|
||||
ino = (pino_t) fs_m_in.REQ_INODE_NR;
|
||||
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
||||
size = buf_left = (size_t) fs_m_in.REQ_MEM_SIZE;
|
||||
pos = (off_t) fs_m_in.REQ_SEEK_POS;
|
||||
ino = fs_m_in.m_vfs_fs_getdents.inode;
|
||||
gid = fs_m_in.m_vfs_fs_getdents.grant;
|
||||
size = buf_left = fs_m_in.m_vfs_fs_getdents.mem_size;
|
||||
pos = fs_m_in.m_vfs_fs_getdents.seek_pos;
|
||||
|
||||
if ((pn = puffs_pn_nodewalk(global_pu, 0, &ino)) == NULL) {
|
||||
lpuffs_debug("walk failed...\n");
|
||||
|
@ -171,8 +171,8 @@ int fs_getdents(void)
|
|||
|
||||
update_timens(pn, ATIME, NULL);
|
||||
|
||||
fs_m_out.RES_NBYTES = written;
|
||||
fs_m_out.RES_SEEK_POS = pos;
|
||||
fs_m_out.m_fs_vfs_getdents.nbytes = written;
|
||||
fs_m_out.m_fs_vfs_getdents.seek_pos = pos;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
|
@ -92,10 +92,10 @@ int do_getdents(void)
|
|||
|
||||
attr.a_mask = SFFS_ATTR_MODE;
|
||||
|
||||
if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)
|
||||
if ((ino = find_inode(m_in.m_vfs_fs_getdents.inode)) == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if(m_in.REQ_SEEK_POS >= ULONG_MAX) return EINVAL;
|
||||
if(m_in.m_vfs_fs_getdents.seek_pos >= ULONG_MAX) return EINVAL;
|
||||
|
||||
if (!IS_DIR(ino)) return ENOTDIR;
|
||||
|
||||
|
@ -108,13 +108,13 @@ int do_getdents(void)
|
|||
|
||||
off = 0;
|
||||
user_off = 0;
|
||||
user_left = m_in.REQ_MEM_SIZE;
|
||||
user_left = m_in.m_vfs_fs_getdents.mem_size;
|
||||
|
||||
/* We use the seek position as file index number. The first position is for
|
||||
* the "." entry, the second position is for the ".." entry, and the next
|
||||
* position numbers each represent a file in the directory.
|
||||
*/
|
||||
for (pos = m_in.REQ_SEEK_POS; ; pos++) {
|
||||
for (pos = m_in.m_vfs_fs_getdents.seek_pos; ; pos++) {
|
||||
/* Determine which inode and name to use for this entry.
|
||||
* We have no idea whether the host will give us "." and/or "..",
|
||||
* so generate our own and skip those from the host.
|
||||
|
@ -190,7 +190,7 @@ int do_getdents(void)
|
|||
|
||||
/* If our own buffer cannot contain the new record, copy out first. */
|
||||
if (off + len > sizeof(buf)) {
|
||||
r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT,
|
||||
r = sys_safecopyto(m_in.m_source, m_in.m_vfs_fs_getdents.grant,
|
||||
user_off, (vir_bytes) buf, off);
|
||||
|
||||
if (r != OK) {
|
||||
|
@ -219,7 +219,7 @@ int do_getdents(void)
|
|||
|
||||
/* If there is anything left in our own buffer, copy that out now. */
|
||||
if (off > 0) {
|
||||
r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, user_off,
|
||||
r = sys_safecopyto(m_in.m_source, m_in.m_vfs_fs_getdents.grant, user_off,
|
||||
(vir_bytes) buf, off);
|
||||
|
||||
if (r != OK)
|
||||
|
@ -228,8 +228,8 @@ int do_getdents(void)
|
|||
user_off += off;
|
||||
}
|
||||
|
||||
m_out.RES_SEEK_POS = pos;
|
||||
m_out.RES_NBYTES = user_off;
|
||||
m_out.m_fs_vfs_getdents.seek_pos = pos;
|
||||
m_out.m_fs_vfs_getdents.nbytes = user_off;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -79,15 +79,15 @@ int fs_getdents(void)
|
|||
int r, skip, get_next, indexed;
|
||||
static char buf[GETDENTS_BUFSIZ];
|
||||
|
||||
if (fs_m_in.REQ_SEEK_POS >= ULONG_MAX)
|
||||
if (fs_m_in.m_vfs_fs_getdents.seek_pos >= ULONG_MAX)
|
||||
return EIO;
|
||||
|
||||
if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL)
|
||||
if ((node = find_inode(fs_m_in.m_vfs_fs_getdents.inode)) == NULL)
|
||||
return EINVAL;
|
||||
|
||||
off = 0;
|
||||
user_off = 0;
|
||||
user_left = fs_m_in.REQ_MEM_SIZE;
|
||||
user_left = fs_m_in.m_vfs_fs_getdents.mem_size;
|
||||
indexed = node->i_indexed;
|
||||
get_next = FALSE;
|
||||
child = NULL;
|
||||
|
@ -98,7 +98,7 @@ int fs_getdents(void)
|
|||
if (r != OK) return r;
|
||||
}
|
||||
|
||||
for (pos = fs_m_in.REQ_SEEK_POS; ; pos++) {
|
||||
for (pos = fs_m_in.m_vfs_fs_getdents.seek_pos; ; pos++) {
|
||||
/* Determine which inode and name to use for this entry. */
|
||||
if (pos == 0) {
|
||||
/* The "." entry. */
|
||||
|
@ -176,7 +176,7 @@ int fs_getdents(void)
|
|||
* first.
|
||||
*/
|
||||
if (off + len > sizeof(buf)) {
|
||||
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT,
|
||||
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.m_vfs_fs_getdents.grant,
|
||||
user_off, (vir_bytes) buf, off);
|
||||
if (r != OK) return r;
|
||||
|
||||
|
@ -198,7 +198,7 @@ int fs_getdents(void)
|
|||
|
||||
/* If there is anything left in our own buffer, copy that out now. */
|
||||
if (off > 0) {
|
||||
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT,
|
||||
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.m_vfs_fs_getdents.grant,
|
||||
user_off, (vir_bytes) buf, off);
|
||||
if (r != OK)
|
||||
return r;
|
||||
|
@ -206,8 +206,8 @@ int fs_getdents(void)
|
|||
user_off += off;
|
||||
}
|
||||
|
||||
fs_m_out.RES_SEEK_POS = pos;
|
||||
fs_m_out.RES_NBYTES = user_off;
|
||||
fs_m_out.m_fs_vfs_getdents.seek_pos = pos;
|
||||
fs_m_out.m_fs_vfs_getdents.nbytes = user_off;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -620,7 +620,7 @@ int fs_getdents(void)
|
|||
struct inode *rip;
|
||||
int r, done;
|
||||
unsigned int block_size, len, reclen;
|
||||
pino_t ino;
|
||||
ino_t ino;
|
||||
cp_grant_id_t gid;
|
||||
size_t size, tmpbuf_off, userbuf_off;
|
||||
off_t pos, off, block_pos, new_pos, ent_pos;
|
||||
|
@ -628,10 +628,10 @@ int fs_getdents(void)
|
|||
struct ext2_disk_dir_desc *d_desc;
|
||||
struct dirent *dep;
|
||||
|
||||
ino = (pino_t) fs_m_in.REQ_INODE_NR;
|
||||
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
||||
size = (size_t) fs_m_in.REQ_MEM_SIZE;
|
||||
pos = (off_t) fs_m_in.REQ_SEEK_POS;
|
||||
ino = fs_m_in.m_vfs_fs_getdents.inode;
|
||||
gid = fs_m_in.m_vfs_fs_getdents.grant;
|
||||
size = fs_m_in.m_vfs_fs_getdents.mem_size;
|
||||
pos = fs_m_in.m_vfs_fs_getdents.seek_pos;
|
||||
|
||||
/* Check whether the position is properly aligned */
|
||||
if ((unsigned int) pos % DIR_ENTRY_ALIGN)
|
||||
|
@ -759,8 +759,8 @@ int fs_getdents(void)
|
|||
if (done && userbuf_off == 0)
|
||||
r = EINVAL; /* The user's buffer is too small */
|
||||
else {
|
||||
fs_m_out.RES_NBYTES = userbuf_off;
|
||||
fs_m_out.RES_SEEK_POS = new_pos;
|
||||
fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off;
|
||||
fs_m_out.m_fs_vfs_getdents.seek_pos = new_pos;
|
||||
rip->i_update |= ATIME;
|
||||
rip->i_dirt = IN_DIRTY;
|
||||
r = OK;
|
||||
|
|
|
@ -159,9 +159,9 @@ int fs_getdents(void)
|
|||
memset(name_old,'\0',NAME_MAX);
|
||||
|
||||
/* Get input parameters */
|
||||
ino = fs_m_in.REQ_INODE_NR;
|
||||
gid = fs_m_in.REQ_GRANT;
|
||||
pos = fs_m_in.REQ_SEEK_POS;
|
||||
ino = fs_m_in.m_vfs_fs_getdents.inode;
|
||||
gid = fs_m_in.m_vfs_fs_getdents.grant;
|
||||
pos = fs_m_in.m_vfs_fs_getdents.seek_pos;
|
||||
|
||||
block_size = v_pri.logical_block_size_l;
|
||||
cur_pos = pos; /* The current position */
|
||||
|
@ -277,8 +277,8 @@ int fs_getdents(void)
|
|||
userbuf_off += tmpbuf_offset;
|
||||
}
|
||||
|
||||
fs_m_out.RES_NBYTES = userbuf_off;
|
||||
fs_m_out.RES_SEEK_POS = cur_pos;
|
||||
fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off;
|
||||
fs_m_out.m_fs_vfs_getdents.seek_pos = cur_pos;
|
||||
|
||||
release_dir_record(dir); /* release the inode */
|
||||
return(OK);
|
||||
|
|
|
@ -616,10 +616,10 @@ int fs_getdents(void)
|
|||
struct dirent *dep;
|
||||
char *cp;
|
||||
|
||||
ino = (pino_t) fs_m_in.REQ_INODE_NR;
|
||||
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
||||
size = (size_t) fs_m_in.REQ_MEM_SIZE;
|
||||
pos = (off_t) fs_m_in.REQ_SEEK_POS;
|
||||
ino = fs_m_in.m_vfs_fs_getdents.inode;
|
||||
gid = fs_m_in.m_vfs_fs_getdents.grant;
|
||||
size = fs_m_in.m_vfs_fs_getdents.mem_size;
|
||||
pos = fs_m_in.m_vfs_fs_getdents.seek_pos;
|
||||
|
||||
/* Check whether the position is properly aligned */
|
||||
if( (unsigned int) pos % DIR_ENTRY_SIZE)
|
||||
|
@ -729,8 +729,8 @@ int fs_getdents(void)
|
|||
if (done && userbuf_off == 0)
|
||||
r = EINVAL; /* The user's buffer is too small */
|
||||
else {
|
||||
fs_m_out.RES_NBYTES = userbuf_off;
|
||||
fs_m_out.RES_SEEK_POS = new_pos;
|
||||
fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off;
|
||||
fs_m_out.m_fs_vfs_getdents.seek_pos = new_pos;
|
||||
if(!rip->i_sp->s_rd_only) {
|
||||
rip->i_update |= ATIME;
|
||||
IN_MARKDIRTY(rip);
|
||||
|
|
|
@ -314,10 +314,10 @@ static int req_getdents_actual(
|
|||
grant_id);
|
||||
|
||||
m.m_type = REQ_GETDENTS;
|
||||
m.REQ_INODE_NR = (pino_t) inode_nr;
|
||||
m.REQ_GRANT = grant_id;
|
||||
m.REQ_MEM_SIZE = size;
|
||||
m.REQ_SEEK_POS = pos;
|
||||
m.m_vfs_fs_getdents.inode = inode_nr;
|
||||
m.m_vfs_fs_getdents.grant = grant_id;
|
||||
m.m_vfs_fs_getdents.mem_size = size;
|
||||
m.m_vfs_fs_getdents.seek_pos = pos;
|
||||
if (!(vmp->m_fs_flags & RES_64BIT) && (pos > INT_MAX)) {
|
||||
/* FS does not support 64-bit off_t and 32 bits is not enough */
|
||||
return EINVAL;
|
||||
|
@ -327,8 +327,8 @@ static int req_getdents_actual(
|
|||
cpf_revoke(grant_id);
|
||||
|
||||
if (r == OK) {
|
||||
*new_pos = m.RES_SEEK_POS;
|
||||
r = m.RES_NBYTES;
|
||||
*new_pos = m.m_fs_vfs_getdents.seek_pos;
|
||||
r = m.m_fs_vfs_getdents.nbytes;
|
||||
}
|
||||
|
||||
return(r);
|
||||
|
|
Loading…
Reference in a new issue