Bug in devinfo or something wrong with me?

Juho Vuori juho.vuori at kepa.fi
Mon May 16 11:11:45 GMT 2005


The below included simple program reliably printfs "error 4\n" on 
5.4-RELEASE. Am I understanding something wrong or is this a bug in 
libdevinfo?

To continue on this however, if you put say sleep(5) between 
devinfo_free() and the second devinfo_init() and manage to change the 
device configuration during the sleep (tested with pluggin in/out a USB 
memory), the program terminates with no errors. I've run into other 
oddities with devinfo as well, but in much more complex situations so 
they might just as well be variations of this simple example.

Juho

/* save this as test.c and compile:
 * cc -o test test.c -ldevinfo
 */

#include <sys/types.h>
#include <devinfo.h>

int
main () {
        struct devinfo_dev *root;

        if (devinfo_init()) {
                printf("error 1\n");
                return -1;
        }
        if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) {
                printf("error 2\n");
                return -1;
        }
        devinfo_free();

        if (devinfo_init()) {
                printf("error 3\n");
                return -1;
        }
        if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) {
                printf("error 4\n");
                return -1;
        }
        devinfo_free();

        printf("no errors\n");
        return 0;
}



More information about the freebsd-hackers mailing list