From ef948c3cc75acd6d61d2ef6de17cfe1262d84230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 27 Nov 2004 13:55:28 +0000 Subject: [PATCH] Yeah, sure, don't compile stuff before checking it in. bfs_open_dir() now checks for read access. bfs_lookup() now checks for execute access and not read access anymore (as reported by Ingo as well). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10273 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 6 ++++-- .../kernel/file_systems/bfs/kernel_interface.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index ceee31b55c..aae157f3c1 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -2110,7 +2110,7 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m if (openMode & O_TRUNC) { // we need write access in order to truncate the file - status = inode->CheckPermission(W_OK); + status = inode->CheckPermissions(W_OK); if (status != B_OK) return status; @@ -2136,6 +2136,8 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m } else if (parent && (mode & S_ATTR_DIR) == 0) return B_BAD_VALUE; + status_t status; + // do we have the power to create new files at all? if (parent != NULL && (status = parent->CheckPermissions(W_OK)) != B_OK) RETURN_ERROR(status); @@ -2144,7 +2146,7 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m InodeAllocator allocator(transaction); block_run run; Inode *inode; - status_t status = allocator.New(&parentRun, mode, run, &inode); + status = allocator.New(&parentRun, mode, run, &inode); if (status < B_OK) return status; diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index c317ecdd59..f2bc562c7e 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -426,7 +426,7 @@ bfs_lookup(void *_ns, void *_directory, const char *file, vnode_id *_vnodeID, in Inode *directory = (Inode *)_directory; // check access permissions - status_t status = directory->CheckPermissions(R_OK); + status_t status = directory->CheckPermissions(X_OK); if (status < B_OK) RETURN_ERROR(status); @@ -742,7 +742,7 @@ bfs_create(void *_ns, void *_directory, const char *name, int omode, int mode, #endif Transaction transaction(volume, directory->BlockNumber()); - status = Inode::Create(transaction, directory, name, S_FILE | (mode & S_IUMSK), + status_t status = Inode::Create(transaction, directory, name, S_FILE | (mode & S_IUMSK), omode, 0, vnodeID); if (status >= B_OK) { @@ -1375,8 +1375,8 @@ bfs_remove_dir(void *_ns, void *_directory, const char *name) } -/** creates fs-specific "cookie" struct that keeps track of where - * you are at in reading through directory entries in bfs_readdir. +/** Opens a directory ready to be traversed. + * bfs_open_dir() is also used by bfs_open_index_dir(). */ static status_t @@ -1389,6 +1389,10 @@ bfs_open_dir(void *_ns, void *_node, void **_cookie) Inode *inode = (Inode *)_node; + status_t status = inode->CheckPermissions(R_OK); + if (status < B_OK) + RETURN_ERROR(status); + // we don't ask here for directories only, because the bfs_open_index_dir() // function utilizes us (so we must be able to open indices as well) if (!inode->IsContainer())