Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Oct 2005 17:28:29 +0300
From:      victor cruceru <victor.cruceru@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: devinfo(3) problem...
Message-ID:  <49402550510240728y555979c9i2fe4adc73137a1e7@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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 <dr2867@pacbell.net>
> 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 )
------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49402550510240728y555979c9i2fe4adc73137a1e7>