From: Lorenzo Campedelli <lorenzo.campedelli@tele2.it>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] vvfat mbr fixes
Date: Sun, 23 Sep 2007 17:55:02 +0200 [thread overview]
Message-ID: <46F68C56.8000408@tele2.it> (raw)
In-Reply-To: <Pine.LNX.4.64.0709231223040.28395@racer.site>
[-- Attachment #1: Type: text/plain, Size: 1638 bytes --]
Johannes Schindelin wrote:
> Hi,
>
> On Sun, 23 Sep 2007, Lorenzo Campedelli wrote:
>
>> While you are working on vvfat issues, could you give a look to the
>> attached small patch?
>
> Okay, this is what I would do:
>
> - not make this handling dependent on vvfat (but this means checking if
> the colon is the second character, because then it is most likely
> a Windows path and does _not_ want special handling), and
>
> - I'd use the result of strrchr() directly.
>
> This is a sketch of the code I propose:
>
> const char *tmp;
>
> ...
>
> get_tmp_filename(tmp_filename, sizeof(tmp_filename));
> /* Handle 'fat:rw:<filename>' */
> tmp = strrchr(backing_filename, ':');
> if (tmp - backing_filename == 2) /* DOS path */
> tmp = NULL;
> else if (tmp - backing_filename > 2 && tmp[-2] == ':')
> tmp -= 2;
> realpath(filename, tmp ? tmp : backing_filename);
>
> Ciao,
> Dscho
>
>
>
>
Hi Johannes,
thanks for your reply. I gave another try at the patch.
I was concerned by having this handling outside of a proper
place (i.e. block-vvfat.c), but if we want to leave it there,
wouldn't it be better to just handle cases which would otherwise
fail, and just try to fix the "fat:" format?
The attached patch only tries to fix things when realpath() fails
to find a match and when the filename starts with a "fat:" header.
This way if anybody really wanted to use an image file named "fat:foo"
could do it without us handling it as a vvfat directory...
The code to handle the search for ':' and the DOS drive name special
case is stolen from block-vvfat.c, so you should like it ;-).
Regards,
Lorenzo
[-- Attachment #2: qemu-0.9.0.20070921-block.c.patch --]
[-- Type: text/x-patch, Size: 954 bytes --]
--- qemu-0.9.0.20070921/block.c.orig 2007-09-23 17:04:21.000000000 +0200
+++ qemu-0.9.0.20070921/block.c 2007-09-23 17:18:39.000000000 +0200
@@ -349,7 +349,19 @@
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
- realpath(filename, backing_filename);
+ if (realpath(filename, backing_filename) == NULL) {
+ if (strstart(filename, "fat:", NULL)) {
+ int i = strrchr(filename, ':') - filename;
+
+ if ((filename[i-2] == ':') && isalpha(filename[i-1]))
+ i -= 1; /* workaround for DOS drive names */
+ else
+ i += 1;
+
+ strncpy(backing_filename, filename, i);
+ realpath(filename + i, backing_filename + i);
+ }
+ }
if (bdrv_create(&bdrv_qcow2, tmp_filename,
total_size, backing_filename, 0) < 0) {
return -1;
next prev parent reply other threads:[~2007-09-23 15:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-22 21:43 [Qemu-devel] [PATCH] vvfat mbr fixes Ivan Kalvachev
2007-09-22 22:48 ` Johannes Schindelin
2007-09-23 7:31 ` [Qemu-devel] " Lorenzo Campedelli
2007-09-23 11:34 ` Johannes Schindelin
2007-09-23 15:55 ` Lorenzo Campedelli [this message]
2007-09-23 19:18 ` Johannes Schindelin
2007-09-23 20:17 ` Lorenzo Campedelli
2007-09-24 10:50 ` [Qemu-devel] " Ivan Kalvachev
2007-09-24 11:18 ` Johannes Schindelin
2007-09-24 14:12 ` Ivan Kalvachev
2007-09-24 15:32 ` Johannes Schindelin
2007-09-24 17:23 ` Ivan Kalvachev
2007-09-24 19:19 ` [Qemu-devel] " Lorenzo Campedelli
2007-09-24 21:58 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46F68C56.8000408@tele2.it \
--to=lorenzo.campedelli@tele2.it \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.