[Bug 277804] stat(2) on UFS volumes reports wrong st_dev (devid) when run through Linux compat layer

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 20 Mar 2024 13:09:43 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277804

--- Comment #6 from Michael Osipov <michaelo@FreeBSD.org> ---
(In reply to John F. Carr from comment #5)

John, this totally makes sense -- in fact that is the case:
> $ stat -f %d /
> 108
> $ stat -f %d /tmp
> 110
> $ stat -f %d /var
> 111
> $ stat -f %d /usr
> 113
> $ stat -f %d /compat/linux/
> 165
> $ /compat/linux/bin/stat --format %d /
> 108
> $ /compat/linux/bin/stat --format %d /tmp
> 165
> $ /compat/linux/bin/stat --format %d /usr
> 165
> $ /compat/linux/bin/stat --format %d /compat/linux
> 165
> $ /compat/linux/bin/stat --format %d /usr/local
> 161
> $ stat -f %d /usr/local
> 161

man 4 linux says:
>      The path translation mechanism makes Linux processes look up file paths
>      under emul_path (defaulting to /compat/linux) before /.  For example,
>      when Linux process attempts to open /etc/passwd, it will really access
>      /compat/linux/etc/passwd, unless the latter does not exist.  This is used
>      to make sure Linux processes load Linux shared libraries instead of their
>      similarly-named FreeBSD counterparts, and also to provide alternative
>      versions of certain other files and virtual file systems.

with:
> $ ll /compat/linux/
> total 25
> lrwxr-xr-x   1 root  wheel     7 2018-04-11 06:59 bin@ -> usr/bin
> dr-xr-xr-x  34 root  wheel   512 2024-02-20 19:19 dev/
> drwxr-xr-x  25 root  wheel  2560 2024-02-20 18:50 etc/
> lrwxr-xr-x   1 root  wheel     7 2018-04-11 06:59 lib@ -> usr/lib
> lrwxr-xr-x   1 root  wheel     9 2018-04-11 06:59 lib64@ -> usr/lib64
> drwxr-xr-x   4 root  wheel   512 2022-01-17 09:44 opt/
> dr-xr-xr-x   1 root  wheel     0 2024-03-20 14:07 proc/
> lrwxr-xr-x   1 root  wheel     8 2024-02-16 20:28 run@ -> /var/run
> lrwxr-xr-x   1 root  wheel     8 2018-04-11 06:59 sbin@ -> usr/sbin
> drwxr-xr-x   2 root  wheel   512 2024-01-30 15:39 srv/
> dr-xr-xr-x   1 root  wheel     0 2024-03-20 14:07 sys/
> drwxrwxrwt   7 root  wheel   512 2023-05-25 15:52 tmp/
> drwxr-xr-x   8 root  wheel   512 2024-02-20 18:50 usr/
> drwxr-xr-x  16 root  wheel   512 2024-02-20 18:50 var/

Thanks John, I didn't think about this.

Although my report looks like bogus then, but how to go from here? Do docs need
improvement or something else or say "works as designed"?

-- 
You are receiving this mail because:
You are the assignee for the bug.