block/vvfat: Propagate errors through init_directories()
Completes the conversion of the open method to Error started in commit
015a103
.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
68c70af16d
commit
d11c8917b2
|
@ -831,7 +831,8 @@ static inline off_t cluster2sector(BDRVVVFATState* s, uint32_t cluster_num)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_directories(BDRVVVFATState* s,
|
static int init_directories(BDRVVVFATState* s,
|
||||||
const char *dirname, int heads, int secs)
|
const char *dirname, int heads, int secs,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
bootsector_t* bootsector;
|
bootsector_t* bootsector;
|
||||||
mapping_t* mapping;
|
mapping_t* mapping;
|
||||||
|
@ -892,7 +893,7 @@ static int init_directories(BDRVVVFATState* s,
|
||||||
if (mapping->mode & MODE_DIRECTORY) {
|
if (mapping->mode & MODE_DIRECTORY) {
|
||||||
mapping->begin = cluster;
|
mapping->begin = cluster;
|
||||||
if(read_directory(s, i)) {
|
if(read_directory(s, i)) {
|
||||||
fprintf(stderr, "Could not read directory %s\n",
|
error_setg(errp, "Could not read directory %s",
|
||||||
mapping->path);
|
mapping->path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -919,9 +920,10 @@ static int init_directories(BDRVVVFATState* s,
|
||||||
cluster = mapping->end;
|
cluster = mapping->end;
|
||||||
|
|
||||||
if(cluster > s->cluster_count) {
|
if(cluster > s->cluster_count) {
|
||||||
fprintf(stderr,"Directory does not fit in FAT%d (capacity %.2f MB)\n",
|
error_setg(errp,
|
||||||
|
"Directory does not fit in FAT%d (capacity %.2f MB)",
|
||||||
s->fat_type, s->sector_count / 2000.0);
|
s->fat_type, s->sector_count / 2000.0);
|
||||||
return -EINVAL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fix fat for entry */
|
/* fix fat for entry */
|
||||||
|
@ -1169,7 +1171,7 @@ DLOG(if (stderr == NULL) {
|
||||||
|
|
||||||
bs->total_sectors = cyls * heads * secs;
|
bs->total_sectors = cyls * heads * secs;
|
||||||
|
|
||||||
if (init_directories(s, dirname, heads, secs)) {
|
if (init_directories(s, dirname, heads, secs, errp)) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue