Revert "remove tsol from xorg-server"
[unleashed-userland.git] / components / libcdio / patches / 01-usehal.patch
blob5e0f85c7b5736815f2869bf06310a98eacec4af9
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
3 @@ -47,6 +47,7 @@
4 #include <errno.h>
5 #include <unistd.h>
6 #include <fcntl.h>
7 +#include <hal/libhal.h>
9 #ifdef HAVE_SYS_CDIO_H
10 # include <sys/cdio.h> /* CDIOCALLOW etc... */
11 @@ -624,6 +625,42 @@
12 return size;
15 +static char *
16 +find_cdroms (LibHalContext *hal_ctx)
18 + int i;
19 + int num_udis;
20 + char **udis;
21 + char *bdev, *rdev;
22 + DBusError error;
24 + dbus_error_init (&error);
26 + udis = libhal_find_device_by_capability (hal_ctx, "storage.cdrom",
27 + &num_udis, &error);
29 + if (dbus_error_is_set (&error)) {
30 + fprintf (stderr, "error: %s: %s\n", error.name, error.message);
31 + goto out;
32 + }
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);
41 + if (rdev != NULL)
42 + return rdev;
43 + }
45 +out:
46 + libhal_free_string_array (udis);
47 + dbus_error_free (&error);
48 + return (NULL);
51 /*!
52 Set the arg "key" with "value" in the source device.
53 Currently "source" and "access-mode" are valid keys.
54 @@ -822,6 +859,33 @@
55 char *volume_action;
56 char *device;
57 struct stat stb;
58 + char *default_device = NULL;
59 + DBusError error;
60 + LibHalContext *hal_ctx;
61 + int ret = 1;
63 + dbus_error_init (&error);
64 + if ((hal_ctx = libhal_ctx_new ()) == NULL) {
65 + fprintf (stderr, "libhal_ctx_new failed\n");
66 + goto halerr;
67 + }
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);
72 + goto halerr;
73 + }
74 + if (!libhal_ctx_init (hal_ctx, &error)) {
75 + fprintf (stderr, "libhal_ctx_init: %s: %s\n",
76 + error.name, error.message);
77 + goto halerr;
78 + }
80 + default_device = find_cdroms(hal_ctx);
82 +halerr:
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.
88 @@ -837,23 +901,32 @@
89 strcmp(volume_action, "insert") == 0) {
90 uint len = strlen(volume_device) + strlen(volume_name) + 2;
91 device = calloc(1, len);
92 - if (device == NULL)
93 - return strdup(DEFAULT_CDIO_DEVICE);
94 + if (device == NULL) {
95 + if (default_device != NULL)
96 + return strdup (default_device);
97 + else
98 + return strdup (DEFAULT_CDIO_DEVICE);
99 + }
100 snprintf(device, len, "%s/%s", volume_device, volume_name);
101 if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) {
102 free(device);
103 - return strdup(DEFAULT_CDIO_DEVICE);
104 + if (default_device != NULL)
105 + return strdup (default_device);
106 + else
107 + return strdup (DEFAULT_CDIO_DEVICE);
109 return 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);
119 return device;
121 - return strdup(DEFAULT_CDIO_DEVICE);
122 + if (default_device != NULL)
123 + return strdup (default_device);
124 + else
125 + return strdup (DEFAULT_CDIO_DEVICE);
128 /*!