mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	lzc: move lzc_ioctl_fd() into lzc proper
Name the OS-specific call lzc_ioctl_fd_os(), and make lzc_ioctl_fd() wrap it, so we can do more in the wrapper. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17344
This commit is contained in:
		
							parent
							
								
									f454cc1723
								
							
						
					
					
						commit
						c4c3917b2a
					
				@ -1,18 +1,21 @@
 | 
			
		||||
libzfs_core_la_CFLAGS  = $(AM_CFLAGS) $(LIBRARY_CFLAGS)
 | 
			
		||||
libzfs_core_la_CFLAGS += -fvisibility=hidden
 | 
			
		||||
 | 
			
		||||
libzfs_core_la_CPPFLAGS  = $(AM_CPPFLAGS)
 | 
			
		||||
libzfs_core_la_CPPFLAGS += -I$(srcdir)/%D%
 | 
			
		||||
 | 
			
		||||
lib_LTLIBRARIES += libzfs_core.la
 | 
			
		||||
CPPCHECKTARGETS += libzfs_core.la
 | 
			
		||||
 | 
			
		||||
libzfs_core_la_SOURCES = \
 | 
			
		||||
	%D%/libzfs_core.c
 | 
			
		||||
	%D%/libzfs_core.c \
 | 
			
		||||
	%D%/libzfs_core_impl.h
 | 
			
		||||
 | 
			
		||||
if BUILD_LINUX
 | 
			
		||||
libzfs_core_la_SOURCES += \
 | 
			
		||||
	%D%/os/linux/libzfs_core_ioctl.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
libzfs_core_la_CPPFLAGS  = $(AM_CPPFLAGS)
 | 
			
		||||
if BUILD_FREEBSD
 | 
			
		||||
libzfs_core_la_CPPFLAGS += -Iinclude/os/freebsd/zfs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -96,6 +96,8 @@
 | 
			
		||||
#define	BIG_PIPE_SIZE (64 * 1024) /* From sys/pipe.h */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "libzfs_core_impl.h"
 | 
			
		||||
 | 
			
		||||
static int g_fd = -1;
 | 
			
		||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
 | 
			
		||||
static int g_refcount;
 | 
			
		||||
@ -171,6 +173,12 @@ libzfs_core_fini(void)
 | 
			
		||||
	(void) pthread_mutex_unlock(&g_lock);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
lzc_ioctl_fd(int fd, unsigned long ioc, zfs_cmd_t *zc)
 | 
			
		||||
{
 | 
			
		||||
	return (lzc_ioctl_fd_os(fd, ioc, zc));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
lzc_ioctl(zfs_ioc_t ioc, const char *name,
 | 
			
		||||
    nvlist_t *source, nvlist_t **resultp)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										36
									
								
								lib/libzfs_core/libzfs_core_impl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								lib/libzfs_core/libzfs_core_impl.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
// SPDX-License-Identifier: CDDL-1.0
 | 
			
		||||
/*
 | 
			
		||||
 * CDDL HEADER START
 | 
			
		||||
 *
 | 
			
		||||
 * The contents of this file are subject to the terms of the
 | 
			
		||||
 * Common Development and Distribution License (the "License").
 | 
			
		||||
 * You may not use this file except in compliance with the License.
 | 
			
		||||
 *
 | 
			
		||||
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 | 
			
		||||
 * or https://opensource.org/licenses/CDDL-1.0.
 | 
			
		||||
 * See the License for the specific language governing permissions
 | 
			
		||||
 * and limitations under the License.
 | 
			
		||||
 *
 | 
			
		||||
 * When distributing Covered Code, include this CDDL HEADER in each
 | 
			
		||||
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 | 
			
		||||
 * If applicable, add the following below this CDDL HEADER, with the
 | 
			
		||||
 * fields enclosed by brackets "[]" replaced with your own identifying
 | 
			
		||||
 * information: Portions Copyright [yyyy] [name of copyright owner]
 | 
			
		||||
 *
 | 
			
		||||
 * CDDL HEADER END
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2012, 2020 by Delphix. All rights reserved.
 | 
			
		||||
 * Copyright 2017 RackTop Systems.
 | 
			
		||||
 * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2019 Datto Inc.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef	_LIBZFS_CORE_IMPL_H
 | 
			
		||||
#define	_LIBZFS_CORE_IMPL_H
 | 
			
		||||
 | 
			
		||||
struct zfs_cmd;
 | 
			
		||||
int lzc_ioctl_fd_os(int, unsigned long, struct zfs_cmd *);
 | 
			
		||||
 | 
			
		||||
#endif	/* _LIBZFS_CORE_IMPL_H */
 | 
			
		||||
@ -26,6 +26,7 @@
 | 
			
		||||
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
 | 
			
		||||
#include <err.h>
 | 
			
		||||
#include <libzfs_core.h>
 | 
			
		||||
#include "libzfs_core_impl.h"
 | 
			
		||||
 | 
			
		||||
int zfs_ioctl_version = ZFS_IOCVER_UNDEF;
 | 
			
		||||
 | 
			
		||||
@ -101,7 +102,7 @@ zcmd_ioctl_compat(int fd, int request, zfs_cmd_t *zc, const int cflag)
 | 
			
		||||
 * error is returned zc_nvlist_dst_size won't be updated.
 | 
			
		||||
 */
 | 
			
		||||
int
 | 
			
		||||
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
 | 
			
		||||
lzc_ioctl_fd_os(int fd, unsigned long request, zfs_cmd_t *zc)
 | 
			
		||||
{
 | 
			
		||||
	size_t oldsize;
 | 
			
		||||
	int ret, cflag = ZFS_CMD_COMPAT_NONE;
 | 
			
		||||
 | 
			
		||||
@ -23,9 +23,10 @@
 | 
			
		||||
#include <sys/param.h>
 | 
			
		||||
#include <sys/zfs_ioctl.h>
 | 
			
		||||
#include <libzfs_core.h>
 | 
			
		||||
#include "libzfs_core_impl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
 | 
			
		||||
lzc_ioctl_fd_os(int fd, unsigned long request, zfs_cmd_t *zc)
 | 
			
		||||
{
 | 
			
		||||
	return (ioctl(fd, request, zc));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user