After trying for a while to debug a failing move_uploaded_file call, I tried
strace -s 8192 -o strace.log -f /etc/init.d/apache22 restart
This produced, among a lot more output, the following lines:
5069 lstat64("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
5069 lstat64("/var/apache22", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
5069 lstat64("/var/apache22/var", 0xbffe0f8c) = -1 ENOENT (No such file or directory)
(Yes, I know the path is a bit strange. It's a legacy application.)
The issue is that "/var/apache22/var" really exists. Pasting verbatim (except for [bracketed text]) from a root session:
# ls -la "/var/apache22/var"
total 24
drwxr-xr-x 6 root root 4096 Mar 7 2011 .
drwxr-xr-x 9 root root 4096 Jan 11 19:18 ..
drwxr-xr-x 10 root root 4096 Mar 7 2011 apache22
drwxr-xr-x 3 root root 4096 Mar 7 2011 log
drwxr-xr-x 2 root root 4096 Jan 11 19:36 run
drwxr-xr-x 3 root root 4096 Mar 7 2011 usr
# stat "/var/apache22/var"
File: `/var/apache22/var'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 804h/2052d Inode: 539214 Links: 6
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-01-11 19:46:47.000000000 +0100
Modify: 2011-03-07 23:27:57.000000000 +0100
Change: 2011-06-06 19:39:40.000000000 +0200
# mount
/dev/sda1 on / type ext3 (rw)
/dev/sda3 on /usr type ext3 (rw)
/dev/sda4 on /var type ext3 (rw)
sysfs on /sys type sysfs (rw)
/var/[product name] on /var/apache22/var/apache22/export/[product name] type none (rw,bind)
There are no symlinks:
# file / /var /var/apache22 /var/apache22/var
/: directory
/var: directory
/var/apache22: directory
/var/apache22/var: directory
# uname -r
2.6.29.6
/proc/1/mountinfoand/proc/5069/mountinfo? Doessetpersonalityappear in the strace? – Gilles Jan 11 '12 at 17:12chroot()involved? – Celada Jan 11 '12 at 17:14