# What about epoll syscall in FreeBSD-10?



## bryn1u (Sep 11, 2014)

Hey,

I'm getting errors in dmesg:

```
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)
Security policy loaded: TrustedBSD MAC/BSD Extended (mac_bsdextended)
linux: pid 84270 (steamcmd): syscall utimensat not implemented
linux: pid 84407 (steamcmd): syscall utimensat not implemented
linux: pid 84414 (steamcmd): syscall utimensat not implemented
linux: pid 84420 (steamcmd): syscall epoll_create not implemented
linux: pid 84526 (steamcmd): syscall utimensat not implemented
linux: pid 84532 (steamcmd): syscall epoll_create not implemented
linux: pid 67746 (steamcmd): syscall utimensat not implemented
linux: pid 67753 (steamcmd): syscall utimensat not implemented
linux: pid 67759 (steamcmd): syscall epoll_create not implemented
linux: pid 67869 (steamcmd): syscall utimensat not implemented
linux: pid 67875 (steamcmd): syscall epoll_create not implemented
linux: pid 68061 (steamcmd): syscall utimensat not implemented
linux: pid 68067 (steamcmd): syscall epoll_create not implemented
linux: pid 72605 (steamcmd): syscall utimensat not implemented
linux: pid 72604 (steamcmd): syscall epoll_create not implemented
linux: pid 72631 (steamcmd): syscall utimensat not implemented
linux: pid 72630 (steamcmd): syscall epoll_create not implemented
linux: pid 6829 (steamcmd): syscall utimensat not implemented
linux: pid 6828 (steamcmd): syscall epoll_create not implemented
root@h0st:/usr/src #
```

I found a patch on https://wiki.freebsd.org/linux-kernel
Link to patch from wiki.freebsd -> http://lev.vlakno.cz/~rdivacky/patches/ ... poll.patch
But when *I* want to patch *I* got something strange:

```
root@h0st:/usr/src # wget http://lev.vlakno.cz/~rdivacky/patches/linux_epoll.patch
--2014-09-11 07:46:17--  http://lev.vlakno.cz/~rdivacky/patches/linux_epoll.patch
Resolving lev.vlakno.cz (lev.vlakno.cz)... 46.28.110.116
Connecting to lev.vlakno.cz (lev.vlakno.cz)|46.28.110.116|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18351 (18K) [text/plain]
Saving to: 'linux_epoll.patch'

100%[==========================================================================================================================>] 18,351      --.-K/s   in 0.04s

2014-09-11 07:46:17 (456 KB/s) - 'linux_epoll.patch' saved [18351/18351]

root@h0st:/usr/src # patch -p1 < linux_epoll.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/linux32_dummy.c.orig
|+++  amd64/linux32/linux32_dummy.c
--------------------------
File to patch:
No file found--skip this patch? [n]
File to patch:
No file found--skip this patch? [n]
File to patch:
No file found--skip this patch? [n]
File to patch:
No file found--skip this patch? [n]
```

Does someone use it?


----------



## SirDice (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

