Re: On write command
On 31/01/2011 01:52, Larry Hall (Cygwin) wrote: On 1/29/2011 8:20 AM, Angelo Graziosi wrote: I would ask if on Cygwin I can use the 'write' command: write - send a message to another user $ write USER [ttyname] I remember I have used it some years ago, but not remember if it was on GNU/Linux or Cygwin. I did a research on http://cygwin.com/packages and didn't find it, but perhaps I did the wrong search.. 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 { shortut_type; pid_tut_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 { shortut_type; pid_tut_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... cheers, DaveK -- 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
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
Re: On write command
On 31/01/2011 11:49, Corinna Vinschen wrote: 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. Nah, I was mistaken. It actually works fine as-is. I was fooled by the way old utmp entries get the first char of the username NULled out into thinking it was getting bad data, but a quick login convinced me that write actually works just fine and all the util-linux maintainer needs do is add the configure option to enable building it. I still think that utmp_data macro is going to return utmp_data_buf[nutdbuf] at some point, though. Shouldn't it be if (utix = nutdbuf)? cheers, DaveK -- 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
Re: On write command
On Jan 31 13:28, Dave Korn wrote: I still think that utmp_data macro is going to return utmp_data_buf[nutdbuf] at some point, though. Shouldn't it be if (utix = nutdbuf)? Indeed. Thanks for catching. I fixed it in CVS. 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
Re: On write command
On 1/29/2011 8:20 AM, Angelo Graziosi wrote: I would ask if on Cygwin I can use the 'write' command: write - send a message to another user $ write USER [ttyname] I remember I have used it some years ago, but not remember if it was on GNU/Linux or Cygwin. I did a research on http://cygwin.com/packages and didn't find it, but perhaps I did the wrong search.. No, that's the correct place to search. If it's not showing up, none of the current packages provide 'write'. -- Larry _ A: Yes. Q: Are you sure? A: Because it reverses the logical flow of conversation. Q: Why is top posting annoying in email? -- 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
Re: On write command
On 1/29/11 5:20 AM, Angelo Graziosi wrote: I would ask if on Cygwin I can use the 'write' command: write - send a message to another user $ write USER [ttyname] I remember I have used it some years ago, but not remember if it was on GNU/Linux or Cygwin. I did a research on http://cygwin.com/packages and didn't find it, but perhaps I did the wrong search.. Even in other Unix environments, write(1) is seldom used these days. Windows *does* provide a way to send a message to other users using the msg command or net send. signature.asc Description: OpenPGP digital signature