how can I tell when my shared text file is in use?

guy at rlgvax.UUCP guy at rlgvax.UUCP
Sat May 12 15:51:12 AEST 1984


> The method i have used (successfully) in the past tackles the problem in
> another way.  ... Then, when it comes to installing the program you use a
> make line which effectively does this series of operations:

> 	rm -f $(INSD)/n$(PRODUCT)
> 	cp $(PRODUCT) $(INSD)/n$(PRODUCT)
> 	cd $(INSD); mv $(PRODUCT) o$(PRODUCT); mv n$(PRODUCT) $(PRODUCT); \
> 		rm -f o$(PRODUCT)

The standard USG UNIX "install" command (in "/etc/install") has a "-o"
option which does exactly this.  The "install" command copies something
to an install directory; if the "-o" option is specified, the current
copy is renamed OLDwhatever and the new one moved there.

By the way, though, the prohibition against removing active shared text
program is not a requirement; 4.1BSD removed it by #ifdefing the four lines
of code in "sys4.c" out that enforce it (the lines are in the "unlink"
routine and read

	if (ip->i_flag&ITEXT && ip->i_nlink == 1) {
		u.u_error = ETXTBSY;
		goto out;
	}

There's no harm in doing so - the inode will not be freed until
the last program using the shared text stops using it; the same is true
of open files (the inode is not freed until the last program using it closes
the file), which the system does let you unlink.  A claim I heard was that
the only reason that prohibition was there was because if the system
crashed, and such files had been unlinked, they would show up as
unreferenced inodes in an "fsck".  Well, 1) so would any files which were
open and had been unlinked, 2) a reasonable version of "fsck" will be able
to fix such things automatically at boot time (Berkeley deserves much praise
for "fsck -p", which USG did *their own version* of and didn't do it as
well!  While I'm on that subject, "/etc/fstab" is also very nice - are you
listening, USG?), and 3) anybody who's worked with Files-11 (the RSX/IAS/VMS
file system) has certainly heard of files "marked for deletion" - the same
sort of thing (half-deleted files) appears in lots of other OSes too.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list