* Removed no longer needed IOCTL_FILE_UNCACHED_IO definition.
* Some cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26706 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -43,4 +43,19 @@ round_up(const IntType& value, const RoundType& to)
|
|||||||
return (value + (to - 1)) & ~((IntType)to - 1);
|
return (value + (to - 1)) & ~((IntType)to - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
is_index(int mode)
|
||||||
|
{
|
||||||
|
return (mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR;
|
||||||
|
// That's a stupid check, but AFAIK the only possible method...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
is_directory(int mode)
|
||||||
|
{
|
||||||
|
return (mode & (S_INDEX_DIR | S_ATTR_DIR | S_IFDIR)) == S_IFDIR;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* UTILITY_H */
|
#endif /* UTILITY_H */
|
||||||
|
|||||||
@@ -26,37 +26,37 @@ static const int32 kDesiredAllocationGroups = 56;
|
|||||||
|
|
||||||
|
|
||||||
class DeviceOpener {
|
class DeviceOpener {
|
||||||
public:
|
public:
|
||||||
DeviceOpener(int fd, int mode);
|
DeviceOpener(int fd, int mode);
|
||||||
DeviceOpener(const char *device, int mode);
|
DeviceOpener(const char* device, int mode);
|
||||||
~DeviceOpener();
|
~DeviceOpener();
|
||||||
|
|
||||||
int Open(const char *device, int mode);
|
int Open(const char* device, int mode);
|
||||||
int Open(int fd, int mode);
|
int Open(int fd, int mode);
|
||||||
void *InitCache(off_t numBlocks, uint32 blockSize);
|
void* InitCache(off_t numBlocks, uint32 blockSize);
|
||||||
void RemoveCache(bool allowWrites);
|
void RemoveCache(bool allowWrites);
|
||||||
|
|
||||||
void Keep();
|
void Keep();
|
||||||
|
|
||||||
int Device() const { return fDevice; }
|
int Device() const { return fDevice; }
|
||||||
int Mode() const { return fMode; }
|
int Mode() const { return fMode; }
|
||||||
bool IsReadOnly() const { return _IsReadOnly(fMode); }
|
bool IsReadOnly() const { return _IsReadOnly(fMode); }
|
||||||
|
|
||||||
status_t GetSize(off_t *_size, uint32 *_blockSize = NULL);
|
status_t GetSize(off_t* _size, uint32* _blockSize = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool _IsReadOnly(int mode)
|
static bool _IsReadOnly(int mode)
|
||||||
{ return (mode & O_RWMASK) == O_RDONLY;}
|
{ return (mode & O_RWMASK) == O_RDONLY;}
|
||||||
static bool _IsReadWrite(int mode)
|
static bool _IsReadWrite(int mode)
|
||||||
{ return (mode & O_RWMASK) == O_RDWR;}
|
{ return (mode & O_RWMASK) == O_RDWR;}
|
||||||
|
|
||||||
int fDevice;
|
int fDevice;
|
||||||
int fMode;
|
int fMode;
|
||||||
void *fBlockCache;
|
void* fBlockCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DeviceOpener::DeviceOpener(const char *device, int mode)
|
DeviceOpener::DeviceOpener(const char* device, int mode)
|
||||||
:
|
:
|
||||||
fBlockCache(NULL)
|
fBlockCache(NULL)
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ DeviceOpener::~DeviceOpener()
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
DeviceOpener::Open(const char *device, int mode)
|
DeviceOpener::Open(const char* device, int mode)
|
||||||
{
|
{
|
||||||
fDevice = open(device, mode | O_NOCACHE);
|
fDevice = open(device, mode | O_NOCACHE);
|
||||||
if (fDevice < 0)
|
if (fDevice < 0)
|
||||||
@@ -126,7 +126,7 @@ DeviceOpener::Open(int fd, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *
|
void*
|
||||||
DeviceOpener::InitCache(off_t numBlocks, uint32 blockSize)
|
DeviceOpener::InitCache(off_t numBlocks, uint32 blockSize)
|
||||||
{
|
{
|
||||||
return fBlockCache = block_cache_create(fDevice, numBlocks, blockSize,
|
return fBlockCache = block_cache_create(fDevice, numBlocks, blockSize,
|
||||||
@@ -156,7 +156,7 @@ DeviceOpener::Keep()
|
|||||||
to compute the size, or fstat() if that failed.
|
to compute the size, or fstat() if that failed.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
DeviceOpener::GetSize(off_t *_size, uint32 *_blockSize)
|
DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
|
||||||
{
|
{
|
||||||
device_geometry geometry;
|
device_geometry geometry;
|
||||||
if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
|
if (ioctl(fDevice, B_GET_GEOMETRY, &geometry) < 0) {
|
||||||
@@ -209,7 +209,7 @@ disk_super_block::IsValid()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
disk_super_block::Initialize(const char *diskName, off_t numBlocks,
|
disk_super_block::Initialize(const char* diskName, off_t numBlocks,
|
||||||
uint32 blockSize)
|
uint32 blockSize)
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(disk_super_block));
|
memset(this, 0, sizeof(disk_super_block));
|
||||||
@@ -272,7 +272,7 @@ disk_super_block::Initialize(const char *diskName, off_t numBlocks,
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
Volume::Volume(fs_volume *volume)
|
Volume::Volume(fs_volume* volume)
|
||||||
:
|
:
|
||||||
fVolume(volume),
|
fVolume(volume),
|
||||||
fBlockAllocator(this),
|
fBlockAllocator(this),
|
||||||
@@ -313,9 +313,9 @@ Volume::Panic()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::Mount(const char *deviceName, uint32 flags)
|
Volume::Mount(const char* deviceName, uint32 flags)
|
||||||
{
|
{
|
||||||
// ToDo: validate the FS in write mode as well!
|
// TODO: validate the FS in write mode as well!
|
||||||
#if (B_HOST_IS_LENDIAN && defined(BFS_BIG_ENDIAN_ONLY)) \
|
#if (B_HOST_IS_LENDIAN && defined(BFS_BIG_ENDIAN_ONLY)) \
|
||||||
|| (B_HOST_IS_BENDIAN && defined(BFS_LITTLE_ENDIAN_ONLY))
|
|| (B_HOST_IS_BENDIAN && defined(BFS_LITTLE_ENDIAN_ONLY))
|
||||||
// in big endian mode, we only mount read-only for now
|
// in big endian mode, we only mount read-only for now
|
||||||
@@ -385,7 +385,7 @@ Volume::Mount(const char *deviceName, uint32 flags)
|
|||||||
|
|
||||||
fRootNode = new Inode(this, ToVnode(Root()));
|
fRootNode = new Inode(this, ToVnode(Root()));
|
||||||
if (fRootNode != NULL && fRootNode->InitCheck() == B_OK) {
|
if (fRootNode != NULL && fRootNode->InitCheck() == B_OK) {
|
||||||
status = publish_vnode(fVolume, ToVnode(Root()), (void *)fRootNode,
|
status = publish_vnode(fVolume, ToVnode(Root()), (void*)fRootNode,
|
||||||
&gBFSVnodeOps, fRootNode->Mode(), 0);
|
&gBFSVnodeOps, fRootNode->Mode(), 0);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
// try to get indices root dir
|
// try to get indices root dir
|
||||||
@@ -482,7 +482,7 @@ Volume::ToBlockRun(off_t block) const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::CreateIndicesRoot(Transaction &transaction)
|
Volume::CreateIndicesRoot(Transaction& transaction)
|
||||||
{
|
{
|
||||||
off_t id;
|
off_t id;
|
||||||
status_t status = Inode::Create(transaction, NULL, NULL,
|
status_t status = Inode::Create(transaction, NULL, NULL,
|
||||||
@@ -497,8 +497,8 @@ Volume::CreateIndicesRoot(Transaction &transaction)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::AllocateForInode(Transaction &transaction, const Inode *parent,
|
Volume::AllocateForInode(Transaction& transaction, const Inode* parent,
|
||||||
mode_t type, block_run &run)
|
mode_t type, block_run& run)
|
||||||
{
|
{
|
||||||
return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(),
|
return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(),
|
||||||
type, run);
|
type, run);
|
||||||
@@ -517,13 +517,13 @@ Volume::WriteSuperBlock()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::UpdateLiveQueries(Inode *inode, const char *attribute, int32 type,
|
Volume::UpdateLiveQueries(Inode* inode, const char* attribute, int32 type,
|
||||||
const uint8 *oldKey, size_t oldLength, const uint8 *newKey,
|
const uint8* oldKey, size_t oldLength, const uint8* newKey,
|
||||||
size_t newLength)
|
size_t newLength)
|
||||||
{
|
{
|
||||||
MutexLocker _(fQueryLock);
|
MutexLocker _(fQueryLock);
|
||||||
|
|
||||||
Query *query = NULL;
|
Query* query = NULL;
|
||||||
while ((query = fQueries.Next(query)) != NULL) {
|
while ((query = fQueries.Next(query)) != NULL) {
|
||||||
query->LiveUpdate(inode, attribute, type, oldKey, oldLength, newKey,
|
query->LiveUpdate(inode, attribute, type, oldKey, oldLength, newKey,
|
||||||
newLength);
|
newLength);
|
||||||
@@ -537,15 +537,15 @@ Volume::UpdateLiveQueries(Inode *inode, const char *attribute, int32 type,
|
|||||||
the queries - it wouldn't safe you anything in this case.
|
the queries - it wouldn't safe you anything in this case.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
Volume::CheckForLiveQuery(const char *attribute)
|
Volume::CheckForLiveQuery(const char* attribute)
|
||||||
{
|
{
|
||||||
// ToDo: check for a live query that depends on the specified attribute
|
// TODO: check for a live query that depends on the specified attribute
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::AddQuery(Query *query)
|
Volume::AddQuery(Query* query)
|
||||||
{
|
{
|
||||||
MutexLocker _(fQueryLock);
|
MutexLocker _(fQueryLock);
|
||||||
fQueries.Add(query);
|
fQueries.Add(query);
|
||||||
@@ -553,7 +553,7 @@ Volume::AddQuery(Query *query)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::RemoveQuery(Query *query)
|
Volume::RemoveQuery(Query* query)
|
||||||
{
|
{
|
||||||
MutexLocker _(fQueryLock);
|
MutexLocker _(fQueryLock);
|
||||||
fQueries.Remove(query);
|
fQueries.Remove(query);
|
||||||
@@ -588,7 +588,7 @@ Volume::CheckSuperBlock(const uint8* data, uint32* _offset)
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ status_t
|
/*static*/ status_t
|
||||||
Volume::Identify(int fd, disk_super_block *superBlock)
|
Volume::Identify(int fd, disk_super_block* superBlock)
|
||||||
{
|
{
|
||||||
uint8 buffer[1024];
|
uint8 buffer[1024];
|
||||||
if (read_pos(fd, 0, buffer, sizeof(buffer)) != sizeof(buffer))
|
if (read_pos(fd, 0, buffer, sizeof(buffer)) != sizeof(buffer))
|
||||||
@@ -604,7 +604,7 @@ Volume::Identify(int fd, disk_super_block *superBlock)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::Initialize(int fd, const char *name, uint32 blockSize,
|
Volume::Initialize(int fd, const char* name, uint32 blockSize,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
{
|
{
|
||||||
// although there is no really good reason for it, we won't
|
// although there is no really good reason for it, we won't
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Axel Dörfler, [email protected].
|
* Copyright 2001-2008, Axel Dörfler, [email protected].
|
||||||
* Parts of this code is based on work previously done by Marcus Overhagen.
|
* Parts of this code is based on work previously done by Marcus Overhagen.
|
||||||
*
|
*
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
@@ -18,9 +18,6 @@
|
|||||||
namespace BFS {
|
namespace BFS {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ToDo: temporary fix! (missing but public ioctls)
|
|
||||||
#define IOCTL_FILE_UNCACHED_IO 10000
|
|
||||||
|
|
||||||
#ifndef _BOOT_MODE
|
#ifndef _BOOT_MODE
|
||||||
extern fs_volume_ops gBFSVolumeOps;
|
extern fs_volume_ops gBFSVolumeOps;
|
||||||
extern fs_vnode_ops gBFSVnodeOps;
|
extern fs_vnode_ops gBFSVnodeOps;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Axel Dörfler, [email protected].
|
* Copyright 2003-2008, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef BFS_ENDIAN_H
|
#ifndef BFS_ENDIAN_H
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
# define HOST_ENDIAN_TO_BFS_INT32(value) __swap_int32(value)
|
# define HOST_ENDIAN_TO_BFS_INT32(value) __swap_int32(value)
|
||||||
# define HOST_ENDIAN_TO_BFS_INT64(value) __swap_int64(value)
|
# define HOST_ENDIAN_TO_BFS_INT64(value) __swap_int64(value)
|
||||||
#else
|
#else
|
||||||
// ToDo: maybe build a version that supports both, big & little endian?
|
// TODO: maybe build a version that supports both, big & little endian?
|
||||||
// But since that will need some kind of global data (to
|
// But since that will need some kind of global data (to
|
||||||
// know of what type this file system is), it's probably
|
// know of what type this file system is), it's probably
|
||||||
// something for the boot loader; anything else would be
|
// something for the boot loader; anything else would be
|
||||||
|
|||||||
Reference in New Issue
Block a user