vold_path.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1994,2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vold.h"
char *path_flip(char *);
char *path_nisquotequote(char *);
/*
* for now, this is a bit on the terse side, however someday I
* might want to have it return more information about the
* path.
*/
/*
* return the type of a "full" pathname (see below).
*/
{
return (0);
}
/* crawl up to the top */
/* do nothing */;
}
return (DIR_DEV);
}
return (DIR_RDSK);
}
return (DIR_DSK);
}
return (DIR_RMT);
}
return (DIR_MT);
}
/* oops -- don't recognize this type */
return (DIR_UNKNOWN);
}
/*
* Return a path to a vnode. Must crawl up the file system tree
* to figure this out. It's a little nasty because walking up
* the tree gives up the path in the wrong order.
*
* Th maximum number of components in a path name is MAXCOMP.
* The worst case is /a/a/a/a/a/a/a (i.e.
* '/' and a single chararcter dir name).
*/
char *
{
char buf[MAXPATHLEN];
int i;
int len;
}
/*
* Crawl up the tree, remembering each vn_name on
* the way up.
*/
}
/* stick the root in there */
/* go back down the list */
for (i -= 1; i >= 0; i--) {
if (len >= MAXPATHLEN) {
warning("path too long, vn 0x%x, name %s\n",
break;
}
}
}
/*
* This function takes a path returned from mnttab, and returns
* a path that can replace it based on the new renamed path.
* There are several special cases.
*/
char *
{
char **mp;
char **ts;
int i;
int mpstop;
/* break paths into components */
/* find out where the rename point is in the mount path */
for (i = 0; mp[i]; i++)
break;
if (mp[i])
mpstop = i + 1;
else
mpstop = i;
buf[0] = '\0';
for (i = 0; ts[i]; i++) {
}
}
}
/*
* Take a path and split it into components, each one sits in
* its own element of the char** returned. It is terminated
* by a null string.
*/
char **
path_split(char *path)
{
int i;
if (*path == '/') {
path++;
}
s = path;
i = 0;
while (p = strchr(s, '/')) {
i++;
s = p+1;
}
s = np;
i = 0;
while (p = strchr(s, '/')) {
val[i++] = s;
*p = '\0';
s = p+1;
}
val[i++] = s;
val[i] = 0;
return (val);
}
/*
* Free a split path (allocated by path_split).
*/
void
path_freeps(char **ps)
{
}
#ifdef UNUSED
/*
* take a regular UNIX pathname with /'s and turn it into a nis+
* name with .'s. Unfortunatly, . in a filename must be quoted.
* That is what the first bit of nastyness is.
*/
char *
{
/* flip the thing around */
/* work on the dot quoting */
s = path;
s++; /* advance beyond the '.'! */
}
if (count) {
#ifdef TESTPATH
#else
#endif
fatal("path_nis");
f = path;
t = np;
while (*f) {
if (*f == '.') {
endquote = 0;
if (s) {
*++s = '"';
f = f - (t - s);
t = s + 1;
} else {
t = np;
*t++ = '"';
f = path;
}
while (*f) {
if (*f == '/') {
*t++ = '"';
*t++ = *f++;
endquote = 1;
break;
} else {
*t++ = *f++;
}
}
if (endquote == 0) {
*t++ = '"';
}
} else {
*t++ = *f++;
}
}
*t = '\0';
}
/* convert all '/' to '.' */
*s = '.';
return (path);
}
char *
path_unnis(char *path)
{
char *s, *p;
char *np;
p = np;
s = path;
while (*s) {
if (*s == '"') {
if (*(s+1) == '"') {
/* quoting a quote */
s += 2;
*p++ = '"';
} else {
/* quotes inserted for a '.' */
s++;
if (quote == 1)
quote = 0;
else
quote = 1;
}
continue;
}
if (*s == '.') {
/* if we're in a quote, a '.' is a '.' */
if (quote == 1)
*p++ = '.';
/* otherwise, a '.' is a '/' */
else
*p++ = '/';
s++;
continue;
}
*p++ = *s++;
}
}
char *
path_nisquotequote(char *path)
{
char *f, *t, *np;
f = path;
f++; /* advance beyond the '"'! */
}
#ifdef TESTPATH
#else
#endif
fatal("path_nisquotequote");
f = path;
t = np;
while (*f) {
if (*f == '"')
*t++ = '"';
*t++ = *f++;
}
return (np);
}
#endif /* UNUSED */
/*
* This is the old crappy (and slow) version of path_make.
*/
#ifdef notdef
/*
* return a full path name starting at the root of the filesystem,
*/
char *
{
char *pn, *s;
/* root case */
}
pn[0] = '\0';
/* cheezy error out */
}
}
/* now flip it (free's pn and makes it a more reasonable size) */
}
char *
{
char *np, *s;
/* flip the string */
#ifdef TESTPATH
#else
#endif
fatal("path_flip");
}
if (path[0] == '/') {
rooted = 1;
} else {
rooted = 0;
}
*s = '\0';
}
if (rooted == 0) {
}
*s = '\0';
}
return (np);
}
#endif