The patch is for the Linux emulation layer, it's not for FreeBSD itself. ZFS doesn't use linux(4) it uses opensolaris(4) (oddly enough there's no man page for it).

The reason the patch fails is because you're in the wrong directory, it should be /usr/src/sys/.

```
dice@molly:/usr/src/sys % ll amd64/linux32/linux32_dummy.c
-rw-r--r--  1 root  wheel  4501 Oct 23  2013 amd64/linux32/linux32_dummy.c
```


----------



## bryn1u (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

I think it do*es*n't work.

```
root@h0st:/usr/src/sys # patch -p1 < linux_epoll.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/linux32_dummy.c.orig
|+++  amd64/linux32/linux32_dummy.c
--------------------------
File to patch:
No file found--skip this patch? [n]
File to patch:
No file found--skip this patch? [n]
File to patch: ^Croot@h0st:/usr/src/sys #
root@h0st:/usr/src/sys # pwd
/usr/src/sys
root@h0st:/usr/src/sys #
```


----------



## SirDice (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

My guess would be that you don't have the kernel sources installed. But as I said, that patch is for the Linux emulation layer. It will do absolutely nothing for your issue.


----------



## abishai (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

I doubt it will work at all - it's outdated.


----------



## bryn1u (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*



			
				SirDice said:
			
		

> My guess would be that you don't have the kernel sources installed. But as I said, that patch is for the Linux emulation layer. It will do absolutely nothing for your issue.



I think you are wrong. 

I have a sources bec*a*use i installed three jails from sources and added new features to _the_ kernel. Now *I* remove all from /usr/src and download with svnlite again, the problem is the same!
It will do all for my issue. Steamcmd needs an epoll system call which has been removed from freebsd FreeBSD.
Read posts (link below), people have the same problem with epo. Steamcmd needs it. This is the main problem.

https://github.com/ValveSoftware/steam- ... ssues/3141


----------



## kpa (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

The Linux emulation layer never has had the epoll system call (neither has the FreeBSD native syscall API), it is unimplemented and the patch you're trying to use is for an older version of FreeBSD than you have and does not apply cleanly.


----------



## obsigna (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*



			
				bryn1u said:
			
		

> I think it dosen't work.
> 
> ```
> root@h0st:/usr/src/sys # patch -p1 < linux_epoll.patch
> ...



My comment is merely about patching. Your patch command does not work, because you asked for stripping one path component by using the option -p1. Having a look at that patch, it is very clear that this is wrong. Remove the -p1 option, and the patch will go.

I ran a quick test on my machine FreeBSD 10-RELEASE-p8 -- note, I did not want to ruin my original sys tree, so I cloned it before, using sysutils/clone to zys:

`# clone /usr/src/sys /usr/src/zys`
`# cd /usr/src/zys`
`# patch < ~/linux_epoll.patch`


```
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/linux32_dummy.c.orig
|+++  amd64/linux32/linux32_dummy.c
--------------------------
Patching file amd64/linux32/linux32_dummy.c using Plan A...
Hunk #1 succeeded at 70 with fuzz 1 (offset 5 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/linux32_proto.h.orig
|+++  amd64/linux32/linux32_proto.h
--------------------------
Patching file amd64/linux32/linux32_proto.h using Plan A...
Hunk #1 succeeded at 766 (offset 14 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/linux32_sysent.c.orig
|+++  amd64/linux32/linux32_sysent.c
--------------------------
Patching file amd64/linux32/linux32_sysent.c using Plan A...
Hunk #1 failed at 274.
1 out of 1 hunks failed--saving rejects to amd64/linux32/linux32_sysent.c.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|---  amd64/linux32/syscalls.master.orig
|+++  amd64/linux32/syscalls.master
--------------------------
Patching file amd64/linux32/syscalls.master using Plan A...
Hunk #1 succeeded at 430 (offset 9 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /dev/null	2008-03-05 19:22:00.000000000 +0100
|+++ compat/linux/linux_epoll.c	2008-03-05 19:28:14.000000000 +0100
--------------------------
(Creating file compat/linux/linux_epoll.c...)
Patching file compat/linux/linux_epoll.c using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /dev/null	2008-03-05 19:22:00.000000000 +0100
|+++ compat/linux/linux_epoll.h	2008-03-05 19:28:15.000000000 +0100
--------------------------
(Creating file compat/linux/linux_epoll.h...)
Patching file compat/linux/linux_epoll.h using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- conf/files.amd64.orig
|+++ conf/files.amd64
--------------------------
Patching file conf/files.amd64 using Plan A...
Hunk #1 succeeded at 475 with fuzz 1 (offset 240 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- conf/files.i386.orig
|+++ conf/files.i386
--------------------------
Patching file conf/files.i386 using Plan A...
Hunk #1 succeeded at 80 with fuzz 1 (offset -4 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- conf/files.pc98.orig
|+++ conf/files.pc98
--------------------------
Patching file conf/files.pc98 using Plan A...
Hunk #1 succeeded at 41 with fuzz 1 (offset -14 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- i386/linux/linux_dummy.c.orig
|+++ i386/linux/linux_dummy.c
--------------------------
Patching file i386/linux/linux_dummy.c using Plan A...
Hunk #1 succeeded at 72 with fuzz 2 (offset 5 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- i386/linux/linux_proto.h.orig
|+++ i386/linux/linux_proto.h
--------------------------
Patching file i386/linux/linux_proto.h using Plan A...
Hunk #1 succeeded at 766 (offset 14 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- i386/linux/linux_sysent.c.orig
|+++ i386/linux/linux_sysent.c
--------------------------
Patching file i386/linux/linux_sysent.c using Plan A...
Hunk #1 failed at 273.
1 out of 1 hunks failed--saving rejects to i386/linux/linux_sysent.c.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- i386/linux/syscalls.master.orig
|+++ i386/linux/syscalls.master
--------------------------
Patching file i386/linux/syscalls.master using Plan A...
Hunk #1 succeeded at 432 (offset 9 lines).
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- modules/linux/Makefile.orig
|+++ modules/linux/Makefile
--------------------------
Patching file modules/linux/Makefile using Plan A...
Hunk #1 failed at 8.
1 out of 1 hunks failed--saving rejects to modules/linux/Makefile.rej
done
```
There are 3 fails out of 14. Not that bad for an outdated patch. However, you need to examine the created *.rej and the respective original files in order to find out what went wrong, and how to correct the patch.

Anyway, I do not know, if this gives you really what your are looking for. Reading the other comments, I am staying with doubts.


----------



## JX8P (Sep 11, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

The patch is against @rdivacky's lemul branch. I believe EPoll support was briefly mainlined for a while during the 10.0-CURRENT cycle; try and find that, and extract it.


----------



## abishai (Sep 12, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*

You can try to try this one - it's for 10-CURRENT codebase  http://svnweb.freebsd.org/base?view=rev ... ion=265327


----------



## bryn1u (Sep 12, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*



			
				abishai said:
			
		

> You can try to try this one - it's for 10-CURRENT codebase  http://svnweb.freebsd.org/base?view=rev ... ion=265327



Ooo thank *yo*u.

But do *I* have to download all paths in revision, create any path or just override files in my /usr/src? *I* mean:


> ```
> Directoryuser/dchagin/lemul/sys/amd64/linux/linux_dummy.c
> Directoryuser/dchagin/lemul/sys/amd64/linux/syscalls.master
> Directoryuser/dchagin/lemul/sys/amd64/linux32/linux32_dummy.c
> ...


----------



## bryn1u (Sep 12, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*


```
user/dchagin/lemul/sys/amd64/linux/linux_dummy.c
```
There isn't something like /usr/sys/amd/linux/.
I use:

```
root@h0st:/usr/src # svnlite co svn://svn.freebsd.org/base/releng/10.0 /usr/src
```
My /usr/src/:

```
root@h0st:/usr/src # cd [file]sys/amd64/[/file]
root@h0st:/usr/src/sys/amd64 # ls
Makefile        amd64           conf            include         pci
acpica          compile         ia32            linux32         vmm
root@h0st:/usr/src/sys/amd64 #
```

There is only linux32, should *I* create a directory or what?


----------



## ondra_knezour (Sep 12, 2014)

*Re: What about epoll syscall in FreeBSD-10 ?*



			
				bryn1u said:
			
		

> There isn't something like /usr/sys/amd/linux/.
> There is only linux32, should I create a directory or what?


/usr/src/..., but that is probably only typo.

I would try to just copy whole lemul/ directory over your /usr/src/. New files and/or directories may be part of the implementation of new functionality.


----------



## bryn1u (Sep 15, 2014)

It doesn't work   

```
--- linux_syscalls.c ---
/usr/src/usr.bin/kdump/../../sys/amd64/linux32/syscalls.master: line 5: syscall number out of sync at 0
line is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
--- sbin.depend__D ---
CC='cc ' mkdep -f .depend -a    -DIPSEC -std=gnu99   /usr/src/sbin/ping/ping.c
--- usr.bin.depend__D ---
*** [linux_syscalls.c] Error code 1

make[4]: stopped in /usr/src/usr.bin/kdump
--- gnu.depend__D ---
echo pre-grohtml: /usr/obj/usr/src/tmp/usr/lib/libc.a /usr/obj/usr/src/gnu/usr.bin/groff/src/preproc/html/../../../src/libs/libgroff/libgroff.a >> .depend
echo pre-grohtml: /usr/obj/usr/src/tmp/usr/lib/libc++.a >> .depend
A failure has been detected in another branch of the parallel make

make[8]: stopped in /usr/src/gnu/usr.bin/groff/src/preproc/html
*** [depend] Error code 2

make[7]: stopped in /usr/src/gnu/usr.bin/groff/src/preproc
1 error

make[7]: stopped in /usr/src/gnu/usr.bin/groff/src/preproc
*** [depend] Error code 2

make[6]: stopped in /usr/src/gnu/usr.bin/groff/src
1 error

make[6]: stopped in /usr/src/gnu/usr.bin/groff/src
*** [depend] Error code 2

make[5]: stopped in /usr/src/gnu/usr.bin/groff
1 error

make[5]: stopped in /usr/src/gnu/usr.bin/groff
*** [depend] Error code 2

make[4]: stopped in /usr/src/gnu/usr.bin
1 error

make[4]: stopped in /usr/src/gnu/usr.bin
*** [depend] Error code 2

make[3]: stopped in /usr/src/gnu
1 error

make[3]: stopped in /usr/src/gnu
*** [gnu.depend__D] Error code 2

make[2]: stopped in /usr/src
--- sbin.depend__D ---
echo ping: /usr/obj/usr/src/tmp/usr/lib/libc.a /usr/obj/usr/src/tmp/usr/lib/libm.a /usr/obj/usr/src/tmp/usr/lib/libipsec.a >> .depend
A failure has been detected in another branch of the parallel make

make[4]: stopped in /usr/src/sbin/ping
*** [depend] Error code 2

make[3]: stopped in /usr/src/sbin
1 error

make[3]: stopped in /usr/src/sbin
*** [sbin.depend__D] Error code 2

make[2]: stopped in /usr/src
--- usr.bin.depend__D ---
1 error

make[4]: stopped in /usr/src/usr.bin/kdump
*** [depend] Error code 2

make[3]: stopped in /usr/src/usr.bin
1 error

make[3]: stopped in /usr/src/usr.bin
*** [usr.bin.depend__D] Error code 2

make[2]: stopped in /usr/src
--- usr.sbin.depend__D ---
echo amd: /usr/obj/usr/src/tmp/usr/lib/libc.a /usr/obj/usr/src/usr.sbin/amd/amd/../libamu/libamu.a /usr/obj/usr/src/tmp/usr/lib/libwrap.a >> .depend
A failure has been detected in another branch of the parallel make

make[5]: stopped in /usr/src/usr.sbin/amd/amd
*** [depend] Error code 2

make[4]: stopped in /usr/src/usr.sbin/amd
1 error

make[4]: stopped in /usr/src/usr.sbin/amd
*** [depend] Error code 2

make[3]: stopped in /usr/src/usr.sbin
1 error

make[3]: stopped in /usr/src/usr.sbin
*** [usr.sbin.depend__D] Error code 2

make[2]: stopped in /usr/src
4 errors

make[2]: stopped in /usr/src
*** [_depend] Error code 2

make[1]: stopped in /usr/src
1 error

make[1]: stopped in /usr/src
*** [buildworld] Error code 2

make: stopped in /usr/src
1 error

make: stopped in /usr/src
root@Oksymoron:/usr/src #
root@Oksymoron:/usr/src #

make[2]: stopped in /usr/src
--- sbin.depend__D ---
echo ping: /usr/obj/usr/src/tmp/usr/lib/libc.a /usr/obj/usr/src/tmp/usr/lib/libm.a /usr/obj/usr/src/tmp/usr/lib/libipsec.a >> .depend
A failure has been detected in another branch of the parallel make

make[4]: stopped in /usr/src/sbin/ping
*** [depend] Error code 2

make[3]: stopped in /usr/src/sbin
1 error

make[3]: stopped in /usr/src/sbin
*** [sbin.depend__D] Error code 2

make[2]: stopped in /usr/src
--- usr.bin.depend__D ---
1 error

make[4]: stopped in /usr/src/usr.bin/kdump
*** [depend] Error code 2

make[3]: stopped in /usr/src/usr.bin
1 error

make[3]: stopped in /usr/src/usr.bin
*** [usr.bin.depend__D] Error code 2

make[2]: stopped in /usr/src
--- usr.sbin.depend__D ---
echo amd: /usr/obj/usr/src/tmp/usr/lib/libc.a /usr/obj/usr/src/usr.sbin/amd/amd/../libamu/libamu.a /usr/obj/usr/src/tmp/usr/lib/libwrap.a >> .depend
A failure has been detected in another branch of the parallel make

make[5]: stopped in /usr/src/usr.sbin/amd/amd
*** [depend] Error code 2

make[4]: stopped in /usr/src/usr.sbin/amd
1 error

make[4]: stopped in /usr/src/usr.sbin/amd
*** [depend] Error code 2

make[3]: stopped in /usr/src/usr.sbin
1 error

make[3]: stopped in /usr/src/usr.sbin
*** [usr.sbin.depend__D] Error code 2

make[2]: stopped in /usr/src
4 errors

make[2]: stopped in /usr/src
*** [_depend] Error code 2

make[1]: stopped in /usr/src
1 error

make[1]: stopped in /usr/src
*** [buildworld] Error code 2

make: stopped in /usr/src
1 error

make: stopped in /usr/src
root@Oksymoron:/usr/src #
```


----------



## ondra_knezour (Sep 15, 2014)

Looks to me you just saved all links from the SVN web browser, didn't you? Those links open given file in browser, HTML formated, like this
http://svnweb.freebsd.org/base/user/dch ... rev=265327
but you want a raw source - http://svnweb.freebsd.org/base/user/dch ... rev=265327

Use either SVN to download (see in the Handbook how to do that) or open all files in web browser and click on the download link, which you give raw file shown above.


----------



## abishai (Sep 15, 2014)

I'm compiling lemul branch at the moment. I'll drop a message if epoll works


----------



## bryn1u (Sep 15, 2014)

abishai said:
			
		

> I'm compiling lemul branch at the moment. I'll drop a message if epoll works



Ok. I would be gratefull. If not drop something too.


----------



## abishai (Sep 17, 2014)

I was unable to start my application (http://dl.4players.de/ts/releases/3.0.13.1/) under the lemul branch. According to ktrace I see epoll calls, but epoll_ctl fails with 
	
	



```
Invalid argument error
```
 and breaks the application.
Here is a `kdump` of the first (and, actually, last epoll calls)

```
38883 ts3client_linux_x86 CALL  linux_epoll_create(0x4e20)
 38883 ts3client_linux_x86 RET   linux_epoll_create  11/0xb
 38883 ts3client_linux_x86 CALL  linux_pipe(0xffffb15c)
 38883 ts3client_linux_x86 RET   linux_pipe  0
 38883 ts3client_linux_x86 CALL  linux_fcntl64(0xc,0x4,0x800)
 38883 ts3client_linux_x86 RET   linux_fcntl64  0
 38883 ts3client_linux_x86 CALL  linux_fcntl64(0xd,0x4,0x800)
 38883 ts3client_linux_x86 RET   linux_fcntl64  0
 38883 ts3client_linux_x86 CALL  linux_epoll_ctl(0xb,0x1,0xc,0xffffb150)
 38883 ts3client_linux_x86 RET   linux_epoll_ctl  -1 errno 22 Invalid argument
 38883 ts3client_linux_x86 CALL  write(0xd,0xffffb175,0x1)
 38883 ts3client_linux_x86 GIO   fd 13 wrote 1 byte
       "\0"
 38883 ts3client_linux_x86 RET   write  1
 38883 ts3client_linux_x86 CALL  linux_socketcall(0x1,0xffffb1f0)
 38883 ts3client_linux_x86 RET   linux_socketcall  14/0xe
 38883 ts3client_linux_x86 CALL  linux_epoll_ctl(0xb,0x1,0xe,0xffffb3a0)
 38883 ts3client_linux_x86 RET   linux_epoll_ctl  -1 errno 22 Invalid argument
 38883 ts3client_linux_x86 CALL  close(0xe)
 38883 ts3client_linux_x86 RET   close  0
 38883 ts3client_linux_x86 CALL  linux_sys_futex(0x29b301e8,0x81,0x7fffffff,0,0xffffae6c,0xffffaf48)
 38883 ts3client_linux_x86 RET   linux_sys_futex  0
 38883 ts3client_linux_x86 CALL  linux_access(0x29c82798,0)
 38883 ts3client_linux_x86 NAMI  "/compat/linux/etc/sysconfig/32bit_ssse3_memcpy_via_32bit_ssse3_memmove"
 38883 ts3client_linux_x86 NAMI  "/etc/sysconfig/32bit_ssse3_memcpy_via_32bit_ssse3_memmove"
 38883 ts3client_linux_x86 RET   linux_access  -1 errno 2 No such file or directory
 38883 ts3client_linux_x86 CALL  linux_gettimeofday(0xffffb5a4,0)
 38883 ts3client_linux_x86 RET   linux_gettimeofday  0
 38883 ts3client_linux_x86 CALL  write(0x1,0x2a0d6000,0x4a)
 38883 ts3client_linux_x86 GIO   fd 1 wrote 74 bytes
       "2014-09-17 00:23:33.827682|WARNING |SCHandler     |  1| Error during bind
```
As far as I can remember, my previous attempt to start teamspeak was failed with the same error, but the problem was unimplemented epoll_create. I wonder if I can ask the lemul branch developer about that epoll_ctl.


----------

