Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 16:50:29 +0100
From:      Willem Jan Withagen <wjw@digiware.nl>
To:        Bob Bishop <rb@gid.co.uk>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Using fstatfs on a ZFS disk
Message-ID:  <f03f94db-e5a8-b57f-ec9a-2d434dff7425@digiware.nl>
In-Reply-To: <1C4DBFA3-5E79-4503-840C-0C548741363B@gid.co.uk>
References:  <ffcfabf1-8cf1-4182-413e-73b7117d66d7@digiware.nl> <1C4DBFA3-5E79-4503-840C-0C548741363B@gid.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On 19-2-2018 16:00, Bob Bishop wrote:
> Hi,
> 
>> On 19 Feb 2018, at 14:48, Willem Jan Withagen <wjw@digiware.nl> 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 */

So I was looking for something like: FS_ZFS_MAGIC

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 <sys/param.h>
#include <sys/mount.h>

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?


--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
>> _______________________________________________
>> 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"
>>
> 
> --
> Bob Bishop
> rb@gid.co.uk
> 
> 
> 
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f03f94db-e5a8-b57f-ec9a-2d434dff7425>