/*
* 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 <unistd.h>
#include <strings.h>
#include <fcntl.h>
#include <errno.h>
#include <note.h>
#include <libshare.h>
#include <libshare_impl.h>
/*
* The cache plugin library interface with the share cache in
* sharetab via sharefs ioctl call.
*
*/
static int cache_pi_init(void);
static void cache_pi_fini(void);
static int sa_cache_init(void *);
static void sa_cache_fini(void *);
static int sa_cache_share_add(nvlist_t *);
static int sa_cache_share_update(nvlist_t *);
static int sa_cache_share_remove(const char *);
static int sa_cache_flush(void);
static int sa_cache_lookup(const char *, const char *, sa_proto_t,
nvlist_t **);
static int sa_cache_find_init(const char *, sa_proto_t, void **);
static int sa_cache_find_next(void *, nvlist_t **);
static int sa_cache_find_fini(void *);
static int sa_cache_validate_name(const char *, sa_validate_flags_t);
static int sa_cache_open_sharetab(void);
static void sa_cache_close_sharetab(void);
static int sa_cache_cvt_err(int);
.sac_hdr = {
.pi_type = 0,
.pi_name = "shared",
.pi_flags = 0,
.pi_init = cache_pi_init,
},
};
static int
cache_pi_init(void)
{
return (sa_cache_open_sharetab());
}
static void
cache_pi_fini(void)
{
}
static int
{
return (SA_OK);
}
static void
{
}
static int
{
return (SA_OK);
}
static int
{
return (SA_OK);
}
static int
{
return (SA_OK);
}
static int
sa_cache_flush(void)
{
return (SA_OK);
}
static int
{
int rc;
return (SA_INVALID_SHARE_NAME);
return (SA_INVALID_SHARE);
return (SA_NO_MEMORY);
sizeof (sharefs_ioc_hdr_t));
} else {
int err;
if (err != 0) {
switch (err) {
case EFAULT:
case ENOTSUP:
break;
default:
break;
}
} else {
}
}
return (rc);
}
static int
{
int rc;
return (SA_INTERNAL_ERR);
ioclen = sizeof (sharefs_ioc_find_init_t);
return (SA_NO_MEMORY);
sizeof (sharefs_ioc_hdr_t));
} else {
rc = SA_NO_MEMORY;
else {
/*
* memory will be freed in find_fini
*/
}
}
return (rc);
}
static int
{
int rc;
return (SA_INTERNAL_ERR);
return (SA_NO_MEMORY);
sizeof (sharefs_ioc_hdr_t));
} else {
int err;
if (err != 0) {
switch (err) {
case EFAULT:
case ENOTSUP:
break;
default:
break;
}
} else {
}
}
return (rc);
}
static int
{
int rc;
ioclen = sizeof (sharefs_ioc_find_fini_t);
return (SA_NO_MEMORY);
sizeof (sharefs_ioc_hdr_t));
} else {
}
return (rc);
}
static int
{
return (SA_NOT_IMPLEMENTED);
}
static int
sa_cache_open_sharetab(void)
{
if (sharefs_fp == NULL) {
salog_error(0, "libshare_cache: Error opening %s: %s",
return (SA_SYSTEM_ERR);
}
return (SA_OK);
}
static void
sa_cache_close_sharetab(void)
{
if (sharefs_fp != NULL) {
(void) fclose(sharefs_fp);
sharefs_fd = -1;
sharefs_fp = NULL;
}
}
static int
{
int rc;
switch (err) {
case ENOENT:
break;
case EFAULT:
break;
case ENOTTY:
break;
case EINVAL:
break;
case EAGAIN:
break;
case ENOMEM:
rc = SA_NO_MEMORY;
break;
case ESTALE:
break;
default:
rc = SA_SYSTEM_ERR;
break;
}
return (rc);
}