_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:
@@ -1,6 +1,6 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the OpenBeOS license.
|
// by the MIT license.
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
\file File.cpp
|
\file File.cpp
|
||||||
@@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern mode_t __gUmask;
|
||||||
|
// declared in sys/umask.c
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
#ifdef USE_OPENBEOS_NAMESPACE
|
||||||
namespace OpenBeOS {
|
namespace OpenBeOS {
|
||||||
#endif
|
#endif
|
||||||
@@ -158,7 +163,7 @@ BFile::SetTo(const entry_ref *ref, uint32 openMode)
|
|||||||
openMode |= O_CLOEXEC;
|
openMode |= O_CLOEXEC;
|
||||||
|
|
||||||
int fd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
|
int fd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
|
||||||
openMode);
|
openMode, DEFFILEMODE & ~__gUmask);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
set_fd(fd);
|
set_fd(fd);
|
||||||
fMode = openMode;
|
fMode = openMode;
|
||||||
@@ -200,7 +205,8 @@ BFile::SetTo(const BEntry *entry, uint32 openMode)
|
|||||||
|
|
||||||
openMode |= O_CLOEXEC;
|
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) {
|
if (fd >= 0) {
|
||||||
set_fd(fd);
|
set_fd(fd);
|
||||||
fMode = openMode;
|
fMode = openMode;
|
||||||
@@ -238,7 +244,7 @@ BFile::SetTo(const char *path, uint32 openMode)
|
|||||||
|
|
||||||
openMode |= O_CLOEXEC;
|
openMode |= O_CLOEXEC;
|
||||||
|
|
||||||
int fd = _kern_open(-1, path, openMode);
|
int fd = _kern_open(-1, path, openMode, DEFFILEMODE & ~__gUmask);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
set_fd(fd);
|
set_fd(fd);
|
||||||
fMode = openMode;
|
fMode = openMode;
|
||||||
@@ -280,7 +286,7 @@ BFile::SetTo(const BDirectory *dir, const char *path, uint32 openMode)
|
|||||||
|
|
||||||
openMode |= O_CLOEXEC;
|
openMode |= O_CLOEXEC;
|
||||||
|
|
||||||
int fd = _kern_open(dir->fDirFd, path, openMode);
|
int fd = _kern_open(dir->fDirFd, path, openMode, DEFFILEMODE & ~__gUmask);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
set_fd(fd);
|
set_fd(fd);
|
||||||
fMode = openMode;
|
fMode = openMode;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the OpenBeOS license.
|
// by the MIT license.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
\file Node.cpp
|
\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);
|
status_t error = (fd >= 0 || path ? B_OK : B_BAD_VALUE);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
|
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) {
|
if (fFd < B_OK && fFd != B_ENTRY_NOT_FOUND) {
|
||||||
// opening read-write failed, re-try read-only
|
// 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)
|
if (fFd < 0)
|
||||||
error = fFd;
|
error = fFd;
|
||||||
@@ -734,11 +734,11 @@ BNode::_SetTo(const entry_ref *ref, bool traverse)
|
|||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
|
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
|
||||||
fFd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
|
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) {
|
if (fFd < B_OK && fFd != B_ENTRY_NOT_FOUND) {
|
||||||
// opening read-write failed, re-try read-only
|
// opening read-write failed, re-try read-only
|
||||||
fFd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
|
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)
|
if (fFd < 0)
|
||||||
error = fFd;
|
error = fFd;
|
||||||
|
|||||||
Reference in New Issue
Block a user