bfs_create() now only checks for write access in the parent directory if a
file really has to be created, thanks to Ingo for reporting this. Inode::Create() now checks for write access to the inode when O_TRUNC is set. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10272 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user