Received: from eggs.gnu.org ([2001:4830:134:3::10]:55998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJlG7-0000ak-AJ for qemu-devel@nongnu.org; Mon, 27 Jul 2015 12:28:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJlG3-000808-7h for qemu-devel@nongnu.org; Mon, 27 Jul 2015 12:28:11 -0400 From: Programmingkid Content-Type: multipart/alternative; boundary=Apple-Mail-46-145782555 Date: Mon, 27 Jul 2015 12:28:03 -0400 Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH] raw-posix.c: Make GetBSDPath() handle caching options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Kevin Wolf Cc: qemu-devel qemu-devel , Qemu-block --Apple-Mail-46-145782555 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Add support for caching options that can be specified from the command line.=20 Signed-off-by: John Arbuckle --- block/raw-posix.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index cbe6574..67d1d48 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1973,8 +1973,8 @@ BlockDriver bdrv_file =3D { =20 #if defined(__APPLE__) && defined(__MACH__) static kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator = ); -static kern_return_t GetBSDPath( io_iterator_t mediaIterator, char = *bsdPath, CFIndex maxPathSize ); - +static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char = *bsdPath, + CFIndex maxPathSize, int flags); kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator ) { kern_return_t kernResult; @@ -2001,7 +2001,8 @@ kern_return_t FindEjectableCDMedia( io_iterator_t = *mediaIterator ) return kernResult; } =20 -kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, = CFIndex maxPathSize ) +kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath, + CFIndex maxPathSize, int flags) { io_object_t nextMedia; kern_return_t kernResult =3D KERN_FAILURE; @@ -2014,7 +2015,9 @@ kern_return_t GetBSDPath( io_iterator_t = mediaIterator, char *bsdPath, CFIndex ma if ( bsdPathAsCFString ) { size_t devPathLength; strcpy( bsdPath, _PATH_DEV ); - strcat( bsdPath, "r" ); + if (flags & BDRV_O_NOCACHE) { + strcat(bsdPath, "r"); + } devPathLength =3D strlen( bsdPath ); if ( CFStringGetCString( bsdPathAsCFString, bsdPath + = devPathLength, maxPathSize - devPathLength, kCFStringEncodingASCII ) ) { kernResult =3D KERN_SUCCESS; @@ -2126,8 +2129,8 @@ static int hdev_open(BlockDriverState *bs, QDict = *options, int flags, int fd; =20 kernResult =3D FindEjectableCDMedia( &mediaIterator ); - kernResult =3D GetBSDPath( mediaIterator, bsdPath, sizeof( = bsdPath ) ); - + kernResult =3D GetBSDPath(mediaIterator, bsdPath, = sizeof(bsdPath), + = flags); if ( bsdPath[ 0 ] !=3D '\0' ) { strcat(bsdPath,"s0"); /* some CDs don't have a partition 0 */ --=20 1.7.5.4 --Apple-Mail-46-145782555 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Add support for = caching options that can be specified from
the command = line. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>= ;

---
 block/raw-posix.c | =   15 +++++++++------
 1 files changed, 9 = insertions(+), 6 deletions(-)

diff = --git a/block/raw-posix.c b/block/raw-posix.c
index = cbe6574..67d1d48 100644
--- a/block/raw-posix.c
+++ = b/block/raw-posix.c
@@ -1973,8 +1973,8 @@ BlockDriver bdrv_file =3D = {

 

-static kern_return_t GetBSDPath( io_iterator_t = mediaIterator, char *bsdPath, CFIndex maxPathSize );
+static kern_return_t GetBSDPath(io_iterator_t = mediaIterator, char *bsdPath,
+          =                     =   CFIndex maxPathSize, int flags);
 kern_return_t = FindEjectableCDMedia( io_iterator_t *mediaIterator )
     kern_return_t     =   kernResult;
@@ -2001,7 +2001,8 @@ kern_return_t = FindEjectableCDMedia( io_iterator_t *mediaIterator )
 }

 

+kern_return_t GetBSDPath(io_iterator_t = mediaIterator, char *bsdPath,
+           =               CFIndex maxPathSize, = int flags)
 {
     io_object_t =     nextMedia;
     kern_return_t =   kernResult =3D KERN_FAILURE;
@@ -2014,7 +2015,9 @@ kern_return_t = GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex = ma
             = strcpy( bsdPath, _PATH_DEV );
-          =   strcat( bsdPath, "r" );
+          =   if (flags & BDRV_O_NOCACHE) {
+        =         strcat(bsdPath, "r");
             if = ( CFStringGetCString( bsdPathAsCFString, bsdPath + devPathLength, = maxPathSize - devPathLength, kCFStringEncodingASCII ) ) {
@@ -2126,8 +2129,8 @@ static int = hdev_open(BlockDriverState *bs, QDict *options, int flags,
 

-        kernResult =3D = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );
+        kernResult =3D = GetBSDPath(mediaIterator, bsdPath, sizeof(bsdPath),
             /* = some CDs don't have a partition 0 */
-- 
1.7.5.4

= --Apple-Mail-46-145782555--