From owner-freebsd-hackers@freebsd.org Mon Feb 19 17:57:18 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C4B1F15C6E for ; Mon, 19 Feb 2018 17:57:18 +0000 (UTC) (envelope-from rb@gid.co.uk) Received: from mx0.gid.co.uk (mx0.gid.co.uk [194.32.164.250]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A40B582C31 for ; Mon, 19 Feb 2018 17:57:17 +0000 (UTC) (envelope-from rb@gid.co.uk) Received: from [194.32.164.27] ([194.32.164.27]) by mx0.gid.co.uk (8.14.2/8.14.2) with ESMTP id w1JHvFSZ011331; Mon, 19 Feb 2018 17:57:15 GMT (envelope-from rb@gid.co.uk) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Using fstatfs on a ZFS disk From: rb@gid.co.uk In-Reply-To: Date: Mon, 19 Feb 2018 17:57:15 +0000 Cc: FreeBSD Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <456B0CAA-367F-478A-BB61-153942C3EB7A@gid.co.uk> References: <1C4DBFA3-5E79-4503-840C-0C548741363B@gid.co.uk> To: Willem Jan Withagen X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2018 17:57:18 -0000 Hi, > On 19 Feb 2018, at 15:50, Willem Jan Withagen wrote: >=20 > On 19-2-2018 16:00, Bob Bishop wrote: >> Hi, >>> On 19 Feb 2018, at 14:48, Willem Jan Withagen = wrote: >>>=20 >>> Hi, >>>=20 >>> I'm trying to find the values of the returned f_type for ZFS >>> in the fstatfs call when a file is on ZFS.... >>>=20 >>> But I have not yet found the definitions of the ENUMS that >>> would fill that value... Let alone the value for ZFS. >> I chased this particular wild goose myself recently. It=E2=80=99s = FS_... in /usr/include/sys/disklabel,h that you want. >=20 > Hi Bob, >=20 > I grepped on MAGIC and FS, but the combo did not deliver anything = useful. So this is already more that I found. > I did get: > /usr/include/ufs/ffs/fs.h:#define FS_UFS1_MAGIC 0x011954 /* = UFS1 fast filesystem magic number */ > /usr/include/ufs/ffs/fs.h:#define FS_UFS2_MAGIC 0x19540119 /* = UFS2 fast filesystem magic number */ > /usr/include/ufs/ffs/fs.h:#define FS_BAD_MAGIC 0x19960408 /* = UFS incomplete newfs magic number */ Those I believe are magic numbers for UFS superblocks...=20 > So I was looking for something like: FS_ZFS_MAGIC ... so you won=E2=80=99t find that. > disklabel.h contains: > #ifdef FSTYPENAMES > static const char *fstypenames[] =3D { >=20 > And further search: > /usr/include/sys/disk/bsd.h:#define FS_ZFS 27 /* Sun's ZFS */ >=20 > Running: > #include "stdio.h" >=20 > #include > #include >=20 > int main() { > struct statfs fstr; > char * str; >=20 > str =3D "/tmp"; > statfs(str, &fstr); > printf("%s, ftype: 0x%x.\n", str, fstr.f_type); > } > results in: > /tmp, ftype: 0xde. >=20 > Now 0xde !=3D 27, so the question is, where is this 0xde specified. > And more important is this f_type constant over all FreeBSD ZFS = filesystems? You got me. And a quick look at sys/kern/vfs_syscalls.c doesn=E2=80=99t = help except to imply that the type is set when the filesystem is = mounted. I have no idea where 0xde comes from. > --WjW >=20 >>> struct statfs { >>> uint32_t f_version; /* structure version number */ >>> uint32_t f_type; /* type of filesystem */ >>> uint64_t f_flags; /* copy of mount exported flags = */ >>> ...... >>> } >>>=20 >>> Any hints where to look would be welcomed. >>>=20 >>> Thanx, >>> --WjW >>> _______________________________________________ >>> freebsd-hackers@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers >>> To unsubscribe, send any mail to = "freebsd-hackers-unsubscribe@freebsd.org" >>>=20 >> -- >> Bob Bishop >> rb@gid.co.uk >=20 -- Bob Bishop t: +44 (0)118 940 1243 rb@gid.co.uk m: +44 (0)783 626 4518