1 /* 2 * CDDL HEADER START 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 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2020 by Delphix. All rights reserved. 24 */ 25 26 #include <time.h> 27 #include <stdlib.h> 28 #include <stdio.h> 29 #include <string.h> 30 #include <fcntl.h> 31 #include <sys/wait.h> 32 #include <unistd.h> 33 #include <dirent.h> 34 #include <sys/types.h> 35 #include <sys/stat.h> 36 #include <libzfs.h> 37 #include <libshare.h> 38 #include "libshare_impl.h" 39 #include "smb.h" 40 41 static sa_fstype_t *smb_fstype; 42 43 /* 44 * Enables SMB sharing for the specified share. 45 */ 46 static int 47 smb_enable_share(sa_share_impl_t impl_share) 48 { 49 (void) impl_share; 50 fprintf(stderr, "No SMB support in FreeBSD yet.\n"); 51 return (SA_NOT_SUPPORTED); 52 } 53 /* 54 * Disables SMB sharing for the specified share. 55 */ 56 static int 57 smb_disable_share(sa_share_impl_t impl_share) 58 { 59 (void) impl_share; 60 fprintf(stderr, "No SMB support in FreeBSD yet.\n"); 61 return (SA_NOT_SUPPORTED); 62 } 63 64 /* 65 * Checks whether the specified SMB share options are syntactically correct. 66 */ 67 static int 68 smb_validate_shareopts(const char *shareopts) 69 { 70 (void) shareopts; 71 fprintf(stderr, "No SMB support in FreeBSD yet.\n"); 72 return (SA_NOT_SUPPORTED); 73 } 74 75 /* 76 * Checks whether a share is currently active. 77 */ 78 static boolean_t 79 smb_is_share_active(sa_share_impl_t impl_share) 80 { 81 (void) impl_share; 82 return (B_FALSE); 83 } 84 85 /* 86 * Called to update a share's options. A share's options might be out of 87 * date if the share was loaded from disk and the "sharesmb" dataset 88 * property has changed in the meantime. This function also takes care 89 * of re-enabling the share if necessary. 90 */ 91 static int 92 smb_update_shareopts(sa_share_impl_t impl_share, const char *shareopts) 93 { 94 (void) impl_share, (void) shareopts; 95 return (SA_OK); 96 } 97 98 static int 99 smb_update_shares(void) 100 { 101 /* Not implemented */ 102 return (0); 103 } 104 /* 105 * Clears a share's SMB options. Used by libshare to 106 * clean up shares that are about to be free()'d. 107 */ 108 static void 109 smb_clear_shareopts(sa_share_impl_t impl_share) 110 { 111 FSINFO(impl_share, smb_fstype)->shareopts = NULL; 112 } 113 114 static const sa_share_ops_t smb_shareops = { 115 .enable_share = smb_enable_share, 116 .disable_share = smb_disable_share, 117 .is_shared = smb_is_share_active, 118 119 .validate_shareopts = smb_validate_shareopts, 120 .update_shareopts = smb_update_shareopts, 121 .clear_shareopts = smb_clear_shareopts, 122 .commit_shares = smb_update_shares, 123 }; 124 125 /* 126 * Initializes the SMB functionality of libshare. 127 */ 128 void 129 libshare_smb_init(void) 130 { 131 smb_fstype = register_fstype("smb", &smb_shareops); 132 } 133