1eda14cbcSMatt Macy /* 2eda14cbcSMatt Macy * CDDL HEADER START 3eda14cbcSMatt Macy * 4eda14cbcSMatt Macy * The contents of this file are subject to the terms of the 5eda14cbcSMatt Macy * Common Development and Distribution License (the "License"). 6eda14cbcSMatt Macy * You may not use this file except in compliance with the License. 7eda14cbcSMatt Macy * 8eda14cbcSMatt Macy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9271171e0SMartin Matuska * or https://opensource.org/licenses/CDDL-1.0. 10eda14cbcSMatt Macy * See the License for the specific language governing permissions 11eda14cbcSMatt Macy * and limitations under the License. 12eda14cbcSMatt Macy * 13eda14cbcSMatt Macy * When distributing Covered Code, include this CDDL HEADER in each 14eda14cbcSMatt Macy * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15eda14cbcSMatt Macy * If applicable, add the following below this CDDL HEADER, with the 16eda14cbcSMatt Macy * fields enclosed by brackets "[]" replaced with your own identifying 17eda14cbcSMatt Macy * information: Portions Copyright [yyyy] [name of copyright owner] 18eda14cbcSMatt Macy * 19eda14cbcSMatt Macy * CDDL HEADER END 20eda14cbcSMatt Macy */ 21eda14cbcSMatt Macy 22eda14cbcSMatt Macy /* 23eda14cbcSMatt Macy * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24eda14cbcSMatt Macy * Use is subject to license terms. 25*c7046f76SMartin Matuska * Copyright (c) 2019, 2022 by Delphix. All rights reserved. 26eda14cbcSMatt Macy */ 27eda14cbcSMatt Macy #ifndef _LIBSPL_LIBSHARE_H 283ff01b23SMartin Matuska #define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default"))) 29eda14cbcSMatt Macy 30716fd348SMartin Matuska #include <sys/types.h> 31eda14cbcSMatt Macy 32eda14cbcSMatt Macy /* 33eda14cbcSMatt Macy * defined error values 34eda14cbcSMatt Macy */ 35eda14cbcSMatt Macy #define SA_OK 0 36716fd348SMartin Matuska #define SA_SYSTEM_ERR 7 /* system error, use errno */ 37716fd348SMartin Matuska #define SA_SYNTAX_ERR 8 /* syntax error on command line */ 38eda14cbcSMatt Macy #define SA_NO_MEMORY 2 /* no memory for data structures */ 39716fd348SMartin Matuska #define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ 40716fd348SMartin Matuska #define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ 41716fd348SMartin Matuska 42716fd348SMartin Matuska /* The following errors are never returned by libshare */ 43716fd348SMartin Matuska #define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ 44eda14cbcSMatt Macy #define SA_DUPLICATE_NAME 3 /* object name is already in use */ 45eda14cbcSMatt Macy #define SA_BAD_PATH 4 /* not a full path */ 46eda14cbcSMatt Macy #define SA_NO_SUCH_GROUP 5 /* group is not defined */ 47eda14cbcSMatt Macy #define SA_CONFIG_ERR 6 /* system configuration error */ 48eda14cbcSMatt Macy #define SA_NO_PERMISSION 9 /* no permission for operation */ 49eda14cbcSMatt Macy #define SA_BUSY 10 /* resource is busy */ 50eda14cbcSMatt Macy #define SA_NO_SUCH_PROP 11 /* property doesn't exist */ 51eda14cbcSMatt Macy #define SA_INVALID_NAME 12 /* name of object is invalid */ 52eda14cbcSMatt Macy #define SA_NOT_ALLOWED 14 /* operation not allowed */ 53eda14cbcSMatt Macy #define SA_BAD_VALUE 15 /* bad value for property */ 54eda14cbcSMatt Macy #define SA_INVALID_SECURITY 16 /* invalid security type */ 55eda14cbcSMatt Macy #define SA_NO_SUCH_SECURITY 17 /* security set not found */ 56eda14cbcSMatt Macy #define SA_VALUE_CONFLICT 18 /* property value conflict */ 57eda14cbcSMatt Macy #define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */ 58eda14cbcSMatt Macy #define SA_INVALID_PATH 20 /* path is sub-dir of existing share */ 59eda14cbcSMatt Macy #define SA_PROP_SHARE_ONLY 22 /* property valid on share only */ 60eda14cbcSMatt Macy #define SA_NOT_SHARED 23 /* path is not shared */ 61eda14cbcSMatt Macy #define SA_NO_SUCH_RESOURCE 24 /* resource not found */ 62eda14cbcSMatt Macy #define SA_RESOURCE_REQUIRED 25 /* resource name is required */ 63eda14cbcSMatt Macy #define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */ 64eda14cbcSMatt Macy #define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */ 65eda14cbcSMatt Macy #define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */ 66eda14cbcSMatt Macy #define SA_NO_SECTION 29 /* protocol requires section info */ 67eda14cbcSMatt Macy #define SA_NO_SUCH_SECTION 30 /* no section found */ 68eda14cbcSMatt Macy #define SA_NO_PROPERTIES 31 /* no properties found */ 69eda14cbcSMatt Macy #define SA_PASSWORD_ENC 32 /* passwords must be encrypted */ 70eda14cbcSMatt Macy #define SA_SHARE_EXISTS 33 /* path or file is already shared */ 71eda14cbcSMatt Macy 72eda14cbcSMatt Macy /* initialization */ 73716fd348SMartin Matuska _LIBSPL_LIBSHARE_H const char *sa_errorstr(int); 74716fd348SMartin Matuska 75716fd348SMartin Matuska /* available protocols */ 76716fd348SMartin Matuska enum sa_protocol { 77716fd348SMartin Matuska SA_PROTOCOL_NFS, 78716fd348SMartin Matuska SA_PROTOCOL_SMB, /* ABI: add before _COUNT */ 79716fd348SMartin Matuska SA_PROTOCOL_COUNT, 80716fd348SMartin Matuska }; 81716fd348SMartin Matuska 82716fd348SMartin Matuska /* lower-case */ 83716fd348SMartin Matuska _LIBSPL_LIBSHARE_H const char *const sa_protocol_names[SA_PROTOCOL_COUNT]; 84eda14cbcSMatt Macy 85eda14cbcSMatt Macy /* share control */ 863ff01b23SMartin Matuska _LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *, 87716fd348SMartin Matuska enum sa_protocol); 88716fd348SMartin Matuska _LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol); 89716fd348SMartin Matuska _LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol); 90716fd348SMartin Matuska _LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol); 91*c7046f76SMartin Matuska _LIBSPL_LIBSHARE_H void sa_truncate_shares(enum sa_protocol); 92eda14cbcSMatt Macy 93eda14cbcSMatt Macy /* protocol specific interfaces */ 94716fd348SMartin Matuska _LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol); 95eda14cbcSMatt Macy 96eda14cbcSMatt Macy #endif /* _LIBSPL_LIBSHARE_H */ 97