This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: On "write" command
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