e5cc85fdc4
This single function allows copying file descriptors from and to processes, and closing a previously copied remote file descriptor. This function replaces the five FD-related UDS backcalls. While it limits the total number of in-flight file descriptors to OPEN_MAX, this change greatly improves crash recovery support of UDS, since all in-flight file descriptors will be closed instead of keeping them open indefinitely (causing VFS to crash on system shutdown). With the new copyfd call, UDS becomes simpler, and the concept of filps is no longer exposed outside of VFS. This patch also moves the checkperms(2) stub into libminlib, thus fully abstracting away message details of VFS communication from UDS. Change-Id: Idd32ad390a566143c8ef66955e5ae2c221cff966
27 lines
588 B
C
27 lines
588 B
C
#include <lib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <minix/safecopies.h>
|
|
|
|
int
|
|
checkperms(endpoint_t endpt, char *path, size_t size)
|
|
{
|
|
cp_grant_id_t grant;
|
|
message m;
|
|
int r;
|
|
|
|
if ((grant = cpf_grant_direct(VFS_PROC_NR, (vir_bytes) path, size,
|
|
CPF_READ | CPF_WRITE)) == GRANT_INVALID)
|
|
return -1; /* called function sets errno */
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
m.VFS_CHECKPERMS_ENDPT = endpt;
|
|
m.VFS_CHECKPERMS_GRANT = grant;
|
|
m.VFS_CHECKPERMS_COUNT = size;
|
|
|
|
r = _syscall(VFS_PROC_NR, VFS_CHECKPERMS, &m);
|
|
|
|
cpf_revoke(grant); /* does not touch errno */
|
|
|
|
return r;
|
|
}
|