stat vs open and pmc files
Nicholas Clark
nick at ccl4.org
Fri Jul 14 18:45:50 BST 2006
On Fri, Jul 14, 2006 at 04:26:34PM +0100, David Cantrell wrote:
> Why does perl use stat() to see if a .pmc file exists, but open() to see
> if a .pm file exists?
>
> eg from strace ...
>
> stat64("/usr/lib/perl5/5.8.3/i586-linux-thread-multi/DirHandle.pmc",
> 0xbfffede0) = -1 ENOENT (No such file or directory)
> open("/usr/lib/perl5/5.8.3/i586-linux-thread-multi/DirHandle.pm",
> O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
> stat64("/usr/lib/perl5/5.8.3/DirHandle.pmc", 0xbfffede0) = -1 ENOENT (No
> such file or directory)
> open("/usr/lib/perl5/5.8.3/DirHandle.pm", O_RDONLY|O_LARGEFILE) = 4
It seems it's actually using stat to decide which one to open:
if (PerlLIO_stat(pmc, &pmcstat) < 0) {
fp = check_type_and_open(name, mode);
}
else {
fp = check_type_and_open(pmc, mode);
}
Nicholas Clark
More information about the london.pm
mailing list