[comp.lang.perl] directory entries chopped on SCO Unix

djm@eng.umd.edu (David J. MacKenzie) (03/02/91)

I just built pl44 on SCO Unix 3.2.2 and find that the filenames
returned by Perl's readdir function are missing the first two
characters.  It works fine on SunOS.  Anyone have a fix for this
problem?
--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (03/03/91)

In article <DJM.91Mar2015606@egypt.eng.umd.edu> djm@eng.umd.edu (David J. MacKenzie) writes:
} I just built pl44 on SCO Unix 3.2.2 and find that the filenames
} returned by Perl's readdir function are missing the first two
} characters.  It works fine on SunOS.  Anyone have a fix for this
} problem?
} --
} David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

Yeah, make sure you DO NOT use -lx when linking.  It has (incorrect,
ore more accurately, outdated) opendir(), readdir(), closedir() etc.
calls, which get used in place of the (correct) ones in libc.

As far as I know, the only thing -lx is needed for in 3.2.2 is the
ancient rdchk() call, which Perl surely isn't using.  You can replace
it with select() or an ioctl() if it is used.
-- 
Bart Schaefer						schaefer@cse.ogi.edu
ZipCode Software Corporation				schaefer@zipcode.com

chip@tct.uucp (Chip Salzenberg) (03/05/91)

According to schaefer@ogicse.ogi.edu (Barton E. Schaefer):
>Yeah, make sure you DO NOT use -lx when linking.  It has (incorrect,
>ore more accurately, outdated) opendir(), readdir(), closedir() etc.

Too true.

>As far as I know, the only thing -lx is needed for in 3.2.2 is the
>ancient rdchk() call ...

Actually, Perl _is_ using routine from -lx: chsize().  It's used to
implement the "truncate" function.  Fortunately, the fcntl() solution
for System V is just as effective, and it doesn't require -lx.

wengland@stephsf.stephsf.com (Bill England) (03/05/91)

In article <18097@ogicse.ogi.edu> schaefer@ogicse.ogi.edu (Barton E. Schaefer) writes:
>In article <DJM.91Mar2015606@egypt.eng.umd.edu> djm@eng.umd.edu (David J. MacKenzie) writes:
>} I just built pl44 on SCO Unix 3.2.2 and find that the filenames
>} returned by Perl's readdir function are missing the first two
>} characters.  It works fine on SunOS.  Anyone have a fix for this
>} problem?
>} --
>} David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>
>
>Yeah, make sure you DO NOT use -lx when linking.  It has (incorrect,
>ore more accurately, outdated) opendir(), readdir(), closedir() etc.
>calls, which get used in place of the (correct) ones in libc.
>
>As far as I know, the only thing -lx is needed for in 3.2.2 is the
>ancient rdchk() call, which Perl surely isn't using.  You can replace
>it with select() or an ioctl() if it is used.

  You might notice that SCO defines both dirent.h, sys/ndir.h, 
  and sys/dir.h .   This is a bit of overkill and would be ok, 
  I guess, except that dirent defines a strange type on the 
  length of the file and throws off the offset of the name 
  by two bytes.

  What I did was modify the config.h file after running Configure
  and commented out DIRENT, uncommented NDIR and also uncommented
  the directory length variable.  

  If the above does not help give me a call.


  Bill England
  wengland@stehpsf.com
-- 
 +-  Bill England,  wengland@stephsf.COM -----------------------------------+
 |   * *      H -> He +24Mev                                                |
 |  * * * ... Oooo, we're having so much fun making itty bitty suns *       |
 |__ * * ___________________________________________________________________| 

djm@eng.umd.edu (David J. MacKenzie) (03/05/91)

In article <18097@ogicse.ogi.edu> schaefer@ogicse.ogi.edu (Barton E. Schaefer) writes:

   } I just built pl44 on SCO Unix 3.2.2 and find that the filenames
   } returned by Perl's readdir function are missing the first two
   } characters.  It works fine on SunOS.  Anyone have a fix for this
   } problem?
   } --
   } David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

   Yeah, make sure you DO NOT use -lx when linking.  It has (incorrect,
   ore more accurately, outdated) opendir(), readdir(), closedir() etc.
   calls, which get used in place of the (correct) ones in libc.

