Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Aug 2026 22:21:05 +0300
From:      Oskar Skog <oskar@oskog97.com>
To:        freebsd-questions@FreeBSD.org
Subject:   Linuxulator: /var/games/foo refers to a different file when reading vs writing
Message-ID:  <2fa3bce0-61e3-45d4-9f62-74dd196ef472@oskog97.com>

index | next in thread | raw e-mail

Both /var/games and /compat/linux/var/games exist
15.1-RELEASE-p2
linux_base-rl9


If I create a file in /var/games it can be opened for reading in Linux
processes, but if I try to open it for writing it will instead try to
create a new file in /compat/linux/var/games.


Setup from FreeBSD:
# echo test > /var/games/foo
# chmod 666 /var/games/foo


Trying reading/writing as unprivileged user in a Linux process:

$ pypy3    # Linux version
 >>>> open('/var/games/foo').read()
'test\n'
 >>>> f = open('/var/games/foo', 'w')
Traceback ...
PermissionError: [Errno 13] Permission denied: '/var/games/foo'


Trying reading/writing as root in a Linux process:

# pypy3
  >>>> open('/var/games/foo').read()
'test\n'
  >>>> f = open('/var/games/foo', 'w')
  >>>> f.write('testtesttest\n')
13
  >>>> f.close()

$ ls -l /var/games/foo /compat/linux/var/games/foo
-rw-r--r--  1 root wheel 13 Aug  4 20:25 /compat/linux/var/games/foo
-rw-rw-rw-  1 root games  5 Aug  4 20:24 /var/games/foo


Is that supposed to happen?


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2fa3bce0-61e3-45d4-9f62-74dd196ef472>