Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
Is that a 32-bit or 64-bit binary? What's the distribution? Is there any virtualization or security feature around (lxr, chroot, SELinux, …)? Are there differences between /proc/1/mountinfo and /proc/5069/mountinfo? Does setpersonality appear in the strace? – Gilles Jan 11 '12 at 17:12
is there a chroot() involved? – Celada Jan 11 '12 at 17:14
@Celada: Looks like that's the issue. If you promote your comment to an answer I'll accept that. – l0b0 Jan 12 '12 at 7:40
@l0b0 ...uh... I'm not really sure if that's proper stackoverflow protocol but okay. I made it a comment instead of an answer in the first place because it was a shot in the dark. – Celada Jan 12 '12 at 10:11
That's fine. I think it's pretty common to "promote" comments to answers if they hit spot on. – l0b0 Jan 12 '12 at 10:48
up vote 2 down vote accepted

Check if Apache is running inside a chroot(). It's the case I can think of where you see /var/apache22/var and it doesn't actually mean /var/apache22/var.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.