From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 24 14:28:31 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E82316A41F for ; Mon, 24 Oct 2005 14:28:31 +0000 (GMT) (envelope-from victor.cruceru@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0DC443D46 for ; Mon, 24 Oct 2005 14:28:30 +0000 (GMT) (envelope-from victor.cruceru@gmail.com) Received: by wproxy.gmail.com with SMTP id i5so630744wra for ; Mon, 24 Oct 2005 07:28:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=S42rJyc2WvivQ+lZj/3MKR5diW7+5ldr59YhVVFte3hU0jLcqnTberRpE0ALMm+NJ09snsolbtHg7zBSSc4AQXU7KUA49btojEkGdvJ1Ly2Lmd1JgIs4Q+eEGMJ4VH8HFEkF/Tk6EFVg7W68KHh26dMVmVlSL38AQh2KsjbEBGs= Received: by 10.54.157.10 with SMTP id f10mr3281374wre; Mon, 24 Oct 2005 07:28:30 -0700 (PDT) Received: by 10.54.91.4 with HTTP; Mon, 24 Oct 2005 07:28:29 -0700 (PDT) Message-ID: <49402550510240728y555979c9i2fe4adc73137a1e7@mail.gmail.com> Date: Mon, 24 Oct 2005 17:28:29 +0300 From: victor cruceru To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: devinfo(3) problem... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: soc-victor@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2005 14:28:31 -0000 Daniel, What is the OS version you are using when this is happening? Did you try to update the libdevinfo (using cvsup for example) to a newer version? I think that under the original 5.4 it is a bug in devinfo(4) with the described behaviour below. > > ------------------------------ > > Message: 5 > Date: Sun, 23 Oct 2005 19:57:00 -0700 > From: Daniel Rudy > Subject: devinfo(3) problem... > To: freebsd-hackers@freebsd.org > Message-ID: <435C4D7C.7080504@pacbell.net> > Content-Type: text/plain; charset=3Dus-ascii > > > Consider the following code fragment: > > > (segment 2) > Calling code section: > /* get devinfo root nexus */ > printf("root ptr: %p\n", root); > result =3D usb_devinfo_root(&root); > printf("root ptr: %p\n", root); > if (result < 0) > { > usb_devinfo_close(); > return(-1); > } > > /* internal: get devinfo root nexus */ > int usb_devinfo_root(struct devinfo_dev **root) > { > printf("root: %p\n", *root); > *root =3D devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); > printf("root: %p\n", *root); <---- second call printf > if (*root =3D=3D NULL) > { > if (usb_param_use_error =3D=3D TRUE) error("usb.c: usb_devinfo_ro= ot: > root device not found", errno); > if (usb_param_errors_fatal =3D=3D TRUE) exit(2); > return(-1); > } > return(0); > } > > The problem is that devinfo_handle_to_device always returns a null > pointer here. Why? The next code segment, devinfo_handle_to_device > returns a proper address. > > (segment 1) > /* get devinfo root nexus */ > root =3D devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); > if (root =3D=3D NULL) > { > devinfo_free(); > return(-1); > } > > output: > usb_param_devmode: 255 > usb_param_devtype: 255 > usb_param_mode_pref: 0 > ioctl result: -1 > devinfo result: 0 > found_ioctl: 0 > found_devinfo: 1 <---- first call > devinfo device name: umass0 > usb_devinfo_open result: 0 > root ptr: 0x2815769c > root: 0x2815769c > root: 0x0 <---- second call > usb.c: usb_devinfo_root: root device not found: No such file or directory > root ptr: 0x0 > Fatal: Unable to get device information > > > Now I have made sure that I have called devinfo_free() during the first > call before calling devinfo_init() a second time. I tried calling this > code branch on the first time, and it executes properly, so why does it > fail on the second call? > > -- > Daniel Rudy > > > -- victor cruceru ------------------------------------------------ Non est respondendum ad omnia. ( Cicero, Pro Murena Oratio ) ------------------------------------------------