diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-12-08 13:35:06 +0200 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-12-11 21:32:46 +0000 |
commit | de1f34cb6351c028ebcc61fea9fa78008ca1a529 (patch) | |
tree | 5741f0c6de842fd7966eb6df47dbd0adb94da6d7 /hw/fw_cfg.c | |
parent | 1ca4d09ae0bcc2fdd6aeef0fdc11f82394f7e757 (diff) |
Change fw_cfg_add_file() to get full file path as a parameter.
Change fw_cfg_add_file() to get full file path as a parameter instead
of building one internally. Two reasons for that. First caller may need
to know how file is named. Second this moves policy of file naming out
from fw_cfg. Platform may want to use more then two levels of
directories for instance.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/fw_cfg.c')
-rw-r--r-- | hw/fw_cfg.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 48b92d69ef..957466dea1 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -277,10 +277,9 @@ int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback, return 1; } -int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename, - uint8_t *data, uint32_t len) +int fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data, + uint32_t len) { - const char *basename; int i, index; if (!s->files) { @@ -297,15 +296,8 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename, fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len); - basename = strrchr(filename, '/'); - if (basename) { - basename++; - } else { - basename = filename; - } - - snprintf(s->files->f[index].name, sizeof(s->files->f[index].name), - "%s/%s", dir, basename); + pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), + filename); 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__, |