From owner-svn-src-head@FreeBSD.ORG Mon Sep 27 18:20:56 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A40C1065672; Mon, 27 Sep 2010 18:20:56 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69B8E8FC19; Mon, 27 Sep 2010 18:20:56 +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 o8RIKuOf045814; Mon, 27 Sep 2010 18:20:56 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8RIKuXX045811; Mon, 27 Sep 2010 18:20:56 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201009271820.o8RIKuXX045811@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 27 Sep 2010 18:20:56 +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: r213221 - head/sys/fs/devfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2010 18:20:56 -0000 Author: jh Date: Mon Sep 27 18:20:56 2010 New Revision: 213221 URL: http://svn.freebsd.org/changeset/base/213221 Log: Add a new function devfs_dev_exists() to be able to find out if a specific devfs path already exists. The function will be used from kern_conf.c to detect duplicate device registrations. Callers must hold the devmtx mutex. Reviewed by: kib Modified: head/sys/fs/devfs/devfs_devs.c head/sys/fs/devfs/devfs_int.h Modified: head/sys/fs/devfs/devfs_devs.c ============================================================================== --- head/sys/fs/devfs/devfs_devs.c Mon Sep 27 18:20:04 2010 (r213220) +++ head/sys/fs/devfs/devfs_devs.c Mon Sep 27 18:20:56 2010 (r213221) @@ -142,6 +142,27 @@ devfs_alloc(int flags) return (cdev); } +int +devfs_dev_exists(const char *name) +{ + struct cdev_priv *cdp; + + mtx_assert(&devmtx, MA_OWNED); + + TAILQ_FOREACH(cdp, &cdevp_list, cdp_list) { + if ((cdp->cdp_flags & CDP_ACTIVE) == 0) + continue; + if (devfs_pathpath(cdp->cdp_c.si_name, name) != 0) + return (1); + if (devfs_pathpath(name, cdp->cdp_c.si_name) != 0) + return (1); + } + if (devfs_dir_find(name) != 0) + return (1); + + return (0); +} + void devfs_free(struct cdev *cdev) { Modified: head/sys/fs/devfs/devfs_int.h ============================================================================== --- head/sys/fs/devfs/devfs_int.h Mon Sep 27 18:20:04 2010 (r213220) +++ head/sys/fs/devfs/devfs_int.h Mon Sep 27 18:20:56 2010 (r213221) @@ -72,6 +72,7 @@ struct cdev_priv { #define cdev2priv(c) member2struct(cdev_priv, cdp_c, c) struct cdev *devfs_alloc(int); +int devfs_dev_exists(const char *); void devfs_free(struct cdev *); void devfs_create(struct cdev *dev); void devfs_destroy(struct cdev *dev);