Add basic OpenBSD support
XXX more work needed to manage VT switches and proper XXX fbtab(4) support to allow for non-root users
This commit is contained in:
parent
f2ff233c26
commit
4b2ecdf936
5 changed files with 33 additions and 4 deletions
|
@ -21,7 +21,7 @@ int drm_drop_master(int fd) {
|
|||
return ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(__NetBSD__)
|
||||
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int path_is_drm(const char *path) {
|
||||
if (STR_HAS_PREFIX("/dev/dri/", path))
|
||||
return 1;
|
||||
|
|
|
@ -25,7 +25,7 @@ int path_is_evdev(const char *path) {
|
|||
int evdev_revoke(int fd) {
|
||||
return ioctl(fd, EVIOCREVOKE, NULL);
|
||||
}
|
||||
#elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int path_is_evdev(const char *path) {
|
||||
(void)path;
|
||||
return 0;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define K_ENABLE K_XLATE
|
||||
#define K_DISABLE K_RAW
|
||||
#define FRSIG SIGIO
|
||||
#elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <dev/wscons/wsdisplay_usl_io.h>
|
||||
#define K_ENABLE K_XLATE
|
||||
#define K_DISABLE K_RAW
|
||||
|
@ -147,6 +147,14 @@ static int get_tty_path(int tty, char path[static TTYPATHLEN]) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__OpenBSD__)
|
||||
static int get_tty_path(int tty, char path[static TTYPATHLEN]) {
|
||||
assert(tty >= 0);
|
||||
if (snprintf(path, TTYPATHLEN, "/dev/ttyC%d", tty) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#error Unsupported platform
|
||||
#endif
|
||||
|
@ -175,7 +183,7 @@ int terminal_current_vt(int fd) {
|
|||
return -1;
|
||||
}
|
||||
return st.v_active;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
int vt;
|
||||
int res = ioctl(fd, VT_GETACTIVE, &vt);
|
||||
close(fd);
|
||||
|
|
|
@ -55,6 +55,23 @@ static int get_peer(int fd, pid_t *pid, uid_t *uid, gid_t *gid) {
|
|||
*uid = cred.unp_euid;
|
||||
*gid = cred.unp_egid;
|
||||
return 0;
|
||||
#elif defined(__OpenBSD__)
|
||||
struct sockpeercred peercred;
|
||||
socklen_t len = sizeof(peercred);
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &len) == -1) {
|
||||
// assume builtin backend
|
||||
if (errno == EINVAL) {
|
||||
*pid = getpid();
|
||||
*uid = getuid();
|
||||
*gid = getgid();
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
*pid = peercred.pid;
|
||||
*uid = peercred.uid;
|
||||
*gid = peercred.gid;
|
||||
return 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
struct xucred cred;
|
||||
socklen_t len = sizeof cred;
|
||||
|
|
|
@ -123,6 +123,10 @@ static int test_signal_event(int signal, void *data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#define SIGRTMIN SIGUSR1
|
||||
#endif
|
||||
|
||||
static void test_poller_single_signal(void) {
|
||||
struct poller poller;
|
||||
test_assert(poller_init(&poller) == 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue