From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/6] fw_cfg: rom loader tweaks.
Date: Fri, 8 Jan 2010 15:25:39 +0100 [thread overview]
Message-ID: <1262960742-18267-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1262960742-18267-1-git-send-email-kraxel@redhat.com>
Changes:
- make dir argument mandatory, we allways have one anyway
(vgaroms or genroms).
- check for duplicates, skip loading if found.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/fw_cfg.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index fe9c527..ea120ba 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -278,7 +278,7 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
uint8_t *data, uint32_t len)
{
const char *basename;
- int index;
+ int i, index;
if (!s->files) {
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
@@ -300,13 +300,17 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
} else {
basename = filename;
}
- if (dir) {
- snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
- "%s/%s", dir, basename);
- } else {
- snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
- "%s", basename);
+
+ snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
+ "%s/%s", dir, basename);
+ for (i = 0; i < index; i++) {
+ if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
+ FW_CFG_DPRINTF("%s: skip duplicate: %s\n", __FUNCTION__,
+ s->files->f[index].name);
+ return 1;
+ }
}
+
s->files->f[index].size = cpu_to_be32(len);
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
--
1.6.5.2
next prev parent reply other threads:[~2010-01-08 14:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-08 14:25 [Qemu-devel] [PATCH 0/6] rom loading saga continued Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 1/6] pc: add machine type for 0.12 Gerd Hoffmann
2010-01-11 19:50 ` Anthony Liguori
2010-01-12 17:10 ` Gerd Hoffmann
2010-01-12 19:18 ` Anthony Liguori
2010-01-12 19:36 ` Anthony Liguori
2010-01-12 20:43 ` Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 2/6] roms: minor fixes and cleanups Gerd Hoffmann
2010-01-08 14:25 ` Gerd Hoffmann [this message]
2010-01-08 14:25 ` [Qemu-devel] [PATCH 4/6] roms: rework rom loading via fw Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 5/6] pci: allow loading roms via fw_cfg Gerd Hoffmann
2010-01-08 14:25 ` [Qemu-devel] [PATCH 6/6] pc: add rombar to compat properties for pc-0.10 and pc-0.11 Gerd Hoffmann
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=1262960742-18267-4-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).