mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KY Srinivasan <kys@microsoft.com>
To: Olaf Hering <olaf@aepfle.de>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"apw@canonical.com" <apw@canonical.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>
Subject: RE: [PATCH V2 1/1] Drivers: hv: Implement the file copy service
Date: Mon, 20 Jan 2014 22:13:30 +0000	[thread overview]
Message-ID: <b29b3b91ff654abab607fe7b689bbfeb@BY2PR03MB299.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20140116104841.GA21768@aepfle.de>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 4631 bytes --]

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

> -----Original Message-----
> From: Olaf Hering [mailto:olaf@aepfle.de]
> Sent: Thursday, January 16, 2014 2:49 AM
> To: KY Srinivasan
> Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; apw@canonical.com; jasowang@redhat.com
> Subject: Re: [PATCH V2 1/1] Drivers: hv: Implement the file copy service
> 
> On Tue, Jan 14, K. Y. Srinivasan wrote:
> 
> > 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 <olaf@aepfle.de>
> 
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index c0e5c90..d1fadb7 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -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);
> +		}
>  	}
>  }
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

  parent reply	other threads:[~2014-01-20 22:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14 19:35 K. Y. Srinivasan
2014-01-14 22:13 ` Olaf Hering
2014-01-14 23:12   ` KY Srinivasan
2014-01-15 16:33 ` Olaf Hering
2014-01-15 19:11   ` KY Srinivasan
2014-01-16  9:42 ` Olaf Hering
2014-01-16 15:52   ` KY Srinivasan
2014-01-17  7:31   ` Dan Carpenter
2014-01-16 10:16 ` Olaf Hering
2014-01-16 15:51   ` KY Srinivasan
2014-01-16 10:48 ` Olaf Hering
2014-01-16 15:50   ` KY Srinivasan
2014-01-20 22:13   ` KY Srinivasan [this message]
2014-01-20 22:16     ` Olaf Hering
2014-01-20 22:23       ` KY Srinivasan
2014-01-16 11:26 ` Olaf Hering
2014-01-16 15:49   ` KY Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b29b3b91ff654abab607fe7b689bbfeb@BY2PR03MB299.namprd03.prod.outlook.com \
    --to=kys@microsoft.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®