[comp.unix.internals] 15mb file exist but doesn't appear in ls or find

coleman@cam.nist.gov (Sean Sheridan Coleman X5672) (09/08/90)

I own a SparcStation 1+ running 4.1 SunOS. I created a large mail folder of 
~ 15mb. When I ran mail, my /tmp directory reduced in size by 15mb but I can't
find a single file that is 15mb large. I found the inode number of the file 
but doing a find -inum in /tmp, that file didn't show. What gives?

On the same line, if the content of my large file is in /tmp physically, hoe
can a programmer write code to do a similar operation, ie put data on a disk
without creating a file?

Third, I want to write a program to sort the mail. I had two ideas to do this:
1. create a linked list of structures that contained the key I wanted to sort on,
the offset into the file where the mail message starts and ends. I would then
sort the linked list and write back the file to disk using the lseek() calls .

2. The second idea I had was to do a quick sort or merge sort using random access
sorting but I wondered how to swap the contents of one place on the disk with the
other place on the disk. If one message were larger then the other message,
wouldn't the larger message write over the message that followed the old message
that you switched with? Is there a way to push all the messages that follow the
smaller of the two messages to make room for the new larger message?

Are there other ideas out there to do this sort?

Thanks very much for the assistance.

Sean Coleman
NIST

Boulder, CO

coleman@bldrdoc.gov

cpcahil@virtech.uucp (Conor P. Cahill) (09/09/90)

In article <4887@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes:
>I own a SparcStation 1+ running 4.1 SunOS. I created a large mail folder of 
>~ 15mb. When I ran mail, my /tmp directory reduced in size by 15mb but I can't
>find a single file that is 15mb large. I found the inode number of the file 
>but doing a find -inum in /tmp, that file didn't show. What gives?

The file probably has been removed but is still open by some process.  When a 
file is removed (unlinked(2)) and there are no file system hard links to that
file, the directory entry is removed from the directory.  If there are any   
processes that have that file open, the file will continue to exist until all
of the processes accessing the file close it.

>On the same line, if the content of my large file is in /tmp physically, hoe
>can a programmer write code to do a similar operation, ie put data on a disk
>without creating a file?

Actually you create the file (thereby having an open file descriptor) and 
ulink it immediatly.  The file will be gone (no other program can get to it)
and when your process closes the file (or the kernel closes it when your
program exits) the data associated with the file will go away.

>Are there other ideas out there to do this sort?

Yes:

	1. use a mailer that allows you to specify a sorted order (like ELM)
	2. sort the data into a second file and then replace the original
	   file with the sorted file.


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

dold@mitisft.Convergent.COM (Clarence Dold) (09/10/90)

in article <4887@alpha.cam.nist.gov>, coleman@cam.nist.gov (Sean Sheridan Coleman X5672) says:

> ~ 15mb. When I ran mail, my /tmp directory reduced in size by 15mb but I can't
> find a single file that is 15mb large. I found the inode number of the file 
> but doing a find -inum in /tmp, that file didn't show. What gives?

You can fopen(), or create a file in any manner you'd care to, and immediately
unlink it.  This leaves it occupying space on disk, with an inode, but no name.
tmpfile(3S) does just that.  The advantage is that a "scratch" file will be
removed when your program terminates for any reason (the last close of a file
with no links (names)).  
-- 
---
Clarence A Dold - dold@tsmiti.Convergent.COM            (408) 435-5293
               ...pyramid!ctnews!tsmiti!dold        FAX (408) 435-3105
               P.O.Box 6685, San Jose, CA 95150-6685         MS#10-007