Skip to contentSkip to conversation

qemu_find_file: check name as a straight path even if it has no '/'

PATCH In review Peter Maydell 3 participants 5 messages May 25, 2012 – Jul 10, 2012 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu_find_file: check name as a straight path even if it has no '/'

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."

---
 vl.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
vl.c +2 -3
index 23ab3a3..4639526 100644
@@ -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) {
Signature · 1 line
1.7.1
#1 lore raw

Am 25.05.2012 14:07, schrieb Peter Maydell:

Quoted 11 lines

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."

Quoted 1 line

Speaking of inconsistencies, I also noticed that the ppc virtex-ml507 machine relies on the .dtb being in the current directory with apparently no way to override. Any chance this can be fixed, Edgar? Maybe it can be unified with the dtb handling on ARM or share the same QemuOpts?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
Quoted 12 lines · Andreas Färber

Am 25.05.2012 14:07, schrieb Peter Maydell:

Quoted 11 lines

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."

Quoted 7 lines
Quoted 1 line

Speaking of inconsistencies, I also noticed that the ppc virtex-ml507 machine relies on the .dtb being in the current directory with apparently no way to override. Any chance this can be fixed, Edgar? Maybe it can be unified with the dtb handling on ARM or share the same QemuOpts?

Yes, absolutely!

Best regards,
Edgar

#3 lore raw
In reply to Peter Maydell

Ping? (patch still applies cleanly to current master; patchwork URL
http://patchwork.ozlabs.org/patch/161324/ )

-- PMM

Quoted 34 lines · Peter Maydell

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."

---
 vl.c |    5 ++---

 1 files changed, 2 insertions(+), 3 deletions(-)
vl.c +2 -4
index 23ab3a3..4639526 100644
@@ -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) {
--

1.7.1

A message that is not in the archive (sent off-list or not yet received): CAFEAcA9KHcJjrK7pzTd7Pexi1Sq46V1DOosoGPS4XxiF2si-yQ@mail.gmail.com

#5 lore raw

Ping^3? This patch has been on the list over six weeks now...

-- PMM

Quoted 45 lines · Peter Maydell

Ping^2?

-- PMM

Quoted 40 lines · Peter Maydell

Ping? (patch still applies cleanly to current master; patchwork URL
http://patchwork.ozlabs.org/patch/161324/ )

-- PMM

Quoted 34 lines · Peter Maydell

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."

---
 vl.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
vl.c +2 -4
index 23ab3a3..4639526 100644
@@ -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) {
--

1.7.1