Discussion:
filesize() fails on file and works on it's copy (same permissions, same directory)
Michał Kochanowicz
2013-08-13 08:00:45 UTC
Permalink
Hello

I've got a file, which can't be checked with filesize(). I copy it (with
permissions) and then I can filesize() the copy. This is same directory,
permissions are same. I don't understand what's the difference. Can you help me?

Original file:
File: 'DSC_5196_fx-1553725666.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 5905591363 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:47:28.107477918 +0200
Modify: 2013-08-12 21:38:27.219913208 +0200
Change: 2013-08-13 00:47:08.931478654 +0200
Birth: -

Copy:
File: 'DSC_5196_fx-1553725666_X.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 144 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:45:48.000000000 +0200
Modify: 2013-08-12 21:38:27.000000000 +0200
Change: 2013-08-13 00:47:28.199477914 +0200
Birth: -

The only difference is inode: (5905591363 - doesn't work vs 144 - does work).

Test script:

<html>
<body>
<pre>
<?
$f3 =
'/home/services/Loading Image...';
$f4 =
'/home/services/Loading Image...';

print $f3.": ".filesize($f3)."\n";
print $f4.": ".filesize($f4)."\n";

?>
</pre>
</body>
</html>

Result:

Warning: filesize(): stat failed for
/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG
in /home/services/httpd/html.galeria.michal.waw.pl/gallery3-3.0.x/test.php on
line 13
/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG:

/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666_X.JPG:
1907383

Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Negin Nickparsa
2013-09-23 08:06:02 UTC
Permalink
regardless of you, saying they have same permissions I think they do not
have the same permission

try to use --reference for chmod to see if there is any differences

try to copy the file keeping the whole permissions from original using sudo
cp -rp and check.
if this copy has the warning then your problem is from the permissions.


Sincerely
Negin Nickparsa


On Tue, Aug 13, 2013 at 11:30 AM, Michał Kochanowicz
Post by Michał Kochanowicz
Hello
I've got a file, which can't be checked with filesize(). I copy it (with
permissions) and then I can filesize() the copy. This is same directory,
permissions are same. I don't understand what's the difference. Can you help me?
File: 'DSC_5196_fx-1553725666.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 5905591363 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:47:28.107477918 +0200
Modify: 2013-08-12 21:38:27.219913208 +0200
Change: 2013-08-13 00:47:08.931478654 +0200
Birth: -
File: 'DSC_5196_fx-1553725666_X.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 144 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:45:48.000000000 +0200
Modify: 2013-08-12 21:38:27.000000000 +0200
Change: 2013-08-13 00:47:28.199477914 +0200
Birth: -
The only difference is inode: (5905591363 - doesn't work vs 144 - does work).
<html>
<body>
<pre>
<?
$f3 = '/home/services/httpd/html.**galeria.XXX/gallery/var/**
albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**
DSC_5196_fx-1553725666.JPG';
$f4 = '/home/services/httpd/html.**galeria.XXX/gallery/var/**
albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**
DSC_5196_fx-1553725666_X.JPG';
print $f3.": ".filesize($f3)."\n";
print $f4.": ".filesize($f4)."\n";
?>
</pre>
</body>
</html>
Warning: filesize(): stat failed for /home/services/httpd/html.**
galeria.XXX/gallery/var/**albums/988_Rok-2013/333_**
Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG in
/home/services/httpd/html.**galeria.michal.waw.pl/**
gallery3-3.0.x/test.php<http://html.galeria.michal.waw.pl/gallery3-3.0.x/test.php>on line 13
/home/services/httpd/html.**galeria.XXX/gallery/var/**
/home/services/httpd/html.**galeria.XXX/gallery/var/**
1907383
Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Carsten Jensen
2013-09-23 10:16:48 UTC
Permalink
if you have console access and the cli version of php works,
what does

echo filesize('/path/to/file');

tell (try running as root, then later as uid 51/webuser)
this will eliminate permission doubts

also you should use <?php as start tag instead of only <?

cheers
Carsten
Post by Negin Nickparsa
regardless of you, saying they have same permissions I think they do not
have the same permission
try to use --reference for chmod to see if there is any differences
try to copy the file keeping the whole permissions from original using sudo
cp -rp and check.
if this copy has the warning then your problem is from the permissions.
Sincerely
Negin Nickparsa
On Tue, Aug 13, 2013 at 11:30 AM, Michał Kochanowicz
Post by Michał Kochanowicz
Hello
I've got a file, which can't be checked with filesize(). I copy it (with
permissions) and then I can filesize() the copy. This is same directory,
permissions are same. I don't understand what's the difference. Can you help me?
File: 'DSC_5196_fx-1553725666.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 5905591363 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:47:28.107477918 +0200
Modify: 2013-08-12 21:38:27.219913208 +0200
Change: 2013-08-13 00:47:08.931478654 +0200
Birth: -
File: 'DSC_5196_fx-1553725666_X.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 144 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:45:48.000000000 +0200
Modify: 2013-08-12 21:38:27.000000000 +0200
Change: 2013-08-13 00:47:28.199477914 +0200
Birth: -
The only difference is inode: (5905591363 - doesn't work vs 144 - does work).
<html>
<body>
<pre>
<?
$f3 = '/home/services/httpd/html.**galeria.XXX/gallery/var/**
albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**
DSC_5196_fx-1553725666.JPG';
$f4 = '/home/services/httpd/html.**galeria.XXX/gallery/var/**
albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**
DSC_5196_fx-1553725666_X.JPG';
print $f3.": ".filesize($f3)."\n";
print $f4.": ".filesize($f4)."\n";
?>
</pre>
</body>
</html>
Warning: filesize(): stat failed for /home/services/httpd/html.**
galeria.XXX/gallery/var/**albums/988_Rok-2013/333_**
Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG in
/home/services/httpd/html.**galeria.michal.waw.pl/**
gallery3-3.0.x/test.php<http://html.galeria.michal.waw.pl/gallery3-3.0.x/test.php>on line 13
/home/services/httpd/html.**galeria.XXX/gallery/var/**
/home/services/httpd/html.**galeria.XXX/gallery/var/**
1907383
Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Michał Kochanowicz
2013-09-23 19:23:19 UTC
Permalink
regardless of you, saying they have same permissions I think they do not have
the same permission
The reason was 64-bit inode number. PHP can't stat() files with 64-bit nodes,
at lease on 32-bit system.

Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tamara Temple
2013-09-23 15:24:39 UTC
Permalink
Hello
I've got a file, which can't be checked with filesize(). I copy it (with permissions) and then I can filesize() the copy. This is same directory, permissions are same. I don't understand what's the difference. Can you help me?
File: 'DSC_5196_fx-1553725666.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 5905591363 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:47:28.107477918 +0200
Modify: 2013-08-12 21:38:27.219913208 +0200
Change: 2013-08-13 00:47:08.931478654 +0200
Birth: -
File: 'DSC_5196_fx-1553725666_X.JPG'
Size: 1907383 Blocks: 3728 IO Block: 4096 regular file
Device: 803h/2051d Inode: 144 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 51/ http) Gid: ( 51/ http)
Access: 2013-08-13 00:45:48.000000000 +0200
Modify: 2013-08-12 21:38:27.000000000 +0200
Change: 2013-08-13 00:47:28.199477914 +0200
Birth: -
The only difference is inode: (5905591363 - doesn't work vs 144 - does work).
<html>
<body>
<pre>
<?
$f3 = '/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG';
$f4 = '/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666_X.JPG';
print $f3.": ".filesize($f3)."\n";
print $f4.": ".filesize($f4)."\n";
?>
</pre>
</body>
</html>
Warning: filesize(): stat failed for /home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG in /home/services/httpd/html.galeria.michal.waw.pl/gallery3-3.0.x/test.php on line 13
/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666_X.JPG: 1907383
Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
That is one whopping-big inode number — I am really out on a limb here, but is this a 32-bit vs 64-bit issue?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Michał Kochanowicz
2013-09-23 19:24:22 UTC
Permalink
Post by Tamara Temple
That is one whopping-big inode number — I am really out on a limb here, but is this a 32-bit vs 64-bit issue?
You're right - 64-bit inode number was a cause. I had to add "inode32" mount
option (XFS).

Regards
Michał
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Search results for 'filesize() fails on file and works on it's copy (same permissions, same directory)' (Questions and Answers)
43
replies
Do they have a yahoo Answers where you live?
started 2006-09-14 15:54:56 UTC
polls & surveys
Loading...