-#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. */
#define EXIT 1
#define MAPDRIVER 122 /* to VFS, map a device */
#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 */
#define VFS_IOCTL_REQ m2_i3
#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 *
*===========================================================================*/
#define TRNS_ADD_ID(t,id) (((t) << 16) | ((id) & 0xFFFF))
#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
/* ask the VFS to verify the permissions */
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_CHECK_PERMS;
- vfs_m.USER_ENDPT = uds_fd_table[minor].owner;
- vfs_m.IO_GRANT = (char *) grant_id;
- vfs_m.COUNT = UNIX_PATH_MAX;
+ vfs_m.m_type = VFS_PFS_CHECK_PERMS;
+ vfs_m.VFS_PFS_ENDPT = uds_fd_table[minor].owner;
+ vfs_m.VFS_PFS_GRANT = grant_id;
+ vfs_m.VFS_PFS_COUNT = UNIX_PATH_MAX;
rc = sendrec(VFS_PROC_NR, &vfs_m);
cpf_revoke(grant_id);
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_VERIFY_FD;
- vfs_m.USER_ENDPT = ep;
- vfs_m.COUNT = fd;
+ vfs_m.m_type = VFS_PFS_VERIFY_FD;
+ vfs_m.VFS_PFS_ENDPT = ep;
+ vfs_m.VFS_PFS_FD = fd;
rc = sendrec(VFS_PROC_NR, &vfs_m);
if (OK != rc) {
printf("(uds) VFS reply => %d\n", vfs_m.m_type);
#endif
- return vfs_m.ADDRESS;
+ return vfs_m.VFS_PFS_FILP;
}
static int set_filp(filp_id_t sfilp)
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_SET_FILP;
- vfs_m.ADDRESS = sfilp;
+ vfs_m.m_type = VFS_PFS_SET_FILP;
+ vfs_m.VFS_PFS_FILP = sfilp;
rc = sendrec(VFS_PROC_NR, &vfs_m);
if (OK != rc) {
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_COPY_FILP;
- vfs_m.USER_ENDPT = to_ep;
- vfs_m.ADDRESS = cfilp;
+ vfs_m.m_type = VFS_PFS_COPY_FILP;
+ vfs_m.VFS_PFS_ENDPT = to_ep;
+ vfs_m.VFS_PFS_FILP = cfilp;
rc = sendrec(VFS_PROC_NR, &vfs_m);
if (OK != rc) {
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_PUT_FILP;
- vfs_m.ADDRESS = pfilp;
+ vfs_m.m_type = VFS_PFS_PUT_FILP;
+ vfs_m.VFS_PFS_FILP = pfilp;
rc = sendrec(VFS_PROC_NR, &vfs_m);
if (OK != rc) {
memset(&vfs_m, '\0', sizeof(message));
- vfs_m.m_type = PFS_REQ_CANCEL_FD;
- vfs_m.USER_ENDPT = ep;
- vfs_m.COUNT = fd;
+ vfs_m.m_type = VFS_PFS_CANCEL_FD;
+ vfs_m.VFS_PFS_ENDPT = ep;
+ vfs_m.VFS_PFS_FD = fd;
rc = sendrec(VFS_PROC_NR, &vfs_m);
if (OK != rc) {
no_sys, /* 121 = (task reply) */
no_sys, /* 122 = (map driver ) */
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": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
/*===========================================================================*
* 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
* this driver, what type of device it is (regular, TTY, asynchronous, clone,
endpoint_t proc_e;
int fd;
- proc_e = job_m_in.USER_ENDPT;
- fd = job_m_in.COUNT;
+ /* This should be replaced with an ACL check. */
+ 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);
- m_out->ADDRESS = (void *) rfilp;
+ m_out->VFS_PFS_FILP = (void *) rfilp;
if (rfilp != NULL) unlock_filp(rfilp);
return (rfilp != NULL) ? OK : EINVAL;
}
int do_set_filp(message *UNUSED(m_out))
{
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);
}
endpoint_t proc_e;
filp_id_t f;
- proc_e = job_m_in.USER_ENDPT;
- f = (filp_id_t) job_m_in.ADDRESS;
+ /* This should be replaced with an ACL check. */
+ 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);
}
int do_put_filp(message *UNUSED(m_out))
{
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);
}
endpoint_t proc_e;
int fd;
- proc_e = job_m_in.USER_ENDPT;
- fd = job_m_in.COUNT;
+ /* This should be replaced with an ACL check. */
+ 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);
}
memset(&m_out, 0, sizeof(m_out));
- if (job_call_nr == MAPDRIVER) {
- error = do_mapdriver();
- } else if (job_call_nr == COMMON_GETSYSINFO) {
+ if (job_call_nr == COMMON_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 {
- /* We're dealing with a POSIX system call from a normal
- * process. Call the internal function that does the work.
+ /* At this point we assume that we're dealing with a call that has been
+ * 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) {
error = ENOSYS;
*===========================================================================*/
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,
- (size_t) job_m_in.COUNT);
+ /* This should be replaced by an ACL check. */
+ 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);
}
/* dmap.c */
void lock_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_locks(void);
int dmap_driver_match(endpoint_t proc, int major);
void dmap_unmap_by_endpt(endpoint_t proc_nr);
struct dmap *get_dmap(endpoint_t proc_e);
struct dmap *get_dmap_by_major(int major);
-int do_mapdriver(void);
int map_service(struct rprocpub *rpub);
void dmap_unmap_by_endpt(endpoint_t proc_nr);
int map_driver(const char *label, int major, endpoint_t proc_nr, int
no_sys, /* 119 = unsused */
no_sys, /* 120 = unsused */
no_sys, /* 121 = (task reply) */
- no_sys, /* 122 = (map driver ) */
+ do_mapdriver, /* 122 = mapdriver */
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": */
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 */
-};