[comp.os.minix] Bug in source file "link.c"

Bruno_Kieba.SBDERX@xerox.com (06/23/88)

When I  implemented the capability-based protection in Minix 1.1, I came across
a little bug (or is there?) in the original file system source file "link.c".  I
corrected it anyhow in my source.  If Dr. Andy Tanenbaum reads this mail note
then this bug could be corrected before the release of 1.3 (please tell me if I
am wrong!).

In the source file "link.c" (File System, Minix 1.1),  if the final directory of
"name2" does not exist (line #11304) then the i-node of "name", previously read
into the i-node table (line #11287), is never "put-inoded" and thus wastes
resources (ie: i-node table entries and file descriptor entries in process table
if many unsuccessful linking to "name2" happen).
If Minix was locking files (UNIX does), then this could entail a deadlock!

The code I guess should be like:

11304		if  (fetch-name(name2, name2-length, M1) != OK)	{
11304.1 ----->	put-inode(rip);      /* put "name"'s i-node first  */
11304.2		return(err-code); /* before returning an error */
11304.3	}
11305		.....(same).....

Am I right?

Bruno 

ast@cs.vu.nl (Andy Tanenbaum) (06/27/88)

In article <3089@louie.udel.EDU> Bruno_Kieba.SBDERX@xerox.com writes:
>... a little bug [in] file system source file "link.c".  
>11304		if  (fetch-name(name2, name2-length, M1) != OK)	{
>11304.1 ----->	put-inode(rip);      /* put "name"'s i-node first  */
>11304.2		return(err-code); /* before returning an error */
>11304.3	}
>11305		.....(same).....

This analysis is correct and has already been noted in this group and fixed in 1.3.

Andy Tanenbaum (ast@cs.vu.nl)
-- 
Andy Tanenbaum (ast@cs.vu.nl)