* add implementation of bindfs, which can be used to bind-mount
a folder to some other place in the filesystem hierarchy * add helper function to VFS that encapsulates the "conversion" of a vnode-pointer to a fs_vnode-pointer (used by bindfs) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40238 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -87,6 +87,7 @@ status_t vfs_entry_ref_to_vnode(dev_t mountID, ino_t directoryID,
|
|||||||
const char *name, struct vnode **_vnode);
|
const char *name, struct vnode **_vnode);
|
||||||
void vfs_vnode_to_node_ref(struct vnode *vnode, dev_t *_mountID,
|
void vfs_vnode_to_node_ref(struct vnode *vnode, dev_t *_mountID,
|
||||||
ino_t *_vnodeID);
|
ino_t *_vnodeID);
|
||||||
|
struct fs_vnode* vfs_fsnode_for_vnode(struct vnode* vnode);
|
||||||
|
|
||||||
int vfs_open_vnode(struct vnode* vnode, int openMode, bool kernel);
|
int vfs_open_vnode(struct vnode* vnode, int openMode, bool kernel);
|
||||||
status_t vfs_lookup_vnode(dev_t mountID, ino_t vnodeID,
|
status_t vfs_lookup_vnode(dev_t mountID, ino_t vnodeID,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
SubDir HAIKU_TOP src add-ons kernel file_systems ;
|
SubDir HAIKU_TOP src add-ons kernel file_systems ;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src add-ons kernel file_systems bfs ;
|
SubInclude HAIKU_TOP src add-ons kernel file_systems bfs ;
|
||||||
|
SubInclude HAIKU_TOP src add-ons kernel file_systems bindfs ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel file_systems cdda ;
|
SubInclude HAIKU_TOP src add-ons kernel file_systems cdda ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel file_systems ext2 ;
|
SubInclude HAIKU_TOP src add-ons kernel file_systems ext2 ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel file_systems fat ;
|
SubInclude HAIKU_TOP src add-ons kernel file_systems fat ;
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003-2009, Ingo Weinhold, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DebugSupport.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\file Debug.cpp
|
||||||
|
\brief Defines debug output function with printf() signature printing
|
||||||
|
into a file.
|
||||||
|
|
||||||
|
\note The initialization is not thread safe!
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// locking support
|
||||||
|
static int32 init_counter = 0;
|
||||||
|
static sem_id dbg_printf_sem = -1;
|
||||||
|
static thread_id dbg_printf_thread = -1;
|
||||||
|
static int dbg_printf_nesting = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG_PRINT
|
||||||
|
static int out = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
init_debugging()
|
||||||
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
if (init_counter++ == 0) {
|
||||||
|
// open the file
|
||||||
|
#if DEBUG_PRINT
|
||||||
|
out = open(DEBUG_PRINT_FILE, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
|
if (out < 0) {
|
||||||
|
error = errno;
|
||||||
|
init_counter--;
|
||||||
|
}
|
||||||
|
#endif // DEBUG_PRINT
|
||||||
|
// allocate the semaphore
|
||||||
|
if (error == B_OK) {
|
||||||
|
dbg_printf_sem = create_sem(1, "dbg_printf");
|
||||||
|
if (dbg_printf_sem < 0)
|
||||||
|
error = dbg_printf_sem;
|
||||||
|
}
|
||||||
|
if (error == B_OK) {
|
||||||
|
#if DEBUG
|
||||||
|
__out("##################################################\n");
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
exit_debugging();
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
exit_debugging()
|
||||||
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
if (--init_counter == 0) {
|
||||||
|
#if DEBUG_PRINT
|
||||||
|
close(out);
|
||||||
|
out = -1;
|
||||||
|
#endif // DEBUG_PRINT
|
||||||
|
delete_sem(dbg_printf_sem);
|
||||||
|
} else
|
||||||
|
error = B_NO_INIT;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
dbg_printf_lock()
|
||||||
|
{
|
||||||
|
thread_id thread = find_thread(NULL);
|
||||||
|
if (thread != dbg_printf_thread) {
|
||||||
|
if (acquire_sem(dbg_printf_sem) != B_OK)
|
||||||
|
return false;
|
||||||
|
dbg_printf_thread = thread;
|
||||||
|
}
|
||||||
|
dbg_printf_nesting++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
dbg_printf_unlock()
|
||||||
|
{
|
||||||
|
thread_id thread = find_thread(NULL);
|
||||||
|
if (thread != dbg_printf_thread)
|
||||||
|
return;
|
||||||
|
dbg_printf_nesting--;
|
||||||
|
if (dbg_printf_nesting == 0) {
|
||||||
|
dbg_printf_thread = -1;
|
||||||
|
release_sem(dbg_printf_sem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dbg_printf_begin()
|
||||||
|
{
|
||||||
|
dbg_printf_lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dbg_printf_end()
|
||||||
|
{
|
||||||
|
dbg_printf_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG_PRINT
|
||||||
|
|
||||||
|
void
|
||||||
|
dbg_printf(const char *format,...)
|
||||||
|
{
|
||||||
|
if (!dbg_printf_lock())
|
||||||
|
return;
|
||||||
|
char buffer[1024];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
// no vsnprintf() on PPC and in kernel
|
||||||
|
#if defined(__INTEL__) && USER
|
||||||
|
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
||||||
|
#else
|
||||||
|
vsprintf(buffer, format, args);
|
||||||
|
#endif
|
||||||
|
va_end(args);
|
||||||
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
|
write(out, buffer, strlen(buffer));
|
||||||
|
dbg_printf_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DEBUG_PRINT
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003-2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 200?, Axel Dörfler, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef DEBUG_SUPPORT_H
|
||||||
|
#define DEBUG_SUPPORT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if !USER
|
||||||
|
# include <KernelExport.h>
|
||||||
|
#endif
|
||||||
|
#include <OS.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
// define all macros we work with -- undefined macros are set to defaults
|
||||||
|
#ifndef USER
|
||||||
|
# define USER 0
|
||||||
|
#endif
|
||||||
|
#ifndef DEBUG
|
||||||
|
# define DEBUG 0
|
||||||
|
#endif
|
||||||
|
#if !DEBUG
|
||||||
|
# undef DEBUG_PRINT
|
||||||
|
# define DEBUG_PRINT 0
|
||||||
|
#endif
|
||||||
|
#ifndef DEBUG_PRINT
|
||||||
|
# define DEBUG_PRINT 0
|
||||||
|
#endif
|
||||||
|
#ifndef DEBUG_APP
|
||||||
|
# define DEBUG_APP "bindfs"
|
||||||
|
#endif
|
||||||
|
#ifndef DEBUG_PRINT_FILE
|
||||||
|
# define DEBUG_PRINT_FILE "/var/log/" DEBUG_APP ".log"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// define the debug output function
|
||||||
|
#if USER
|
||||||
|
# include <stdio.h>
|
||||||
|
# if DEBUG_PRINT
|
||||||
|
# define __out dbg_printf
|
||||||
|
# else
|
||||||
|
# define __out printf
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <KernelExport.h>
|
||||||
|
# include <null.h>
|
||||||
|
# if DEBUG_PRINT
|
||||||
|
# define __out dbg_printf
|
||||||
|
# else
|
||||||
|
# define __out dprintf
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// define the PANIC() macro
|
||||||
|
#ifndef PANIC
|
||||||
|
# if USER
|
||||||
|
# define PANIC(str) debugger(str)
|
||||||
|
# else
|
||||||
|
# define PANIC(str) panic(str)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// functions exported by this module
|
||||||
|
status_t init_debugging();
|
||||||
|
status_t exit_debugging();
|
||||||
|
void dbg_printf_begin();
|
||||||
|
void dbg_printf_end();
|
||||||
|
#if DEBUG_PRINT
|
||||||
|
void dbg_printf(const char *format,...);
|
||||||
|
#else
|
||||||
|
static inline void dbg_printf(const char *,...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Short overview over the debug output macros:
|
||||||
|
// PRINT()
|
||||||
|
// is for general messages that very unlikely should appear in a release
|
||||||
|
// build
|
||||||
|
// FATAL()
|
||||||
|
// this is for fatal messages, when something has really gone wrong
|
||||||
|
// INFORM()
|
||||||
|
// general information, as disk size, etc.
|
||||||
|
// REPORT_ERROR(status_t)
|
||||||
|
// prints out error information
|
||||||
|
// RETURN_ERROR(status_t)
|
||||||
|
// calls REPORT_ERROR() and return the value
|
||||||
|
// D()
|
||||||
|
// the statements in D() are only included if DEBUG is defined
|
||||||
|
|
||||||
|
|
||||||
|
#define DEBUG_THREAD find_thread(NULL)
|
||||||
|
#define DEBUG_CONTEXT(x) \
|
||||||
|
{ \
|
||||||
|
dbg_printf_begin(); \
|
||||||
|
__out(DEBUG_APP " [%Ld: %5ld] ", system_time(), DEBUG_THREAD); \
|
||||||
|
x; \
|
||||||
|
dbg_printf_end(); \
|
||||||
|
}
|
||||||
|
#define DEBUG_CONTEXT_FUNCTION(prefix, x) \
|
||||||
|
{ \
|
||||||
|
dbg_printf_begin(); \
|
||||||
|
__out(DEBUG_APP " [%Ld: %5ld] %s" prefix, system_time(), DEBUG_THREAD, \
|
||||||
|
__PRETTY_FUNCTION__); \
|
||||||
|
x; \
|
||||||
|
dbg_printf_end(); \
|
||||||
|
}
|
||||||
|
#define DEBUG_CONTEXT_LINE(x) \
|
||||||
|
{ \
|
||||||
|
dbg_printf_begin(); \
|
||||||
|
__out(DEBUG_APP " [%Ld: %5ld] %s:%d: ", system_time(), DEBUG_THREAD, \
|
||||||
|
__PRETTY_FUNCTION__, __LINE__); \
|
||||||
|
x; \
|
||||||
|
dbg_printf_end(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TPRINT(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define TREPORT_ERROR(status) \
|
||||||
|
DEBUG_CONTEXT_LINE( __out("%s\n", strerror(status)) )
|
||||||
|
#define TRETURN_ERROR(err) \
|
||||||
|
{ \
|
||||||
|
status_t _status = err; \
|
||||||
|
if (_status < B_OK) \
|
||||||
|
TREPORT_ERROR(_status); \
|
||||||
|
return _status; \
|
||||||
|
}
|
||||||
|
#define TSET_ERROR(var, err) \
|
||||||
|
{ \
|
||||||
|
status_t _status = err; \
|
||||||
|
if (_status < B_OK) \
|
||||||
|
TREPORT_ERROR(_status); \
|
||||||
|
var = _status; \
|
||||||
|
}
|
||||||
|
#define TFUNCTION(x...) DEBUG_CONTEXT_FUNCTION( ": ", __out(x) )
|
||||||
|
#define TFUNCTION_START() DEBUG_CONTEXT_FUNCTION( "\n", )
|
||||||
|
#define TFUNCTION_END() DEBUG_CONTEXT_FUNCTION( " done\n", )
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
#define PRINT(x...) TPRINT(x)
|
||||||
|
#define REPORT_ERROR(status) TREPORT_ERROR(status)
|
||||||
|
#define RETURN_ERROR(err) TRETURN_ERROR(err)
|
||||||
|
#define SET_ERROR(var, err) TSET_ERROR(var, err)
|
||||||
|
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define FUNCTION(x...) TFUNCTION(x)
|
||||||
|
#define FUNCTION_START() TFUNCTION_START()
|
||||||
|
#define FUNCTION_END() TFUNCTION_END()
|
||||||
|
#define DARG(x) x
|
||||||
|
#define D(x) {x;};
|
||||||
|
#else
|
||||||
|
#define PRINT(x...) ;
|
||||||
|
#define REPORT_ERROR(status) ;
|
||||||
|
#define RETURN_ERROR(status) return status;
|
||||||
|
#define SET_ERROR(var, err) var = err;
|
||||||
|
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define FUNCTION(x...) ;
|
||||||
|
#define FUNCTION_START() ;
|
||||||
|
#define FUNCTION_END() ;
|
||||||
|
#define DARG(x)
|
||||||
|
#define D(x) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TOUCH
|
||||||
|
#define TOUCH(var) (void)var
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DEBUG_SUPPORT_H
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
SubDir HAIKU_TOP src add-ons kernel file_systems bindfs ;
|
||||||
|
|
||||||
|
|
||||||
|
UsePrivateKernelHeaders ;
|
||||||
|
# UsePrivateHeaders shared ;
|
||||||
|
|
||||||
|
|
||||||
|
HAIKU_BIND_FS_SOURCES =
|
||||||
|
DebugSupport.cpp
|
||||||
|
kernel_interface.cpp
|
||||||
|
Node.cpp
|
||||||
|
Volume.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
KernelAddon bindfs
|
||||||
|
:
|
||||||
|
$(HAIKU_BIND_FS_SOURCES)
|
||||||
|
: $(HAIKU_STATIC_LIBSUPC++)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
#HaikuSubInclude userland ;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "Node.h"
|
||||||
|
|
||||||
|
|
||||||
|
Node::Node(ino_t id, mode_t mode)
|
||||||
|
:
|
||||||
|
fSourceID(id),
|
||||||
|
fMode(mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Node::~Node()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef NODE_H
|
||||||
|
#define NODE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <fs_interface.h>
|
||||||
|
|
||||||
|
|
||||||
|
class Node {
|
||||||
|
public:
|
||||||
|
Node(ino_t sourceID, mode_t mode);
|
||||||
|
~Node();
|
||||||
|
|
||||||
|
ino_t ID() const { return fSourceID; }
|
||||||
|
// currently, we reuse the source-ID
|
||||||
|
|
||||||
|
ino_t SourceID() const { return fSourceID; }
|
||||||
|
mode_t Mode() const { return fMode; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ino_t fSourceID;
|
||||||
|
mode_t fMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // NODE_H
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef UTILS_H
|
||||||
|
#define UTILS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
|
#include <vfs.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::AutoDeleter;
|
||||||
|
|
||||||
|
|
||||||
|
struct VnodePut
|
||||||
|
{
|
||||||
|
inline void operator()(vnode* _vnode)
|
||||||
|
{
|
||||||
|
if (_vnode != NULL)
|
||||||
|
vfs_put_vnode(_vnode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VnodePutter : AutoDeleter<vnode, VnodePut>
|
||||||
|
{
|
||||||
|
VnodePutter() : AutoDeleter<vnode, VnodePut>() {}
|
||||||
|
|
||||||
|
VnodePutter(vnode* _vnode) : AutoDeleter<vnode, VnodePut>(_vnode) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UTILS_H
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "Volume.h"
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <driver_settings.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
|
#include <vfs.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
|
#include "DebugSupport.h"
|
||||||
|
#include "kernel_interface.h"
|
||||||
|
#include "Node.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Volume
|
||||||
|
|
||||||
|
|
||||||
|
Volume::Volume(fs_volume* fsVolume)
|
||||||
|
:
|
||||||
|
fFSVolume(fsVolume),
|
||||||
|
fSourceFSVolume(NULL),
|
||||||
|
fRootNode(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Volume::~Volume()
|
||||||
|
{
|
||||||
|
delete fRootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Volume::Mount(const char* parameterString)
|
||||||
|
{
|
||||||
|
const char* source = NULL;
|
||||||
|
void* parameterHandle = parse_driver_settings_string(parameterString);
|
||||||
|
if (parameterHandle != NULL) {
|
||||||
|
source = get_driver_parameter(parameterHandle, "source", NULL, NULL);
|
||||||
|
delete_driver_settings(parameterHandle);
|
||||||
|
}
|
||||||
|
if (source == NULL || source[0] == '\0') {
|
||||||
|
ERROR("need source folder ('source' parameter)!\n");
|
||||||
|
RETURN_ERROR(B_BAD_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct vnode* sourceVnode;
|
||||||
|
status_t error = vfs_get_vnode_from_path(source, true, &sourceVnode);
|
||||||
|
if (error != B_OK)
|
||||||
|
RETURN_ERROR(error);
|
||||||
|
if (sourceVnode == NULL)
|
||||||
|
RETURN_ERROR(B_ENTRY_NOT_FOUND);
|
||||||
|
fs_vnode* sourceFSNode = vfs_fsnode_for_vnode(sourceVnode);
|
||||||
|
fSourceFSVolume = volume_for_vnode(sourceFSNode);
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
if ((stat(source, &st)) != 0)
|
||||||
|
RETURN_ERROR(B_ERROR);
|
||||||
|
|
||||||
|
strlcpy(fName, "bindfs:", sizeof(fName));
|
||||||
|
strlcpy(fName, source, sizeof(fName));
|
||||||
|
|
||||||
|
// create the root node
|
||||||
|
fRootNode = new(std::nothrow) Node(st.st_ino, st.st_mode);
|
||||||
|
if (fRootNode == NULL)
|
||||||
|
RETURN_ERROR(B_NO_MEMORY);
|
||||||
|
|
||||||
|
_InitVnodeOpsFrom(sourceFSNode);
|
||||||
|
|
||||||
|
// publish the root node
|
||||||
|
error = publish_vnode(fFSVolume, fRootNode->ID(), fRootNode, &fVnodeOps,
|
||||||
|
fRootNode->Mode() & S_IFMT, 0);
|
||||||
|
if (error != B_OK) {
|
||||||
|
delete fRootNode;
|
||||||
|
fRootNode = NULL;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Volume::Unmount()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Volume::_InitVnodeOpsFrom(fs_vnode* sourceNode)
|
||||||
|
{
|
||||||
|
// vnode ops
|
||||||
|
int opsCount = sizeof(fVnodeOps) / sizeof(void*);
|
||||||
|
for (int i = 0; i < opsCount; ++i) {
|
||||||
|
if (((void**)sourceNode->ops)[i] == NULL)
|
||||||
|
((void**)&fVnodeOps)[i] = NULL;
|
||||||
|
else
|
||||||
|
((void**)&fVnodeOps)[i] = ((void**)&gBindFSVnodeOps)[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef VOLUME_H
|
||||||
|
#define VOLUME_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <fs_interface.h>
|
||||||
|
|
||||||
|
|
||||||
|
class Node;
|
||||||
|
|
||||||
|
|
||||||
|
class Volume {
|
||||||
|
public:
|
||||||
|
Volume(fs_volume* fsVolume);
|
||||||
|
~Volume();
|
||||||
|
|
||||||
|
fs_volume* FSVolume() const { return fFSVolume; }
|
||||||
|
dev_t ID() const { return fFSVolume->id; }
|
||||||
|
|
||||||
|
fs_volume* SourceFSVolume() const
|
||||||
|
{ return fSourceFSVolume; }
|
||||||
|
|
||||||
|
Node* RootNode() const { return fRootNode; }
|
||||||
|
const char* Name() const { return fName; }
|
||||||
|
|
||||||
|
status_t Mount(const char* parameterString);
|
||||||
|
void Unmount();
|
||||||
|
|
||||||
|
const fs_vnode_ops* VnodeOps() const { return &fVnodeOps; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct VolumeListener;
|
||||||
|
friend struct VolumeListener;
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t _InitVnodeOpsFrom(fs_vnode* sourceNode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
fs_volume* fFSVolume;
|
||||||
|
fs_volume* fSourceFSVolume;
|
||||||
|
Node* fRootNode;
|
||||||
|
|
||||||
|
fs_vnode_ops fVnodeOps;
|
||||||
|
|
||||||
|
char fName[B_PATH_NAME_LENGTH];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // VOLUME_H
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef KERNEL_INTERFACE_H
|
||||||
|
#define KERNEL_INTERFACE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <fs_interface.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern fs_volume_ops gBindFSVolumeOps;
|
||||||
|
extern fs_vnode_ops gBindFSVnodeOps;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // KERNEL_INTERFACE_H
|
||||||
@@ -4100,6 +4100,18 @@ vfs_vnode_to_node_ref(struct vnode* vnode, dev_t* _mountID, ino_t* _vnodeID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Helper function abstracting the process of "converting" a given
|
||||||
|
vnode-pointer to a fs_vnode-pointer.
|
||||||
|
Currently only used in bindfs.
|
||||||
|
*/
|
||||||
|
extern "C" fs_vnode*
|
||||||
|
vfs_fsnode_for_vnode(struct vnode* vnode)
|
||||||
|
{
|
||||||
|
return vnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Calls fs_open() on the given vnode and returns a new
|
Calls fs_open() on the given vnode and returns a new
|
||||||
file descriptor for it
|
file descriptor for it
|
||||||
|
|||||||
Reference in New Issue
Block a user