www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/01/31/06:49:45

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 31 Jan 2011 12:49:19 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: On "write" command
Message-ID: <20110131114919.GJ1057@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4D441414 DOT 1010407 AT alice DOT it> <4D4615E0 DOT 9040903 AT cygwin DOT com> <4D46A30D DOT 2010706 AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <4D46A30D.2010706@gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jan 31 11:54, Dave Korn wrote:
> On 31/01/2011 01:52, Larry Hall (Cygwin) wrote:
> > No, that's the correct place to search.  If it's not showing up, none of
> > the current packages provide 'write'.
> 
>   It's part of util-linux, but it's configured out of the build on Cygwin,
> because it relies on a working utmp file to operate.  Which we don't have.
> Hmm, I'm in the middle of a gcc testrun right now and can't rebuild my DLL,
> but I noticed a few "interesting" points about the code:
> 
> winsup/cygwin/include/utmpx.h
> 
> > /* Must be kept in sync with struct utmp as defined in sys/utmp.h! */
> > struct utmpx
> > {
> >  short	ut_type;
> >  pid_t	ut_pid;
> >  char	ut_line[UT_LINESIZE];
> >  char   ut_id[UT_IDLEN];
> >  time_t ut_time;
> >  char	ut_user[UT_NAMESIZE];
> >  char	ut_host[UT_HOSTSIZE];
> >  long	ut_addr;
> >  struct timeval ut_tv;
> > };
> 
> winsup/cygwin/include/sys/utmp.h
> 
> > struct utmp
> > {
> >  short	ut_type;
> >  pid_t	ut_pid;
> >  char	ut_line[UT_LINESIZE];
> >  char  ut_id[UT_IDLEN];
> >  time_t ut_time;
> >  char	ut_user[UT_NAMESIZE];
> >  char	ut_host[UT_HOSTSIZE];
> >  long	ut_addr;
> > };
> 
>   That could explain why successive calls to getutent() appear to "lose frame"
> across the contents of utmp.  Also,
> 
> winsup/cygwin/syscalls.cc
> 
> > /* Note: do not make NO_COPY */
> > static struct utmp utmp_data_buf[16];
> > static unsigned utix = 0;
> > #define nutdbuf (sizeof (utmp_data_buf) / sizeof (utmp_data_buf[0]))
> > #define utmp_data ({ \
> >   if (utix > nutdbuf) \
> >     utix = 0; \
> >   utmp_data_buf + utix++; \
> > })
> 
>   I haven't slept all night, but isn't that going to overrun by one?  Anyway
> with the fix to utmp.h to add ut_tv (and a #include <sys/time.h>), write.exe
> compiles and works...

The utmp file is in the old utmp format for backward compatibility.  The
utx functions are available and return a ut_tv field, but it's just
extracted from the utmp ut_time field at function call time.  The right
thing to do for write is to have a autoconf test for the ut_tv field
and not using it, if it's not available.

In theory we should switch to a utmpx file at one point.  When we do
this, we can also add the ut_addr_v6 field, which is missing so far.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019