Fixed the case that a file to be created non-exclusively is a symlink

(bug #2183).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25271 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-04-30 14:21:02 +00:00
parent ec12806d2f
commit 503912f733
1 changed files with 19 additions and 0 deletions

View File

@ -4498,6 +4498,25 @@ create_vnode(struct vnode *directory, const char *name, int openMode,
if ((openMode & O_EXCL) != 0)
return B_FILE_EXISTS;
// If the node is a symlink, we have to follow it, unless
// O_NOTRAVERSE is set.
if (S_ISLNK(vnode->type) && (openMode & O_NOTRAVERSE) == 0) {
putter.Put();
char clonedName[B_FILE_NAME_LENGTH + 1];
if (strlcpy(clonedName, name, B_FILE_NAME_LENGTH)
>= B_FILE_NAME_LENGTH) {
return B_NAME_TOO_LONG;
}
inc_vnode_ref_count(directory);
status = vnode_path_to_vnode(directory, clonedName, true, 0,
kernel, &vnode, NULL);
if (status != B_OK)
return status;
putter.SetTo(vnode);
}
status = open_vnode(vnode, openMode & ~O_CREAT, kernel);
// on success keep the vnode reference for the FD
if (status >= 0)