/*
* 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
* 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
*/
/*
*/
#include <strings.h>
#include <libintl.h>
#include <libnvpair.h>
#include <errno.h>
#include <synch.h>
#include <note.h>
#include <sys/sysmacros.h>
#include <libshare.h>
#include <libshare_impl.h>
#include <sharefs/sharetab.h>
static int sa_legacy_init(void);
static void sa_legacy_fini(void);
static void *sa_legacy_open(libshare_handle_t *);
static void sa_legacy_close(void *);
static int sa_legacy_share_read(libshare_handle_t *, const char *,
const char *, nvlist_t **);
nvlist_t **);
static int sa_legacy_share_remove(libshare_handle_t *, const char *,
const char *, boolean_t);
static int sa_legacy_share_get_acl(libshare_handle_t *, const char *,
const char *, acl_t **);
static int sa_legacy_share_set_acl(libshare_handle_t *, const char *,
const char *, acl_t *);
static int sa_legacy_get_mntpnt_for_path(libshare_handle_t *, const char *,
static int sa_legacy_sharing_enabled(libshare_handle_t *, const char *,
const char *, sa_proto_t *);
static int sa_legacy_sharing_get_prop(libshare_handle_t *, const char *,
const char *, sa_proto_t, char **);
static int sa_legacy_sharing_set_prop(libshare_handle_t *, const char *,
const char *, sa_proto_t, const char *);
struct legacy_mount; /* forward declaration */
typedef struct legacy_mount {
char *lm_mntpnt;
char *lm_mntopts;
typedef struct legacy_handle {
static void sa_legacy_cleanup_smf(legacy_handle_t *);
char *, size_t);
static void sa_legacy_cleanup_mounts(legacy_handle_t *);
.saf_hdr = {
.pi_ptype = SA_PLUGIN_FS,
.pi_type = SA_FS_LEGACY,
.pi_name = "legacy",
.pi_flags = 0,
},
};
static int
sa_legacy_init(void)
{
return (SA_OK);
}
static void
sa_legacy_fini(void)
{
/* do nothing */
}
static void
{
}
}
}
}
}
static void
{
}
}
static legacy_handle_t *
legacy_init(void)
{
return (NULL);
goto err;
goto err;
if ((hdl->legacy_smf_instance =
goto err;
if ((hdl->legacy_smf_scope =
goto err;
hdl->legacy_smf_scope) != 0)
goto err;
if ((hdl->legacy_smf_service =
goto err;
hdl->legacy_smf_service) != 0)
goto err;
hdl->legacy_smf_instance) != 0)
goto err;
return (hdl);
err:
return (NULL);
}
static void
{
}
static void *
{
salog_error(0, "libshare_legacy: failed to open legacy handle");
return (NULL);
}
return (hdl);
}
static void
{
}
/*
* sa_legacy_fix_share_name
*
* some valid SMB share names contain characters illegal in SMF. This
* function maps to a valid character set. Since it is only used when
* referencing SMF, it only needs a one way mapping.
*/
static char *
{
*newshare++ = '_';
} else {
}
sharename++;
}
*newshare = '\0';
}
/*
* legacy_common_transaction
*
* implements both store and remove of SMF property.
*/
static int
{
char *sharename;
ret = SA_NO_MEMORY;
goto err;
}
ret = SA_SYSTEM_ERR;
goto err;
}
ret = SA_SYSTEM_ERR;
goto err;
}
SCF_GROUP_FRAMEWORK, 0, pg) != 0) {
switch (scf_error()) {
break;
default:
ret = SA_SYSTEM_ERR;
break;
}
goto err;
}
}
ret = SA_SYSTEM_ERR;
goto err;
}
ret = SA_SYSTEM_ERR;
goto err;
}
if (dowrite) {
sharename, SCF_TYPE_OPAQUE) == 0 ||
sharename, SCF_TYPE_OPAQUE) == 0) {
ret = SA_SYSTEM_ERR;
}
/* The value is in the transaction */
} else {
/* Value couldn't be constructed */
ret = SA_SYSTEM_ERR;
}
/* The entry is in the transaction or NULL */
} else {
ret = SA_SYSTEM_ERR;
}
} else {
sharename) != 0)
ret = SA_SYSTEM_ERR;
else
}
if (ret == SA_SYSTEM_ERR)
goto err;
if (scf_transaction_commit(trans) < 0)
ret = SA_SYSTEM_ERR;
err:
if (ret == SA_SYSTEM_ERR &&
/*
* Cleanup if there were any errors that didn't leave these
* values where they would be cleaned up later.
*/
switch (ret) {
case SA_SYSTEM_ERR:
scf_strerror(scf_error()));
break;
default:
break;
}
return (ret);
}
static int
{
int ret;
return (ret);
}
/*ARGSUSED*/
static int
{
char *sh_name;
int rc;
goto out;
}
goto out;
}
goto out;
if (rc < 0) {
rc = SA_SYSTEM_ERR;
salog_error(0, "sa_legacy_share_write: "
"error writing share '%s': %s",
goto out;
} else {
}
out:
return (rc);
}
static int
{
char *path;
char *sharename;
char *mntpnt;
return (rc);
goto done;
/* While fs_name should be a mountpoint, make sure */
goto done;
continue;
}
break;
}
}
done:
return (rc);
}
static int
{
return (SA_OK);
}
static int
{
int rc;
return (rc);
rc = SA_SYSTEM_ERR;
} else {
hdl->srh_smf_pg) != 0) {
rc = SA_SYSTEM_ERR;
}
}
hdl->srh_smf_pg) != 0) {
rc = SA_SYSTEM_ERR;
}
}
return (rc);
}
static int
{
void *nvlist;
char *name;
char *mntpnt;
return (SA_NO_MEMORY);
ret = SA_NO_MEMORY;
goto done;
}
hdl->srh_smf_prop) == 0) {
break;
}
scf_limit(SCF_LIMIT_MAX_NAME_LENGTH)) > 0) {
continue;
hdl->srh_smf_value) == 0) {
nvlist, nvlistsize) >= 0) {
if (nvlist_unpack(nvlist,
nvlistsize, share, 0) != 0)
ret = SA_SYSTEM_ERR;
} else {
ret = SA_SYSTEM_ERR;
}
break;
break;
/* skip since on other file system */
nvlist_free(*share);
} else {
ret = SA_SYSTEM_ERR;
}
} else {
ret = SA_SYSTEM_ERR;
}
}
done:
return (ret);
}
static int
{
int rc;
return (rc);
rc = SA_SYSTEM_ERR;
goto err;
}
err:
return (rc);
}
static int
{
return (SA_NOT_SUPPORTED);
}
static int
{
return (SA_NOT_SUPPORTED);
}
/*
* sa_legacy_get_mntpnt_for_path
*
* A path identifies its mount point by its st_dev field in stat. To
* find the mount point, work backward up the path until the st_dev
* doesn't match. The last to match was the root (mountpoint).
*/
static int
{
int err;
#if defined(lint)
#endif
return (SA_PATH_NOT_FOUND);
return (SA_SYSTEM_ERR);
/* special case of mount point being the path */
if (mntopts != 0)
return (SA_OK);
}
ret = SA_NO_MEMORY;
goto done;
}
goto done;
}
while (*path != '\0') {
char *work;
*work = '\0';
/*
* lookup mnttab entry for "/"
*/
} else {
}
break;
if (ret == SA_NO_SHARE_DIR)
}
}
done:
return (ret);
}
static int
{
/*
* There isn't a way to mark a legacy file system as
* shareable. Assume ALL.
*/
*protos = SA_PROT_ALL;
return (SA_OK);
}
static int
{
return (SA_NO_MEMORY);
return (SA_OK);
}
static int
{
return (SA_OK);
}
static int
{
return (SA_OK);
}
/*
* sa_legacy_mntpnt_is_zoned
*
* always return negative
*/
/* ARGSUSED */
static int
{
return (0);
}
static int
{
/*
* since sa_legacy_cleanup_mounts() sets legacy_mounts to NULL
* when cleaning so we use that to force a reload of the mount
* table.
*/
}
ret = SA_SYSTEM_ERR;
goto done;
}
ret = SA_NO_MEMORY;
break;
}
ret = SA_NO_MEMORY;
break;
}
ret = SA_NO_MEMORY;
break;
}
} else {
}
}
}
mp_len);
}
opt_len);
}
break;
}
}
done:
return (ret);
}