Make PFS backcalls regular VFS calls
- prefix them with VFS_ as they are going to VFS; - give these calls normal call numbers; - give them their own set of message field aliases; - also make do_mapdriver a regular call. Change-Id: I2140439f288b06d699a1f65438bd8306509b259e
This commit is contained in:
parent
3af30c2c60
commit
f6915d3dee
11 changed files with 85 additions and 75 deletions
|
@ -1,4 +1,4 @@
|
||||||
#define NCALLS 124 /* number of system calls allowed */
|
#define NCALLS 130 /* number of system calls allowed */
|
||||||
|
|
||||||
/* In case it isn't obvious enough: this list is sorted numerically. */
|
/* In case it isn't obvious enough: this list is sorted numerically. */
|
||||||
#define EXIT 1
|
#define EXIT 1
|
||||||
|
@ -110,3 +110,10 @@
|
||||||
|
|
||||||
#define MAPDRIVER 122 /* to VFS, map a device */
|
#define MAPDRIVER 122 /* to VFS, map a device */
|
||||||
#define GETRUSAGE 123 /* to PM, VFS */
|
#define GETRUSAGE 123 /* to PM, VFS */
|
||||||
|
|
||||||
|
#define VFS_PFS_CHECK_PERMS 124 /* to VFS */
|
||||||
|
#define VFS_PFS_VERIFY_FD 125 /* to VFS */
|
||||||
|
#define VFS_PFS_SET_FILP 126 /* to VFS */
|
||||||
|
#define VFS_PFS_COPY_FILP 127 /* to VFS */
|
||||||
|
#define VFS_PFS_PUT_FILP 128 /* to VFS */
|
||||||
|
#define VFS_PFS_CANCEL_FD 129 /* to VFS */
|
||||||
|
|
|
@ -934,6 +934,13 @@
|
||||||
#define VFS_IOCTL_REQ m2_i3
|
#define VFS_IOCTL_REQ m2_i3
|
||||||
#define VFS_IOCTL_ARG m2_p1
|
#define VFS_IOCTL_ARG m2_p1
|
||||||
|
|
||||||
|
/* Field names for the PFS backcalls to VFS. */
|
||||||
|
#define VFS_PFS_ENDPT m2_i1
|
||||||
|
#define VFS_PFS_GRANT m2_i2
|
||||||
|
#define VFS_PFS_COUNT m2_i3
|
||||||
|
#define VFS_PFS_FD m2_i3
|
||||||
|
#define VFS_PFS_FILP m2_p1
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* Messages for VM server *
|
* Messages for VM server *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
|
|
@ -137,19 +137,5 @@ typedef u32_t pino_t; /* Protocol version of ino_t */
|
||||||
#define TRNS_ADD_ID(t,id) (((t) << 16) | ((id) & 0xFFFF))
|
#define TRNS_ADD_ID(t,id) (((t) << 16) | ((id) & 0xFFFF))
|
||||||
#define TRNS_DEL_ID(t) ((short)((t) >> 16))
|
#define TRNS_DEL_ID(t) ((short)((t) >> 16))
|
||||||
|
|
||||||
#define PFS_BASE (VFS_BASE + 100)
|
|
||||||
|
|
||||||
#define PFS_REQ_CHECK_PERMS (PFS_BASE + 1)
|
|
||||||
#define PFS_REQ_VERIFY_FD (PFS_BASE + 2)
|
|
||||||
#define PFS_REQ_SET_FILP (PFS_BASE + 3)
|
|
||||||
#define PFS_REQ_COPY_FILP (PFS_BASE + 4)
|
|
||||||
#define PFS_REQ_PUT_FILP (PFS_BASE + 5)
|
|
||||||
#define PFS_REQ_CANCEL_FD (PFS_BASE + 6)
|
|
||||||
|
|
||||||
#define PFS_NREQS 7
|
|
||||||
|
|
||||||
#define IS_PFS_VFS_RQ(type) (type >= PFS_BASE && \
|
|
||||||
type < (PFS_BASE + PFS_NREQS))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,10 @@ static int check_perms(devminor_t minor, struct sockaddr_un *addr)
|
||||||
/* ask the VFS to verify the permissions */
|
/* ask the VFS to verify the permissions */
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_CHECK_PERMS;
|
vfs_m.m_type = VFS_PFS_CHECK_PERMS;
|
||||||
vfs_m.USER_ENDPT = uds_fd_table[minor].owner;
|
vfs_m.VFS_PFS_ENDPT = uds_fd_table[minor].owner;
|
||||||
vfs_m.IO_GRANT = (char *) grant_id;
|
vfs_m.VFS_PFS_GRANT = grant_id;
|
||||||
vfs_m.COUNT = UNIX_PATH_MAX;
|
vfs_m.VFS_PFS_COUNT = UNIX_PATH_MAX;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
cpf_revoke(grant_id);
|
cpf_revoke(grant_id);
|
||||||
|
@ -82,9 +82,9 @@ static filp_id_t verify_fd(endpoint_t ep, int fd)
|
||||||
|
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_VERIFY_FD;
|
vfs_m.m_type = VFS_PFS_VERIFY_FD;
|
||||||
vfs_m.USER_ENDPT = ep;
|
vfs_m.VFS_PFS_ENDPT = ep;
|
||||||
vfs_m.COUNT = fd;
|
vfs_m.VFS_PFS_FD = fd;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
if (OK != rc) {
|
if (OK != rc) {
|
||||||
|
@ -97,7 +97,7 @@ static filp_id_t verify_fd(endpoint_t ep, int fd)
|
||||||
printf("(uds) VFS reply => %d\n", vfs_m.m_type);
|
printf("(uds) VFS reply => %d\n", vfs_m.m_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return vfs_m.ADDRESS;
|
return vfs_m.VFS_PFS_FILP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_filp(filp_id_t sfilp)
|
static int set_filp(filp_id_t sfilp)
|
||||||
|
@ -112,8 +112,8 @@ static int set_filp(filp_id_t sfilp)
|
||||||
|
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_SET_FILP;
|
vfs_m.m_type = VFS_PFS_SET_FILP;
|
||||||
vfs_m.ADDRESS = sfilp;
|
vfs_m.VFS_PFS_FILP = sfilp;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
if (OK != rc) {
|
if (OK != rc) {
|
||||||
|
@ -141,9 +141,9 @@ static int copy_filp(endpoint_t to_ep, filp_id_t cfilp)
|
||||||
|
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_COPY_FILP;
|
vfs_m.m_type = VFS_PFS_COPY_FILP;
|
||||||
vfs_m.USER_ENDPT = to_ep;
|
vfs_m.VFS_PFS_ENDPT = to_ep;
|
||||||
vfs_m.ADDRESS = cfilp;
|
vfs_m.VFS_PFS_FILP = cfilp;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
if (OK != rc) {
|
if (OK != rc) {
|
||||||
|
@ -170,8 +170,8 @@ static int put_filp(filp_id_t pfilp)
|
||||||
|
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_PUT_FILP;
|
vfs_m.m_type = VFS_PFS_PUT_FILP;
|
||||||
vfs_m.ADDRESS = pfilp;
|
vfs_m.VFS_PFS_FILP = pfilp;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
if (OK != rc) {
|
if (OK != rc) {
|
||||||
|
@ -198,9 +198,9 @@ static int cancel_fd(endpoint_t ep, int fd)
|
||||||
|
|
||||||
memset(&vfs_m, '\0', sizeof(message));
|
memset(&vfs_m, '\0', sizeof(message));
|
||||||
|
|
||||||
vfs_m.m_type = PFS_REQ_CANCEL_FD;
|
vfs_m.m_type = VFS_PFS_CANCEL_FD;
|
||||||
vfs_m.USER_ENDPT = ep;
|
vfs_m.VFS_PFS_ENDPT = ep;
|
||||||
vfs_m.COUNT = fd;
|
vfs_m.VFS_PFS_FD = fd;
|
||||||
|
|
||||||
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
rc = sendrec(VFS_PROC_NR, &vfs_m);
|
||||||
if (OK != rc) {
|
if (OK != rc) {
|
||||||
|
|
|
@ -135,6 +135,12 @@ int (*call_vec[])(void) = {
|
||||||
no_sys, /* 121 = (task reply) */
|
no_sys, /* 121 = (task reply) */
|
||||||
no_sys, /* 122 = (map driver ) */
|
no_sys, /* 122 = (map driver ) */
|
||||||
do_getrusage, /* 123 = getrusage */
|
do_getrusage, /* 123 = getrusage */
|
||||||
|
no_sys, /* 124 = (check_perms) */
|
||||||
|
no_sys, /* 125 = (verify_fd) */
|
||||||
|
no_sys, /* 126 = (set_filp) */
|
||||||
|
no_sys, /* 127 = (copy_filp) */
|
||||||
|
no_sys, /* 128 = (put_filp) */
|
||||||
|
no_sys, /* 129 = (cancel_fd) */
|
||||||
};
|
};
|
||||||
/* This should not fail with "array size is negative": */
|
/* This should not fail with "array size is negative": */
|
||||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||||
|
|
|
@ -59,7 +59,7 @@ void unlock_dmap(struct dmap *dp)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_mapdriver *
|
* do_mapdriver *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int do_mapdriver()
|
int do_mapdriver(message *UNUSED(m_out))
|
||||||
{
|
{
|
||||||
/* Create a device->driver mapping. RS will tell us which major is driven by
|
/* Create a device->driver mapping. RS will tell us which major is driven by
|
||||||
* this driver, what type of device it is (regular, TTY, asynchronous, clone,
|
* this driver, what type of device it is (regular, TTY, asynchronous, clone,
|
||||||
|
|
|
@ -450,11 +450,14 @@ int do_verify_fd(message *m_out)
|
||||||
endpoint_t proc_e;
|
endpoint_t proc_e;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
proc_e = job_m_in.USER_ENDPT;
|
/* This should be replaced with an ACL check. */
|
||||||
fd = job_m_in.COUNT;
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
proc_e = job_m_in.VFS_PFS_ENDPT;
|
||||||
|
fd = job_m_in.VFS_PFS_FD;
|
||||||
|
|
||||||
rfilp = (struct filp *) verify_fd(proc_e, fd);
|
rfilp = (struct filp *) verify_fd(proc_e, fd);
|
||||||
m_out->ADDRESS = (void *) rfilp;
|
m_out->VFS_PFS_FILP = (void *) rfilp;
|
||||||
if (rfilp != NULL) unlock_filp(rfilp);
|
if (rfilp != NULL) unlock_filp(rfilp);
|
||||||
return (rfilp != NULL) ? OK : EINVAL;
|
return (rfilp != NULL) ? OK : EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +483,11 @@ filp_id_t sfilp;
|
||||||
int do_set_filp(message *UNUSED(m_out))
|
int do_set_filp(message *UNUSED(m_out))
|
||||||
{
|
{
|
||||||
filp_id_t f;
|
filp_id_t f;
|
||||||
f = (filp_id_t) job_m_in.ADDRESS;
|
|
||||||
|
/* This should be replaced with an ACL check. */
|
||||||
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
f = (filp_id_t) job_m_in.VFS_PFS_FILP;
|
||||||
return set_filp(f);
|
return set_filp(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,8 +530,11 @@ int do_copy_filp(message *UNUSED(m_out))
|
||||||
endpoint_t proc_e;
|
endpoint_t proc_e;
|
||||||
filp_id_t f;
|
filp_id_t f;
|
||||||
|
|
||||||
proc_e = job_m_in.USER_ENDPT;
|
/* This should be replaced with an ACL check. */
|
||||||
f = (filp_id_t) job_m_in.ADDRESS;
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
proc_e = job_m_in.VFS_PFS_ENDPT;
|
||||||
|
f = (filp_id_t) job_m_in.VFS_PFS_FILP;
|
||||||
|
|
||||||
return copy_filp(proc_e, f);
|
return copy_filp(proc_e, f);
|
||||||
}
|
}
|
||||||
|
@ -550,7 +560,11 @@ filp_id_t pfilp;
|
||||||
int do_put_filp(message *UNUSED(m_out))
|
int do_put_filp(message *UNUSED(m_out))
|
||||||
{
|
{
|
||||||
filp_id_t f;
|
filp_id_t f;
|
||||||
f = (filp_id_t) job_m_in.ADDRESS;
|
|
||||||
|
/* This should be replaced with an ACL check. */
|
||||||
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
f = (filp_id_t) job_m_in.VFS_PFS_FILP;
|
||||||
return put_filp(f);
|
return put_filp(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,8 +611,11 @@ int do_cancel_fd(message *UNUSED(m_out))
|
||||||
endpoint_t proc_e;
|
endpoint_t proc_e;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
proc_e = job_m_in.USER_ENDPT;
|
/* This should be replaced with an ACL check. */
|
||||||
fd = job_m_in.COUNT;
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
proc_e = job_m_in.VFS_PFS_ENDPT;
|
||||||
|
fd = job_m_in.VFS_PFS_FD;
|
||||||
|
|
||||||
return cancel_fd(proc_e, fd);
|
return cancel_fd(proc_e, fd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,24 +256,14 @@ static void do_work(void)
|
||||||
|
|
||||||
memset(&m_out, 0, sizeof(m_out));
|
memset(&m_out, 0, sizeof(m_out));
|
||||||
|
|
||||||
if (job_call_nr == MAPDRIVER) {
|
if (job_call_nr == COMMON_GETSYSINFO) {
|
||||||
error = do_mapdriver();
|
|
||||||
} else if (job_call_nr == COMMON_GETSYSINFO) {
|
|
||||||
error = do_getsysinfo();
|
error = do_getsysinfo();
|
||||||
} else if (IS_PFS_VFS_RQ(job_call_nr)) {
|
|
||||||
if (who_e != PFS_PROC_NR) {
|
|
||||||
printf("VFS: only PFS is allowed to make nested VFS calls\n");
|
|
||||||
error = ENOSYS;
|
|
||||||
} else if (job_call_nr <= PFS_BASE ||
|
|
||||||
job_call_nr >= PFS_BASE + PFS_NREQS) {
|
|
||||||
error = ENOSYS;
|
|
||||||
} else {
|
|
||||||
job_call_nr -= PFS_BASE;
|
|
||||||
error = (*pfs_call_vec[job_call_nr])(&m_out);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* We're dealing with a POSIX system call from a normal
|
/* At this point we assume that we're dealing with a call that has been
|
||||||
* process. Call the internal function that does the work.
|
* made specifically to VFS. Typically it will be a POSIX call from a
|
||||||
|
* normal process, but we also handle a few calls made by system
|
||||||
|
* processes (such as PFS) through here. Call the internal function
|
||||||
|
* that does the work.
|
||||||
*/
|
*/
|
||||||
if (job_call_nr < 0 || job_call_nr >= NCALLS) {
|
if (job_call_nr < 0 || job_call_nr >= NCALLS) {
|
||||||
error = ENOSYS;
|
error = ENOSYS;
|
||||||
|
|
|
@ -870,6 +870,9 @@ size_t pathlen;
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int do_check_perms(message *UNUSED(m_out))
|
int do_check_perms(message *UNUSED(m_out))
|
||||||
{
|
{
|
||||||
return check_perms(job_m_in.USER_ENDPT, (cp_grant_id_t) job_m_in.IO_GRANT,
|
/* This should be replaced by an ACL check. */
|
||||||
(size_t) job_m_in.COUNT);
|
if (who_e != PFS_PROC_NR) return EPERM;
|
||||||
|
|
||||||
|
return check_perms(job_m_in.VFS_PFS_ENDPT, job_m_in.VFS_PFS_GRANT,
|
||||||
|
(size_t) job_m_in.VFS_PFS_COUNT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void cdev_up(int major);
|
||||||
/* dmap.c */
|
/* dmap.c */
|
||||||
void lock_dmap(struct dmap *dp);
|
void lock_dmap(struct dmap *dp);
|
||||||
void unlock_dmap(struct dmap *dp);
|
void unlock_dmap(struct dmap *dp);
|
||||||
int do_mapdriver(void);
|
int do_mapdriver(message *m_out);
|
||||||
void init_dmap(void);
|
void init_dmap(void);
|
||||||
void init_dmap_locks(void);
|
void init_dmap_locks(void);
|
||||||
int dmap_driver_match(endpoint_t proc, int major);
|
int dmap_driver_match(endpoint_t proc, int major);
|
||||||
|
@ -64,7 +64,6 @@ void dmap_endpt_up(endpoint_t proc_nr, int is_blk);
|
||||||
void dmap_unmap_by_endpt(endpoint_t proc_nr);
|
void dmap_unmap_by_endpt(endpoint_t proc_nr);
|
||||||
struct dmap *get_dmap(endpoint_t proc_e);
|
struct dmap *get_dmap(endpoint_t proc_e);
|
||||||
struct dmap *get_dmap_by_major(int major);
|
struct dmap *get_dmap_by_major(int major);
|
||||||
int do_mapdriver(void);
|
|
||||||
int map_service(struct rprocpub *rpub);
|
int map_service(struct rprocpub *rpub);
|
||||||
void dmap_unmap_by_endpt(endpoint_t proc_nr);
|
void dmap_unmap_by_endpt(endpoint_t proc_nr);
|
||||||
int map_driver(const char *label, int major, endpoint_t proc_nr, int
|
int map_driver(const char *label, int major, endpoint_t proc_nr, int
|
||||||
|
|
|
@ -136,19 +136,14 @@ int (*call_vec[])(message *m_out) = {
|
||||||
no_sys, /* 119 = unsused */
|
no_sys, /* 119 = unsused */
|
||||||
no_sys, /* 120 = unsused */
|
no_sys, /* 120 = unsused */
|
||||||
no_sys, /* 121 = (task reply) */
|
no_sys, /* 121 = (task reply) */
|
||||||
no_sys, /* 122 = (map driver ) */
|
do_mapdriver, /* 122 = mapdriver */
|
||||||
do_getrusage, /* 123 = getrusage */
|
do_getrusage, /* 123 = getrusage */
|
||||||
|
do_check_perms, /* 124 = from PFS: check_perms */
|
||||||
|
do_verify_fd, /* 125 = from PFS: verify_fd */
|
||||||
|
do_set_filp, /* 126 = from PFS: set_filp */
|
||||||
|
do_copy_filp, /* 127 = from PFS: copy_filp */
|
||||||
|
do_put_filp, /* 128 = from PFS: put_filp */
|
||||||
|
do_cancel_fd, /* 129 = from PFS: cancel_fd */
|
||||||
};
|
};
|
||||||
/* This should not fail with "array size is negative": */
|
/* This should not fail with "array size is negative": */
|
||||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||||
|
|
||||||
int (*pfs_call_vec[])(message *m_out) = {
|
|
||||||
|
|
||||||
no_sys, /* 0 */
|
|
||||||
do_check_perms, /* 1 */
|
|
||||||
do_verify_fd, /* 2 */
|
|
||||||
do_set_filp, /* 3 */
|
|
||||||
do_copy_filp, /* 4 */
|
|
||||||
do_put_filp, /* 5 */
|
|
||||||
do_cancel_fd /* 6 */
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue