Created
December 26, 2020 02:20
-
-
Save akhenakh/d76adb669deec2d4db3816dd76d5d0e7 to your computer and use it in GitHub Desktop.
spice-gtk.diff compile spice-gtk 0.39 on osx m1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/cd-scsi.h b/src/cd-scsi.h | |
index 6351f4a..feb935e 100644 | |
--- a/src/cd-scsi.h | |
+++ b/src/cd-scsi.h | |
@@ -26,6 +26,8 @@ | |
#include "cd-usb-bulk-msd.h" | |
#include "scsi-constants.h" | |
+#include <CoreFoundation/CoreFoundation.h> | |
+ | |
#if defined(G_OS_WIN32) | |
#include <winsock2.h> | |
#include <windows.h> | |
@@ -35,6 +37,11 @@ | |
#define htobe32(x) htonl(x) | |
#endif | |
+#define be32toh(x) CFSwapInt32BigToHost(x) | |
+#define htobe32(x) CFSwapInt32HostToBig(x) | |
+#define le32toh(x) CFSwapInt32LittleToHost(x) | |
+#define htole32(x) CFSwapInt32HostToLittle(x) | |
+ | |
typedef enum ScsiXferDir { | |
SCSI_XFER_NONE = 0, /* TEST_UNIT_READY, ... */ | |
SCSI_XFER_FROM_DEV, /* READ, INQUIRY, MODE_SENSE, ... */ | |
diff --git a/src/cd-usb-bulk-msd.h b/src/cd-usb-bulk-msd.h | |
index e2a0e52..be2abd4 100644 | |
--- a/src/cd-usb-bulk-msd.h | |
+++ b/src/cd-usb-bulk-msd.h | |
@@ -21,6 +21,7 @@ | |
#pragma once | |
#include <gio/gio.h> | |
+#include <CoreFoundation/CoreFoundation.h> | |
#include "cd-scsi-dev-params.h" | |
diff --git a/src/usb-device-cd.c b/src/usb-device-cd.c | |
index b9fa317..8cc5a3c 100644 | |
--- a/src/usb-device-cd.c | |
+++ b/src/usb-device-cd.c | |
@@ -37,8 +37,6 @@ | |
#else | |
#include <sys/stat.h> | |
#include <sys/ioctl.h> | |
-#include <linux/fs.h> | |
-#include <linux/cdrom.h> | |
#endif | |
#include "usb-emulation.h" | |
@@ -94,93 +92,17 @@ typedef struct SpiceUsbEmulatedDevice UsbCd; | |
static int cd_device_open_stream(SpiceCdLU *unit, const char *filename) | |
{ | |
- unit->device = 0; | |
- | |
- if (!unit->filename && !filename) { | |
- SPICE_DEBUG("%s: file name not provided", __FUNCTION__); | |
- return -1; | |
- } | |
- if (unit->filename && filename) { | |
- g_free(unit->filename); | |
- unit->filename = NULL; | |
- } | |
- if (filename) { | |
- unit->filename = g_strdup(filename); | |
- } | |
- | |
- int fd = open(unit->filename, O_RDONLY | O_NONBLOCK); | |
- if (fd < 0) { | |
- SPICE_DEBUG("%s: can't open file %s", __FUNCTION__, unit->filename); | |
- return -1; | |
- } | |
- | |
- struct stat file_stat = { 0 }; | |
- if (fstat(fd, &file_stat) || file_stat.st_size == 0) { | |
- file_stat.st_size = 0; | |
- unit->device = 1; | |
- if (!ioctl(fd, BLKGETSIZE64, &file_stat.st_size) && | |
- !ioctl(fd, BLKSSZGET, &unit->blockSize)) { | |
- } | |
- } | |
- unit->size = file_stat.st_size; | |
- close(fd); | |
- if (unit->size) { | |
- GFile *file_object = g_file_new_for_path(unit->filename); | |
- unit->stream = g_file_read(file_object, NULL, NULL); | |
- g_clear_object(&file_object); | |
- } | |
- if (!unit->stream) { | |
- SPICE_DEBUG("%s: can't open stream on %s", __FUNCTION__, unit->filename); | |
- return -1; | |
- } | |
- | |
- return 0; | |
+ return -1; | |
} | |
static int cd_device_load(SpiceCdLU *unit, gboolean load) | |
{ | |
- int error; | |
- if (!unit->device || !unit->filename) { | |
- return -1; | |
- } | |
- int fd = open(unit->filename, O_RDONLY | O_NONBLOCK); | |
- if (fd < 0) { | |
return -1; | |
- } | |
- if (load) { | |
- error = ioctl(fd, CDROMCLOSETRAY, 0); | |
- } else { | |
- ioctl(fd, CDROM_LOCKDOOR, 0); | |
- error = ioctl(fd, CDROMEJECT, 0); | |
- } | |
- if (error) { | |
- // note that ejecting might be available only for root | |
- // loading might be available also for regular user | |
- SPICE_DEBUG("%s: can't %sload %s, res %d, errno %d", | |
- __FUNCTION__, load ? "" : "un", unit->filename, error, errno); | |
- } | |
- close(fd); | |
- return error; | |
} | |
static int cd_device_check(SpiceCdLU *unit) | |
{ | |
- int error; | |
- if (!unit->device || !unit->filename) { | |
return -1; | |
- } | |
- int fd = open(unit->filename, O_RDONLY | O_NONBLOCK); | |
- if (fd < 0) { | |
- return -1; | |
- } | |
- error = ioctl(fd, CDROM_DRIVE_STATUS, 0); | |
- error = (error == CDS_DISC_OK) ? 0 : -1; | |
- if (!error) { | |
- error = ioctl(fd, CDROM_DISC_STATUS, 0); | |
- error = (error == CDS_DATA_1) ? 0 : -1; | |
- } | |
- close(fd); | |
- return error; | |
} | |
#else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using brew for all dependencies
==> Dependencies
Build: autoconf ✔, autogen ✔, automake ✔, gobject-introspection ✔, intltool ✔, libtool ✔, pkg-config ✔, vala ✔, meson ✔
Required: atk ✔, cairo ✔, gdk-pixbuf ✔, gettext ✔, glib ✔, gstreamer ✔, gtk+3 ✔, jpeg ✔, json-glib ✔, libusb ✔, lz4 ✔, openssl@1.1 ✔, opus ✔, pango ✔, pixman ✔, spice-protocol ✔, usbredir ✔