[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/30] block: simplify path_is_absolute
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 17/30] block: simplify path_is_absolute |
Date: |
Thu, 10 May 2012 13:49:21 +0200 |
From: Paolo Bonzini <address@hidden>
On Windows, all the logic is already in is_windows_drive and
is_windows_drive_prefix. On POSIX, there is no need to look
out for colons.
The win32 code changes the behaviour in some cases, we could have
something like "d:foo.img". The old code would treat it as relative
path, the new one as absolute. Now the path is absolute, because to
go from c:/program files/blah to d:foo.img you cannot say c:/program
files/blah/d:foo.img. You have to say d:foo.img. But you could also
say it's relative because (I think, at least it was like that in DOS
15 years ago) d:foo.img is relative to the current path of drive D.
Considering how path_is_absolute is used by path_combine, I think it's
better to treat it as absolute.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/block.c b/block.c
index 2978135..0fb188f 100644
--- a/block.c
+++ b/block.c
@@ -210,21 +210,14 @@ static int path_has_protocol(const char *path)
int path_is_absolute(const char *path)
{
- const char *p;
#ifdef _WIN32
/* specific case for names like: "\\.\d:" */
- if (*path == '/' || *path == '\\')
+ if (is_windows_drive(path) || is_windows_drive_prefix(path)) {
return 1;
-#endif
- p = strchr(path, ':');
- if (p)
- p++;
- else
- p = path;
-#ifdef _WIN32
- return (*p == '/' || *p == '\\');
+ }
+ return (*path == '/' || *path == '\\');
#else
- return (*p == '/');
+ return (*path == '/');
#endif
}
--
1.7.6.5
- [Qemu-devel] [PATCH 03/30] block: fail live snapshot if disk has no medium, (continued)
- [Qemu-devel] [PATCH 03/30] block: fail live snapshot if disk has no medium, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 04/30] block: push bdrv_change_backing_file error checking up from drivers, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 10/30] qtest: Add floppy test, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 06/30] block: open backing file as read-only when probing for size, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 09/30] qtest: Add function to send QMP commands, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 12/30] block: another bdrv_append fix, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 07/30] block: fix allocation size for dirty bitmap, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 02/30] block: add mode argument to blockdev-snapshot-sync, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 05/30] block: update in-memory backing file and format, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 14/30] block: fully delete bs->file when closing, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 17/30] block: simplify path_is_absolute,
Kevin Wolf <=
- [Qemu-devel] [PATCH 08/30] qemu-iotests: strip spaces from qemu-img/qemu-io/qemu command lines, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 13/30] block: do not reuse the backing file across bdrv_close/bdrv_open, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 20/30] qemu-img: make "info" backing file output correct and easier to use, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 18/30] block: protect path_has_protocol from filenames with colons, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 11/30] block: fix snapshot on QED, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 15/30] block: add block_job_sleep_ns, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 16/30] block: wait for job callback in block_job_cancel_sync, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 23/30] stream: fix sectors not allocated test, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 19/30] block: move field reset from bdrv_open_common to bdrv_close, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 26/30] stream: fix HMP block_job_set_speed, Kevin Wolf, 2012/05/10