Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160590369
D22465.id66110.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D22465.id66110.diff
View Options
Index: head/sys/amd64/linux/linux_dummy.c
===================================================================
--- head/sys/amd64/linux/linux_dummy.c
+++ head/sys/amd64/linux/linux_dummy.c
@@ -60,7 +60,6 @@
UNIMPLEMENTED(vserver);
DUMMY(sendfile);
-DUMMY(syslog);
DUMMY(setfsuid);
DUMMY(setfsgid);
DUMMY(sysfs);
Index: head/sys/amd64/linux32/linux32_dummy.c
===================================================================
--- head/sys/amd64/linux32/linux32_dummy.c
+++ head/sys/amd64/linux32/linux32_dummy.c
@@ -63,7 +63,6 @@
DUMMY(stime);
DUMMY(olduname);
-DUMMY(syslog);
DUMMY(uname);
DUMMY(vhangup);
DUMMY(swapoff);
Index: head/sys/arm64/linux/linux_dummy.c
===================================================================
--- head/sys/arm64/linux/linux_dummy.c
+++ head/sys/arm64/linux/linux_dummy.c
@@ -65,7 +65,6 @@
UNIMPLEMENTED(vserver);
DUMMY(sendfile);
-DUMMY(syslog);
DUMMY(setfsuid);
DUMMY(setfsgid);
DUMMY(vhangup);
Index: head/sys/compat/linux/linux_misc.h
===================================================================
--- head/sys/compat/linux/linux_misc.h
+++ head/sys/compat/linux/linux_misc.h
@@ -149,6 +149,9 @@
#define LINUX_GRND_NONBLOCK 0x0001
#define LINUX_GRND_RANDOM 0x0002
+/* Linux syslog flags */
+#define LINUX_SYSLOG_ACTION_READ_ALL 3
+
#if defined(__amd64__) && !defined(COMPAT_LINUX32)
int linux_ptrace_status(struct thread *td, int pid, int status);
#endif
Index: head/sys/compat/linux/linux_misc.c
===================================================================
--- head/sys/compat/linux/linux_misc.c
+++ head/sys/compat/linux/linux_misc.c
@@ -47,6 +47,7 @@
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/mount.h>
+#include <sys/msgbuf.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/priv.h>
@@ -2288,4 +2289,67 @@
if (args->start & PAGE_MASK)
return (EINVAL);
return (kern_mincore(td, args->start, args->len, args->vec));
+}
+
+#define SYSLOG_TAG "<6>"
+
+int
+linux_syslog(struct thread *td, struct linux_syslog_args *args)
+{
+ char buf[128], *src, *dst;
+ u_int seq;
+ int buflen, error;
+
+ if (args->type != LINUX_SYSLOG_ACTION_READ_ALL) {
+ linux_msg(td, "syslog unsupported type 0x%x", args->type);
+ return (EINVAL);
+ }
+
+ if (args->len < 6) {
+ td->td_retval[0] = 0;
+ return (0);
+ }
+
+ error = priv_check(td, PRIV_MSGBUF);
+ if (error)
+ return (error);
+
+ mtx_lock(&msgbuf_lock);
+ msgbuf_peekbytes(msgbufp, NULL, 0, &seq);
+ mtx_unlock(&msgbuf_lock);
+
+ dst = args->buf;
+ error = copyout(&SYSLOG_TAG, dst, sizeof(SYSLOG_TAG));
+ /* The -1 is to skip the trailing '\0'. */
+ dst += sizeof(SYSLOG_TAG) - 1;
+
+ while (error == 0) {
+ mtx_lock(&msgbuf_lock);
+ buflen = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq);
+ mtx_unlock(&msgbuf_lock);
+
+ if (buflen == 0)
+ break;
+
+ for (src = buf; src < buf + buflen && error == 0; src++) {
+ if (*src == '\0')
+ continue;
+
+ if (dst >= args->buf + args->len)
+ goto out;
+
+ error = copyout(src, dst, 1);
+ dst++;
+
+ if (*src == '\n' && *(src + 1) != '<' &&
+ dst + sizeof(SYSLOG_TAG) < args->buf + args->len) {
+ error = copyout(&SYSLOG_TAG,
+ dst, sizeof(SYSLOG_TAG));
+ dst += sizeof(SYSLOG_TAG) - 1;
+ }
+ }
+ }
+out:
+ td->td_retval[0] = dst - args->buf;
+ return (error);
}
Index: head/sys/i386/linux/linux_dummy.c
===================================================================
--- head/sys/i386/linux/linux_dummy.c
+++ head/sys/i386/linux/linux_dummy.c
@@ -64,7 +64,6 @@
DUMMY(stime);
DUMMY(fstat);
DUMMY(olduname);
-DUMMY(syslog);
DUMMY(uname);
DUMMY(vhangup);
DUMMY(vm86old);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jun 26, 11:43 PM (11 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34345538
Default Alt Text
D22465.id66110.diff (3 KB)
Attached To
Mode
D22465: Implement Linux syslog(2) syscall; just enough to make the dmesg(8) utility work.
Attached
Detach File
Event Timeline
Log In to Comment