Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site warwick.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!mhuxt!mhuxr!ulysses!allegra!mit-eddie!think!harvard!seismo!mcvax!ukc!warwick!cudcv From: cudcv@daisy.warwick.UUCP (Rob McMahon) Newsgroups: net.unix-wizards Subject: Re: /tmp versus temporary file types Message-ID: <136@daisy.warwick.UUCP> Date: Fri, 13-Sep-85 11:54:23 EDT Article-I.D.: daisy.136 Posted: Fri Sep 13 11:54:23 1985 Date-Received: Sun, 29-Sep-85 04:19:40 EDT References: <136@mcgill-vision.UUCP> Reply-To: cudcv@daisy.UUCP (Rob McMahon) Organization: Computer Unit, Warwick University, UK Lines: 42 Xpath: warwick daisy daisy ubu In article <136@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes: >> ....like to see some discussion on: /tmp. >> ....anybody can 'rm /tmp/*', read files there, etc.... > > unlink(tempfn); /* in case a file by that name already exists */ > fd = open(tempfn,O_CREAT|O_TRUNC|O_RDWR,0644); > /* O_RDWR and 0644 are variable depending on the application */ > unlink(tempfn); I have always felt this was a mess. How about an O_TEMP option to open, so that you can do something like fd = open(dirname, O_TEMP); to atomically create and unlink a file on the same filesystem as dirname if the user has write permission to the directory dirname. This would save having to guess a unique name, checking to see if the name already existed, leaving files around if the program or system crashed between the open and the unlink, people accidentally removing other peoples temporary files (I get people coming to me saying "but I didn't think the system would let me remove other peoples files", having destroyed half a dozen peoples long troff jobs running in the background). A new system call flink(fd, name, mode) char *name; would be useful too, so that a link could be created for an open temporary file. This would save file transfer programs, for example, having to create a temporary file on the same file system, which it leaves around if it fails (or worse yet overwrite the existing file before it knows whether the transfer will succeed. Daemons wouldn't have to create files tf... and change them to cf... later. Doesn't this seem like a cleaner way of working ? I look at my /tmp filesystem which is normally 2% full, but occasionally overflows with disasterous consequences, and I cringe. Maybe we could do away with those find /tmp -mtime +1 -exec rm -f {} \; things in /etc/rc and crontab ? Any thoughts ... Rob McMahon, Computer Unit, Warwick University, Coventry, England UUCP: ..!mcvax!ukc!warwick!cudcv Brought to you by Super Global Mega Corp .com