libzfs_impl.h (231946) | libzfs_impl.h (248369) |
---|---|
1/* 2 * CDDL HEADER SART 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 10 unchanged lines hidden (view full) --- 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>. 25 * All rights reserved. 26 * Copyright (c) 2011 by Delphix. All rights reserved. | 1/* 2 * CDDL HEADER SART 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 10 unchanged lines hidden (view full) --- 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>. 25 * All rights reserved. 26 * Copyright (c) 2011 by Delphix. All rights reserved. |
27 * Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved. |
|
27 */ 28 29#ifndef _LIBFS_IMPL_H 30#define _LIBFS_IMPL_H 31 32#include <sys/dmu.h> 33#include <sys/fs/zfs.h> 34#include <sys/zfs_ioctl.h> --- 176 unchanged lines hidden (view full) --- 211 212extern int zfs_unshare_proto(zfs_handle_t *, 213 const char *, zfs_share_proto_t *); 214 215extern void libzfs_fru_clear(libzfs_handle_t *, boolean_t); 216 217#ifndef sun 218static int zfs_kernel_version = 0; | 28 */ 29 30#ifndef _LIBFS_IMPL_H 31#define _LIBFS_IMPL_H 32 33#include <sys/dmu.h> 34#include <sys/fs/zfs.h> 35#include <sys/zfs_ioctl.h> --- 176 unchanged lines hidden (view full) --- 212 213extern int zfs_unshare_proto(zfs_handle_t *, 214 const char *, zfs_share_proto_t *); 215 216extern void libzfs_fru_clear(libzfs_handle_t *, boolean_t); 217 218#ifndef sun 219static int zfs_kernel_version = 0; |
220static int zfs_ioctl_version = 0; |
|
219 220/* 221 * This is FreeBSD version of ioctl, because Solaris' ioctl() updates 222 * zc_nvlist_dst_size even if an error is returned, on FreeBSD if an 223 * error is returned zc_nvlist_dst_size won't be updated. 224 */ 225static __inline int 226zcmd_ioctl(int fd, unsigned long cmd, zfs_cmd_t *zc) 227{ | 221 222/* 223 * This is FreeBSD version of ioctl, because Solaris' ioctl() updates 224 * zc_nvlist_dst_size even if an error is returned, on FreeBSD if an 225 * error is returned zc_nvlist_dst_size won't be updated. 226 */ 227static __inline int 228zcmd_ioctl(int fd, unsigned long cmd, zfs_cmd_t *zc) 229{ |
228 size_t oldsize, zfs_kernel_version_size; | 230 size_t oldsize, zfs_kernel_version_size, zfs_ioctl_version_size; |
229 int version, ret, cflag = ZFS_CMD_COMPAT_NONE; 230 | 231 int version, ret, cflag = ZFS_CMD_COMPAT_NONE; 232 |
231 zfs_kernel_version_size = sizeof(zfs_kernel_version); 232 if (zfs_kernel_version == 0) { 233 sysctlbyname("vfs.zfs.version.spa", &zfs_kernel_version, 234 &zfs_kernel_version_size, NULL, 0); | 233 zfs_ioctl_version_size = sizeof(zfs_ioctl_version); 234 if (zfs_ioctl_version == 0) { 235 sysctlbyname("vfs.zfs.version.ioctl", &zfs_ioctl_version, 236 &zfs_ioctl_version_size, NULL, 0); |
235 } 236 | 237 } 238 |
237 if (zfs_kernel_version == SPA_VERSION_15 || 238 zfs_kernel_version == SPA_VERSION_14 || 239 zfs_kernel_version == SPA_VERSION_13) 240 cflag = ZFS_CMD_COMPAT_V15; | 239 /* 240 * If vfs.zfs.version.ioctl is not defined, assume we have v28 241 * compatible binaries and use vfs.zfs.version.spa to test for v15 242 */ 243 if (zfs_ioctl_version < ZFS_IOCVER_DEADMAN) { 244 cflag = ZFS_CMD_COMPAT_V28; 245 zfs_kernel_version_size = sizeof(zfs_kernel_version); |
241 | 246 |
247 if (zfs_kernel_version == 0) { 248 sysctlbyname("vfs.zfs.version.spa", 249 &zfs_kernel_version, 250 &zfs_kernel_version_size, NULL, 0); 251 } 252 253 if (zfs_kernel_version == SPA_VERSION_15 || 254 zfs_kernel_version == SPA_VERSION_14 || 255 zfs_kernel_version == SPA_VERSION_13) 256 cflag = ZFS_CMD_COMPAT_V15; 257 } 258 |
|
242 oldsize = zc->zc_nvlist_dst_size; 243 ret = zcmd_ioctl_compat(fd, cmd, zc, cflag); 244 245 if (ret == 0 && oldsize < zc->zc_nvlist_dst_size) { 246 ret = -1; 247 errno = ENOMEM; 248 } 249 250 return (ret); 251} 252#define ioctl(fd, cmd, zc) zcmd_ioctl((fd), (cmd), (zc)) 253#endif /* !sun */ 254 255#ifdef __cplusplus 256} 257#endif 258 259#endif /* _LIBFS_IMPL_H */ | 259 oldsize = zc->zc_nvlist_dst_size; 260 ret = zcmd_ioctl_compat(fd, cmd, zc, cflag); 261 262 if (ret == 0 && oldsize < zc->zc_nvlist_dst_size) { 263 ret = -1; 264 errno = ENOMEM; 265 } 266 267 return (ret); 268} 269#define ioctl(fd, cmd, zc) zcmd_ioctl((fd), (cmd), (zc)) 270#endif /* !sun */ 271 272#ifdef __cplusplus 273} 274#endif 275 276#endif /* _LIBFS_IMPL_H */ |