diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 4425381197..ceee31b55c 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -2109,6 +2109,11 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m return B_NOT_ALLOWED; if (openMode & O_TRUNC) { + // we need write access in order to truncate the file + status = inode->CheckPermission(W_OK); + if (status != B_OK) + return status; + // truncate the existing file WriteLocked locked(inode->Lock()); @@ -2131,6 +2136,10 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m } else if (parent && (mode & S_ATTR_DIR) == 0) return B_BAD_VALUE; + // do we have the power to create new files at all? + if (parent != NULL && (status = parent->CheckPermissions(W_OK)) != B_OK) + RETURN_ERROR(status); + // allocate space for the new inode InodeAllocator allocator(transaction); block_run run; 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 9bd9375b0c..c317ecdd59 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -726,10 +726,6 @@ bfs_create(void *_ns, void *_directory, const char *name, int omode, int mode, if (!directory->IsDirectory()) RETURN_ERROR(B_BAD_TYPE); - status_t status = directory->CheckPermissions(W_OK); - if (status < B_OK) - RETURN_ERROR(status); - // We are creating the cookie at this point, so that we don't have // to remove the inode if we don't have enough free memory later... file_cookie *cookie = (file_cookie *)malloc(sizeof(file_cookie));