[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 02:24:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277804

Konstantin Belousov <kib@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kib@FreeBSD.org

--- Comment #3 from Konstantin Belousov <kib@FreeBSD.org> ---
I am not sure what happens there.  Most likely, you would need to add some
printf()s in your linux64.ko to get more diagnostic there.

First, look at the long comment at the start of sys/compat/linux/linux.h
describing arrangements for Linux and FreeBSD dev_t <-> (major, minor) layouts.
I do not see anything special in the value of e.g. 55 vs. 52 for the /var dev_t
in the last message.  I even wrote a simple check to ensure that I did not
missed anything:
#include <sys/param.h>
#include <sys/conf.h>
#include <stdbool.h>
#include <stdio.h>
#include "linux.h"

int
main(void)
{
        dev_t d = 55;
        dev_t ld = linux_encode_dev(major(d), minor(d));

        printf("%#lx %#lx %#x %#x\n", d, ld, linux_decode_major(ld),
            linux_decode_minor(ld));
}

(you need to provide -I <path to src>/sys/compat/linux when compiling it.

So perhaps check what is the dev_t for /var before linux_new_encode_dev() in
linux_kern_statat() on your machine.

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