if (read_bootsectandvi(&bs, &volinfo, &mydata->fatsize)) {
debug("error: reading boot sector\n");
- return -1;
+ return -EIO;
}
total_sector = bs.total_sect;
mydata->fatbuf = memalign(ARCH_DMA_MINALIGN, FATBUFSIZE);
if (mydata->fatbuf == NULL) {
debug("Error: allocating memory\n");
- return -1;
+ return -ENOMEM;
}
if (disk_read(cursect,
(mydata->clust_size) :
PREFETCH_BLOCKS, do_fat_read_at_block) < 0) {
debug("Error: reading rootdir block\n");
+ ret = -EIO;
goto exit;
}
dentptr = (dir_entry *) do_fat_read_at_block;
size);
if (ret) {
printf("Error: %llu overflow\n", size);
+ ret = -ENOSPC;
goto exit;
}
}
ret = clear_fatent(mydata, start_cluster);
if (ret) {
printf("Error: clearing FAT entries\n");
+ ret = -EIO;
goto exit;
}
ret = start_cluster = find_empty_cluster(mydata);
if (ret < 0) {
printf("Error: finding empty cluster\n");
+ ret = -ENOSPC;
goto exit;
}
ret = check_overflow(mydata, start_cluster, size);
if (ret) {
printf("Error: %llu overflow\n", size);
+ ret = -ENOSPC;
goto exit;
}
ret = start_cluster = find_empty_cluster(mydata);
if (ret < 0) {
printf("Error: finding empty cluster\n");
+ ret = -ENOSPC;
goto exit;
}
ret = check_overflow(mydata, start_cluster, size);
if (ret) {
printf("Error: %llu overflow\n", size);
+ ret = -ENOSPC;
goto exit;
}
} else {
ret = set_contents(mydata, retdent, buffer, size, actwrite);
if (ret < 0) {
printf("Error: writing contents\n");
+ ret = -EIO;
goto exit;
}
debug("attempt to write 0x%llx bytes\n", *actwrite);
ret = flush_dirty_fat_buffer(mydata);
if (ret) {
printf("Error: flush fat buffer\n");
+ ret = -EIO;
goto exit;
}
/* Write directory table to device */
ret = set_cluster(mydata, dir_curclust, get_dentfromdir_block,
mydata->clust_size * mydata->sect_size);
- if (ret)
+ if (ret) {
printf("Error: writing directory entry\n");
+ ret = -EIO;
+ }
exit:
free(mydata->fatbuf);
{
if (offset != 0) {
printf("Error: non zero offset is currently not supported.\n");
- return -1;
+ return -EINVAL;
}
printf("writing %s\n", filename);