svn commit: r211507 - stable/8/sys/fs/devfs
Jaakko Heinonen
jh at FreeBSD.org
Thu Aug 19 15:33:44 UTC 2010
Author: jh
Date: Thu Aug 19 15:33:43 2010
New Revision: 211507
URL: http://svn.freebsd.org/changeset/base/211507
Log:
MFC r208951:
Add a new function devfs_parent_dirent() for resolving devfs parent
directory entry. Use the new function in devfs_fqpn(), devfs_lookupx()
and devfs_vptocnp() instead of manually resolving the parent entry.
Modified:
stable/8/sys/fs/devfs/devfs.h
stable/8/sys/fs/devfs/devfs_devs.c
stable/8/sys/fs/devfs/devfs_vnops.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cam/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/fs/devfs/devfs.h
==============================================================================
--- stable/8/sys/fs/devfs/devfs.h Thu Aug 19 13:24:13 2010 (r211506)
+++ stable/8/sys/fs/devfs/devfs.h Thu Aug 19 15:33:43 2010 (r211507)
@@ -180,6 +180,7 @@ void devfs_populate (struct devfs_mount
void devfs_cleanup (struct devfs_mount *dm);
void devfs_unmount_final(struct devfs_mount *mp);
struct devfs_dirent *devfs_newdirent (char *name, int namelen);
+struct devfs_dirent *devfs_parent_dirent(struct devfs_dirent *de);
struct devfs_dirent *devfs_vmkdir (struct devfs_mount *, char *name, int namelen, struct devfs_dirent *dotdot, u_int inode);
struct devfs_dirent *devfs_find (struct devfs_dirent *dd, const char *name, int namelen);
Modified: stable/8/sys/fs/devfs/devfs_devs.c
==============================================================================
--- stable/8/sys/fs/devfs/devfs_devs.c Thu Aug 19 13:24:13 2010 (r211506)
+++ stable/8/sys/fs/devfs/devfs_devs.c Thu Aug 19 15:33:43 2010 (r211507)
@@ -195,6 +195,26 @@ devfs_newdirent(char *name, int namelen)
}
struct devfs_dirent *
+devfs_parent_dirent(struct devfs_dirent *de)
+{
+
+ if (de->de_dirent->d_type != DT_DIR)
+ return (de->de_dir);
+
+ if (de->de_flags & (DE_DOT | DE_DOTDOT))
+ return (NULL);
+
+ de = TAILQ_FIRST(&de->de_dlist); /* "." */
+ if (de == NULL)
+ return (NULL);
+ de = TAILQ_NEXT(de, de_list); /* ".." */
+ if (de == NULL)
+ return (NULL);
+
+ return (de->de_dir);
+}
+
+struct devfs_dirent *
devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen, struct devfs_dirent *dotdot, u_int inode)
{
struct devfs_dirent *dd;
Modified: stable/8/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/8/sys/fs/devfs/devfs_vnops.c Thu Aug 19 13:24:13 2010 (r211506)
+++ stable/8/sys/fs/devfs/devfs_vnops.c Thu Aug 19 15:33:43 2010 (r211507)
@@ -230,9 +230,11 @@ devfs_vptocnp(struct vop_vptocnp_args *a
goto finished;
}
*buflen = i;
- de = TAILQ_FIRST(&de->de_dlist); /* "." */
- de = TAILQ_NEXT(de, de_list); /* ".." */
- de = de->de_dir;
+ de = devfs_parent_dirent(de);
+ if (de == NULL) {
+ error = ENOENT;
+ goto finished;
+ }
mtx_lock(&devfs_de_interlock);
*dvp = de->de_vnode;
if (*dvp != NULL) {
@@ -278,9 +280,9 @@ devfs_fqpn(char *buf, struct vnode *dvp,
return (NULL);
bcopy(de->de_dirent->d_name, buf + i,
de->de_dirent->d_namlen);
- de = TAILQ_FIRST(&de->de_dlist); /* "." */
- de = TAILQ_NEXT(de, de_list); /* ".." */
- de = de->de_dir;
+ de = devfs_parent_dirent(de);
+ if (de == NULL)
+ return (NULL);
}
return (buf + i);
}
@@ -778,10 +780,10 @@ devfs_lookupx(struct vop_lookup_args *ap
if (flags & ISDOTDOT) {
if ((flags & ISLASTCN) && nameiop != LOOKUP)
return (EINVAL);
+ de = devfs_parent_dirent(dd);
+ if (de == NULL)
+ return (ENOENT);
VOP_UNLOCK(dvp, 0);
- de = TAILQ_FIRST(&dd->de_dlist); /* "." */
- de = TAILQ_NEXT(de, de_list); /* ".." */
- de = de->de_dir;
error = devfs_allocv(de, dvp->v_mount, vpp);
*dm_unlock = 0;
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
More information about the svn-src-all
mailing list