Implemented the most basic functionality required to cleanly mount and unmount
(at least in userlandfs). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34069 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
246aa3e3e2
commit
b932032a35
18
src/add-ons/kernel/file_systems/packagefs/Directory.cpp
Normal file
18
src/add-ons/kernel/file_systems/packagefs/Directory.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Directory.h"
|
||||
|
||||
|
||||
Directory::Directory(ino_t id)
|
||||
:
|
||||
Node(id)
|
||||
{
|
||||
}
|
||||
|
||||
Directory::~Directory()
|
||||
{
|
||||
}
|
19
src/add-ons/kernel/file_systems/packagefs/Directory.h
Normal file
19
src/add-ons/kernel/file_systems/packagefs/Directory.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef DIRECTORY_H
|
||||
#define DIRECTORY_H
|
||||
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
|
||||
class Directory : public Node {
|
||||
public:
|
||||
Directory(ino_t id);
|
||||
virtual ~Directory();
|
||||
};
|
||||
|
||||
|
||||
#endif // DIRECTORY_H
|
@ -1,10 +1,20 @@
|
||||
SubDir HAIKU_TOP src add-ons kernel file_systems packagefs ;
|
||||
|
||||
|
||||
KernelAddon packagefs
|
||||
:
|
||||
kernel_interface.cpp
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
|
||||
HAIKU_PACKAGE_FS_SOURCES =
|
||||
DebugSupport.cpp
|
||||
Directory.cpp
|
||||
kernel_interface.cpp
|
||||
Node.cpp
|
||||
Volume.cpp
|
||||
;
|
||||
|
||||
|
||||
KernelAddon packagefs
|
||||
: $(HAIKU_PACKAGE_FS_SOURCES)
|
||||
: $(HAIKU_STATIC_LIBSUPC++)
|
||||
;
|
||||
|
||||
|
19
src/add-ons/kernel/file_systems/packagefs/Node.cpp
Normal file
19
src/add-ons/kernel/file_systems/packagefs/Node.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
|
||||
Node::Node(ino_t id)
|
||||
:
|
||||
fID(id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Node::~Node()
|
||||
{
|
||||
}
|
24
src/add-ons/kernel/file_systems/packagefs/Node.h
Normal file
24
src/add-ons/kernel/file_systems/packagefs/Node.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
|
||||
#include <fs_interface.h>
|
||||
|
||||
|
||||
class Node {
|
||||
public:
|
||||
Node(ino_t id);
|
||||
virtual ~Node();
|
||||
|
||||
ino_t ID() const { return fID; }
|
||||
|
||||
private:
|
||||
ino_t fID;
|
||||
};
|
||||
|
||||
|
||||
#endif // NODE_H
|
54
src/add-ons/kernel/file_systems/packagefs/Volume.cpp
Normal file
54
src/add-ons/kernel/file_systems/packagefs/Volume.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Volume.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "Directory.h"
|
||||
#include "kernel_interface.h"
|
||||
|
||||
|
||||
// node ID of the root directory
|
||||
static const ino_t kRootDirectoryID = 1;
|
||||
|
||||
|
||||
Volume::Volume(fs_volume* fsVolume)
|
||||
:
|
||||
fFSVolume(fsVolume),
|
||||
fRootDirectory(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Volume::~Volume()
|
||||
{
|
||||
delete fRootDirectory;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Volume::Mount()
|
||||
{
|
||||
// create the root node
|
||||
fRootDirectory = new(std::nothrow) Directory(kRootDirectoryID);
|
||||
if (fRootDirectory == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// publish it
|
||||
status_t error = publish_vnode(fFSVolume, fRootDirectory->ID(),
|
||||
fRootDirectory, &gPackageFSVnodeOps, S_IFDIR, 0);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Volume::Unmount()
|
||||
{
|
||||
}
|
31
src/add-ons/kernel/file_systems/packagefs/Volume.h
Normal file
31
src/add-ons/kernel/file_systems/packagefs/Volume.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef VOLUME_H
|
||||
#define VOLUME_H
|
||||
|
||||
|
||||
#include <fs_interface.h>
|
||||
|
||||
|
||||
class Directory;
|
||||
|
||||
|
||||
class Volume {
|
||||
public:
|
||||
Volume(fs_volume* fsVolume);
|
||||
~Volume();
|
||||
|
||||
status_t Mount();
|
||||
void Unmount();
|
||||
|
||||
Directory* RootDirectory() const { return fRootDirectory; }
|
||||
|
||||
private:
|
||||
fs_volume* fFSVolume;
|
||||
Directory* fRootDirectory;
|
||||
};
|
||||
|
||||
|
||||
#endif // VOLUME_H
|
@ -4,39 +4,78 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "kernel_interface.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <fs_info.h>
|
||||
#include <fs_interface.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
extern fs_volume_ops gPackageFSVolumeOps;
|
||||
extern fs_vnode_ops gPackageFSVnodeOps;
|
||||
#include "DebugSupport.h"
|
||||
#include "Directory.h"
|
||||
#include "Volume.h"
|
||||
|
||||
|
||||
static const uint32 kOptimalIOSize = 64 * 1024;
|
||||
|
||||
|
||||
// #pragma mark - Volume
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_mount(fs_volume* _volume, const char* device, uint32 flags,
|
||||
const char* parameters, ino_t* rootID)
|
||||
packagefs_mount(fs_volume* fsVolume, const char* device, uint32 flags,
|
||||
const char* parameters, ino_t* _rootID)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
FUNCTION("fsVolume: %p, device: \"%s\", flags: %#lx, parameters: \"%s\"\n",
|
||||
fsVolume, device, flags, parameters);
|
||||
|
||||
// create a Volume object
|
||||
Volume* volume = new(std::nothrow) Volume(fsVolume);
|
||||
if (volume == NULL)
|
||||
RETURN_ERROR(B_NO_MEMORY);
|
||||
ObjectDeleter<Volume> volumeDeleter(volume);
|
||||
|
||||
status_t error = volume->Mount();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// set return values
|
||||
*_rootID = volume->RootDirectory()->ID();
|
||||
fsVolume->private_volume = volumeDeleter.Detach();
|
||||
fsVolume->ops = &gPackageFSVolumeOps;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_unmount(fs_volume* fs)
|
||||
packagefs_unmount(fs_volume* fsVolume)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
Volume* volume = (Volume*)fsVolume->private_volume;
|
||||
|
||||
FUNCTION("volume: %p\n", volume);
|
||||
|
||||
volume->Unmount();
|
||||
delete volume;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_read_fs_info(fs_volume* fs, struct fs_info* info)
|
||||
packagefs_read_fs_info(fs_volume* fsVolume, struct fs_info* info)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
FUNCTION("volume: %p, info: %p\n", fsVolume->private_volume, info);
|
||||
|
||||
info->flags = B_FS_IS_READONLY;
|
||||
info->block_size = 4096;
|
||||
info->io_size = kOptimalIOSize;
|
||||
info->total_blocks = info->free_blocks = 1;
|
||||
strlcpy(info->volume_name, "Package FS", sizeof(info->volume_name));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -44,17 +83,27 @@ packagefs_read_fs_info(fs_volume* fs, struct fs_info* info)
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_lookup(fs_volume* fs, fs_vnode* _dir, const char* entryName,
|
||||
ino_t* vnid)
|
||||
packagefs_lookup(fs_volume* fsVolume, fs_vnode* fsDir, const char* entryName,
|
||||
ino_t* _vnid)
|
||||
{
|
||||
Volume* volume = (Volume*)fsVolume->private_volume;
|
||||
Node* dir = (Node*)fsDir->private_node;
|
||||
|
||||
FUNCTION("volume: %p, dir: %p (%lld), entry: \"%s\"\n", volume, dir,
|
||||
dir->ID(), entryName);
|
||||
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_get_vnode(fs_volume* fs, ino_t vnid, fs_vnode* node, int* _type,
|
||||
uint32* _flags, bool reenter)
|
||||
packagefs_get_vnode(fs_volume* fsVolume, ino_t vnid, fs_vnode* fsNode,
|
||||
int* _type, uint32* _flags, bool reenter)
|
||||
{
|
||||
Volume* volume = (Volume*)fsVolume->private_volume;
|
||||
|
||||
FUNCTION("volume: %p, vnid: %lld\n", volume, vnid);
|
||||
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -85,9 +134,26 @@ packagefs_access(fs_volume* fs, fs_vnode* _node, int mode)
|
||||
|
||||
|
||||
static status_t
|
||||
packagefs_read_stat(fs_volume* fs, fs_vnode* _node, struct stat* st)
|
||||
packagefs_read_stat(fs_volume* fsVolume, fs_vnode* fsNode, struct stat* st)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
Volume* volume = (Volume*)fsVolume->private_volume;
|
||||
Node* node = (Node*)fsNode->private_node;
|
||||
|
||||
FUNCTION("volume: %p, node: %p (%lld)\n", volume, node, node->ID());
|
||||
|
||||
// TODO: Fill in correctly!
|
||||
st->st_mode = S_IFDIR;
|
||||
st->st_nlink = 1;
|
||||
st->st_uid = 0;
|
||||
st->st_gid = 0;
|
||||
st->st_size = 0;
|
||||
st->st_blksize = kOptimalIOSize;
|
||||
st->st_atime = 0;
|
||||
st->st_mtime = 0;
|
||||
st->st_ctime = 0;
|
||||
st->st_crtime = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -170,9 +236,13 @@ packagefs_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT:
|
||||
init_debugging();
|
||||
PRINT("package_std_ops(): B_MODULE_INIT\n");
|
||||
return B_OK;
|
||||
|
||||
case B_MODULE_UNINIT:
|
||||
PRINT("package_std_ops(): B_MODULE_UNINIT\n");
|
||||
exit_debugging();
|
||||
return B_OK;
|
||||
|
||||
default:
|
||||
|
16
src/add-ons/kernel/file_systems/packagefs/kernel_interface.h
Normal file
16
src/add-ons/kernel/file_systems/packagefs/kernel_interface.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef KERNEL_INTERFACE_H
|
||||
#define KERNEL_INTERFACE_H
|
||||
|
||||
|
||||
#include <fs_interface.h>
|
||||
|
||||
|
||||
extern fs_volume_ops gPackageFSVolumeOps;
|
||||
extern fs_vnode_ops gPackageFSVnodeOps;
|
||||
|
||||
|
||||
#endif // KERNEL_INTERFACE_H
|
@ -4,9 +4,10 @@ SubDir HAIKU_TOP src add-ons kernel file_systems packagefs userland ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) ] ;
|
||||
|
||||
|
||||
Addon <userland>packagefs
|
||||
:
|
||||
kernel_interface.cpp
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
|
||||
Addon <userland>packagefs
|
||||
: $(HAIKU_PACKAGE_FS_SOURCES)
|
||||
: libuserlandfs_haiku_kernel.so $(TARGET_LIBSUPC++)
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user