mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-07 15:01:44 +00:00
tools: hv: report ENOSPC errors in hv_fcopy_daemon
Currently some "Unspecified error 0x80004005" is reported on the Windows side if something fails. Handle the ENOSPC case and return ERROR_DISK_FULL, which allows at least Copy-VMFile to report a meaning full error. Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3cace4a616
commit
b4ed5d1682
2 changed files with 18 additions and 3 deletions
|
@ -313,6 +313,7 @@ enum hv_kvp_exchg_pool {
|
||||||
#define HV_INVALIDARG 0x80070057
|
#define HV_INVALIDARG 0x80070057
|
||||||
#define HV_GUID_NOTFOUND 0x80041002
|
#define HV_GUID_NOTFOUND 0x80041002
|
||||||
#define HV_ERROR_ALREADY_EXISTS 0x80070050
|
#define HV_ERROR_ALREADY_EXISTS 0x80070050
|
||||||
|
#define HV_ERROR_DISK_FULL 0x80070070
|
||||||
|
|
||||||
#define ADDR_FAMILY_NONE 0x00
|
#define ADDR_FAMILY_NONE 0x00
|
||||||
#define ADDR_FAMILY_IPV4 0x01
|
#define ADDR_FAMILY_IPV4 0x01
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
|
|
||||||
static int target_fd;
|
static int target_fd;
|
||||||
static char target_fname[W_MAX_PATH];
|
static char target_fname[W_MAX_PATH];
|
||||||
|
static unsigned long long filesize;
|
||||||
|
|
||||||
static int hv_start_fcopy(struct hv_start_fcopy *smsg)
|
static int hv_start_fcopy(struct hv_start_fcopy *smsg)
|
||||||
{
|
{
|
||||||
int error = HV_E_FAIL;
|
int error = HV_E_FAIL;
|
||||||
char *q, *p;
|
char *q, *p;
|
||||||
|
|
||||||
|
filesize = 0;
|
||||||
p = (char *)smsg->path_name;
|
p = (char *)smsg->path_name;
|
||||||
snprintf(target_fname, sizeof(target_fname), "%s/%s",
|
snprintf(target_fname, sizeof(target_fname), "%s/%s",
|
||||||
(char *)smsg->path_name, (char *)smsg->file_name);
|
(char *)smsg->path_name, (char *)smsg->file_name);
|
||||||
|
@ -98,14 +100,26 @@ done:
|
||||||
static int hv_copy_data(struct hv_do_fcopy *cpmsg)
|
static int hv_copy_data(struct hv_do_fcopy *cpmsg)
|
||||||
{
|
{
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
|
bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
|
||||||
cpmsg->offset);
|
cpmsg->offset);
|
||||||
|
|
||||||
if (bytes_written != cpmsg->size)
|
filesize += cpmsg->size;
|
||||||
return HV_E_FAIL;
|
if (bytes_written != cpmsg->size) {
|
||||||
|
switch (errno) {
|
||||||
|
case ENOSPC:
|
||||||
|
ret = HV_ERROR_DISK_FULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = HV_E_FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
syslog(LOG_ERR, "pwrite failed to write %llu bytes: %ld (%s)",
|
||||||
|
filesize, (long)bytes_written, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hv_copy_finished(void)
|
static int hv_copy_finished(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue