From nobody Tue Mar 19 08:46:28 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TzQLY2RZCz5Ds9h for ; Tue, 19 Mar 2024 08:46:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TzQLX63Qbz4SgM for ; Tue, 19 Mar 2024 08:46:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710837988; a=rsa-sha256; cv=none; b=DrWKfVf8MxmaQm5JEzgx9SWJlXY030wCC+keC4x5+pMqXqlUHMREC/9/uB8VVPkggegCqs lCjpJN9pmQma6IQ51XBcLeymETjiTQVmTKL0n4GkLpbEhJuIKtMAS9yysldT/mk7/ncXu0 8nYu5+TI05pBkK2RZmhHBFtC4iYKY/UPTS9j7w2YM85JEAvqosIiivkyhT3WNOHzm/6h/K jQYhWHFySGfzynTfBfvjf6i74o3wZdvXGsG0k8OkNGg6fr5Ty5VWD6IZcOybXpS8TbBLMy CsKhUEWwj1E36x6uiQwa5Tz161xgrljDT6M/7KcLo9MjDnviKUJcbNebaZIETA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710837988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FMKcGOfVcVlHSEviFv11B1eotrt5HRvGMAL+YT/b0fA=; b=ZhBBqGVpgBLW+eXe1PVSkev+/ucVzGuE0gou0OTiyZai4j+zJ0rl9qKa1l1y4Acy/1D6Yp euHUszWkS4FzQP16htbb8urKAoTc6nIt4FZrOGmPphWatRAHV9D5QZ+Nl03R3JBaZeZi60 LDoYAipLPUwV6uKmS/78S/UEGMw/C3FHoGdoLlJ4+RpUOclJ37krOA2L1js430Rpjf38oM HAOatTtDISMuU93ykecSURSRXlceMEL04sZ5lFz3eRrY4cWwxQQDNVZrRDRcrQtxwLWjyY PutaY+YmAhWbGVoZpW2MiyEls9yTPJr7TtQX0021kcwFF5sB9Kx/RBblbNcUTw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TzQLX5gLXz11JL for ; Tue, 19 Mar 2024 08:46:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 42J8kS8H044719 for ; Tue, 19 Mar 2024 08:46:28 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 42J8kSJ1044718 for bugs@FreeBSD.org; Tue, 19 Mar 2024 08:46:28 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277804] stat(2) on UFS volumes reports wrong st_dev (devid) when run through Linux compat layer Date: Tue, 19 Mar 2024 08:46:28 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 15.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: michaelo@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277804 Bug ID: 277804 Summary: stat(2) on UFS volumes reports wrong st_dev (devid) when run through Linux compat layer Product: Base System Version: 15.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: michaelo@FreeBSD.org This is a upstream report of https://lists.gnu.org/archive/html/bug-coreutils/2024-03/msg00045.html. Broken down we have the following problem: Consider this simple C program: > #include > #include > #include > #include > #include >=20 > int main(int argc, char *argv[]) { > char *fs =3D argv[1]; > struct stat sb; > if (!stat(fs, &sb)) { > int major =3D major(sb.st_dev); > int minor =3D minor(sb.st_dev); > printf("%s:%ld, major: %d, minor: %d\n", fs, sb.st_dev, major= , minor); > } > return 0; > } Compile it once on FreeBSD and Linux and run both on FreeBSD with the follo= wing UFS volumes mounted (not reproducible with ZFS or NFS mounts): > $ df -t ufs > Filesystem 1K-blocks Used Avail Capacity Mounted on > /dev/da0p2 2031132 629168 1239476 34% / > /dev/da0p4 4053308 245928 3483116 7% /tmp > /dev/da0p5 4053308 864504 2864540 23% /var > /dev/da0p6 8106716 798660 6659520 11% /var/tmp > /dev/da0p7 12180252 7877268 3328564 70% /usr > /dev/gvinum/local 24360604 16555848 5855908 74% /usr/local > /dev/gvinum/ports 48741436 23930092 20912032 53% /usr/ports > /dev/gvinum/obj 20307196 15515764 3166860 83% /usr/obj > /dev/gvinum/pgsql 32487548 5266684 24621864 18% /usr/local/pg= sql > /dev/gvinum/nexus2 32487548 13744292 16144256 46% /var/nexus2 > /dev/gvinum/svn 8106716 5183236 2274944 69% /var/svn > /dev/gvinum/osipovmi 30450780 21861900 6152820 78% /var/osipovmi > /dev/gvinum/poudriere 64995324 37001360 22794340 62% /var/poudriere > /dev/gvinum/compat 4053308 984876 2744168 26% /compat > /dev/gvinum/bastille 81249212 59453292 15295984 80% /usr/local/ba= stille FreeBSD executable: > $ df -t ufs | cut -f 6 -w | sed 1d | xargs -I% ./stat-freebsd % > /:108, major: 0, minor: 108 > /tmp:110, major: 0, minor: 110 > /var:111, major: 0, minor: 111 > /var/tmp:112, major: 0, minor: 112 > /usr:113, major: 0, minor: 113 > /usr/local:161, major: 0, minor: 161 > /usr/ports:142, major: 0, minor: 142 > /usr/obj:141, major: 0, minor: 141 > /usr/local/pgsql:140, major: 0, minor: 140 > /var/nexus2:162, major: 0, minor: 162 > /var/svn:163, major: 0, minor: 163 > /var/osipovmi:164, major: 0, minor: 164 > /var/poudriere:166, major: 0, minor: 166 > /compat:165, major: 0, minor: 165 > /usr/local/bastille:139, major: 0, minor: 139 now the Linux executable: > $ file stat-linux > stat-linux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamica= lly linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, = BuildID[sha1]=3D4f0f500b4e20d2a43770db4afa7e94c834d8ccca, not stripped > $ df -t ufs | cut -f 6 -w | sed 1d | xargs -I% ./stat-linux % > /:108, major: 0, minor: 108 > /tmp:165, major: 0, minor: 165 > /var:165, major: 0, minor: 165 > /var/tmp:112, major: 0, minor: 112 > /usr:165, major: 0, minor: 165 > /usr/local:161, major: 0, minor: 161 > /usr/ports:142, major: 0, minor: 142 > /usr/obj:141, major: 0, minor: 141 > /usr/local/pgsql:140, major: 0, minor: 140 > /var/nexus2:162, major: 0, minor: 162 > /var/svn:163, major: 0, minor: 163 > /var/osipovmi:164, major: 0, minor: 164 > /var/poudriere:166, major: 0, minor: 166 > /compat:165, major: 0, minor: 165 > /usr/local/bastille:139, major: 0, minor: 139 So if you use df(1) from /compat/linux those incorrectly FS are omitted: > $ /compat/linux/usr/bin/linux-df -a -B 512 -P -t ufs -T > Dateisystem Typ 512-Bl=C3=B6cke Benutzt Verf=C3=BCgbar Kapaz= it=C3=A4t Eingeh=C3=A4ngt auf > /dev/da0p2 ufs 4062264 1258336 2478952 34% / > /dev/da0p4 ufs 8106616 1969752 5488336 27% /tmp > /dev/da0p5 - - - - - /var > /dev/da0p6 ufs 16213432 1597320 13319040 11% /var/= tmp > /dev/da0p7 - - - - - /usr > /dev/gvinum/local ufs 48721208 33111696 11711816 74% /usr/= local > /dev/gvinum/ports ufs 97482872 47860184 41824064 54% /usr/= ports > /dev/gvinum/obj ufs 40614392 31031528 6333720 84% /usr/= obj > /dev/gvinum/pgsql ufs 64975096 10533368 49243728 18% /usr/= local/pgsql > /dev/gvinum/nexus2 ufs 64975096 27488584 32288512 46% /var/= nexus2 > /dev/gvinum/svn ufs 16213432 10366472 4549888 70% /var/= svn > /dev/gvinum/osipovmi ufs 60901560 43723800 12305640 79% /var/= osipovmi > /dev/gvinum/poudriere ufs 129990648 74002720 45588680 62% /var/= poudriere > /dev/gvinum/compat - - - - - /comp= at > /dev/gvinum/bastille ufs 162498424 118906584 30591968 80% /usr/= local/bastille This can be reproduced with 13-STABLE: FreeBSD deblndw011x.ad001.siemens.net 13.3-STABLE FreeBSD 13.3-STABLE 77814= c959 GENERIC amd64 and on 15-STABLE: FreeBSD deblndw013x5v.ad001.siemens.net 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n268454-9097284b98be: Thu Feb 22 03:00:34 UTC 2024=20=20=20=20 root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 I assume the bug is somewhere here: * https://github.com/freebsd/freebsd-src/blob/e29be07861173f87b2dd46db1d0c7cb= cf72d4ad0/sys/compat/linux/linux_stats.c#L707 * https://github.com/freebsd/freebsd-src/blob/main/sys/compat/linux/linux.h= #L55 --=20 You are receiving this mail because: You are the assignee for the bug.=