devtolin.c revision 414388d7cb2ee98771e2ac7c2338c460abd44304
/*
* 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) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
/*
* return ptr to LSZ-byte string, "?" if not found
* device must be character device
* maintains small list in tlist structure for speed
*/
#include <stdio.h>
#include "acctdef.h"
#include <dirent.h>
#include <string.h>
static int tsize1;
static struct tlist {
char *strncpy();
static char dev_dir[] = "/dev";
static char *def_srch_dirs[] = { "/dev/term",
NULL };
static int srch_dir();
char *
{
char **srch_dirs; /* priority directories to search first */
int found = 0;
int dirno = 0;
/* if /dev is one of the priority directories we should only
search its top level for now (set depth = MAX_SEARCH_DEPTH) */
MAX_SRCH_DEPTH : 1),
NULL);
dirno++;
}
/* if not yet found search remaining /dev directory skipping the
priority directories */
if (!found)
/* if found then put it (without the "/dev/" prefix) in the tlist
structure and return the path name without the "/dev/" prefix */
if (found) {
tsize1++;
}
return(file_name+5);
} else
/* if not found put "?" in the tlist structure for that device and
return "?" */
tsize1++;
}
return("?");
}
static int
char *path; /* current path */
int depth; /* current depth */
char *skip_dirs[]; /* directories that don't need searched */
{
struct dirent *d;
int dirno = 0;
int found = 0;
int path_len;
char *last_comp;
/* do we need to search this directory? */
return(0);
/* open the directory */
return(0);
/* initialize file name using path name */
*last_comp++ = '/';
/* start searching this directory */
if (d->d_ino != 0) {
/* if name would not be too long append it to
directory name, otherwise skip this entry */
continue;
else
/* if this directory entry has the device number we need,
then the name is found. Otherwise if it's a directory
(not . or ..) and we haven't gone too deep, recurse. */
found = 1;
break;
} else if ((depth < MAX_SRCH_DEPTH) &&
}
return(found);
}