
This patch prepares for moving of the creation of socket files on the file system from the libc bind(2) stub into the UDS service. This change is necessary for the socket type agnostic libc implementation. The change is not yet activated - the code that is not yet used is enclosed in "#if NOT_YET" blocks. The activation needs to be atomic with UDS's switch to libsockdriver; otherwise, user applications may break. As part of the change, various UDS bind(2) semantics are changed to match the POSIX standard and other operating systems. In implementation terms, the service-only VFS API checkperms(2) is renamed to socketpath(2), and extended with a new subcall which creates a new socket file. An extension to test56 checks the new bind(2) semantics of UDS, although most new tests are still disabled until activation as well. Finally, as further preparation for a more structural redesign of the UDS service, also return the <device,inode> number pair for the created or checked file name, and make returning the canonized path name optional. Change-Id: I892d04b3301d4b911bdc571632ddde65fb747a8a
36 lines
751 B
C
36 lines
751 B
C
#include "syslib.h"
|
|
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <minix/safecopies.h>
|
|
|
|
int
|
|
socketpath(endpoint_t endpt, char * path, size_t size, int what, dev_t * dev,
|
|
ino_t * ino)
|
|
{
|
|
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 ENOMEM;
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
m.m_lsys_vfs_socketpath.endpt = endpt;
|
|
m.m_lsys_vfs_socketpath.grant = grant;
|
|
m.m_lsys_vfs_socketpath.count = size;
|
|
m.m_lsys_vfs_socketpath.what = what | SPATH_CANONIZE;
|
|
|
|
r = _taskcall(VFS_PROC_NR, VFS_SOCKETPATH, &m);
|
|
|
|
cpf_revoke(grant);
|
|
|
|
if (r == OK) {
|
|
*dev = m.m_vfs_lsys_socketpath.device;
|
|
*ino = m.m_vfs_lsys_socketpath.inode;
|
|
}
|
|
|
|
return r;
|
|
}
|