From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 23 00:40:06 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E656B1065673 for ; Sun, 23 Oct 2011 00:40:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BD8338FC15 for ; Sun, 23 Oct 2011 00:40:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p9N0e5cj073171 for ; Sun, 23 Oct 2011 00:40:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p9N0e5cr073170; Sun, 23 Oct 2011 00:40:05 GMT (envelope-from gnats) Resent-Date: Sun, 23 Oct 2011 00:40:05 GMT Resent-Message-Id: <201110230040.p9N0e5cr073170@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Yuriy Taraday Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D72091065673 for ; Sun, 23 Oct 2011 00:35:23 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id ADAAF8FC0C for ; Sun, 23 Oct 2011 00:35:23 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p9N0ZNwT035691 for ; Sun, 23 Oct 2011 00:35:23 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p9N0ZN8k035690; Sun, 23 Oct 2011 00:35:23 GMT (envelope-from nobody) Message-Id: <201110230035.p9N0ZN8k035690@red.freebsd.org> Date: Sun, 23 Oct 2011 00:35:23 GMT From: Yuriy Taraday To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/161912: kernel sends incorrect notify to devctl about device changes X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Oct 2011 00:40:06 -0000 >Number: 161912 >Category: kern >Synopsis: kernel sends incorrect notify to devctl about device changes >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Oct 23 00:40:05 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Yuriy Taraday >Release: 8.1-RELEASE-p2 >Organization: >Environment: FreeBSD greater 8.1-RELEASE-p2 FreeBSD 8.1-RELEASE-p2 #0: Sun Oct 23 04:13:10 MSD 2011 root@greater:/usr/obj/usr/src/sys/MYCONF amd64 >Description: When new device node is created or destroyed, kernel sends notify to devctl in this form: !system=DEVFS subsystem=CDEV type=DESTROY cdev= where is being substituted with the name of device. If device name contains whitespaces, devd scraps out everything but the part before the first space in cdev parameter, so we can not correctly handle device name in devd. >How-To-Repeat: I found out the problem when I was looking into what happens in devd when I insert my USB flash drive. System eventually creates "msdosfs/ADATA UFD" device, but devd handles it as "msdosfs/ADATA" device. >Fix: See attached patch. It wraps in double quotes so that devd ignores spaces in it. Patch attached with submission follows: --- ./sys/kern/kern_conf.c.orig 2011-10-23 03:55:45.000000000 +0400 +++ ./sys/kern/kern_conf.c 2011-10-23 04:10:57.000000000 +0400 @@ -510,19 +510,21 @@ static void notify(struct cdev *dev, const char *ev, int flags) { - static const char prefix[] = "cdev="; + static const char prefix[] = "cdev=\""; char *data; int namelen; if (cold) return; namelen = strlen(dev->si_name); - data = malloc(namelen + sizeof(prefix), M_TEMP, + data = malloc(namelen + sizeof(prefix) + 1, M_TEMP, (flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK); if (data == NULL) return; memcpy(data, prefix, sizeof(prefix) - 1); - memcpy(data + sizeof(prefix) - 1, dev->si_name, namelen + 1); + memcpy(data + sizeof(prefix) - 1, dev->si_name, namelen); + data[sizeof(prefix) + namelen - 1] = '"'; + data[sizeof(prefix) + namelen] = '\0'; devctl_notify("DEVFS", "CDEV", ev, data); free(data, M_TEMP); } >Release-Note: >Audit-Trail: >Unformatted: