From patchwork Wed Jun 6 18:24:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 163412 X-Patchwork-Delegate: thomas.petazzoni@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 0A9E7B6FA1 for ; Thu, 7 Jun 2012 04:24:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 026871001D6; Wed, 6 Jun 2012 18:24:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FgFEZWi99-Uk; Wed, 6 Jun 2012 18:24:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C5FEFFFE59; Wed, 6 Jun 2012 18:24:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 219AB8F753 for ; Wed, 6 Jun 2012 18:24:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1D9A7A0481 for ; Wed, 6 Jun 2012 18:24:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9p2xIEJSBwIA for ; Wed, 6 Jun 2012 18:24:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f46.google.com (mail-pz0-f46.google.com [209.85.210.46]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8061BA0252 for ; Wed, 6 Jun 2012 18:24:22 +0000 (UTC) Received: by dady13 with SMTP id y13so10191663dad.33 for ; Wed, 06 Jun 2012 11:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=fM+pmRKYgdd+OtyFnFb8FsZgeO2dcbZ+MFY6f4QYv/U=; b=brdi9S0PVk0nqIm6taLWJbCYneenyg3ffO/eMd5nAiYoq0XDrzGTN7Am7242ppt+Q9 IM3abNWufeCPWdvaVN8K/tT3TFlF0xKVKTaqwgavrDSiHLK4Jfwn87yLeGdu6cS3Rpem EfXTR+YuOHSb5ADufBWYkwY52oKANZhxPpiVcOQ/IHGF7jusc4UQW0v/eL4NI9Y9W+kV /aX8rpJ/bVHOvQuREj8jRdK7QEotXHRz+E17EMXt1i88eIrPpC67nB2HrykV78e2Aaxb XIxSNOfT+iLeDooSuhVesmiSmgNVmu9/gXn3qaM2BEuyfPG8XeUEfJgsJaStV3qhTbjq icqw== Received: by 10.68.202.99 with SMTP id kh3mr60268335pbc.157.1339007062123; Wed, 06 Jun 2012 11:24:22 -0700 (PDT) Received: from jmaggard-ThinkPad-W520.infrant-6.com ([64.94.70.253]) by mx.google.com with ESMTPS id py5sm1171620pbb.1.2012.06.06.11.24.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jun 2012 11:24:21 -0700 (PDT) From: Justin Maggard To: buildroot@uclibc.org Date: Wed, 6 Jun 2012 11:24:12 -0700 Message-Id: <1339007052-13670-1-git-send-email-jmaggard10@gmail.com> X-Mailer: git-send-email 1.7.9.5 Cc: Justin Maggard Subject: [Buildroot] [PATCH] New package: dtach X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: Justin Maggard Also included is a scrollback patch from Justin Bogner. Signed-off-by: Justin Maggard --- package/Config.in | 1 + package/dtach/Config.in | 8 +++ package/dtach/dtach-scrollback.patch | 113 ++++++++++++++++++++++++++++++++++ package/dtach/dtach.mk | 15 +++++ 4 files changed, 137 insertions(+) create mode 100644 package/dtach/Config.in create mode 100644 package/dtach/dtach-scrollback.patch create mode 100644 package/dtach/dtach.mk diff --git a/package/Config.in b/package/Config.in index 2b69c57..c87726f 100644 --- a/package/Config.in +++ b/package/Config.in @@ -624,6 +624,7 @@ source "package/bash/Config.in" source "package/dash/Config.in" endif source "package/dialog/Config.in" +source "package/dtach/Config.in" source "package/file/Config.in" source "package/inotify-tools/Config.in" source "package/lockfile-progs/Config.in" diff --git a/package/dtach/Config.in b/package/dtach/Config.in new file mode 100644 index 0000000..033536b --- /dev/null +++ b/package/dtach/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_DTACH + bool "dtach" + help + dtach is a tiny program that emulates the detach feature of screen, + allowing you to run a program in an environment that is protected + from the controlling terminal and attach to it later. + + http://dtach.sourceforge.net/ diff --git a/package/dtach/dtach-scrollback.patch b/package/dtach/dtach-scrollback.patch new file mode 100644 index 0000000..576d3ff --- /dev/null +++ b/package/dtach/dtach-scrollback.patch @@ -0,0 +1,113 @@ +diff --git a/dtach.h b/dtach.h +index f2f4951..ef47d99 100644 +--- a/dtach.h ++++ b/dtach.h +@@ -124,6 +124,8 @@ struct packet + */ + #define BUFSIZE 4096 + ++#define SCROLLSIZE 8192 ++ + /* This hopefully moves to the bottom of the screen */ + #define EOS "\033[999H" + +diff --git a/master.c b/master.c +index 34cd0fa..4ddc255 100644 +--- a/master.c ++++ b/master.c +@@ -54,6 +54,10 @@ struct client + /* The pseudo-terminal created for the child process. */ + static struct pty the_pty; + ++/* The scrollback buffer */ ++static unsigned char scrollback[SCROLLSIZE]; ++static int scroll_end, scroll_full; ++ + #ifndef HAVE_FORKPTY + pid_t forkpty(int *amaster, char *name, struct termios *termp, + struct winsize *winp); +@@ -214,6 +218,66 @@ pid_t forkpty(int *amaster, char *name, struct termios *termp, + return s; + } + ++/* Write the data in *buf into the scrollback buffer */ ++static void ++write_scrollback(unsigned char *buf, int len) ++{ ++ int n; ++ if (len > SCROLLSIZE) ++ { ++ buf = buf + (len - SCROLLSIZE); ++ len = SCROLLSIZE; ++ } ++ ++ n = SCROLLSIZE - scroll_end; ++ if (n >= len) ++ { ++ memcpy(scrollback + scroll_end, buf, ++ len * sizeof(unsigned char)); ++ scroll_end += len * sizeof(unsigned char); ++ scroll_full = 1; ++ } ++ else ++ { ++ memcpy(scrollback + scroll_end, buf, ++ n * sizeof(unsigned char)); ++ scroll_end = len - n; ++ memcpy(scrollback, buf, ++ scroll_end * sizeof(unsigned char)); ++ } ++} ++ ++/* Send the data in the scrollback buffer to client */ ++static void ++send_scrollback(struct client *p) ++{ ++ int written, len; ++ if (scroll_full) ++ { ++ len = SCROLLSIZE - scroll_end; ++ written = 0; ++ while (written < len) ++ { ++ int n = write(p->fd, scrollback + scroll_end + written, ++ len - written); ++ if (n > 0) ++ written += n; ++ else if (n == 0 || errno != EINTR) ++ break; ++ } ++ } ++ len = scroll_end; ++ written = 0; ++ while (written < len) ++ { ++ int n = write(p->fd, scrollback + written, len - written); ++ if (n > 0) ++ written += n; ++ else if (n == 0 || errno != EINTR) ++ break; ++ } ++} ++ + /* Process activity on the pty - Input and terminal changes are sent out to + ** the attached clients. If the pty goes away, we die. */ + static void +@@ -296,6 +360,8 @@ pid_t forkpty(int *amaster, char *name, struct termios *termp, + /* Try again if nothing happened. */ + if (!FD_ISSET(s, &readfds) && nclients == 0) + goto top; ++ ++ write_scrollback( buf, len ); + } + + /* Process activity on the control socket */ +@@ -324,6 +390,8 @@ pid_t forkpty(int *amaster, char *name, struct termios *termp, + if (p->next) + p->next->pprev = &p->next; + *(p->pprev) = p; ++ ++ send_scrollback( p ); + } + + /* Process activity from a client. */ diff --git a/package/dtach/dtach.mk b/package/dtach/dtach.mk new file mode 100644 index 0000000..c35bcba --- /dev/null +++ b/package/dtach/dtach.mk @@ -0,0 +1,15 @@ +############################################################# +# +# dtach +# +############################################################# + +DTACH_VERSION = 0.8 +DTACH_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/dtach + +define DTACH_INSTALL_TARGET_CMDS + $(INSTALL) -D $(@D)/dtach -m 0755 \ + $(TARGET_DIR)/usr/bin/dtach +endef + +$(eval $(call AUTOTARGETS))