mosquitto: fix build
[oi-userland.git] / components / runtime / wine / patches / 04-create-scsi-info.patch
blob1dd6adfd8b974c17f6bf56047d7f0db5e77d19ea
1 --- wine-4.4/dlls/kernel32/Makefile.in.1 2019-09-30 21:18:02.672434942 +0000
2 +++ wine-4.4/dlls/kernel32/Makefile.in 2019-09-30 21:18:32.770874323 +0000
3 @@ -2,7 +2,7 @@
4 MODULE = kernel32.dll
5 IMPORTLIB = kernel32
6 IMPORTS = winecrt0 kernelbase ntdll
7 -EXTRALIBS = $(COREFOUNDATION_LIBS) $(POLL_LIBS) $(RT_LIBS)
8 +EXTRALIBS = $(COREFOUNDATION_LIBS) $(POLL_LIBS) $(RT_LIBS) -ldevinfo
9 EXTRADLLFLAGS = -nodefaultlibs -Wb,-F,KERNEL32.dll -Wl,--image-base,0x7b400000
11 C_SRCS = \
12 --- wine-4.4/dlls/kernel32/oldconfig.c.~1~ 2019-03-15 23:18:31.000000000 +0000
13 +++ wine-4.4/dlls/kernel32/oldconfig.c 2019-10-01 03:26:42.508639311 +0000
14 @@ -42,6 +42,13 @@
15 # include <linux/hdreg.h>
16 #endif
18 +#if defined(__sun) || defined(sun)
19 +#include <libdevinfo.h>
20 +#include <string.h>
21 +#include <sys/stat.h>
22 +#include <sys/mkdev.h>
23 +#endif
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winternl.h"
28 @@ -263,7 +270,172 @@
29 return 1;
32 +#if defined(__sun) || defined(sun)
33 +static int walk_devlinks(di_devlink_t devlink, void *arg)
35 + char **path= (char **)arg;
37 + *path = strdup(di_devlink_path(devlink));
39 + return (DI_WALK_TERMINATE);
42 +static int process_minors(di_node_t node, unsigned char* port, int is_cdrom, int is_scsi) {
43 + int major;
44 + di_minor_t minor;
45 + di_devlink_handle_t devlink_hdl;
46 + char *cUnixDeviceName = NULL;
48 + devlink_hdl = di_devlink_init(NULL, 0);
49 + if (devlink_hdl == NULL) {
50 + ERR("Couldn't init devlink handle\n");
51 + return -1;
52 + }
54 + major = di_driver_major(node);
55 + minor = DI_MINOR_NIL;
56 + while ((minor = di_minor_next(node, minor)) != DI_MINOR_NIL) {
57 + char *mname;
58 + char *devlink = NULL;
59 + char *minor_path;
60 + dev_t dev;
62 + dev = di_minor_devt(minor);
63 + if (major == major(dev) && di_minor_type(minor) == DDM_MINOR &&
64 + di_minor_spectype(minor) == S_IFBLK) {
66 + minor_path = di_devfs_minor_path(minor);
67 + mname = di_minor_name(minor);
68 + dev = di_minor_devt(minor);
69 + (void) di_devlink_walk(devlink_hdl, NULL, minor_path,
70 + DI_PRIMARY_LINK, &devlink, walk_devlinks);
71 + if (devlink) {
72 + /* If devlink ends with d0 or p0, it's device name. Prefer d0 names. */
73 + int dl = strlen(devlink);
75 + if (dl > 2 && devlink[dl-1] == '0' && devlink[dl-2] == 'd') {
76 + if (cUnixDeviceName != NULL) {
77 + free(cUnixDeviceName);
78 + }
79 + cUnixDeviceName = strdup(devlink);
80 + }
81 + if (dl > 2 && devlink[dl-1] == '0' && devlink[dl-2] == 'p' && cUnixDeviceName == NULL) {
82 + cUnixDeviceName = strdup(devlink);
83 + }
84 + }
85 + }
87 + }
88 + di_devlink_fini (&devlink_hdl);
90 + if (cUnixDeviceName) {
91 + SCSI_ADDRESS scsi_addr;
92 + char cDevModel[40];
93 + UINT nType;
94 + char *dtype;
96 + if (is_cdrom) {
97 + nType = DRIVE_CDROM;
98 + strcpy(cDevModel, "Wine CDROM");
99 + } else {
100 + nType = DRIVE_FIXED;
101 + strcpy(cDevModel, "Wine harddisk");
104 + if (is_scsi) {
105 + dtype = "WINE scsi";
106 + } else {
107 + dtype = "atapi";
110 + scsi_addr.PortNumber = *port;
111 + scsi_addr.PathId = 0;
112 + scsi_addr.TargetId = 0;
113 + scsi_addr.Lun = 0;
115 + create_scsi_entry(&scsi_addr, dtype, nType, cDevModel, cUnixDeviceName);
116 + (*port)++;
117 + free (cUnixDeviceName);
119 + return 0;
123 +static int get_ide_disks(di_node_t node, void *arg) {
124 + unsigned char* port = (unsigned char *)arg;
125 + char *path;
126 + char *driver;
128 + path = di_devfs_path(node);
129 + if (path != NULL) {
130 + char *device_type = NULL;
131 + char *s;
132 + di_prop_lookup_strings (DDI_DEV_T_ANY, node, "device_type",
133 + &device_type);
134 + if ((di_prop_lookup_strings (DDI_DEV_T_ANY, node, "class", &s) > 0) &&
135 + (strcmp (s, "dada") == 0)) {
136 + driver = di_driver_name(node);
138 + if (process_minors(node, port, 0, 0) < 0) {
139 + di_devfs_path_free(path);
140 + return DI_WALK_TERMINATE;
143 + di_devfs_path_free(path);
145 + return DI_WALK_CONTINUE;
148 +static int get_scsi_disks(di_node_t node, void *arg) {
149 + unsigned char* port = (unsigned char *)arg;
150 + char *path, *driver;
151 + int *i = NULL;
152 + int is_cdrom = 0;
154 + path = di_devfs_path(node);
155 + if (path != NULL) {
156 + driver = di_driver_name(node);
157 + if (driver != NULL && strcmp(driver,"sd") == 0){
158 + if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "inquiry-device-type", &i) > 0) {
159 + if (*i == 0x07 || *i == 0x05) {
160 + is_cdrom = 1;
163 + if (process_minors(node, port, is_cdrom, 1) < 0) {
164 + di_devfs_path_free(path);
165 + return DI_WALK_TERMINATE;
170 + return DI_WALK_CONTINUE;
173 +static void create_hardware_branch(void)
175 + di_node_t node;
176 + unsigned char uFirstSCSIPort = 0;
178 + /* Enumerate ide disks as atapi devices */
179 + node = di_init("/", DINFOCPYALL);
180 + if (node != DI_NODE_NIL) {
181 + di_walk_node (node, DI_WALK_CLDFIRST, &uFirstSCSIPort, get_ide_disks);
182 + di_fini(node);
183 + } else {
184 + ERR("Couldn't di_init while getting IDE disks\n");
187 + /* Enumerate scsi block devices */
188 + node = di_init("/", DINFOCPYALL);
189 + if (node != DI_NODE_NIL) {
190 + di_walk_node (node, DI_WALK_CLDFIRST, &uFirstSCSIPort, get_scsi_disks);
191 + di_fini(node);
192 + } else {
193 + ERR("Couldn't di_init while getting SCSI disks\n");
197 +#else
198 /* create the hardware registry branch */
199 static void create_hardware_branch(void)
201 @@ -390,6 +562,7 @@
202 WARN("Incorrect %s format\n", procname_scsi);
203 fclose( procfile );
205 +#endif
208 /***********************************************************************