linux-um archives
 help / color / mirror / Atom feed
From: Dan Shearer <dan@shearer.org>
To: Jeff Dike <jdike@addtoit.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] Draft docs for port console channel
Date: Sat, 24 Jan 2004 18:50:57 +1030	[thread overview]
Message-ID: <20040124082057.GG4203@erizo.shearer.org> (raw)
In-Reply-To: <20040123144320.GB6768@ccure.user-mode-linux.org>

On Fri, Jan 23, 2004 at 09:43:20AM -0500, Jeff Dike wrote:

> > 	The login program, which is receiving data from the master side of 
> > 	the pty that telnetd opened, sends the data back through this pipe
> 
> And no.  port_helper passes the actual file descriptor back to UML through
> the unix socket on fd 3.  Then, UML receives characters directly from telnetd
> without port_helper having to relay them.

Got it now. Here is a patch to port-helper that might help others.

> Otherwise, this is pretty good.

You mean apart from the fact that I missed the point entirely.

Another fumbling newbie question: why can't we just have the fd for the
unix socket for xterm connected before xterm is exec'd? Then there would
be no need for open_socket in port-helper. I'm sure there's an obvious
reason.

-- 
Dan Shearer
dan@shearer.org


--- port-helper.c.orig
+++ port-helper.c
@@ -1,3 +1,15 @@
+/* port-helper
+
+Used by the port and xterm console channels for User Mode Linux.
+
+Tells UML "here is a file descriptor for my stdin as given to me by 
+xterm or telnetd". Once UML has that (with os_rcv_fd()) UML opens it
+for read and write, and the console is functional.
+
+(c) Jeff Dike 2002-2004
+
+*/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
@@ -8,8 +20,17 @@
 #include <sys/un.h>
 #include <sys/uio.h>
 
+/* pass the fd over an fd that is already connected to a socket */
 static void send_fd(int fd, int target)
 {
+
+  /* File descriptors are specific to a process and normally only
+     sharable with another process by inheritence with fork(). The 
+     alternative is to use sendmsg with a special flag that says 
+     "I'm knowingly giving another process information from my private 
+     file descriptor table" (SCM_RIGHTS) 
+  */
+
   char anc[CMSG_SPACE(sizeof(fd))];
   struct msghdr msg;
   struct cmsghdr *cmsg;
@@ -42,6 +63,8 @@
   }
 }
 
+/* for xterm we don't have an open socket, we only have the name
+ of a file used as a Unix socket by UML. So we need to open it. */
 static int open_socket(char *name)
 {
   struct sockaddr_un sock;
@@ -74,12 +97,17 @@
 {
   int fd;
 
-  if((argc > 1) && !strcmp(argv[1], "-uml-socket")) fd = open_socket(argv[2]);
-  else fd = 3;
+  if((argc > 1) && !strcmp(argv[1], "-uml-socket")) {
+	/* inherited a filename not an open fd */
+	fd = open_socket(argv[2]);
+  } else {
+	/* inherited fd of the listening TCP socket */
+	fd = 3;
+  }
 
   signal(SIGHUP, SIG_IGN);
   if(ioctl(0, TIOCNOTTY, 0) < 0)
-    perror("TIOCNOTTY failed");
+    perror("TIOCNOTTY failed in port-helper, check UML's exec call for xterm or telnetd");
   send_fd(0, fd);
   pause();
   return(0);


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  reply	other threads:[~2004-01-26 10:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-23  3:56 [uml-devel] Draft docs for port console channel Dan Shearer
2004-01-23 14:43 ` Jeff Dike
2004-01-24  8:20   ` Dan Shearer [this message]
2004-01-24 18:20     ` Jeff Dike
2004-01-25 23:38       ` Dan Shearer
2004-01-26 18:14         ` Jeff Dike

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=20040124082057.GG4203@erizo.shearer.org \
    --to=dan@shearer.org \
    --cc=jdike@addtoit.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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