/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* where.c - get full pathname including host:
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "sharetab.h"
FILE *setsharetab();
void endsharetab();
extern int Debug;
/*
* where(pn, host, fsname, within)
*
* pn is the pathname we are looking for,
* host gets the name of the host owning the file system,
* fsname gets the file system name on the host,
* within gets whatever is left from the pathname
*
* Returns: 0 if ERROR, 1 if OK
*/
int
char *pn;
char *host;
char *fsname;
char *within;
{
char *p;
if (Debug)
char *errstr;
errstr = "unknown error";
if (Debug)
printf("where: stat failed");
return (0);
}
/*
* first get the working directory,
*/
curdir);
return (0);
}
} else {
*p = 0;
} else {
}
}
}
/*
* findmount(qualpn, host, fsname, within)
*
* Searches the mount table to find the appropriate file system
* for a given absolute path name.
* host gets the name of the host owning the file system,
* fsname gets the file system name on the host,
* within gets whatever is left from the pathname
*
* Returns: 0 on failure, 1 on success.
*/
int
char *qualpn;
char *host;
char *fsname;
char *within;
{
int bestlen = 0,
bestnfs = 0;
*mnt;
int i,
len;
if (Debug)
for (i = 0; i < 10; i++) {
break;
sleep(1);
}
return (0);
}
bestname[0] = '\0';
/*
* If it is not nfs filesystem type, skip the
* entry
*/
continue;
if (Debug)
/*
* If the last matching character is neither / nor
* the end of the pathname, not a real match
* (except for matching root, len==1)
*/
continue;
}
if (Debug)
}
/*
* If the file system was of type NFS, then there should already
* be a host name, otherwise, use ours.
*/
if (endhost) {
*endhost++ = 0;
/*
* special case to keep the "/" when we match root
*/
if (bestlen == 1)
bestlen = 0;
} else {
/*
* If this is our file system, try for an even longer
*/
if (mfp = setsharetab()) {
sizeof (bestname));
}
}
}
if (Debug)
printf("findmount: qualpn %s\nhost %s\nfsname %s\nwithin %s\n",
return (1);
}
/*
* Returns: length of second argument if it is a prefix of the
* first argument, otherwise zero.
*/
int
{
int len;
return (len);
return (0);
}
*setsharetab()
{
FILE *f;
if (f == NULL) {
return (NULL);
}
return (f);
}
void
endsharetab(f)
FILE *f;
{
(void) fclose(f);
}