Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/devfs/devfs_dir.c
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
/* Returns 1 if the path is in the directory list. */ | /* Returns 1 if the path is in the directory list. */ | ||||
int | int | ||||
devfs_dir_find(const char *path) | devfs_dir_find(const char *path) | ||||
{ | { | ||||
struct dirlistent *dle; | struct dirlistent *dle; | ||||
mtx_lock(&dirlist_mtx); | mtx_lock(&dirlist_mtx); | ||||
LIST_FOREACH(dle, &devfs_dirlist, link) { | LIST_FOREACH(dle, &devfs_dirlist, link) { | ||||
if (devfs_pathpath(dle->dir, path) != 0) { | if (strcmp(dle->dir, path) == 0) { | ||||
mtx_unlock(&dirlist_mtx); | mtx_unlock(&dirlist_mtx); | ||||
return (1); | return (1); | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&dirlist_mtx); | mtx_unlock(&dirlist_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
devfs_dir_unref_de(struct devfs_mount *dm, struct devfs_dirent *de) | devfs_dir_unref_de(struct devfs_mount *dm, struct devfs_dirent *de) | ||||
{ | { | ||||
char dirname[SPECNAMELEN + 1], *namep; | char dirname[SPECNAMELEN + 1], *namep; | ||||
namep = devfs_fqpn(dirname, dm, de, NULL); | namep = devfs_fqpn(dirname, dm, de, NULL); | ||||
KASSERT(namep != NULL, ("devfs_unref_dir_de: NULL namep")); | KASSERT(namep != NULL, ("devfs_unref_dir_de: NULL namep")); | ||||
devfs_dir_unref(namep); | devfs_dir_unref(namep); | ||||
} | |||||
/* Returns 1 if the path p1 contains the path p2. */ | |||||
int | |||||
devfs_pathpath(const char *p1, const char *p2) | |||||
{ | |||||
for (;;p1++, p2++) { | |||||
if (*p1 != *p2) { | |||||
if (*p1 == '/' && *p2 == '\0') | |||||
return (1); | |||||
else | |||||
return (0); | |||||
} else if (*p1 == '\0') | |||||
return (1); | |||||
} | |||||
/* NOTREACHED */ | |||||
} | } |