[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debian-user-digest Digest V2004 #384



On Sun, 2004-02-01 at 16:21, debian-user-digest-request@lists.debian.org
wrote:
> 
> ______________________________________________________________________
> 
> From: C. Chad Wallace <ccwall@telus.net>
> To: d-user <debian-user@lists.debian.org>
> Subject: Re: Huge apache temp files
> Date: 01 Feb 2004 12:54:14 -0800
> 
> C. Chad Wallace wrote:
> > Hello,
> > 
> > I noticed today that apache is filling up my disk with a huge file in 
> > /tmp.  Two files show up in /tmp if I have either apache or apache-ssl 
> > running and are removed when both are stopped.  Here are the two files 
> > in /tmp:
> > 
> > -rw-------    1 root     root     67108864 Feb  1 11:09 
> > session_mm_apache0.mem
> > -rw-------    1 root     root            0 Feb  1 11:09 
> > session_mm_apache0.sem
> 
> Well, it appears I jumped the gun on blaming that file for filling my 
> disk. :-)  Upon closer inspection (namely 'ls -hsl'), it looks like the 
> file only takes up one kilobyte.  But I'm still curious as to why the 
> other size field shows such a huge number.
> 
> Chad.

Unix can create files with "holes". I.E. no space allocated to the hole.
For example:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

main(int argc, char **argv)
{
  int fd;
  int buf = 1;

  fd = open("/tmp/xxx", O_RDWR|O_CREAT|O_EXCL);
  lseek(fd, 10000000, SEEK_SET);
  write(fd, &buf, 1);
  close(fd);
  exit(0);
}
-------------------------------------
This creates a file that seems to be 10000000 bytes long - as shown by
ls, but actually only takes a single byte. du shows it as 8K long since
this is the minimum amount that can actually be allocated. This is well
known in the data base community, since if you dump/restore these files
in a simple-minded way, they become actually as large as they seem to
be.
-- 
Graham Campbell <gc1111@optonline.net>



Reply to: