_kern_open[_entry_ref]() now replaces the _kern_create[_entry_ref]() calls.

That allows BFile to actually create files (it didn't use that syscall at
all before).
Also fixed setting the permission bits of the newly created file depending on umask
(the __gUmask variable should probably be moved into a separate header).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11208 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-02-02 06:26:47 +00:00
parent 2ab3ff4495
commit 3af4214aeb
2 changed files with 18 additions and 12 deletions
+12 -6
View File
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
// This software is part of the Haiku distribution and is covered
// by the MIT license.
//---------------------------------------------------------------------
/*!
\file File.cpp
@@ -16,6 +16,11 @@
#include <syscalls.h>
extern mode_t __gUmask;
// declared in sys/umask.c
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
@@ -158,7 +163,7 @@ BFile::SetTo(const entry_ref *ref, uint32 openMode)
openMode |= O_CLOEXEC;
int fd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
openMode);
openMode, DEFFILEMODE & ~__gUmask);
if (fd >= 0) {
set_fd(fd);
fMode = openMode;
@@ -200,7 +205,8 @@ BFile::SetTo(const BEntry *entry, uint32 openMode)
openMode |= O_CLOEXEC;
int fd = _kern_open(entry->fDirFd, entry->fName, openMode | O_CLOEXEC);
int fd = _kern_open(entry->fDirFd, entry->fName, openMode | O_CLOEXEC,
DEFFILEMODE & ~__gUmask);
if (fd >= 0) {
set_fd(fd);
fMode = openMode;
@@ -238,7 +244,7 @@ BFile::SetTo(const char *path, uint32 openMode)
openMode |= O_CLOEXEC;
int fd = _kern_open(-1, path, openMode);
int fd = _kern_open(-1, path, openMode, DEFFILEMODE & ~__gUmask);
if (fd >= 0) {
set_fd(fd);
fMode = openMode;
@@ -280,7 +286,7 @@ BFile::SetTo(const BDirectory *dir, const char *path, uint32 openMode)
openMode |= O_CLOEXEC;
int fd = _kern_open(dir->fDirFd, path, openMode);
int fd = _kern_open(dir->fDirFd, path, openMode, DEFFILEMODE & ~__gUmask);
if (fd >= 0) {
set_fd(fd);
fMode = openMode;
+6 -6
View File
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
// This software is part of the Haiku distribution and is covered
// by the MIT license.
//----------------------------------------------------------------------
/*!
\file Node.cpp
@@ -700,10 +700,10 @@ BNode::_SetTo(int fd, const char *path, bool traverse)
status_t error = (fd >= 0 || path ? B_OK : B_BAD_VALUE);
if (error == B_OK) {
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
fFd = _kern_open(fd, path, O_RDWR | O_CLOEXEC | traverseFlag);
fFd = _kern_open(fd, path, O_RDWR | O_CLOEXEC | traverseFlag, 0);
if (fFd < B_OK && fFd != B_ENTRY_NOT_FOUND) {
// opening read-write failed, re-try read-only
fFd = _kern_open(fd, path, O_RDONLY | O_CLOEXEC | traverseFlag);
fFd = _kern_open(fd, path, O_RDONLY | O_CLOEXEC | traverseFlag, 0);
}
if (fFd < 0)
error = fFd;
@@ -734,11 +734,11 @@ BNode::_SetTo(const entry_ref *ref, bool traverse)
if (error == B_OK) {
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
fFd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
O_RDWR | O_CLOEXEC | traverseFlag);
O_RDWR | O_CLOEXEC | traverseFlag, 0);
if (fFd < B_OK && fFd != B_ENTRY_NOT_FOUND) {
// opening read-write failed, re-try read-only
fFd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
O_RDONLY | O_CLOEXEC | traverseFlag);
O_RDONLY | O_CLOEXEC | traverseFlag, 0);
}
if (fFd < 0)
error = fFd;