From owner-freebsd-hackers@freebsd.org Mon Feb 19 18:33:52 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 B4530F18BE2 for ; Mon, 19 Feb 2018 18:33:52 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (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 2662A8497F for ; Mon, 19 Feb 2018 18:33:51 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w1JIXir0078023; Mon, 19 Feb 2018 10:33:44 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w1JIXhVL078022; Mon, 19 Feb 2018 10:33:43 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201802191833.w1JIXhVL078022@pdx.rh.CN85.dnsmgr.net> Subject: Re: Using fstatfs on a ZFS disk In-Reply-To: <456B0CAA-367F-478A-BB61-153942C3EB7A@gid.co.uk> To: rb@gid.co.uk Date: Mon, 19 Feb 2018 10:33:43 -0800 (PST) CC: Willem Jan Withagen , FreeBSD Hackers X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Mailman-Approved-At: Mon, 19 Feb 2018 18:51:47 +0000 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 18:33:53 -0000 > Hi, > > > On 19 Feb 2018, at 15:50, Willem Jan Withagen wrote: > > > > On 19-2-2018 16:00, Bob Bishop wrote: > >> Hi, > >>> On 19 Feb 2018, at 14:48, Willem Jan Withagen wrote: > >>> > >>> Hi, > >>> > >>> I'm trying to find the values of the returned f_type for ZFS > >>> in the fstatfs call when a file is on ZFS.... > >>> > >>> 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?s FS_... in /usr/include/sys/disklabel,h that you want. > > > > Hi Bob, > > > > 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... > > > So I was looking for something like: FS_ZFS_MAGIC > > ... so you won?t find that. > > > disklabel.h contains: > > #ifdef FSTYPENAMES > > static const char *fstypenames[] = { > > > > And further search: > > /usr/include/sys/disk/bsd.h:#define FS_ZFS 27 /* Sun's ZFS */ > > > > Running: > > #include "stdio.h" > > > > #include > > #include > > > > int main() { > > struct statfs fstr; > > char * str; > > > > str = "/tmp"; > > statfs(str, &fstr); > > printf("%s, ftype: 0x%x.\n", str, fstr.f_type); > > } > > results in: > > /tmp, ftype: 0xde. > > > > Now 0xde != 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?t help except to imply that the type is set when the filesystem is mounted. I have no idea where 0xde comes from. Could that 0xde be the start of 0xdeadcode? 0xde is 222 decimal, that does not ring a bell for me either. > > --WjW > > > >>> 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 */ > >>> ...... > >>> } > >>> > >>> Any hints where to look would be welcomed. > >>> > >>> Thanx, > >>> --WjW > >> -- > >> Bob Bishop > >> rb@gid.co.uk > -- > Bob Bishop t: +44 (0)118 940 1243 > rb@gid.co.uk m: +44 (0)783 626 4518 -- Rod Grimes rgrimes@freebsd.org