From owner-svn-src-all@FreeBSD.ORG Wed Jun 9 15:29:13 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AF671065675; Wed, 9 Jun 2010 15:29:13 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4AC438FC25; Wed, 9 Jun 2010 15:29:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o59FTCwR062587; Wed, 9 Jun 2010 15:29:12 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o59FTCP3062583; Wed, 9 Jun 2010 15:29:12 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201006091529.o59FTCP3062583@svn.freebsd.org> From: Jaakko Heinonen Date: Wed, 9 Jun 2010 15:29:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208951 - head/sys/fs/devfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2010 15:29:13 -0000 Author: jh Date: Wed Jun 9 15:29:12 2010 New Revision: 208951 URL: http://svn.freebsd.org/changeset/base/208951 Log: 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. Reviewed by: kib Modified: head/sys/fs/devfs/devfs.h head/sys/fs/devfs/devfs_devs.c head/sys/fs/devfs/devfs_vnops.c Modified: head/sys/fs/devfs/devfs.h ============================================================================== --- head/sys/fs/devfs/devfs.h Wed Jun 9 14:54:05 2010 (r208950) +++ head/sys/fs/devfs/devfs.h Wed Jun 9 15:29:12 2010 (r208951) @@ -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: head/sys/fs/devfs/devfs_devs.c ============================================================================== --- head/sys/fs/devfs/devfs_devs.c Wed Jun 9 14:54:05 2010 (r208950) +++ head/sys/fs/devfs/devfs_devs.c Wed Jun 9 15:29:12 2010 (r208951) @@ -198,6 +198,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: head/sys/fs/devfs/devfs_vnops.c ============================================================================== --- head/sys/fs/devfs/devfs_vnops.c Wed Jun 9 14:54:05 2010 (r208950) +++ head/sys/fs/devfs/devfs_vnops.c Wed Jun 9 15:29:12 2010 (r208951) @@ -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); } @@ -789,10 +791,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);