Yep, that fixed it.  Configure automatically detects that -lx exists
and includes it in the suggested list of libraries to link with, but
all I had to do was explicitly type in the rest of them at the prompt
instead of accepting the default.  Configure also seems to have
detected that fcntl exists and used that instead of chsize.

Apparently what happens if you use -lx is perl mismatches the dirent.h
header file with the -lx directory routines, which return a
different-sized struct.  If you use either sys/ndir.h with -lx, or
dirent.h with the libc routines, it should work.  However, I have
heard somewhere that the -lx directory routines don't work under NFS
(because they don't use the getdents syscall), which we plan to start
using sometime, so I don't want to use them.
--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

wengland@stephsf.stephsf.com (Bill England) (03/07/91)

In article <DJM.91Mar5054514@egypt.eng.umd.edu> djm@eng.umd.edu (David J. MacKenzie) writes:
>[...]
>Apparently what happens if you use -lx is perl mismatches the dirent.h
>header file with the -lx directory routines, which return a
>different-sized struct.  If you use either sys/ndir.h with -lx, or

  Thanks,  that makes more sense than what I thought was going on. The
  config does contain some code to skip dirent on Xenix boxes and 
  (presumably)  use sys/ndir.  Would modification of the config to 
  drop the Xenix specific test and also dropping the -lx library
  work better on Xenix boxes ?  Sorry I can't test Xenix here.


  Bill England
  wengland@stephsf.com
-- 
 +-  Bill England,  wengland@stephsf.COM -----------------------------------+
 |   * *      H -> He +24Mev                                                |
 |  * * * ... Oooo, we're having so much fun making itty bitty suns *       |
 |__ * * ___________________________________________________________________| 

ronald@robobar.co.uk (Ronald S H Khoo) (03/07/91)

wengland@stephsf.stephsf.com (Bill England) writes:

>   Would modification of the config to 
>   drop the Xenix specific test and also dropping the -lx library
>   work better on Xenix boxes ?  Sorry I can't test Xenix here.

This is a difficult question to answer, mostly because it's hard to
tell exactly what kind of Xenix you have.

	Early releases didn't have any kind of ndir  -- no problem

	Many releases have only sys/ndir + -lx       -- no problem

	SCO Xenix 2.3.[012] have ndir + dirent, but dirent is reputedly
		broken on .0 and .1, hence the hack to undef it.

	*However*, the kernel upgrade to 2.3.3 (where dirent apparently works)
	from any lower 2.3.? is a free upgrade, which you can anon FTP or UUCP.

I use dirent -- I had to make a decision which set of directory routines
to throw out (so that there would be no confusion), so I threw out the
old ones.  This means I have to manually remove the ! defined(M_XENIX)
hacks from the source which is very ugh.

My opinion is that the hacks should be removed seeing as they only apply
to a small number of operating system versions which you upgrade for
free anyway.  Chip may disagree with me.  It all rather depends on your
particular point of view.

You could hack Configure to do case "`uname -r`" in 2.3.[01])
I guess.  It's a lot of code to handle just one specific case,
since you have to determine whether to do it or not as well.

In short, I Really Don't Know But It's All Very Annoying.

Just another Xenix user,
-- 
Ronald Khoo <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)

chip@tct.uucp (Chip Salzenberg) (03/09/91)

According to ronald@robobar.co.uk (Ronald S H Khoo):
>My opinion is that the hacks should be removed seeing as they only apply
>to a small number of operating system versions which you upgrade for
>free anyway.  Chip may disagree with me.

I agree... _if_ the old "#ifdef M_XENIX" is replaced by the more
accurate "#ifdef SYS_NDIR".  That provides an out for those sites that
still haven't upgraded to a dirent-capable version of Xenix.

>In short, I Really Don't Know But It's All Very Annoying.

What he said.  Sigh.
-- 
Chip Salzenberg at Teltronics/TCT     <chip@tct.uucp>, <uunet!pdn!tct!chip>
 "Most of my code is written by myself.  That is why so little gets done."
                 -- Herman "HLLs will never fly" Rubin