svcadm(1M)을 검색하려면 섹션에서 1M 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
scandir(3c)
Standard C Library Functions scandir(3C)
NAME
scandir, alphasort - scan a directory
SYNOPSIS
#include <sys/types.h>
#include <dirent.h>
int scandir(const char *dirname, struct dirent *(*namelist[]),
int (*select)(const struct dirent *),
int (*dcomp)(const struct dirent **,
const struct dirent **));
int alphasort(const struct dirent **d1,
const struct dirent **d2);
DESCRIPTION
The scandir() function reads the directory dirname using readdir(3C)
and builds an array of pointers to directory entries using malloc(3C).
The namelist argument is a pointer to an array of structure pointers.
The select argument is a pointer to a routine that is called with a
pointer to a directory entry and returns a non-zero value if the direc‐
tory entry is included in the array. If this pointer is NULL, then all
the directory entries are included. The dcomp argument is a pointer to
a routine that is passed to qsort(3C), which sorts the completed array.
If this pointer is NULL, the array is not sorted.
The alphasort() function can be used as the dcomp() function parameter
for the scandir() function to sort the directory entries into alphabet‐
ical order, as if by the strcoll(3C) function. Its arguments are the
two directory entries to compare.
RETURN VALUES
The scandir() function returns the number of entries in the array and a
pointer to the array through the namelist argument. When an error is
encountered, scandir() returns -1 and errno is set to indicate the
error.
The alphasort() function returns an integer greater than, equal to, or
less than 0 if the directory entry name pointed to by d1 is greater
than, equal to, or less than the directory entry name pointed to by d2
when both are interpreted as appropriate to the current locale. There
is no return value reserved to indicate an error.
ERRORS
The scandir() function will fail if:
EACCES Search permission is denied for the component of the
path prefix of dir or read permission is denied for
dir.
ELOOP A loop exists in the symbolic links encountered during
resolving the dir argument.
ENAMETOOLONG The length of a component of a pathname is longer than
{NAME_MAX}.
ENOENT A component of dir does not name an existing directory
or dir is an empty string.
ENOMEM Insufficient storage space.
ENOTDIR A component of dir names an existing file that is nei‐
ther a directory nor a symbolic link to a directory.
EOVERFLOW One of the values to be returned or passed to a call‐
back function cannot be represented correctly.
The scandir() function may fail if:
ELOOP More than {SYMLOOP_MAX} symbolic links were encountered
during resolution of the dir argument.
EMFILE All file descriptors available to the process are cur‐
rently open.
ENAMETOOLONG The length of a pathname exceeds {PATH_MAX}, or path‐
name resolution of a symbolic link produced an interme‐
diate result with a length that exceeds {PATH_MAX}.
ENFILE Too many files are currently open in the system.
USAGE
The scandir() and alphasort() functions have transitional interfaces
for 64-bit file offsets. See lf64(7).
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelSee below.
The scandir() function is Unsafe. The alphasort() function is Safe.
SEE ALSO
malloc(3C), qsort(3C), readdir(3C), strcoll(3C), attributes(7), lf64(7)
Oracle Solaris 11.4 09 May 2016 scandir(3C)