Home | History | Annotate | Download | only in smbsrv
      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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 
     26 #ifndef _SMBSRV_LMSHARE_H
     27 #define	_SMBSRV_LMSHARE_H
     28 
     29 #pragma ident	"@(#)lmshare.h	1.2	08/01/04 SMI"
     30 
     31 /*
     32  * This file defines the LanMan (CIFS/SMB) resource share interface.
     33  */
     34 
     35 #include <sys/param.h>
     36 #include <smbsrv/string.h>
     37 #include <smbsrv/hash_table.h>
     38 #include <smbsrv/smb_fsd.h>
     39 #include <smbsrv/wintypes.h>
     40 #include <smbsrv/lmerr.h>
     41 
     42 #ifndef _KERNEL
     43 #include <libshare.h>
     44 #endif
     45 
     46 #ifdef __cplusplus
     47 extern "C" {
     48 #endif
     49 
     50 #define	SHOPT_AD_CONTAINER	"ad-container"
     51 #define	SHOPT_NAME		"name"	/* name is a pseudo property */
     52 
     53 #define	SMB_DEFAULT_SHARE_GROUP	"smb"
     54 #define	SMB_PROTOCOL_NAME	"smb"
     55 
     56 /*
     57  * Despite the fact that the MAXNAMELEN is 256, we only
     58  * support a maximum share name length of 15 characters.
     59  */
     60 #define	LMSHR_VALID_NAME_MAX		15
     61 #define	LMSHR_VALID_NAME_BUFSIZ		16
     62 #define	LMSHR_COMMENT_MAX		(64 * MTS_MB_CHAR_MAX)
     63 
     64 /*
     65  * Mode should be renamed to flags.
     66  *
     67  * LMSHRM_TRANS		Transient share
     68  * LMSHRM_PERM		Permanent share
     69  */
     70 #define	LMSHRM_TRANS			0x0001
     71 #define	LMSHRM_PERM			0x0002
     72 #define	LMSHRM_ALL			(LMSHRM_TRANS | LMSHRM_PERM)
     73 
     74 #define	LMSHR_PUBLISH	0
     75 #define	LMSHR_UNPUBLISH	1
     76 
     77 #define	LMSHR_ADD	0
     78 #define	LMSHR_DELETE	1
     79 
     80 
     81 /*
     82  * refcnt is currently only used for autohome.  autohome needs a refcnt
     83  * because a user can map his autohome share from more than one client
     84  * at the same time and the share should only be removed when the last
     85  * one is disconnected
     86  */
     87 typedef struct lmshare_info {
     88 	char share_name[MAXNAMELEN];
     89 	char directory[MAXPATHLEN];
     90 	char comment[LMSHR_COMMENT_MAX];
     91 	char container[MAXPATHLEN];
     92 	int mode;
     93 	int stype;
     94 	int refcnt;
     95 } lmshare_info_t;
     96 
     97 typedef struct lmshare_iterator {
     98 	lmshare_info_t si;
     99 	HT_ITERATOR *iterator;
    100 	unsigned int iteration;
    101 	int mode;
    102 } lmshare_iterator_t;
    103 
    104 #define	LMSHARES_PER_REQUEST  10
    105 typedef struct lmshare_list {
    106 	int	no;
    107 	lmshare_info_t	smbshr[LMSHARES_PER_REQUEST];
    108 } lmshare_list_t;
    109 
    110 
    111 #ifndef _KERNEL
    112 /*
    113  * CIFS share management functions (private to the smb daemon).
    114  */
    115 extern int lmshare_start(void);
    116 extern void lmshare_stop(void);
    117 extern lmshare_iterator_t *lmshare_open_iterator(int mode);
    118 extern void lmshare_close_iterator(lmshare_iterator_t *iterator);
    119 extern lmshare_info_t *lmshare_iterate(lmshare_iterator_t *iterator);
    120 
    121 extern DWORD lmshare_list(int offset, lmshare_list_t *list);
    122 extern DWORD lmshare_list_transient(int offset, lmshare_list_t *list);
    123 extern int lmshare_num_transient(void);
    124 
    125 extern int lmshare_num_shares(void);
    126 extern DWORD lmshare_add(lmshare_info_t *si, int);
    127 extern DWORD lmshare_delete(char *share_name, int);
    128 extern DWORD lmshare_rename(char *from, char *to, int);
    129 extern DWORD lmshare_getinfo(char *share_name, lmshare_info_t *si);
    130 extern DWORD lmshare_setinfo(lmshare_info_t *si, int);
    131 extern DWORD lmshare_get_realpath(const char *srcbuf, char *dstbuf, int maxlen);
    132 extern void lmshare_do_publish(lmshare_info_t *, char, int);
    133 
    134 extern int lmshare_exists(char *share_name);
    135 extern int lmshare_is_special(char *share_name);
    136 extern int lmshare_is_restricted(char *share_name);
    137 extern int lmshare_is_admin(char *share_name);
    138 extern int lmshare_is_valid(char *share_name);
    139 extern int lmshare_is_dir(char *path);
    140 /* XXX Move these 2 functions in mlsvc_util.h, after the libmlsvc cleanup */
    141 extern sa_group_t smb_get_smb_share_group(sa_handle_t handle);
    142 extern void smb_build_lmshare_info(char *share_name, char *path,
    143     sa_optionset_t opts, lmshare_info_t *si);
    144 
    145 /* The following 3 functions are called by FSD user-space library */
    146 extern DWORD lmshare_add_adminshare(char *volname, unsigned char drive);
    147 
    148 #endif /* _KERNEL */
    149 
    150 /*
    151  * LanMan share API (for both SMB kernel module and GUI/CLI sub-system)
    152  *
    153  * NOTE: If any error is encounted by either the door server or client,
    154  * NERR_InternalError will be returned by most functions.
    155  * lmshrd_num_shares will return -1 while the lmshrd_open_iterator/
    156  * lmshrd_close_iterator will return NULL.
    157  */
    158 
    159 extern uint64_t lmshrd_open_iterator(int mode);
    160 extern DWORD lmshrd_close_iterator(uint64_t iterator);
    161 extern DWORD lmshrd_iterate(uint64_t iterator, lmshare_info_t *si);
    162 #ifndef _KERNEL
    163 extern DWORD lmshrd_list(int offset, lmshare_list_t *list);
    164 extern DWORD lmshrd_list_transient(int offset, lmshare_list_t *list);
    165 extern DWORD lmshrd_num_transient(void);
    166 #endif
    167 extern int lmshrd_num_shares(void);
    168 extern DWORD lmshrd_delete(char *share_name);
    169 extern DWORD lmshrd_rename(char *from, char *to);
    170 extern DWORD lmshrd_getinfo(char *share_name, lmshare_info_t *si);
    171 extern DWORD lmshrd_add(lmshare_info_t *si);
    172 extern DWORD lmshrd_setinfo(lmshare_info_t *si);
    173 
    174 extern int lmshrd_exists(char *share_name);
    175 extern int lmshrd_is_special(char *share_name);
    176 extern int lmshrd_is_restricted(char *share_name);
    177 extern int lmshrd_is_admin(char *share_name);
    178 extern int lmshrd_is_valid(char *share_name);
    179 extern int lmshrd_is_dir(char *path);
    180 
    181 /*
    182  * The SMB kernel module must invoke the following functions to start/stop
    183  * the LanMan share door client.
    184  */
    185 #ifdef _KERNEL
    186 extern int lmshrd_kclient_start(void);
    187 extern void lmshrd_kclient_stop(void);
    188 #endif
    189 
    190 #ifdef __cplusplus
    191 }
    192 #endif
    193 
    194 #endif /* _SMBSRV_LMSHARE_H */
    195