From owner-svn-src-all@FreeBSD.ORG Tue Jan 8 19:40:03 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 47FBC8C1; Tue, 8 Jan 2013 19:40:03 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi [195.197.172.111]) by mx1.freebsd.org (Postfix) with ESMTP id C1B557E1; Tue, 8 Jan 2013 19:40:02 +0000 (UTC) Received: from a91-153-116-96.elisa-laajakaista.fi (a91-153-116-96.elisa-laajakaista.fi [91.153.116.96]) by gw03.mail.saunalahti.fi (Postfix) with SMTP id 14D6F2165CD; Tue, 8 Jan 2013 21:31:48 +0200 (EET) Date: Tue, 8 Jan 2013 21:31:47 +0200 From: Jaakko Heinonen To: John Baldwin Subject: Re: svn commit: r244585 - in head: . sys/geom/label Message-ID: <20130108193146.GA1815@a91-153-116-96.elisa-laajakaista.fi> References: <201212221343.qBMDhCHa086834@svn.freebsd.org> <201301041218.07804.john@baldwin.cx> <20130105092252.GA1832@a91-153-116-96.elisa-laajakaista.fi> <201301070927.07157.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201301070927.07157.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@freebsd.org, pjd@FreeBSD.org, svn-src-all@freebsd.org, kib@FreeBSD.org, svn-src-head@freebsd.org, imp@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Tue, 08 Jan 2013 19:40:03 -0000 On 2013-01-07, John Baldwin wrote: > I think if it isn't hard to do so, we should aim to preserve labels as they > are generally intended to be human readable as-is. Just preserving spaces is > probably sufficient for this as they are probably the most commonly used > character in labels affected by this change. All right. I have prepared patches for review. - Quote device names in devctl(4) device events. This allows events to work for device names containing spaces. - Allow spaces again in device names. Requested by: jhb PR: kern/161912 %%% Index: sys/kern/kern_conf.c =================================================================== --- sys/kern/kern_conf.c (revision 245155) +++ sys/kern/kern_conf.c (working copy) @@ -536,17 +536,17 @@ notify(struct cdev *dev, const char *ev, { static const char prefix[] = "cdev="; char *data; - int namelen, mflags; + size_t datalen; + int mflags; if (cold) return; mflags = (flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK; - namelen = strlen(dev->si_name); - data = malloc(namelen + sizeof(prefix), M_TEMP, mflags); + datalen = strlen(dev->si_name) + sizeof(prefix) + 2; + data = malloc(datalen, M_TEMP, mflags); if (data == NULL) return; - memcpy(data, prefix, sizeof(prefix) - 1); - memcpy(data + sizeof(prefix) - 1, dev->si_name, namelen + 1); + snprintf(data, datalen, "%s\"%s\"", prefix, dev->si_name); devctl_notify_f("DEVFS", "CDEV", ev, data, mflags); free(data, M_TEMP); } @@ -699,11 +699,11 @@ prep_devname(struct cdev *dev, const cha for (to = dev->si_name; *from != '\0'; from++, to++) { /* - * Spaces and double quotation marks cause - * problems for the devctl(4) protocol. - * Reject names containing those characters. + * Double quotation marks cause problems for the + * devctl(4) protocol. Reject names containing + * those characters. */ - if (isspace(*from) || *from == '"') + if (*from == '"') return (EINVAL); /* Treat multiple sequential slashes as single. */ while (from[0] == '/' && from[1] == '/') Index: sys/geom/geom_dev.c =================================================================== --- sys/geom/geom_dev.c (revision 245155) +++ sys/geom/geom_dev.c (working copy) @@ -107,15 +107,15 @@ static void g_dev_attrchanged(struct g_consumer *cp, const char *attr) { struct cdev *dev; - char buf[SPECNAMELEN + 6]; + char buf[SPECNAMELEN + 8]; if (strcmp(attr, "GEOM::media") == 0) { dev = cp->geom->softc; - snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); + snprintf(buf, sizeof(buf), "cdev=\"%s\"", dev->si_name); devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); dev = cp->cp_alias_dev; if (dev != NULL) { - snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); + snprintf(buf, sizeof(buf), "cdev=\"%s\"", dev->si_name); devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); } %%% Don't mangle spaces in label names. Requested by: jhb %%% Index: sys/geom/label/g_label.c =================================================================== --- sys/geom/label/g_label.c (revision 245155) +++ sys/geom/label/g_label.c (working copy) @@ -148,7 +148,7 @@ g_label_mangle_name(char *label, size_t sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN); for (c = label; *c != '\0'; c++) { - if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%') + if (!isprint(*c) || *c =='"' || *c == '%') sbuf_printf(sb, "%%%02X", *c); else sbuf_putc(sb, *c); Index: UPDATING =================================================================== --- UPDATING (revision 245155) +++ UPDATING (working copy) @@ -33,9 +33,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10 20121222: GEOM_LABEL now mangles label names read from file system metadata. - Mangling affect labels containing spaces, non-printable characters, - '%' or '"'. Device names in /etc/fstab and other places may need to - be updated. + Mangling affect labels containing non-printable characters, '%' or + '"'. Device names in /etc/fstab and other places may need to be + updated. 20121217: By default, only the 10 most recent kernel dumps will be saved. To %%% -- Jaakko