Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.
Moderator: General Moderators
dml
Forum Contributor
Posts: 133 Joined: Sat Jan 26, 2008 2:20 pm
Post
by dml » Sat Jan 26, 2008 2:29 pm
Hi, any reason why the "blksize" and "blocks" elements returned by stat() should be -1? Just curious.
Code: Select all
> stat testfile
File: `testfile'
Size: 223 Blocks: 8 IO Block: 4096 regular file
> php -r '$s = stat("testfile");var_dump($s["blocks"]);'
int(-1)
> php --version
PHP 5.2.0-8+etch9 (cli) (built: Dec 29 2007 03:30:27)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Sat Jan 26, 2008 2:42 pm
Hm ...
Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1.
Weird ...
I have no problems with this:
~# php --version
PHP 5.2.4 (cli) (built: Oct 27 2007 19:25:27)
~# stat 1.txt
File: `1.txt'
Size: 13389 Blocks: 32 IO Block: 131072 regular file
~# php -r '$s = stat("1.txt");var_dump($s["blocks"]);'
int(32)
There are 10 types of people in this world, those who understand binary and those who don't
dml
Forum Contributor
Posts: 133 Joined: Sat Jan 26, 2008 2:20 pm
Post
by dml » Sat Jan 26, 2008 3:08 pm
Yeah, I was wondering about that st_blksize thing. I don't know what it is, nor how to confirm whether my (Linux) system supports it. Nevertheless, it seems strange that PHP compiled for Linux can't just make the system call to get the information.
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Sat Jan 26, 2008 4:00 pm
Just tried it with:
Code: Select all
php --version
PHP 5.2.0-8+etch10 (cli) (built: Jan 18 2008 18:52:58)
The same result as yours:
Code: Select all
["blksize"]=>
int(-1)
["blocks"]=>
int(-1)
I don't know what's hapenning... Maybe this is a fixed PHP5 CLI bug in later versions.
There are 10 types of people in this world, those who understand binary and those who don't
dml
Forum Contributor
Posts: 133 Joined: Sat Jan 26, 2008 2:20 pm
Post
by dml » Sat Jan 26, 2008 4:58 pm
Thanks for trying that out. Good to know it's not something weird with the way I've set up my system.