Message types for VFS lookup
Change-Id: Ic4d2a616ebc986c4b405b6b9ee0bd7c3b59e81d2
This commit is contained in:
@@ -41,15 +41,15 @@ int fs_lookup(void)
|
||||
int r, r1, flags, symlinks;
|
||||
unsigned int len;
|
||||
size_t offset = 0, path_size;
|
||||
pino_t dir_ino, root_ino;
|
||||
ino_t dir_ino, root_ino;
|
||||
struct puffs_node *pn;
|
||||
|
||||
grant = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
||||
path_size = (size_t) fs_m_in.REQ_PATH_SIZE; /* Size of the buffer */
|
||||
len = (int) fs_m_in.REQ_PATH_LEN; /* including terminating nul */
|
||||
dir_ino = (pino_t) fs_m_in.REQ_DIR_INO;
|
||||
root_ino = (pino_t) fs_m_in.REQ_ROOT_INO;
|
||||
flags = (int) fs_m_in.REQ_FLAGS;
|
||||
grant = fs_m_in.m_vfs_fs_lookup.grant_path;
|
||||
path_size = fs_m_in.m_vfs_fs_lookup.path_size; /* Size of the buffer */
|
||||
len = fs_m_in.m_vfs_fs_lookup.path_len; /* including terminating nul */
|
||||
dir_ino = fs_m_in.m_vfs_fs_lookup.dir_ino;
|
||||
root_ino = fs_m_in.m_vfs_fs_lookup.root_ino;
|
||||
flags = fs_m_in.m_vfs_fs_lookup.flags;
|
||||
|
||||
/* Check length. */
|
||||
if (len > sizeof(user_path)) return(E2BIG); /* too big for buffer */
|
||||
@@ -65,13 +65,13 @@ int fs_lookup(void)
|
||||
|
||||
memset(&credentials, 0, sizeof(credentials));
|
||||
if(!(flags & PATH_GET_UCRED)) { /* Do we have to copy uid/gid credentials? */
|
||||
caller_uid = (uid_t) fs_m_in.REQ_UID;
|
||||
caller_gid = (gid_t) fs_m_in.REQ_GID;
|
||||
caller_uid = fs_m_in.m_vfs_fs_lookup.uid;
|
||||
caller_gid = fs_m_in.m_vfs_fs_lookup.gid;
|
||||
} else {
|
||||
if((r=fs_lookup_credentials(&credentials,
|
||||
&caller_uid, &caller_gid,
|
||||
(cp_grant_id_t) fs_m_in.REQ_GRANT2,
|
||||
(size_t) fs_m_in.REQ_UCRED_SIZE)) != OK)
|
||||
fs_m_in.m_vfs_fs_lookup.grant_ucred,
|
||||
fs_m_in.m_vfs_fs_lookup.ucred_size)) != OK)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ int fs_lookup(void)
|
||||
|
||||
if (r == ELEAVEMOUNT || r == ESYMLINK) {
|
||||
/* Report offset and the error */
|
||||
fs_m_out.RES_OFFSET = offset;
|
||||
fs_m_out.RES_SYMLOOP = symlinks;
|
||||
fs_m_out.m_fs_vfs_lookup.offset = offset;
|
||||
fs_m_out.m_fs_vfs_lookup.symloop = symlinks;
|
||||
|
||||
return(r);
|
||||
}
|
||||
@@ -106,19 +106,19 @@ int fs_lookup(void)
|
||||
pn->pn_count++;
|
||||
}
|
||||
|
||||
fs_m_out.RES_INODE_NR = pn->pn_va.va_fileid;
|
||||
fs_m_out.RES_MODE = pn->pn_va.va_mode;
|
||||
fs_m_out.RES_FILE_SIZE = pn->pn_va.va_size;
|
||||
fs_m_out.RES_SYMLOOP = symlinks;
|
||||
fs_m_out.RES_UID = pn->pn_va.va_uid;
|
||||
fs_m_out.RES_GID = pn->pn_va.va_gid;
|
||||
fs_m_out.m_fs_vfs_lookup.inode = pn->pn_va.va_fileid;
|
||||
fs_m_out.m_fs_vfs_lookup.mode = pn->pn_va.va_mode;
|
||||
fs_m_out.m_fs_vfs_lookup.file_size = pn->pn_va.va_size;
|
||||
fs_m_out.m_fs_vfs_lookup.symloop = symlinks;
|
||||
fs_m_out.m_fs_vfs_lookup.uid = pn->pn_va.va_uid;
|
||||
fs_m_out.m_fs_vfs_lookup.gid = pn->pn_va.va_gid;
|
||||
|
||||
/* This is only valid for block and character specials. But it doesn't
|
||||
* cause any harm to set RES_DEV always. */
|
||||
fs_m_out.RES_DEV = pn->pn_va.va_rdev;
|
||||
* cause any harm to always set the device field. */
|
||||
fs_m_out.m_fs_vfs_lookup.device = pn->pn_va.va_rdev;
|
||||
|
||||
if (r == EENTERMOUNT) {
|
||||
fs_m_out.RES_OFFSET = offset;
|
||||
fs_m_out.m_fs_vfs_lookup.offset = offset;
|
||||
}
|
||||
|
||||
return(r);
|
||||
|
||||
@@ -203,7 +203,7 @@ int do_lookup(void)
|
||||
{
|
||||
/* Resolve a path string to an inode.
|
||||
*/
|
||||
pino_t dir_ino_nr, root_ino_nr;
|
||||
ino_t dir_ino_nr, root_ino_nr;
|
||||
struct inode *cur_ino, *root_ino;
|
||||
struct inode *next_ino = NULL;
|
||||
struct sffs_attr attr;
|
||||
@@ -211,19 +211,19 @@ int do_lookup(void)
|
||||
char name[NAME_MAX+1];
|
||||
char *ptr, *last;
|
||||
vfs_ucred_t ucred;
|
||||
pmode_t mask;
|
||||
mode_t mask;
|
||||
size_t len;
|
||||
int r;
|
||||
|
||||
dir_ino_nr = m_in.REQ_DIR_INO;
|
||||
root_ino_nr = m_in.REQ_ROOT_INO;
|
||||
len = m_in.REQ_PATH_LEN;
|
||||
dir_ino_nr = m_in.m_vfs_fs_lookup.dir_ino;
|
||||
root_ino_nr = m_in.m_vfs_fs_lookup.root_ino;
|
||||
len = m_in.m_vfs_fs_lookup.path_len;
|
||||
|
||||
/* Fetch the path name. */
|
||||
if (len < 1 || len > PATH_MAX)
|
||||
return EINVAL;
|
||||
|
||||
r = sys_safecopyfrom(m_in.m_source, m_in.REQ_GRANT, 0,
|
||||
r = sys_safecopyfrom(m_in.m_source, m_in.m_vfs_fs_lookup.grant_path, 0,
|
||||
(vir_bytes) buf, len);
|
||||
|
||||
if (r != OK)
|
||||
@@ -238,22 +238,22 @@ int do_lookup(void)
|
||||
/* Fetch the credentials, and generate a search access mask to test against
|
||||
* directory modes.
|
||||
*/
|
||||
if (m_in.REQ_FLAGS & PATH_GET_UCRED) {
|
||||
if (m_in.REQ_UCRED_SIZE != sizeof(ucred)) {
|
||||
if (m_in.m_vfs_fs_lookup.flags & PATH_GET_UCRED) {
|
||||
if (m_in.m_vfs_fs_lookup.ucred_size != sizeof(ucred)) {
|
||||
printf("%s: bad credential structure size\n", sffs_name);
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
r = sys_safecopyfrom(m_in.m_source, m_in.REQ_GRANT2, 0,
|
||||
(vir_bytes) &ucred, m_in.REQ_UCRED_SIZE);
|
||||
r = sys_safecopyfrom(m_in.m_source, m_in.m_vfs_fs_lookup.grant_ucred, 0,
|
||||
(vir_bytes) &ucred, m_in.m_vfs_fs_lookup.ucred_size);
|
||||
|
||||
if (r != OK)
|
||||
return r;
|
||||
}
|
||||
else {
|
||||
ucred.vu_uid = m_in.REQ_UID;
|
||||
ucred.vu_gid = m_in.REQ_GID;
|
||||
ucred.vu_uid = m_in.m_vfs_fs_lookup.uid;
|
||||
ucred.vu_gid = m_in.m_vfs_fs_lookup.gid;
|
||||
ucred.vu_ngroups = 0;
|
||||
}
|
||||
|
||||
@@ -322,19 +322,19 @@ int do_lookup(void)
|
||||
assert(r != EENTERMOUNT && r != ESYMLINK);
|
||||
|
||||
if (r == ELEAVEMOUNT) {
|
||||
m_out.RES_OFFSET = (int) (last - buf);
|
||||
m_out.RES_SYMLOOP = 0;
|
||||
m_out.m_fs_vfs_lookup.offset = (last - buf);
|
||||
m_out.m_fs_vfs_lookup.symloop = 0;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
m_out.RES_INODE_NR = INODE_NR(cur_ino);
|
||||
m_out.RES_MODE = get_mode(cur_ino, attr.a_mode);
|
||||
m_out.RES_FILE_SIZE = attr.a_size;
|
||||
m_out.RES_UID = sffs_params->p_uid;
|
||||
m_out.RES_GID = sffs_params->p_gid;
|
||||
m_out.RES_DEV = NO_DEV;
|
||||
m_out.m_fs_vfs_lookup.inode = INODE_NR(cur_ino);
|
||||
m_out.m_fs_vfs_lookup.mode = get_mode(cur_ino, attr.a_mode);
|
||||
m_out.m_fs_vfs_lookup.file_size = attr.a_size;
|
||||
m_out.m_fs_vfs_lookup.uid = sffs_params->p_uid;
|
||||
m_out.m_fs_vfs_lookup.gid = sffs_params->p_gid;
|
||||
m_out.m_fs_vfs_lookup.device = NO_DEV;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ int fs_lookup(void)
|
||||
{
|
||||
/* Resolve a path string to an inode.
|
||||
*/
|
||||
pino_t dir_ino_nr, root_ino_nr;
|
||||
ino_t dir_ino_nr, root_ino_nr;
|
||||
struct inode *cur_ino, *next_ino, *root_ino;
|
||||
char path[PATH_MAX], name[PNAME_MAX+1];
|
||||
char *ptr, *last;
|
||||
@@ -157,33 +157,35 @@ int fs_lookup(void)
|
||||
size_t len;
|
||||
int r, r2, symloop;
|
||||
|
||||
dir_ino_nr = fs_m_in.REQ_DIR_INO;
|
||||
root_ino_nr = fs_m_in.REQ_ROOT_INO;
|
||||
len = fs_m_in.REQ_PATH_LEN;
|
||||
dir_ino_nr = fs_m_in.m_vfs_fs_lookup.dir_ino;
|
||||
root_ino_nr = fs_m_in.m_vfs_fs_lookup.root_ino;
|
||||
len = fs_m_in.m_vfs_fs_lookup.path_len;
|
||||
|
||||
/* Fetch the path name. */
|
||||
if (len < 1 || len > PATH_MAX)
|
||||
return EINVAL;
|
||||
|
||||
r = sys_safecopyfrom(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,
|
||||
(vir_bytes) path, (phys_bytes) len);
|
||||
r = sys_safecopyfrom(fs_m_in.m_source,
|
||||
fs_m_in.m_vfs_fs_lookup.grant_path, 0, (vir_bytes) path,
|
||||
(phys_bytes) len);
|
||||
if (r != OK) return r;
|
||||
|
||||
if (path[len-1] != 0) return EINVAL;
|
||||
|
||||
/* Fetch the caller's credentials. */
|
||||
if (fs_m_in.REQ_FLAGS & PATH_GET_UCRED) {
|
||||
assert(fs_m_in.REQ_UCRED_SIZE == sizeof(ucred));
|
||||
if (fs_m_in.m_vfs_fs_lookup.flags & PATH_GET_UCRED) {
|
||||
assert(fs_m_in.m_vfs_fs_lookup.ucred_size == sizeof(ucred));
|
||||
|
||||
r = sys_safecopyfrom(fs_m_in.m_source, fs_m_in.REQ_GRANT2, 0,
|
||||
(vir_bytes) &ucred, fs_m_in.REQ_UCRED_SIZE);
|
||||
r = sys_safecopyfrom(fs_m_in.m_source,
|
||||
fs_m_in.m_vfs_fs_lookup.grant_ucred, 0,
|
||||
(vir_bytes) &ucred, fs_m_in.m_vfs_fs_lookup.ucred_size);
|
||||
|
||||
if (r != OK)
|
||||
return r;
|
||||
}
|
||||
else {
|
||||
ucred.vu_uid = fs_m_in.REQ_UID;
|
||||
ucred.vu_gid = fs_m_in.REQ_GID;
|
||||
ucred.vu_uid = fs_m_in.m_vfs_fs_lookup.uid;
|
||||
ucred.vu_gid = fs_m_in.m_vfs_fs_lookup.gid;
|
||||
ucred.vu_ngroups = 0;
|
||||
}
|
||||
|
||||
@@ -228,7 +230,7 @@ int fs_lookup(void)
|
||||
/* Perform symlink resolution if we have to. */
|
||||
if (r == OK && S_ISLNK(next_ino->i_stat.mode) &&
|
||||
(ptr[0] != '\0' ||
|
||||
!(fs_m_in.REQ_FLAGS & PATH_RET_SYMLINK))) {
|
||||
!(fs_m_in.m_vfs_fs_lookup.flags & PATH_RET_SYMLINK))) {
|
||||
|
||||
if (++symloop == _POSIX_SYMLOOP_MAX) {
|
||||
put_inode(next_ino);
|
||||
@@ -285,28 +287,28 @@ int fs_lookup(void)
|
||||
/* Copy back the path if we resolved at least one symlink. */
|
||||
if (symloop > 0 && (r == ELEAVEMOUNT || r == ESYMLINK)) {
|
||||
r2 = sys_safecopyto(fs_m_in.m_source,
|
||||
fs_m_in.REQ_GRANT, 0, (vir_bytes) path,
|
||||
strlen(path) + 1);
|
||||
fs_m_in.m_vfs_fs_lookup.grant_path, 0,
|
||||
(vir_bytes) path, strlen(path) + 1);
|
||||
|
||||
if (r2 != OK)
|
||||
r = r2;
|
||||
}
|
||||
|
||||
if (r == ELEAVEMOUNT || r == ESYMLINK) {
|
||||
fs_m_out.RES_OFFSET = (int) (last - path);
|
||||
fs_m_out.RES_SYMLOOP = symloop;
|
||||
fs_m_out.m_fs_vfs_lookup.offset = (int) (last - path);
|
||||
fs_m_out.m_fs_vfs_lookup.symloop = symloop;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* On success, leave the resulting file open and return its details. */
|
||||
fs_m_out.RES_INODE_NR = get_inode_number(cur_ino);
|
||||
fs_m_out.RES_MODE = cur_ino->i_stat.mode;
|
||||
fs_m_out.RES_FILE_SIZE = cur_ino->i_stat.size;
|
||||
fs_m_out.RES_UID = cur_ino->i_stat.uid;
|
||||
fs_m_out.RES_GID = cur_ino->i_stat.gid;
|
||||
fs_m_out.RES_DEV = cur_ino->i_stat.dev;
|
||||
fs_m_out.m_fs_vfs_lookup.inode = get_inode_number(cur_ino);
|
||||
fs_m_out.m_fs_vfs_lookup.mode = cur_ino->i_stat.mode;
|
||||
fs_m_out.m_fs_vfs_lookup.file_size = cur_ino->i_stat.size;
|
||||
fs_m_out.m_fs_vfs_lookup.uid = cur_ino->i_stat.uid;
|
||||
fs_m_out.m_fs_vfs_lookup.gid = cur_ino->i_stat.gid;
|
||||
fs_m_out.m_fs_vfs_lookup.device = cur_ino->i_stat.dev;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user