Drivers: hv: Implement the file copy service
PATCH v2 1/1 Drivers: hv: Implement the file copy service
Implement the file copy service for Linux guests on Hyper-V. This permits the host to copy a file (over VMBUS) into the guest. This facility is part of "guest integration services" supported on the Windows platform. Here is a link that provides additional details on this functionality:
http://technet.microsoft.com/en-us/library/dn464282.aspx
In V1 version of the patch I have addressed comments from Olaf Hering <[email protected]> and Dan Carpenter <[email protected]>
In this version of the patch I have made globals static.
--- drivers/hv/Makefile | 2 +- drivers/hv/hv_fcopy.c | 422 ++++++++++++++++++++++++++++++++++++++++++++ drivers/hv/hv_util.c | 10 + include/linux/hyperv.h | 60 +++++++ tools/hv/hv_fcopy_daemon.c | 174 ++++++++++++++++++ 5 files changed, 667 insertions(+), 1 deletions(-) create mode 100644 drivers/hv/hv_fcopy.c create mode 100644 tools/hv/hv_fcopy_daemon.c
drivers/hv/Makefile +1 -1
@@ -5,4 +5,4 @@ obj-$(CONFIG_HYPERV_BALLOON) += hv_balloon.o hv_vmbus-y := vmbus_drv.o \ hv.o connection.o channel.o \ channel_mgmt.o ring_buffer.o -hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o +hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o
drivers/hv/hv_fcopy.c new file +422 -0
422 lines not on this page · raw message
drivers/hv/hv_util.c +10 -0
@@ -82,6 +82,12 @@ static struct hv_util_service util_vss = { .util_deinit = hv_vss_deinit, }; +static struct hv_util_service util_fcopy = { + .util_cb = hv_fcopy_onchannelcallback, + .util_init = hv_fcopy_init, + .util_deinit = hv_fcopy_deinit, +}; +static void perform_shutdown (struct work_struct *dummy) {orderly_poweroff (true);
@@ -401,6 +407,10 @@ static const struct hv_vmbus_device_id id_table[] = { { HV_VSS_GUID, .driver_data = (unsigned long )&util_vss }, + /* File copy GUID */ + { HV_FCOPY_GUID, + .driver_data = (unsigned long )&util_fcopy + }, { }, };
include/linux/hyperv.h +60 -0
84 lines not on this page · raw message
tools/hv/hv_fcopy_daemon.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Quoted 11 lines · K. Y. Srinivasan
drivers/hv/hv_fcopy.c new file +11
-0+static ssize_t fcopy_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +int error =0 ; + +if (count !=sizeof (int )) +return 0 ; + +if (copy_from_user (&error, buf,sizeof (int ))) +return -EFAULT ; +
drivers/hv/hv_fcopy.c
Quoted 10 lines
drivers/hv/hv_fcopy.c new file +8
-0+if (in_hand_shake) { +fcopy_handle_handshake (); +return 0 ; + } +/* +* Register with the kernel. +*/ +write (fcopy_fd, &version,sizeof (int ));
Shouldnt there be some version check already even in this initial implementation? What if there will be a newer daemon running on an older kernel?
Olaf
Quoted 30 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Tuesday, January 14, 2014 2:13 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceQuoted 15 lines · K. Y. Srinivasan
drivers/hv/hv_fcopy.c new file +15
-0+static ssize_t fcopy_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +int error =0 ; + +if (count !=sizeof (int )) +return 0 ; + +if (copy_from_user (&error, buf,sizeof (int ))) +return -EFAULT ; + +if (in_hand_shake) { +fcopy_handle_handshake (); +return 0 ; + }
Quoted 9 lines
tools/hv/hv_fcopy_daemon.c line 133
Quoted 4 lines
tools/hv/hv_fcopy_daemon.c new file +4
-0+/* +* Register with the kernel. +*/ +write (fcopy_fd, &version,sizeof (int ));Shouldnt there be some version check already even in this initial implementation? What if there will be a newer daemon running on an older kernel?
Currently, the daemon registers with the kernel passing its version number. I will make the version check "real".
Thanks,
K. Y
Quoted 2 lines
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
tools/hv/hv_fcopy_daemon.c line 54
Quoted 5 lines · K. Y. Srinivasan
tools/hv/hv_fcopy_daemon.c new file +4
-0+static int hv_start_fcopy (struct hv_start_fcopy *smsg) + if (access((char *)smsg->path_name, F_OK)) { +if (smsg->copy_flags &CREATE_PATH ) { +if (mkdir ((char *)smsg->path_name,0755 )) {
KY,
I guess this needs a loop over every path compoment to implement 'mkdir -p', if the "-CreateFullPath" option is used?
Hopefully "-DestinationPath" is an arbitrary string and does not require some sort of C: prefix. ;-)
Olaf
Quoted 14 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Wednesday, January 15, 2014 8:33 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceQuoted 1 line · K. Y. Srinivasan
+static int
hv_start_fcopy(struct hv_start_fcopy *smsg)
Quoted 8 lines
tools/hv/hv_fcopy_daemon.c line 54
Quoted 3 lines
tools/hv/hv_fcopy_daemon.c new file +3
-0+if (access ((char *)smsg->path_name,F_OK )) { +if (smsg->copy_flags &CREATE_PATH ) { +if (mkdir ((char *)smsg->path_name,0755 )) {KY,
I guess this needs a loop over every path compoment to implement 'mkdir -p', if the "-CreateFullPath" option is used?
Yes; I will make the change. The good news is that for the destination path and file name, the host does not interpret the path components.
Regards,
K. Y
Quoted 6 lines
Hopefully "-DestinationPath" is an arbitrary string and does not require some sort of C: prefix. ;-)
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
include/linux/hyperv.h struct hv_vss_msg { · line 117
Quoted 12 lines · K. Y. Srinivasan
include/linux/hyperv.h +12
-0+enum hv_fcopy_op { +START_FILE_COPY =0 , +WRITE_TO_FILE , +COMPLETE_FCOPY , +CANCEL_FCOPY , +}; + +struct hv_fcopy_hdr { +enum hv_fcopy_op operation; +uuid_le service_id0;/* currently unused */ +uuid_le service_id1;/* currently unused */ +} __attribute__((packed));
Is enum a fixed size? This struct is used in other structs, so I wonder what will happen to the kernel/user protocol if any of that changes. Or with a 64bit kernel and 32bit daemon. Maybe operation should be __u32?
Olaf
Quoted 12 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Thursday, January 16, 2014 1:42 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceOn Tue, Jan 14, K. Y. Srinivasan wrote:
Quoted 16 lines
include/linux/hyperv.h struct hv_vss_msg { · line 117
Quoted 12 lines
include/linux/hyperv.h +12
-0+enum hv_fcopy_op { +START_FILE_COPY =0 , +WRITE_TO_FILE , +COMPLETE_FCOPY , +CANCEL_FCOPY , +}; + +struct hv_fcopy_hdr { +enum hv_fcopy_op operation; +uuid_le service_id0;/* currently unused */ +uuid_le service_id1;/* currently unused */ +} __attribute__((packed));Is enum a fixed size? This struct is used in other structs, so I wonder what will happen to the kernel/user protocol if any of that changes. Or with a 64bit kernel and 32bit daemon. Maybe operation should be
__u32?
I will check and make the necessary changes.
Thank you,
K. Y
Quoted 3 lines
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 16 lines · Olaf Hering
include/linux/hyperv.h struct hv_vss_msg { · line 117
Quoted 12 lines · K. Y. Srinivasan
include/linux/hyperv.h +12
-0+enum hv_fcopy_op { +START_FILE_COPY =0 , +WRITE_TO_FILE , +COMPLETE_FCOPY , +CANCEL_FCOPY , +}; + +struct hv_fcopy_hdr { +enum hv_fcopy_op operation; +uuid_le service_id0;/* currently unused */ +uuid_le service_id1;/* currently unused */ +} __attribute__((packed));Is enum a fixed size?
No, it's not. The compiler has a lot of latitude in choosing the size for enums.
regards,
dan carpenter
include/linux/hyperv.h line 30
Quoted 7 lines · K. Y. Srinivasan
+++
b/include/linux/hyperv.hinclude/linux/hyperv.h +2
-0@@ -26,6 +26,8 @@#define _HYPERV_H#include <linux/types.h> +#include <linux/uuid.h> +#include <linux/limits.h>
limits.h is not required.
Olaf
Quoted 16 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Thursday, January 16, 2014 2:17 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceQuoted 4 lines · K. Y. Srinivasan
+++
b/include/linux/hyperv.hinclude/linux/hyperv.h +0
-0@@ -26,6 +26,8 @@#define _HYPERV_H
Quoted 5 lines
include/linux/hyperv.h line 30
Quoted 3 lines
include/linux/hyperv.h +2
-0#include <linux/types.h> +#include <linux/uuid.h> +#include <linux/limits.h>
limits.his not required.
Will get rid of it.
Thanks,
K. Y
Quoted 2 lines
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 4 lines · K. Y. Srinivasan
Implement the file copy service for Linux guests on Hyper-V. This permits the host to copy a file (over VMBUS) into the guest. This facility is part of "guest integration services" supported on the Windows platform. Here is a link that provides additional details on this functionality:
The change below fixes some warnings in the daemon code. Compile tested only.
I also think the newlines in some of the syslog calls should be removed.
Olaf
hv_fcopy_daemon.c: In function 'hv_start_fcopy':
hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16 *' [-Wformat=]
smsg->file_name);
^
hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 5 has type '__u16 *' [-Wformat=] hv_fcopy_daemon.c:57:6: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16 *' [-Wformat=]
errno, strerror(errno));
^
hv_fcopy_daemon.c:61:4: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16 *' [-Wformat=]
syslog(LOG_ERR, "Invalid path: %s\n", smsg->path_name);
^
hv_fcopy_daemon.c: In function 'main':
hv_fcopy_daemon.c:117:8: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result [-Wunused-result]
daemon(1, 0);
^
hv_fcopy_daemon.c:132:7: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
write(fcopy_fd, &version, sizeof(int));
^
hv_fcopy_daemon.c:171:9: warning: ignoring return value of 'pwrite', declared with attribute warn_unused_result [-Wunused-result]
pwrite(fcopy_fd, &error, sizeof(int), 0);
^tools/hv/hv_fcopy_daemon.c +15 -8
@@ -35,14 +35,14 @@#include <dirent.h> static int target_fd; -char target_fname[W_MAX_PATH ]; +static char target_fname[W_MAX_PATH ];static int hv_start_fcopy (struct hv_start_fcopy *smsg) {int error =HV_E_FAIL ; -sprintf (target_fname,"%s%s%s" , smsg->path_name,"/" , - smsg->file_name); +snprintf (target_fname,sizeof (target_fname),"%s/%s" , + (char *)smsg->path_name, (char *)smsg->file_name);syslog (LOG_INFO ,"Target file name: %s\n" , target_fname);/*
@@ -54,12 +54,12 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)if (mkdir ((char *)smsg->path_name,0755 )) {syslog (LOG_ERR ,"Failed to create '%s'; error: %d %s\n" , - smsg->path_name, + (char *)smsg->path_name, errno,strerror (errno)); goto done; } }else { -syslog (LOG_ERR ,"Invalid path: %s\n" , smsg->path_name); +syslog (LOG_ERR ,"Invalid path: %s" , (char *)smsg->path_name); goto done; } }
@@ -115,7 +115,8 @@ int main(void)char *buffer[4096 *2 ];struct hv_fcopy_hdr *in_msg; -daemon (1 ,0 ); +if (daemon (1 ,0 )) +return 1 ;openlog ("HV_FCOPY" ,0 ,LOG_USER );syslog (LOG_INFO ,"HV_FCOPY starting; pid is:%d" ,getpid ());
@@ -130,7 +131,10 @@ int main(void)/* * Register with the kernel. */ -write (fcopy_fd, &version,sizeof (int )); +if (write (fcopy_fd, &version,sizeof (int )) !=sizeof (int )) { +syslog (LOG_ERR ,"write failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + }while (1 ) {/*
@@ -169,6 +173,9 @@ int main(void) } -pwrite (fcopy_fd, &error,sizeof (int ),0 ); +if (pwrite (fcopy_fd, &error,sizeof (int ),0 ) !=sizeof (int )) { +syslog (LOG_ERR ,"pwrite failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + } } }
Quoted 117 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Thursday, January 16, 2014 2:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceQuoted 4 lines · K. Y. Srinivasan
Implement the file copy service for Linux guests on Hyper-V. This permits the host to copy a file (over VMBUS) into the guest. This facility is part of "guest integration services" supported on the Windows platform. Here is a link that provides additional details on this functionality:
The change below fixes some warnings in the daemon code. Compile tested only.
I also think the newlines in some of the syslog calls should be removed.Olaf
hv_fcopy_daemon.c: In function 'hv_start_fcopy':
hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16*' [-Wformat=]smsg->file_name); ^hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 5 has type '
__u16*' [-Wformat=] hv_fcopy_daemon.c:57:6: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16*' [-Wformat=]errno, strerror(errno)); ^ hv_fcopy_daemon.c:61:4: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16 *' [-Wformat=] syslog(LOG_ERR, "Invalid path: %s\n", smsg->path_name); ^ hv_fcopy_daemon.c: In function 'main': hv_fcopy_daemon.c:117:8: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result [-Wunused-result] daemon(1, 0); ^ hv_fcopy_daemon.c:132:7: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result] write(fcopy_fd, &version, sizeof(int)); ^ hv_fcopy_daemon.c:171:9: warning: ignoring return value of 'pwrite', declared with attribute warn_unused_result [-Wunused-result] pwrite(fcopy_fd, &error, sizeof(int), 0); ^Signed-off-by Olaf Hering <[email protected]>tools/hv/hv_fcopy_daemon.c +5
-5@@ -35,14 +35,14 @@#include <dirent.h> static int target_fd; -char target_fname[W_MAX_PATH ]; +static char target_fname[W_MAX_PATH ];static int hv_start_fcopy (struct hv_start_fcopy *smsg) {int error =HV_E_FAIL ; -sprintf (target_fname,"%s%s%s" , smsg->path_name,"/" , - smsg->file_name); +snprintf (target_fname,sizeof (target_fname),"%s/%s" , + (char *)smsg->path_name, (char *)smsg->file_name);syslog (LOG_INFO ,"Target file name: %s\n" , target_fname);/* @@ -54,12 +54,12 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)if (mkdir ((char *)smsg->path_name,0755 )) {syslog (LOG_ERR ,"Failed to create '%s'; error: %d %s\n" , - smsg->path_name, + (char *)smsg->path_name, errno,strerror (errno)); goto done; } }else { -syslog (LOG_ERR ,"Invalid path: %s\n" , smsg- >path_name); +syslog (LOG_ERR ,"Invalid path: %s" , (char *)smsg- >path_name); goto done;tools/hv/hv_fcopy_daemon.c +6
-2} }@@ -115,7 +115,8 @@ int main(void)char *buffer[4096 *2 ];struct hv_fcopy_hdr *in_msg; -daemon (1 ,0 ); +if (daemon (1 ,0 )) +return 1 ;openlog ("HV_FCOPY" ,0 ,LOG_USER );syslog (LOG_INFO ,"HV_FCOPY starting; pid is:%d" ,getpid ());@@ -130,7 +131,10 @@ int main(void)/* * Register with the kernel. */ -write (fcopy_fd, &version,sizeof (int )); +if (write (fcopy_fd, &version,sizeof (int )) !=sizeof (int )) { +syslog (LOG_ERR ,"write failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + }while (1 ) {/*
tools/hv/hv_fcopy_daemon.c int main(void) · line 181
Quoted 10 lines
tools/hv/hv_fcopy_daemon.c +4
-1@@ -169,6 +173,9 @@ int main(void) } -pwrite (fcopy_fd, &error,sizeof (int ),0 ); +if (pwrite (fcopy_fd, &error,sizeof (int ),0 ) !=sizeof (int )) { +syslog (LOG_ERR ,"pwrite failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + } } }
Thanks Olaf; I will include these changes in the next version.
K. Y ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Olaf,
I am cleaning up the code based on your feedback. By the time I am done with my cleanup, I doubt if this patch would apply. Do you mind if I were to include your changes here as part of my cleanup?
Thank you,
K. Y
Quoted 115 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Thursday, January 16, 2014 2:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceQuoted 4 lines · K. Y. Srinivasan
Implement the file copy service for Linux guests on Hyper-V. This permits the host to copy a file (over VMBUS) into the guest. This facility is part of "guest integration services" supported on the Windows platform. Here is a link that provides additional details on this functionality:
The change below fixes some warnings in the daemon code. Compile tested only.
I also think the newlines in some of the syslog calls should be removed.Olaf
hv_fcopy_daemon.c: In function 'hv_start_fcopy':
hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16*' [-Wformat=]smsg->file_name); ^hv_fcopy_daemon.c:44:3: warning: format '%s' expects argument of type 'char *', but argument 5 has type '
__u16*' [-Wformat=] hv_fcopy_daemon.c:57:6: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16*' [-Wformat=]errno, strerror(errno)); ^ hv_fcopy_daemon.c:61:4: warning: format '%s' expects argument of type 'char *', but argument 3 has type '__u16 *' [-Wformat=] syslog(LOG_ERR, "Invalid path: %s\n", smsg->path_name); ^ hv_fcopy_daemon.c: In function 'main': hv_fcopy_daemon.c:117:8: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result [-Wunused-result] daemon(1, 0); ^ hv_fcopy_daemon.c:132:7: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result] write(fcopy_fd, &version, sizeof(int)); ^ hv_fcopy_daemon.c:171:9: warning: ignoring return value of 'pwrite', declared with attribute warn_unused_result [-Wunused-result] pwrite(fcopy_fd, &error, sizeof(int), 0); ^Signed-off-by Olaf Hering <[email protected]>tools/hv/hv_fcopy_daemon.c +5
-5@@ -35,14 +35,14 @@#include <dirent.h> static int target_fd; -char target_fname[W_MAX_PATH ]; +static char target_fname[W_MAX_PATH ];static int hv_start_fcopy (struct hv_start_fcopy *smsg) {int error =HV_E_FAIL ; -sprintf (target_fname,"%s%s%s" , smsg->path_name,"/" , - smsg->file_name); +snprintf (target_fname,sizeof (target_fname),"%s/%s" , + (char *)smsg->path_name, (char *)smsg->file_name);syslog (LOG_INFO ,"Target file name: %s\n" , target_fname);/* @@ -54,12 +54,12 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)if (mkdir ((char *)smsg->path_name,0755 )) {syslog (LOG_ERR ,"Failed to create '%s'; error: %d %s\n" , - smsg->path_name, + (char *)smsg->path_name, errno,strerror (errno)); goto done; } }else { -syslog (LOG_ERR ,"Invalid path: %s\n" , smsg- >path_name); +syslog (LOG_ERR ,"Invalid path: %s" , (char *)smsg- >path_name); goto done;tools/hv/hv_fcopy_daemon.c +6
-2} }@@ -115,7 +115,8 @@ int main(void)char *buffer[4096 *2 ];struct hv_fcopy_hdr *in_msg; -daemon (1 ,0 ); +if (daemon (1 ,0 )) +return 1 ;openlog ("HV_FCOPY" ,0 ,LOG_USER );syslog (LOG_INFO ,"HV_FCOPY starting; pid is:%d" ,getpid ());@@ -130,7 +131,10 @@ int main(void)/* * Register with the kernel. */ -write (fcopy_fd, &version,sizeof (int )); +if (write (fcopy_fd, &version,sizeof (int )) !=sizeof (int )) { +syslog (LOG_ERR ,"write failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + }while (1 ) {/*
tools/hv/hv_fcopy_daemon.c int main(void) · line 181
Quoted 10 lines
tools/hv/hv_fcopy_daemon.c +4
-1@@ -169,6 +173,9 @@ int main(void) } -pwrite (fcopy_fd, &error,sizeof (int ),0 ); +if (pwrite (fcopy_fd, &error,sizeof (int ),0 ) !=sizeof (int )) { +syslog (LOG_ERR ,"pwrite failed: %s" ,strerror (errno)); +exit (EXIT_FAILURE ); + } } }
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 3 lines · KY Srinivasan
I am cleaning up the code based on your feedback. By the time I am done with my cleanup, I doubt if this patch would apply. Do you mind if I were to include your changes here as part of my cleanup?
Yes, thats fine.
Olaf
Quoted 10 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Monday, January 20, 2014 2:16 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy service
Quoted 7 lines
Quoted 3 lines · KY Srinivasan
I am cleaning up the code based on your feedback. By the time I am done with my cleanup, I doubt if this patch would apply. Do you mind if I were to include your changes here as part of my cleanup?
Yes, thats fine.
Thanks Olaf.
K. Y
Quoted 3 lines
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
On Tue, Jan 14, K. Y. Srinivasan wrote:
This function should return valid numbers:
drivers/hv/hv_fcopy.c line 290
Quoted 7 lines
drivers/hv/hv_fcopy.c new file +7
-0+static ssize_t fcopy_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +int error =0 ; + +if (count !=sizeof (int )) +return 0 ;
Should be an error.
drivers/hv/hv_fcopy.c line 297
Quoted 7 lines
drivers/hv/hv_fcopy.c new file +7
-0+ +if (copy_from_user (&error, buf,sizeof (int ))) +return -EFAULT ; + +if (in_hand_shake) { +fcopy_handle_handshake (); +return 0 ;
Should be sizeof(int).
Quoted 11 lines
drivers/hv/hv_fcopy.c new file +11
-0+ } + +/* +* Complete the transaction by forwarding the result +* to the host. But first, cancel the timeout. +*/ +if (cancel_delayed_work_sync (&fcopy_work)) +fcopy_respond_to_host (error); + +return sizeof (int ); +}
Quoted 34 lines
-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Thursday, January 16, 2014 3:27 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy serviceOn Tue, Jan 14, K. Y. Srinivasan wrote:
This function should return valid numbers:
drivers/hv/hv_fcopy.c line 290
Quoted 7 lines
drivers/hv/hv_fcopy.c new file +7
-0+static ssize_t fcopy_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +int error =0 ; + +if (count !=sizeof (int )) +return 0 ;Should be an error.
drivers/hv/hv_fcopy.c line 297
Quoted 7 lines
drivers/hv/hv_fcopy.c new file +7
-0+ +if (copy_from_user (&error, buf,sizeof (int ))) +return -EFAULT ; + +if (in_hand_shake) { +fcopy_handle_handshake (); +return 0 ;Should be sizeof(int).
Quoted 11 lines
drivers/hv/hv_fcopy.c line 308
Quoted 11 lines
drivers/hv/hv_fcopy.c new file +11
-0+ } + +/* +* Complete the transaction by forwarding the result +* to the host. But first, cancel the timeout. +*/ +if (cancel_delayed_work_sync (&fcopy_work)) +fcopy_respond_to_host (error); + +return sizeof (int ); +}
Olaf,
I will make the changes in the next version of this patch.
Thank you,
K. Y ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