/*
* 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) 1996,1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "dump.h"
/*
* File system mount table input routines. We handle a
* a combination of BSD and SVR4 formats by coding functions
* to explicitly read the SVR4 vfstab file and using
* #define's to build a routine to read both BSD files
* (fstab and mtab) and SVR4's mnttab file. Internally
*/
static struct pmntent {
} *mnttable;
/* Note that nothing is ever free()'d, so this is safe */
#ifdef __STDC__
#else /* !__STDC__ */
static struct mntent *mygetmntent();
static struct mntent *allocmntent();
static int idatesort();
#endif
static struct mntent *
FILE *f;
char *name;
{
int status;
return (&mt);
switch (status) {
case EOF: break; /* normal exit condition */
case MNT_TOOLONG:
break;
case MNT_TOOMANY:
break;
case MNT_TOOFEW:
break;
default:
"Unknown return code, %d, from getmntent() on %s\n"),
break;
}
return (NULL);
}
/*
* Read in SVR4 vfstab-format table.
*/
static struct pmntent *
char *tablename;
{
int status;
/*
* No need to secure this, as tablename is hard-coded to VFSTAB,
* and that file is in /etc. If random people have write-permission
* there, then there are more problems than any degree of paranoia
* on our part can fix.
*/
return ((struct pmntent *)0);
}
if (vfs.vfs_fstype == (char *)0 ||
continue;
/*
* Guaranteed by caller that pm will also be NULL,
* so no memory leak to worry about.
*/
else {
/* Guaranteed pm not NULL by caller and local logic */
}
}
switch (status) {
case EOF: break; /* normal exit condition */
case VFS_TOOLONG:
break;
case VFS_TOOMANY:
break;
case VFS_TOOFEW:
break;
default:
"Unknown return code, %d, from getvfsent() on %s\n"),
break;
}
return (pm);
}
static struct mntent *
{
return (new);
}
void
{
return;
/*
* Read in the file system mount tables. Order
* is important as the first matched entry is used
* if the target device/filesystem is not mounted.
* We try fstab or vfstab first, then mtab or mnttab.
*/
}
static struct pmntent *
char *tablename;
{
return ((struct pmntent *)0);
}
continue;
/*
* Guaranteed by caller that pm will also be NULL,
* so no memory leak to worry about.
*/
else {
/* Guaranteed pm not NULL by caller and local logic */
}
}
return (pm);
}
/*
* Search in fstab and potentially mtab for a file name.
* If "mounted" is non-zero, the target file system must
* be mounted in order for the search to succeed.
* This file name can be either the special or the path file name.
*
* The entries in either fstab or mtab are the BLOCK special names,
* not the character special names.
* The caller of mnttabsearch assures that the character device
* is dumped (that is much faster)
*
* The file name can omit the leading '/'.
*/
struct mntent *
char *key;
int mounted;
{
char *s;
char *gotreal;
s = NULL;
goto found;
goto found;
goto found;
goto found;
if (key[0] != '/') {
goto found;
goto found;
goto found;
}
free(s);
continue;
/* Pointer comparison, not string comparison */
free(s);
/*
* Found a match; return immediately if
* it is mounted (valid), otherwise just
* record if it's the first matched entry.
*/
return (mnt);
}
/*
* If we get here, there were either
* no matches, or no matched entries
* were mounted. Return failure if
* we were supposed to find a mounted
* entry, otherwise return the first
* matched entry (or null).
*/
if (mounted)
return ((struct mntent *)0);
return (first);
}
static int set;
void
#ifdef __STDC__
setmnttab(void)
#else
#endif
{
set = 1;
}
struct mntent *
#ifdef __STDC__
getmnttab(void)
#else
#endif
{
if (!set)
setmnttab();
if (current) {
}
return ((struct mntent *)0);
}