From 3af4214aeb7eae0e7ebb5938fa1619800b15a958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Feb 2005 06:26:47 +0000 Subject: [PATCH] _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 --- src/kits/storage/File.cpp | 18 ++++++++++++------ src/kits/storage/Node.cpp | 12 ++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/kits/storage/File.cpp b/src/kits/storage/File.cpp index be55c4a8d2..f1b6a966f5 100644 --- a/src/kits/storage/File.cpp +++ b/src/kits/storage/File.cpp @@ -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 + +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; diff --git a/src/kits/storage/Node.cpp b/src/kits/storage/Node.cpp index 939c382928..32bb22765d 100644 --- a/src/kits/storage/Node.cpp +++ b/src/kits/storage/Node.cpp @@ -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;