Messages in this thread Patch in this message | | | Date | Sun, 24 Jan 1999 21:50:42 -0800 (PST) | From | Linus Torvalds <> | Subject | Re: pre9/final-Bug, introduced in pre8 |
| |
On Sun, 24 Jan 1999, Kurt Huwig wrote: > > I narrowed down my problem and it was introduced in pre8: > > Compile this code > > ---- cut here ---- > #include <fcntlbits.h> > void main( int argc, char *argv[] ) { > open( argv[ 1 ], O_WRONLY|O_CREAT|O_TRUNC, 0666 ); > } > ---- and here ---- > > and run it like this > > strace ./a.out >(cat - ) > > with 2.0.36 & 2.2.0-pre[67] you get: > > open("/dev/fd/63", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 > > with 2.2.0-pre[89] you get: > > open("/dev/fd/63", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 ENOENT (No > such file or directory)
Ok, this seems to be due to pre9 removing some rather bogus code that happened to hide another problem in open_namei().
I haven't actually tested this, but it looks really obvious, so does this patch fix it for you? (This should also fix a potential performance bogosity - there's absolutely no reason why we should get the directory lock when we don't need to for a normal open of an existing file).
Linus
----- --- v2.2.0-pre9/linux/fs/namei.c Wed Jan 20 23:14:06 1999 +++ linux/fs/namei.c Sun Jan 24 21:48:39 1999 @@ -678,9 +678,12 @@ if (flag & O_CREAT) { struct dentry *dir; - error = -EEXIST; - if (dentry->d_inode && (flag & O_EXCL)) + if (dentry->d_inode) { + if (!(flag & O_EXCL)) + goto nocreate; + error = -EEXIST; goto exit; + } dir = lock_parent(dentry); if (!check_parent(dir, dentry)) { @@ -723,6 +726,7 @@ goto exit; } +nocreate: error = -ENOENT; inode = dentry->d_inode; if (!inode)
- 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/
| |