7 #include <prop/proplib.h>
11 struct mydev_params params
;
17 if ((devfd
= open("/dev/mydev", O_RDONLY
, 0)) < 0) {
18 fprintf(stderr
, "Failed to open /dev/mydev\n");
22 /* Send ioctl request in the traditional way */
24 strncpy(params
.string
, "Hello World", MAX_STR
);
26 if (ioctl(devfd
, MYDEVOLDIOCTL
, ¶ms
) == -1) {
28 err(EXIT_FAILURE
, "ioctl()");
31 /* Create dictionary and add a <key, value> pair in it */
32 pd
= prop_dictionary_create();
35 err(EXIT_FAILURE
, "prop_dictionary_create()");
38 ps
= prop_string_create_cstring("value");
41 prop_object_release(pd
);
42 err(EXIT_FAILURE
, "prop_string_create_cstring()");
45 if (prop_dictionary_set(pd
, "key", ps
) == false) {
47 prop_object_release(ps
);
48 prop_object_release(pd
);
49 err(EXIT_FAILURE
, "prop_dictionary_set()");
52 prop_object_release(ps
);
54 /* Send dictionary to kernel space */
55 prop_dictionary_send_ioctl(pd
, devfd
, MYDEVSETPROPS
);
57 prop_object_release(pd
);
60 if (close(devfd
) == -1)
61 err(EXIT_FAILURE
, "close()");