diff --git a/src/libs/compat/freebsd_network/Jamfile b/src/libs/compat/freebsd_network/Jamfile index 1dddf1817e..509a582b67 100644 --- a/src/libs/compat/freebsd_network/Jamfile +++ b/src/libs/compat/freebsd_network/Jamfile @@ -37,7 +37,7 @@ KernelStaticLibrary libfreebsd_network.a : mbuf.c mii.c mutex.c - priv.c + priv.cpp synch.c taskqueue.c unit.c diff --git a/src/libs/compat/freebsd_network/compat/sys/pcpu.h b/src/libs/compat/freebsd_network/compat/sys/pcpu.h index aacd760aba..858d57b7f8 100644 --- a/src/libs/compat/freebsd_network/compat/sys/pcpu.h +++ b/src/libs/compat/freebsd_network/compat/sys/pcpu.h @@ -6,9 +6,17 @@ #define _FBSD_COMPAT_SYS_PCPU_H_ -#include +#include -#define curthread (thread_get_current_thread()) +struct thread; + +#define curthread ((struct thread*)NULL) + /* NOTE: Dereferencing curthread will crash, which is intentional. There is + no FreeBSD compatible struct thread and Haiku's should not be used as it + is only valid for the current thread or with proper locking. Currently + only priv_check() expects a struct thread parameter and ignores it. Using + NULL will show us when other uses appear. */ + #endif /* _FBSD_COMPAT_SYS_PCPU_H_ */ diff --git a/src/libs/compat/freebsd_network/compat/sys/priv.h b/src/libs/compat/freebsd_network/compat/sys/priv.h index 8b78ce4460..4ba76e34c6 100644 --- a/src/libs/compat/freebsd_network/compat/sys/priv.h +++ b/src/libs/compat/freebsd_network/compat/sys/priv.h @@ -6,6 +6,9 @@ #define _FBSD_COMPAT_SYS_PRIV_H_ +#include + + /* * 802.11-related privileges. */ @@ -25,6 +28,11 @@ struct thread; +__BEGIN_DECLS + int priv_check(struct thread*, int); +__END_DECLS + + #endif /* _FBSD_COMPAT_SYS_PRIV_H_ */ diff --git a/src/libs/compat/freebsd_network/priv.c b/src/libs/compat/freebsd_network/priv.cpp similarity index 64% rename from src/libs/compat/freebsd_network/priv.c rename to src/libs/compat/freebsd_network/priv.cpp index 6a1351e09c..61525ba7e7 100644 --- a/src/libs/compat/freebsd_network/priv.c +++ b/src/libs/compat/freebsd_network/priv.cpp @@ -14,8 +14,12 @@ * FreeBSD has a more sophisticated privilege checking system. * We only check for superuser rights. */ -int priv_check(struct thread *thread, int privilegeLevel) +int +priv_check(struct thread *thread, int privilegeLevel) { + // Note: The thread parameter is ignored intentionally (cf. the comment in + // pcpu.h). Currently calling this function is only valid for the current + // thread. if (thread_get_current_thread()->team->effective_uid == 0) return ENOERR;