From patchwork Fri May 25 12:07:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8972 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D53B823E37 for ; Fri, 25 May 2012 12:07:11 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 96C89A1896D for ; Fri, 25 May 2012 12:07:11 +0000 (UTC) Received: by yenq6 with SMTP id q6so300803yen.11 for ; Fri, 25 May 2012 05:07:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=otzszg+EehomoLpJpqFztRzXsN8yLe64vKRx/fzOlwo=; b=cxsTBwOr4BdFRpkQypnQoYjkrX1JyIq4mI2t6GhcQu7K+hdlStBdhewGEXW2OVbknd HH153OvKRrDl4fto8Z6Zbk5N+WgruIsQdmyKkzy3SekWsNK7dSrhgwp/rm4JB8hGLBQG EanYTJCJYtjhnw4kcImviPLAOHxZFZamnyOKTAts7dkrYGWA1G7CtqK77wn7eLuRSaRF 5eCSpLvpiHbNqHNp05rDNP0XapgWGXiTm0/CXCMtkO9CYG1kymcbzj4vZBjesGiy2M06 7Rh0dqacODLAWmlhJQbTG84jCELPzmquobEXzxJ3MNiIT/TxDUmygo4Hf7uCUKEcLX6B j0mg== Received: by 10.50.222.202 with SMTP id qo10mr8411220igc.0.1337947630789; Fri, 25 May 2012 05:07:10 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp15240ibb; Fri, 25 May 2012 05:07:09 -0700 (PDT) Received: by 10.216.141.15 with SMTP id f15mr1568463wej.82.1337947629088; Fri, 25 May 2012 05:07:09 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id g5si3304138wel.78.2012.05.25.05.07.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 May 2012 05:07:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1SXtIL-0002FJ-EL; Fri, 25 May 2012 13:07:01 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori Subject: [PATCH] qemu_find_file: check name as a straight path even if it has no '/' Date: Fri, 25 May 2012 13:07:01 +0100 Message-Id: <1337947621-8610-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQmYfgWjprjSDtxsxhoqf2pl/bMDwM2oTjJbr6zRbp3odiSt6/r5H/l5c1oRS3blzm64bpgw Make qemu_find_file() check for the passed in name as a straight pathname even if it doesn't have any path separator character in it. This means that "-bios foo", "-dtb foo" etc will find a file 'foo' in the current directory. This removes an inconsistency with -kernel and -initrd, which both accept plain filenames as meaning files in the current directory. It's also less confusing for the user than an undocumented restriction that "this option accepts a filename, except for the special case where the filename you pass happens not to have a '/' in it, in which case we'll ignore it." Signed-off-by: Peter Maydell --- vl.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 23ab3a3..4639526 100644 --- a/vl.c +++ b/vl.c @@ -1801,9 +1801,8 @@ char *qemu_find_file(int type, const char *name) const char *subdir; char *buf; - /* If name contains path separators then try it as a straight path. */ - if ((strchr(name, '/') || strchr(name, '\\')) - && access(name, R_OK) == 0) { + /* Try the name as a straight path first */ + if (access(name, R_OK) == 0) { return g_strdup(name); } switch (type) {