fs_reparse.c revision aab83bb83be7342f6cfccaed8d5fe0b2f404855d
/*
* 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
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef _KERNEL
#include <fs/fs_reparse.h>
#else
#include <string.h>
#include <limits.h>
#include <sys/fs_reparse.h>
#endif
static char *reparse_skipspace(char *cp);
/* array of characters not allowed in service type string */
/*
* reparse_init()
*
* Function to allocate a new name-value pair list.
* Caller needs to call reparse_free() to free memory
* used by the list when done.
*
* Return pointer to new list else return NULL.
*/
nvlist_t *
reparse_init(void)
{
/*
* Service type is unique, only one entry
* of each service type is allowed
*/
return (NULL);
return (nvl);
}
/*
* reparse_free()
*
* Function to free memory of a nvlist allocated previously
* by reparse_init().
*/
void
{
}
/*
* reparse_parse()
*
* Parse the specified string and populate the nvlist with the svc_types
* and data from the 'string'. The string could be read from the reparse
* point symlink body. This routine will allocate memory that must be
* freed by reparse_free().
*
* If ok return 0 and the nvlist is populated, otherwise return error code.
*/
int
{
int err;
return (EINVAL);
return (err);
return (err);
return (0);
}
static char *
reparse_skipspace(char *cp)
{
cp++;
return (cp);
}
static boolean_t
reparse_validate_svctype(char *svc_str)
{
return (B_FALSE);
return (B_FALSE);
}
}
return (B_TRUE);
}
static boolean_t
{
return (B_FALSE);
return (B_FALSE);
*cp = '\0';
/*
* make sure service type and service data are non-empty string.
*/
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Format of reparse data:
* @{REPARSE@{servicetype:data} [@{servicetype:data}] ...}
* REPARSE_TAG_STR@{REPARSE_TOKEN} [@{REPARSE_TOKEN}] ... REPARSE_TAG_END
*
* Validating reparse data:
* . check for valid length of reparse data
* . check for valid reparse data format
* Return 0 if OK else return error code.
*/
int
reparse_validate(const char *string)
{
}
/*
* reparse_validate_create_nvlist
*
* dual-purpose function:
* . Validate a reparse data string.
* . Validate a reparse data string and parse the data
* into a nvlist.
*/
static int
{
return (EINVAL);
return (ENAMETOOLONG);
return (ENOMEM);
/* check FS_REPARSE_TAG_STR */
strlen(FS_REPARSE_TAG_STR))) {
return (EINVAL);
}
/* locate FS_REPARSE_TAG_END_CHAR */
return (EINVAL);
}
save_e_ptr = cp;
*cp = '\0';
cp++; /* should point to NULL, or spaces */
if (*cp) {
*save_e_ptr = save_e;
return (EINVAL);
}
/* skip FS_REPARSE_TAG_STR */
/* skip spaces after FS_REPARSE_TAG_STR */
tcnt = 0;
/* check FS_TOKEN_START_STR */
strlen(FS_TOKEN_START_STR))) {
*save_e_ptr = save_e;
return (EINVAL);
}
/* skip over FS_TOKEN_START_STR */
/* locate FS_TOKEN_END_STR */
*save_e_ptr = save_e;
return (EINVAL);
}
tcnt++;
*cp = '\0';
/* check for valid characters in service type */
*save_e_ptr = save_e;
return (EINVAL);
}
*save_e_ptr = save_e;
return (EINVAL);
}
*save_e_ptr = save_e;
return (EINVAL);
}
/* create a nvpair entry */
*save_e_ptr = save_e;
return (err);
}
/* skip over FS_TOKEN_END_STR */
}
*save_e_ptr = save_e;
}
static int
{
int err;
return (EINVAL);
*cp = '\0';
return (err);
}
static int
{
return (EINVAL);
}