Re: [RFC] What should we do with FAT inode numbers?

Mitchell Blank Jr (mitch@execpc.com)
Sat, 16 Jan 1999 14:16:02 -0600


Colin Plumb wrote:
>> This means that zero-length files sort of have no identity. I'm not
>> too terribly worried about that.

> Unfortunately, this is the one case where constant inode numbers really
> do matter. Almost any program that encodes the inode number in the datafile
> will do something like:
> f=creat(...); // f is now zero-length
> fstat(f,&st); // get the inode number
> sprintf(buf,"%d\n",st.st_ino);
> write(f,buf,strlen(buf)); // oops... inode number just changed..

> No, I don't have a solution for this problem.

Well, the solution to this is a simple extension of the one I mentioned:
pre-emptively allocate a block to the file when it is created. Then the
inode number only changes if it is closed *without* writing anything to it.

That will solve the common case above. The only difficult one is
f=creat(name, ...); // f is now zero-length
fstat(f,&st); // get the inode number
close(f);
stat(name,&st2); // oops... inode number just changed

-- 
	-Colin

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/