From patchwork Mon Jul 27 16:28:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 500492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B6F72140313 for ; Tue, 28 Jul 2015 02:28:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=IcmIoeSB; dkim-atps=neutral Received: from localhost ([::1]:54548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJlGQ-0000th-5Y for incoming@patchwork.ozlabs.org; Mon, 27 Jul 2015 12:28:30 -0400 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 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]:36807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJlG2-0007zt-Rd; Mon, 27 Jul 2015 12:28:07 -0400 Received: by qges31 with SMTP id s31so8797817qge.3; Mon, 27 Jul 2015 09:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:cc:to:mime-version; bh=57JP2NMLxOazkNE2atW7zfOl13BFQMoO9a02s0nC3aE=; b=IcmIoeSBhUsX0Wux0Tb5NT0F8mtK4RChYDgrQcSRzLk4svo1sXtMRBtWBgFLJNGS8V 7SPonFOucCm44MecZAzZUsIK4zokKIaoQ+kI1sbsbn2EwwFKJbb0XZLP+jsjYNKDtUqc 0UOa18b7Fr91c2O4Dwjnn8aldG5h8SdsMFo4HOCZsk5ePSzVy7x1t5+26qcQaKMoNYeG tlifCKEQS8HavHYHMI0ATK9bDczcCDYSjDQb8rvlHxFVROqBR3uNrZoIStyzkB6o7afs K8xhl6Xv/aAwv4WZqaaJkH/m2vx4g/sD7W2R6cgzT1vzAZLBA4chWKOFWB8kOM2nALjL 4j/w== X-Received: by 10.140.239.129 with SMTP id k123mr44256760qhc.66.1438014485929; Mon, 27 Jul 2015 09:28:05 -0700 (PDT) Received: from [192.168.0.6] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id o69sm3400773qga.38.2015.07.27.09.28.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jul 2015 09:28:05 -0700 (PDT) From: Programmingkid Date: Mon, 27 Jul 2015 12:28:03 -0400 Message-Id: To: Stefan Hajnoczi , Kevin Wolf Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::235 Cc: qemu-devel qemu-devel , Qemu-block Subject: [Qemu-devel] [PATCH] raw-posix.c: Make GetBSDPath() handle caching options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add support for caching options that can be specified from the command line. Signed-off-by: John Arbuckle Reviewed-by: Stefan Hajnoczi --- 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 = { #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; } -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 = 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 = strlen( bsdPath ); if ( CFStringGetCString( bsdPathAsCFString, bsdPath + devPathLength, maxPathSize - devPathLength, kCFStringEncodingASCII ) ) { kernResult = KERN_SUCCESS; @@ -2126,8 +2129,8 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, int fd; kernResult = FindEjectableCDMedia( &mediaIterator ); - kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) ); - + kernResult = GetBSDPath(mediaIterator, bsdPath, sizeof(bsdPath), + flags); if ( bsdPath[ 0 ] != '\0' ) { strcat(bsdPath,"s0"); /* some CDs don't have a partition 0 */