Skip to content

Commit

Permalink
lib-fs: If fs_get_metadata() isn't implemented, return internal metad…
Browse files Browse the repository at this point in the history
…ata anyway

The metadata is sometimes used for transferring internal metadata within the
files. This metadata isn't stored to disk. So even if the fs driver doesn't
support metadata at all, it should still be possible to get/set the internal
metadata. Setting it was already possible, but getting wasn't.
  • Loading branch information
sirainen authored and villesavolainen committed Feb 12, 2019
1 parent 88b909c commit 3bef9e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib-fs/fs-api.c
Expand Up @@ -471,6 +471,11 @@ int fs_get_metadata(struct fs_file *file,
int ret;

if (file->fs->v.get_metadata == NULL) {
if (array_is_created(&file->metadata)) {
/* Return internal metadata. */
*metadata_r = &file->metadata;
return 0;
}
fs_set_error(file->fs, "Metadata not supported by backend");
return -1;
}
Expand Down

0 comments on commit 3bef9e5

Please sign in to comment.