Got rid of the Storage Kit's kernel abstraction layer, which was

unfortunately quite slow and made some things more complicated than they
needed to be.
Implemented a few missing things (e.g. BSymLink and node locking).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8694 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2004-08-28 20:14:46 +00:00
parent 233e6dadef
commit db10640de9
25 changed files with 1731 additions and 1137 deletions
+5 -2
View File
@@ -78,6 +78,8 @@ public:
BDirectory &operator=(const BDirectory &dir);
private:
friend class BNode;
virtual void _ErectorDirectory1();
virtual void _ErectorDirectory2();
virtual void _ErectorDirectory3();
@@ -87,13 +89,14 @@ private:
private:
virtual void close_fd();
BPrivate::Storage::FileDescriptor get_fd() const;
int get_fd() const;
private:
uint32 _reservedData[7];
BPrivate::Storage::FileDescriptor fDirFd;
int fDirFd;
friend class BEntry;
friend class BFile;
};
+9 -8
View File
@@ -14,7 +14,6 @@
#include <SupportDefs.h>
#include <Statable.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
@@ -77,6 +76,11 @@ public:
BEntry &operator=(const BEntry &item);
private:
friend class BDirectory;
friend class BFile;
friend class BNode;
friend class BSymLink;
virtual void _PennyEntry1();
virtual void _PennyEntry2();
virtual void _PennyEntry3();
@@ -90,11 +94,10 @@ private:
/*! BEntry implementation of BStatable::set_stat() */
virtual status_t set_stat(struct stat &st, uint32 what);
status_t set(BPrivate::Storage::FileDescriptor dir, const char *path,
bool traverse);
status_t set(int dir, const char *path, bool traverse);
/*! File descriptor for the entry's parent directory. */
BPrivate::Storage::FileDescriptor fDirFd;
int fDirFd;
/*! Leaf name of the entry. */
char *fName;
@@ -104,6 +107,8 @@ private:
status_t set_name(const char *name);
status_t _Rename(BEntry& target, bool clobber);
void Dump(const char *name = NULL);
};
@@ -118,7 +123,3 @@ bool operator<(const entry_ref &a, const entry_ref &b);
#endif
#endif // _ENTRY_H
+1 -1
View File
@@ -71,7 +71,7 @@ private:
uint32 _reservedData[8];
private:
BPrivate::Storage::FileDescriptor get_fd() const;
int get_fd() const;
private:
//! The file's open mode.
+6 -4
View File
@@ -11,7 +11,6 @@
#define _NODE_H
#include <Statable.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
@@ -115,14 +114,17 @@ private:
uint32 rudeData[4];
private:
status_t set_fd(BPrivate::Storage::FileDescriptor fd);
status_t set_fd(int fd);
virtual void close_fd();
void set_status(status_t newStatus);
status_t _SetTo(int fd, const char *path, bool traverse);
status_t _SetTo(const entry_ref *ref, bool traverse);
virtual status_t set_stat(struct stat &st, uint32 what);
BPrivate::Storage::FileDescriptor fFd;
BPrivate::Storage::FileDescriptor fAttrFd;
int fFd;
int fAttrFd;
status_t fCStatus;
status_t InitAttrDir();
+1 -5
View File
@@ -15,8 +15,6 @@
#include <OS.h>
#include <SupportDefs.h>
#include <StorageDefs.Private.h>
class BVolume;
struct entry_ref;
@@ -119,9 +117,7 @@ private:
bool fLive;
port_id fPort;
long fToken;
BPrivate::Storage::FileDescriptor fQueryFd;
int fQueryFd;
};
#endif // _QUERY_H
+2 -22
View File
@@ -39,15 +39,6 @@ public:
BSymLink(const BDirectory *dir, const char *path);
virtual ~BSymLink();
// WORKAROUND
// SetTo() methods: Part of a work around until someone has an idea how to
// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
status_t SetTo(const entry_ref *ref);
status_t SetTo(const BEntry *entry);
status_t SetTo(const char *path);
status_t SetTo(const BDirectory *dir, const char *path);
void Unset();
ssize_t ReadLink(char *buf, size_t size);
ssize_t MakeLinkedPath(const char *dirPath, BPath *path);
@@ -55,11 +46,6 @@ public:
bool IsAbsolute();
// WORKAROUND
// operator=(): Part of a work around until someone has an idea how to
// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
BSymLink &operator=(const BSymLink &link);
private:
virtual void _MissingSymLink1();
virtual void _MissingSymLink2();
@@ -68,15 +54,11 @@ private:
virtual void _MissingSymLink5();
virtual void _MissingSymLink6();
// WORKAROUND
// fSecretEntry: Part of a work around until someone has an idea how to
// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
// uint32 _reservedData[4];
uint32 _reservedData[3];
uint32 _reservedData[4];
BEntry *fSecretEntry;
private:
BPrivate::Storage::FileDescriptor get_fd() const;
int get_fd() const;
};
#ifdef USE_OPENBEOS_NAMESPACE
@@ -84,5 +66,3 @@ private:
#endif
#endif // _SYM_LINK_H
+54
View File
@@ -11,14 +11,22 @@
#ifndef _STORAGE_SUPPORT_H
#define _STORAGE_SUPPORT_H
#include <dirent.h>
#include <string>
namespace BPrivate {
namespace Storage {
// For convenience:
struct LongDirEntry : dirent { char _buffer[B_FILE_NAME_LENGTH]; };
//! Returns whether the supplied path is absolute.
bool is_absolute_path(const char *path);
status_t parse_path(const char *fullPath, int &dirEnd, int &leafStart,
int &leafEnd);
status_t parse_path(const char *fullPath, char *dirPath, char *leaf);
//! splits a path name into directory path and leaf name
status_t split_path(const char *fullPath, char *&path, char *&leaf);
@@ -84,9 +92,55 @@ void escape_path(const char *str, char *result);
*/
void escape_path(char *str);
/*! \brief Returns whether the supplied device ID refers to the root FS.
*/
bool device_is_root_device(dev_t device);
// FDCloser
class FDCloser {
public:
FDCloser(int fd)
: fFD(fd)
{
}
~FDCloser()
{
Close();
}
void SetTo(int fd)
{
Close();
fFD = fd;
}
// implemented in the source file to not expose syscalls to the unit tests
// which include this file too
void Close();
// void Close()
// {
// if (fFD >= 0)
// _kern_close(fFD);
// fFD = -1;
// }
int Detach()
{
int fd = fFD;
fFD = -1;
return fd;
}
private:
int fFD;
};
}; // namespace Storage
}; // namespace BPrivate
using BPrivate::Storage::FDCloser;
#endif // _STORAGE_SUPPORT_H