1 --- libcdio-0.93/lib/driver/solaris.c.~1~ 2014-06-21 06:10:56.000000000 +0400
2 +++ libcdio-0.93/lib/driver/solaris.c 2015-09-11 07:29:46.035552587 +0300
7 +#include <hal/libhal.h>
10 # include <sys/cdio.h> /* CDIOCALLOW etc... */
16 +find_cdroms (LibHalContext *hal_ctx)
24 + dbus_error_init (&error);
26 + udis = libhal_find_device_by_capability (hal_ctx, "storage.cdrom",
29 + if (dbus_error_is_set (&error)) {
30 + fprintf (stderr, "error: %s: %s\n", error.name, error.message);
34 + /* Return first device found */
35 + for (i = 0; i < num_udis; i++) {
36 + bdev = libhal_device_get_property_string (hal_ctx,
37 + udis[i], "block.device", &error);
38 + rdev = libhal_device_get_property_string (hal_ctx,
39 + udis[i], "block.solaris.raw_device", &error);
46 + libhal_free_string_array (udis);
47 + dbus_error_free (&error);
52 Set the arg "key" with "value" in the source device.
53 Currently "source" and "access-mode" are valid keys.
58 + char *default_device = NULL;
60 + LibHalContext *hal_ctx;
63 + dbus_error_init (&error);
64 + if ((hal_ctx = libhal_ctx_new ()) == NULL) {
65 + fprintf (stderr, "libhal_ctx_new failed\n");
68 + if (!libhal_ctx_set_dbus_connection (hal_ctx,
69 + dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
70 + fprintf (stderr, "libhal_ctx_set_dbus_connection: %s %s\n",
71 + error.name, error.message);
74 + if (!libhal_ctx_init (hal_ctx, &error)) {
75 + fprintf (stderr, "libhal_ctx_init: %s: %s\n",
76 + error.name, error.message);
80 + default_device = find_cdroms(hal_ctx);
83 + libhal_ctx_shutdown(hal_ctx, &error);
84 + libhal_ctx_free(hal_ctx);
86 /* vold and its directory /vol have been replaced by "Tamarack" which
87 is based on hald. This happened in 2006.
89 strcmp(volume_action, "insert") == 0) {
90 uint len = strlen(volume_device) + strlen(volume_name) + 2;
91 device = calloc(1, len);
93 - return strdup(DEFAULT_CDIO_DEVICE);
94 + if (device == NULL) {
95 + if (default_device != NULL)
96 + return strdup (default_device);
98 + return strdup (DEFAULT_CDIO_DEVICE);
100 snprintf(device, len, "%s/%s", volume_device, volume_name);
101 if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) {
103 - return strdup(DEFAULT_CDIO_DEVICE);
104 + if (default_device != NULL)
105 + return strdup (default_device);
107 + return strdup (DEFAULT_CDIO_DEVICE);
111 /* Check if it could be a Solaris media*/
112 - if((stat(DEFAULT_CDIO_DEVICE, &stb) == 0) && S_ISDIR(stb.st_mode)) {
113 - uint len = strlen(DEFAULT_CDIO_DEVICE + 4);
114 - device = calloc(1, len);
115 - snprintf(device, len, "%s/s0", DEFAULT_CDIO_DEVICE);
116 + if(default_device != NULL && (stat(default_device, &stb) == 0) && S_ISDIR(stb.st_mode)) {
117 + device = calloc(1, strlen(default_device) + 4);
118 + sprintf(device, "%s/s0", default_device);
121 - return strdup(DEFAULT_CDIO_DEVICE);
122 + if (default_device != NULL)
123 + return strdup (default_device);
125 + return strdup (DEFAULT_CDIO_DEVICE);