From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastian Blank Subject: Re: [PATCH] xc: deal with xen/evtchn and xen/gntdev device names Date: Sat, 29 May 2010 08:53:42 +0200 Message-ID: <20100529065342.GB12168@wavehammer.waldi.eu.org> References: <4C00690B.2020303@goop.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Content-Disposition: inline In-Reply-To: <4C00690B.2020303@goop.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Fitzhardinge Cc: Xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, May 28, 2010 at 06:08:27PM -0700, Jeremy Fitzhardinge wrote: > + if (asprintf(&devname, "xen!%s", dev) == 0) > + if (asprintf(&devpath, "%s/%s", DEVXEN, dev) == 0) asprintf is a glibc extension. Is it really necessary to support long device names for fun or would some 64 byte on the stack be enough? > + devnum = xc_find_device_number(dev); > + if (devnum == -1) > + devnum = xc_find_device_number(devname); Checks should always go from the special ("xen!...") to the gerneral. Also the device is dev_t, not integer. > + /* > + * If we know what the correct device is and the path doesn't > + * exist or isn't a device, then remove it so we can create the > + * device. > + */ > + if (devnum != -1 && > + (stat(devpath, &st) != 0 || !S_ISCHR(st.st_mode))) { Why should it exist and be something else then a character device? The admin is free to break the system as she likes. > + fd = open(devpath, O_RDWR); Whitespace. Bastian -- ... bacteriological warfare ... hard to believe we were once foolish enough to play around with that. -- McCoy, "The Omega Glory", stardate unknown