[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Opening files so that no cr/lf translation is done.



This is a bit of an interesting one - certainly it's been giving me my
fair share of migraine problems.

I made a rash (in restrospect) announcement about the Taylor UUCP
package a short while ago, let me qualify the state of things now :

uucico works fine, with the exception of the ability to detatch from
the controlling terminal.  I assume this has something to do with the
differences between "normal" fork() and the MiNT fork() - this is not
a terrible problem, although it makes it (AFAIK) impossible for 
uucico to receive SIGHUP from the modem, or to put uuxqt in the
background.

uuxqt does not.

In particular, compressed newsbatches get mangled.

This had me stumped for some time - particularly because the 'od' in
the shu194st.zoo archive on atari.archive has the same problem : so I 
have two files, of different size, that 'od' to the same file.

Jens - if you're reading this, both thanks _and_ flames - can you fix
it please? 

Now, I don't know how many of you have tangled with the innards of
Taylor, but it's not hugely pretty - everything is abstracted to the 
n'th degree, which probably makes it _great_ for porting, but learning
it is no fun at all 8(

I have verified that the rnews I am using works (feeding it a compressed
newsbatch results in it being neatly stashed where it should (ownership
is wrong, ends up as uucp not news, despite sticky bit on /bin/rnews,
but that's life 8( ) and I can verify that it is correct with 
tail +2 <newsbatch> |zcat |less

However, if I use uuxqt to invoke rnews, things don't work out.

This is what it does : after parsing the X. files and taking appropriate
security precautions, this call is made... (uuxqt.c)

  if (! fsysdep_execute (qsys,
	 zQuser == NULL ? (const char *) "uucp" : zQuser,
	 (const char **) azQargs, zfullcmd, zQinput,
	 zoutput, fshell, iQlock_seq, &zerror, &ftemp))

where the arguments of interest are zQinput and zoutput. (char *filename)

In fsysdep_execute() zQinput becomes zinput, and we have :

  if (zinput != NULL)
    {
      aidescs[0] = open ((char *) zinput, O_RDONLY | O_NOCTTY, 0);
      if (aidescs[0] < 0)
	{
	  ulog (LOG_ERROR, "open (%s): %s", zinput, strerror (errno));
	  ferr = TRUE;
	}
      else if (fcntl (aidescs[0], F_SETFD,
		      fcntl (aidescs[0], F_GETFD, 0) | FD_CLOEXEC) < 0)
	{
	  ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
	  ferr = TRUE;
	}	
    }


and for zoutput :

  if (! ferr && zoutput != NULL)
    {
      aidescs[1] = creat ((char *) zoutput, IPRIVATE_FILE_MODE);
      if (aidescs[1] < 0)
	{
	  ulog (LOG_ERROR, "creat (%s): %s", zoutput, strerror (errno));
	  *pftemp = TRUE;
	  ferr = TRUE;
	}
      else if (fcntl (aidescs[1], F_SETFD,
		      fcntl (aidescs[1], F_GETFD, 0) | FD_CLOEXEC) < 0)
	{
	  ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno));
	  ferr = TRUE;
	}	
    }


Zoutput is not very important for rnews, but it may well be for other
applications.

I'm not going to go further - there's too much to wade through, but in
brief : this routine calls ixsspawn() which takes, amongst many
other arguments, the filedescriptors in aidescs[0] and [1], which are
used as stdin and stdout for the command.

Somewhere along the line here, translation occurs... 
I have looked at open.c in the pl44 mintlibs, but the nondiscussion
of CRMOD has left me none the wiser.

If anyone has a suggestion, I'm open to ideas...

-- 
# mike smith : miff@apanix.apana.org.au - Silicon grease monkey        #
# "The question 'why are the fundamental laws of nature mathematical'  #
# then invites the trivial response 'because we define as fundamental  #
# those laws which are mathematical'". Paul Davies, _The_Mind_of_God_. #