Problem with nlink from stat().

D

DJ Austin

Hi All,

I'm losing a lot of hair with this problem, and I hope some of you had
bumped into this problem before and can help me out.

I have 2 Windows XP machines. One desktop and one laptop. I installed
both cygwin (www.cygwin.com) and perl (www.activestate.com) late last
year (sometime in November 2002) on both computers, and everything
works fine.

My laptop disk went bad 2 weeks ago and I had to replace it and
reinstall XP, cygwin and perl. I went to cygwin.com and
activestate.com to install the latest version of both software.

My perl script that had never failed before fails now on my laptop. I
had isolated the problem to the following test case:


#!/usr/local/bin/perl

($dev, $ino, $mode, $nlink) = stat ('.') unless $nlink;
print "nlnk = $nlink\n";
print "dev = $dev\n";
print "ino = $ino\n";
print "mode = $mode\n";

The problem is: the nlink is always 1 no matter what directory/file I
stat.

Please note that the same test case above runs fine (as expected) on
my desktop. I notice that I have perl 5.6.1, and my laptop has 5.8.1,
so I uninstall 5.8.1 and install 5.6.1 thinking that it has conflict
with cygwin. Problem still exists. So, next step is to remove cygwin
and re-install it again thinking it was corrupted. No go.

Please note that when I install cygwin, I did not include perl, so I
know cygwin doesn't install perl, and my perl comes from
activestate.com installation.

I have searched the FAQ to no avail, and search on google returns a
lot of result but mostly on ctime/mtime issues.

Any help/pointer will be highly appreciated. Thanks in advance!
 
S

Sisyphus

DJ said:
#!/usr/local/bin/perl

($dev, $ino, $mode, $nlink) = stat ('.') unless $nlink;
print "nlnk = $nlink\n";
print "dev = $dev\n";
print "ino = $ino\n";
print "mode = $mode\n";

Hmmm .... 'perldoc perlport' states that 'device' and 'inode' are
meaningless on Win32.
The problem is: the nlink is always 1 no matter what directory/file I
stat.

On my various builds (5.6 and 5.8) of perl on both my Win2k laptop
(NTFS) and Win2k desktop (FAT), I find that stat() seems to be always
returning a value of 1 for nlink.

Can't really help much ... I wondered whether different behaviour might
be explained in terms of different file systems - NTFS versus FAT, for
instance - but the fact that my laptop and my desktop are giving the
same results would suggest that isn't a factor.

I found in 'perlport', in the section headed 'link OLDFILE,NEWFILE', the
statement that "hard links are implemented on Win32 (Windows NT and
Windows 2000) under NTFS only."
But there's no specific mention of 'nlink' in the section of perlport
that deals with the stat function.

Anyway - just thought I'd mention all that in case it triggers something
for you.

Cheers,
Rob
 
K

ko

DJ said:
Hi All,

I'm losing a lot of hair with this problem, and I hope some of you had
bumped into this problem before and can help me out.

I have 2 Windows XP machines. One desktop and one laptop. I installed
both cygwin (www.cygwin.com) and perl (www.activestate.com) late last
year (sometime in November 2002) on both computers, and everything
works fine.

Are you sure that you didn't install Cygwin's Perl last year? Try a
'perl -v' on the desktop to verify. You'll get something like this:

This is perl, v5.8.0 built for cygwin-multi-64int
....

[snip code]
The problem is: the nlink is always 1 no matter what directory/file I
stat.

Please note that the same test case above runs fine (as expected) on
my desktop. I notice that I have perl 5.6.1, and my laptop has 5.8.1,
so I uninstall 5.8.1 and install 5.6.1 thinking that it has conflict
with cygwin. Problem still exists. So, next step is to remove cygwin
and re-install it again thinking it was corrupted. No go.

Please note that when I install cygwin, I did not include perl, so I
know cygwin doesn't install perl, and my perl comes from
activestate.com installation.

Created a test script and Cygwin Perl returned the link count.

To use ActiveState Perl, created a symlink:

$ ln -s c:/perl/bin/perl.exe /usr/local/bin/perl
$ perl -v

This is perl, v5.8.1 built for MSWin32-x86-multi-thread
....

Then the test script gave the same result you are getting - a link count
of one for everything.

HTH - keith
 
D

DJ Austin

First of all, thanks for everybody who responded to my inquiry via
post or direct email. I appreciate it.

Keith is correct, the issue is with ActiveState perl installation.
Installing perl from cygwin.com solves my problem. Thanks, Keith!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top