All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Hahn <hahn@univention.de>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Xen-devel@lists.xensource.com
Subject: Re: [PATCH v2] no-fork option for tapdisk2 debugging
Date: Tue, 21 Jun 2011 17:12:07 +0200	[thread overview]
Message-ID: <201106211712.11205.hahn@univention.de> (raw)
In-Reply-To: <19968.43712.196951.660273@mariner.uk.xensource.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 886 bytes --]

Hello Ian,

Am Dienstag 21 Juni 2011 16:29:20 schrieb Ian Jackson:
> That should be folded into the first patch, which otherwise leaves the
> indentation wrong.

Done. I submitted it as an extra patch only for simplifying review of the 
additional implementation.

> Also, you to add a Signed-off-by line to your patch to signify its
> copyright status (see below).

The original patch already contained the Signed-off-line, since I knew you (or 
somebody else) would be asking for it ;-) If more is needed, please ask 
again.

Sincerely
Philipp Hahn
-- 
Philipp Hahn           Open Source Software Engineer      hahn@univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/

[-- Attachment #1.1.2: tapdisk2.diff --]
[-- Type: text/x-diff, Size: 1676 bytes --]

no-fork option for tapdisk2 debugging.

To simplify running tapdisk2 from a debugger, add an opttion "-n" to disable foring into the background.

Signed-off-by: Philipp Hahn <hahn@univention.de>
--
[v2] fold extra indention patch into patch.
--- xen-4.0.1.orig/tools/blktap2/drivers/tapdisk2.c	2010-08-25 12:22:07.000000000 +0200
+++ xen-4.0.1/tools/blktap2/drivers/tapdisk2.c	2011-06-17 17:37:35.000000000 +0200
@@ -402,7 +402,7 @@ tapdisk2_wait_for_device(void)
 static void
 usage(const char *app, int err)
 {
-	fprintf(stderr, "usage: %s <-n file>\n", app);
+	fprintf(stderr, "usage: %s [-f] -n driver:file\n", app);
 	exit(err);
 }
 
@@ -411,10 +411,11 @@ main(int argc, char *argv[])
 {
 	int c;
 	char *params;
+	int do_fork = 1;
 
 	params = NULL;
 
-	while ((c = getopt(argc, argv, "n:s:h")) != -1) {
+	while ((c = getopt(argc, argv, "n:s:fh")) != -1) {
 		switch (c) {
 		case 'n':
 			params = optarg;
@@ -430,6 +431,9 @@ main(int argc, char *argv[])
 			exit(EXIT_FAILURE);
 #endif
 			break;
+		case 'f':
+			do_fork = 0;
+			break;
 		default:
 			usage(argv[0], EINVAL);
 		}
@@ -438,12 +442,17 @@ main(int argc, char *argv[])
 	if (!params || optind != argc)
 		usage(argv[0], EINVAL);
 
-	if (pipe(channel) == -1) {
-		printf("pipe failed: %d\n", errno);
-		return errno;
-	}
+	if (do_fork) {
+		if (pipe(channel) == -1) {
+			printf("pipe failed: %d\n", errno);
+			return errno;
+		}
+	} else {
+		channel[0] = dup(STDIN_FILENO);
+		channel[1] = dup(STDERR_FILENO);
+	}
 
-	switch (fork()) {
+	switch (do_fork ? fork() : 0) {
 	case -1:
 		printf("fork failed: %d\n", errno);
 		return errno;

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2011-06-21 15:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 13:29 [PATCH] no-fork option for tapdisk2 debugging Philipp Hahn
2011-06-21 14:29 ` Ian Jackson
2011-06-21 15:12   ` Philipp Hahn [this message]
2011-06-21 15:14     ` [PATCH v2] " Ian Jackson
2011-06-21 15:40       ` Philipp Hahn
2011-06-21 15:53         ` Ian Jackson

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=201106211712.11205.hahn@univention.de \
    --to=hahn@univention.de \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.