|
@@ -41,7 +41,7 @@
|
|
|
#include "scsi/pr-manager.h"
|
|
|
#include "scsi/constants.h"
|
|
|
|
|
|
-#if defined(__APPLE__) && (__MACH__)
|
|
|
+#if defined(CONFIG_HOST_DEVICE) && defined(__APPLE__) && (__MACH__)
|
|
|
#include <paths.h>
|
|
|
#include <sys/param.h>
|
|
|
#include <IOKit/IOKitLib.h>
|
|
@@ -181,7 +181,16 @@ typedef struct BDRVRawReopenState {
|
|
|
bool check_cache_dropped;
|
|
|
} BDRVRawReopenState;
|
|
|
|
|
|
-static int fd_open(BlockDriverState *bs);
|
|
|
+static int fd_open(BlockDriverState *bs)
|
|
|
+{
|
|
|
+ BDRVRawState *s = bs->opaque;
|
|
|
+
|
|
|
+ /* this is just to ensure s->fd is sane (its called by io ops) */
|
|
|
+ if (s->fd >= 0)
|
|
|
+ return 0;
|
|
|
+ return -EIO;
|
|
|
+}
|
|
|
+
|
|
|
static int64_t raw_getlength(BlockDriverState *bs);
|
|
|
|
|
|
typedef struct RawPosixAIOData {
|
|
@@ -252,6 +261,12 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if defined(CONFIG_IOS)
|
|
|
+static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
|
|
+{
|
|
|
+ return -ENOTSUP; // not supported on iOS
|
|
|
+}
|
|
|
+#else /* CONFIG_IOS */
|
|
|
/*
|
|
|
* Get logical block size via ioctl. On success store it in @sector_size_p.
|
|
|
*/
|
|
@@ -284,6 +299,7 @@ static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
|
|
|
|
|
return success ? 0 : -errno;
|
|
|
}
|
|
|
+#endif /* !CONFIG_IOS */
|
|
|
|
|
|
/**
|
|
|
* Get physical block size of @fd.
|
|
@@ -2309,7 +2325,7 @@ again:
|
|
|
}
|
|
|
if (size == 0)
|
|
|
#endif
|
|
|
-#if defined(__APPLE__) && defined(__MACH__)
|
|
|
+#if !defined(CONFIG_IOS) && defined(__APPLE__) && defined(__MACH__)
|
|
|
{
|
|
|
uint64_t sectors = 0;
|
|
|
uint32_t sector_size = 0;
|
|
@@ -3251,6 +3267,8 @@ BlockDriver bdrv_file = {
|
|
|
/***********************************************/
|
|
|
/* host device */
|
|
|
|
|
|
+#if defined(CONFIG_HOST_DEVICE)
|
|
|
+
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
|
|
static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
|
|
|
CFIndex maxPathSize, int flags);
|
|
@@ -3543,16 +3561,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
|
|
|
}
|
|
|
#endif /* linux */
|
|
|
|
|
|
-static int fd_open(BlockDriverState *bs)
|
|
|
-{
|
|
|
- BDRVRawState *s = bs->opaque;
|
|
|
-
|
|
|
- /* this is just to ensure s->fd is sane (its called by io ops) */
|
|
|
- if (s->fd >= 0)
|
|
|
- return 0;
|
|
|
- return -EIO;
|
|
|
-}
|
|
|
-
|
|
|
static coroutine_fn int
|
|
|
hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
|
|
|
{
|
|
@@ -3876,6 +3884,8 @@ static BlockDriver bdrv_host_cdrom = {
|
|
|
};
|
|
|
#endif /* __FreeBSD__ */
|
|
|
|
|
|
+#endif /* CONFIG_HOST_DEVICE */
|
|
|
+
|
|
|
static void bdrv_file_init(void)
|
|
|
{
|
|
|
/*
|
|
@@ -3883,6 +3893,7 @@ static void bdrv_file_init(void)
|
|
|
* registered last will get probed first.
|
|
|
*/
|
|
|
bdrv_register(&bdrv_file);
|
|
|
+#if defined(CONFIG_HOST_DEVICE)
|
|
|
bdrv_register(&bdrv_host_device);
|
|
|
#ifdef __linux__
|
|
|
bdrv_register(&bdrv_host_cdrom);
|
|
@@ -3890,6 +3901,7 @@ static void bdrv_file_init(void)
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
bdrv_register(&bdrv_host_cdrom);
|
|
|
#endif
|
|
|
+#endif /* CONFIG_HOST_DEVICE */
|
|
|
}
|
|
|
|
|
|
block_init(bdrv_file_init);
|