You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Peter Galbavy <pe...@knowtion.net> on 2002/11/20 15:50:09 UTC

"bug" in FileId() ?

Apologies for not being a subscriber to the list. My bad. I will subscribe
shortly, but I want to get this one out for comment.

In 2.49, the t/inode_names test failed on OpenBSD/i386 (3.2-current). After
quite a bit of head scratching, I >think< I know what the problem is;

The test of the stat elements [0] and [1] (in sub FileId() around line
540 -below) is redundent and will always fail where an OS may return '0' for
either value - in this case I think that 'dev' is '0' for the root
filesystem on OpenBSD:

    my @inode_stat = ();
    if($self->{inode_names}) {
        print STDERR "\ninode_names is SET\n";
        @inode_stat = stat($file);
        unless($inode_stat[0] && $inode_stat[1]) {
            @inode_stat = ();
        }
    }

perl's stat() returns and empty array if the stat fails, so the above code
can be reduced to:

   my @inode_stat = ();
    if($self->{inode_names}) {
        print STDERR "\ninode_names is SET\n";
        @inode_stat = stat($file);
    }

And it now works for me and passes all tests.

Obviously, this could just be me misunderstanding what this is meant to do,
and I am happy to be enlightened.

rgds,
--
Peter Galbavy
Knowtion Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: "bug" in FileId() ?

Posted by Josh Chamas <jo...@chamas.com>.
Ian Cass wrote:
>>What I would like to avoid is having InodeNames try to work on
>>any system for which device and file ids are 0
> 
> 
> But surely on some weird systems that might be valid? If the stat call
> fails, it will return undef. It should therefore be safe to assume that if
> the stat call does not return undef, it has suceeded and the results are
> valid?
> 

Its not that the stat call would fail, but that the
dev/file inode portions returned on the stat call
would be meaningless, like 0,0 or undef,undef

I believe I saw this a long while back on some win32 perl,
so that is why I test for the inode numbers at all.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: "bug" in FileId() ?

Posted by Ian Cass <ia...@mblox.com>.
> What I would like to avoid is having InodeNames try to work on
> any system for which device and file ids are 0

But surely on some weird systems that might be valid? If the stat call
fails, it will return undef. It should therefore be safe to assume that if
the stat call does not return undef, it has suceeded and the results are
valid?

--
Ian Cass


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: "bug" in FileId() ?

Posted by Josh Chamas <jo...@chamas.com>.
Peter Galbavy wrote:
 >
> perl's stat() returns and empty array if the stat fails, so the above code
> can be reduced to:
> 
>    my @inode_stat = ();
>     if($self->{inode_names}) {
>         print STDERR "\ninode_names is SET\n";
>         @inode_stat = stat($file);
>     }
> 
> And it now works for me and passes all tests.
> 

For now, let's try this code:

     if($self->{inode_names}) {
	@inode_stat = stat($file);
	# one or the other device or file ids must be not 0
	unless($inode_stat[0] || $inode_stat[1]) {
	    @inode_stat = ();
	}

What I would like to avoid is having InodeNames try to work on
any system for which device and file ids are 0

I'll send you a copy of this distribution privately so you
can test on your system.

Regards,

Josh

________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org