Path: blob/main/sys/contrib/openzfs/lib/libspl/include/libshare.h
48406 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* 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.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/2122/*23* Copyright 2008 Sun Microsystems, Inc. All rights reserved.24* Use is subject to license terms.25* Copyright (c) 2019, 2022 by Delphix. All rights reserved.26*/27#ifndef _LIBSPL_LIBSHARE_H28#define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default")))2930#include <sys/types.h>3132/*33* defined error values34*/35#define SA_OK 036#define SA_SYSTEM_ERR 7 /* system error, use errno */37#define SA_SYNTAX_ERR 8 /* syntax error on command line */38#define SA_NO_MEMORY 2 /* no memory for data structures */39#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */40#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */4142/* The following errors are never returned by libshare */43#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */44#define SA_DUPLICATE_NAME 3 /* object name is already in use */45#define SA_BAD_PATH 4 /* not a full path */46#define SA_NO_SUCH_GROUP 5 /* group is not defined */47#define SA_CONFIG_ERR 6 /* system configuration error */48#define SA_NO_PERMISSION 9 /* no permission for operation */49#define SA_BUSY 10 /* resource is busy */50#define SA_NO_SUCH_PROP 11 /* property doesn't exist */51#define SA_INVALID_NAME 12 /* name of object is invalid */52#define SA_NOT_ALLOWED 14 /* operation not allowed */53#define SA_BAD_VALUE 15 /* bad value for property */54#define SA_INVALID_SECURITY 16 /* invalid security type */55#define SA_NO_SUCH_SECURITY 17 /* security set not found */56#define SA_VALUE_CONFLICT 18 /* property value conflict */57#define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */58#define SA_INVALID_PATH 20 /* path is sub-dir of existing share */59#define SA_PROP_SHARE_ONLY 22 /* property valid on share only */60#define SA_NOT_SHARED 23 /* path is not shared */61#define SA_NO_SUCH_RESOURCE 24 /* resource not found */62#define SA_RESOURCE_REQUIRED 25 /* resource name is required */63#define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */64#define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */65#define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */66#define SA_NO_SECTION 29 /* protocol requires section info */67#define SA_NO_SUCH_SECTION 30 /* no section found */68#define SA_NO_PROPERTIES 31 /* no properties found */69#define SA_PASSWORD_ENC 32 /* passwords must be encrypted */70#define SA_SHARE_EXISTS 33 /* path or file is already shared */7172/* initialization */73_LIBSPL_LIBSHARE_H const char *sa_errorstr(int);7475/* available protocols */76enum sa_protocol {77SA_PROTOCOL_NFS,78SA_PROTOCOL_SMB, /* ABI: add before _COUNT */79SA_PROTOCOL_COUNT,80};8182/* lower-case */83_LIBSPL_LIBSHARE_H const char *const sa_protocol_names[SA_PROTOCOL_COUNT];8485/* share control */86_LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *,87enum sa_protocol);88_LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol);89_LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol);90_LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol);91_LIBSPL_LIBSHARE_H void sa_truncate_shares(enum sa_protocol);9293/* protocol specific interfaces */94_LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol);9596#endif /* _LIBSPL_LIBSHARE_H */979899