[haiku-commits] r42619 - haiku/trunk/src/system/kernel/fs

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 10 Aug 2011 22:53:06 +0200 (CEST)

Author: axeld
Date: 2011-08-10 22:53:06 +0200 (Wed, 10 Aug 2011)
New Revision: 42619
Changeset: https://dev.haiku-os.org/changeset/42619

Modified:
   haiku/trunk/src/system/kernel/fs/vfs.cpp
Log:
* Fixed reversed handling of O_NOTRAVERSE in attr_open(), and attr_create().
* Added support for O_NOFOLLOW for those two as well.


Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/vfs.cpp    2011-08-10 19:14:49 UTC (rev 
42618)
+++ haiku/trunk/src/system/kernel/fs/vfs.cpp    2011-08-10 20:53:06 UTC (rev 
42619)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@xxxxxxx
- * Copyright 2002-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Copyright 2002-2011, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  *
  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -5308,7 +5308,7 @@
        FUNCTION(("file_open_entry_ref(ref = (%ld, %Ld, %s), openMode = %d)\n",
                mountID, directoryID, name, openMode));
 
-       bool traverse = ((openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0);
+       bool traverse = (openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0;
 
        // get the vnode matching the entry_ref
        struct vnode* vnode;
@@ -5337,7 +5337,7 @@
 static int
 file_open(int fd, char* path, int openMode, bool kernel)
 {
-       bool traverse = ((openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0);
+       bool traverse = (openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0;
 
        FUNCTION(("file_open: fd: %d, entry path = '%s', omode %d, kernel %d\n",
                fd, path, openMode, kernel));
@@ -6396,12 +6396,18 @@
        if (name == NULL || *name == '\0')
                return B_BAD_VALUE;
 
+       bool traverse = (openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0;
        struct vnode* vnode;
-       status_t status = fd_and_path_to_vnode(fd, path,
-               (openMode & O_NOTRAVERSE) != 0, &vnode, NULL, kernel);
+       status_t status = fd_and_path_to_vnode(fd, path, traverse, &vnode, NULL,
+               kernel);
        if (status != B_OK)
                return status;
 
+       if ((openMode & O_NOFOLLOW) != 0 && S_ISLNK(vnode->Type())) {
+               status = B_LINK_LIMIT;
+               goto err;
+       }
+
        if (!HAS_FS_CALL(vnode, create_attr)) {
                status = B_READ_ONLY_DEVICE;
                goto err;
@@ -6436,12 +6442,18 @@
        if (name == NULL || *name == '\0')
                return B_BAD_VALUE;
 
+       bool traverse = (openMode & (O_NOTRAVERSE | O_NOFOLLOW)) == 0;
        struct vnode* vnode;
-       status_t status = fd_and_path_to_vnode(fd, path,
-               (openMode & O_NOTRAVERSE) != 0, &vnode, NULL, kernel);
+       status_t status = fd_and_path_to_vnode(fd, path, traverse, &vnode, NULL,
+               kernel);
        if (status != B_OK)
                return status;
 
+       if ((openMode & O_NOFOLLOW) != 0 && S_ISLNK(vnode->Type())) {
+               status = B_LINK_LIMIT;
+               goto err;
+       }
+
        if (!HAS_FS_CALL(vnode, open_attr)) {
                status = B_NOT_SUPPORTED;
                goto err;


Other related posts:

  • » [haiku-commits] r42619 - haiku/trunk/src/system/kernel/fs - axeld