/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <dirent.h>
#include <regex.h>
#include <errno.h>
#include <stdarg.h>
#include <libdevinfo.h>
#include <zone.h>
#include <syslog.h>
#include <assert.h>
struct finddevhdl {
int npaths;
int curpath;
char **paths;
};
((getzoneid() == GLOBAL_ZONEID) && \
/*
* Return true if a device exists
* If the path refers into the /dev filesystem, use a
* private interface to query if the device exists but
* without triggering an implicit reconfig if it does not.
* Note: can only function properly with absolute pathnames
* and only functions for persisted global /dev names, ie
* those managed by devfsadm. For paths other than
* /dev, stat(2) is sufficient.
*/
int
{
int rv;
if (GLOBAL_DEV_PATH(devname)) {
return ((rv == 0) ? 1 : 0);
}
return (1);
return (0);
}
/*
* Use the standard library readdir to read the contents of
* directories on alternate root mounted filesystems.
* Return results as per dev_readdir_devfs().
*
* The directory is traversed twice. First, to calculate
* the size of the buffer required; second, to copy the
* directory contents into the buffer. If the directory
* contents grow in between passes, which should almost
* never happen, start over again.
*/
static int
{
size_t n;
return (ENOENT);
return (ENOMEM);
}
n = 0;
continue;
n++;
}
return (ENOMEM);
}
n = 0;
continue;
/*
* restart if directory contents have out-grown
* buffer allocated in the first pass.
*/
goto restart;
}
return (ENOMEM);
}
n++;
}
return (0);
}
/*
* Use of the dev filesystem's private readdir does not trigger
* the implicit device reconfiguration.
*
* Note: only useable with paths mounted on an instance of the
* dev filesystem.
*
* Does not return the . and .. entries.
* Empty directories are returned as an zero-length list.
* ENOENT is returned as a NULL list pointer.
*/
static int
{
int n;
int rv;
char *pathlist;
char *p;
int len;
return (ENOMEM);
if (rv != 0) {
return (rv);
}
for (;;) {
return (ENOMEM);
}
if (rv == 0) {
for (n = 0, p = pathlist;
n++;
}
return (ENOMEM);
}
for (n = 0, p = pathlist;
return (ENOMEM);
}
}
return (0);
}
switch (errno) {
case EAGAIN:
break;
case ENOENT:
default:
return (errno);
}
}
/*NOTREACHED*/
}
int
{
if (GLOBAL_DEV_PATH(path)) {
}
}
/*
* Return true if a directory is empty
* Use the standard library readdir to determine if a directory is
* empty.
*/
static int
{
return (ENOENT);
continue;
return (0); /* not empty */
}
return (1); /* empty */
}
/*
* Use of the dev filesystem's private readdir does (not trigger
* the implicit device reconfiguration) to determine if a directory
* is empty.
*
* Note: only useable with paths mounted on an instance of the
* dev filesystem.
*
* Does not return the . and .. entries.
* Empty directories are returned as an zero-length list.
* ENOENT is returned as a NULL list pointer.
*/
static int
{
int rv;
int empty;
if (rv == 0) {
return (empty);
}
return (0);
}
int
{
if (GLOBAL_DEV_PATH(path)) {
return (finddev_emptydir_devfs(path));
}
return (finddev_emptydir_alt(path));
}
void
{
int i;
}
}
const char *
{
}
return (path);
}