LibBeAdapter.cpp now only translates some syscalls; it will probably removed
once we do the final transition to the new kernel API. NodeMonitor.cpp and kernel_interface.POSIX.cpp now call Haiku syscalls where appropriate (they are connected to R5 via LibBeAdapter). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
51403af8f9
commit
1f5d3007c4
@ -1,24 +1,34 @@
|
||||
// LibBeAdapter.cpp
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <List.h>
|
||||
#include <Path.h>
|
||||
#include <string.h>
|
||||
|
||||
status_t
|
||||
entry_ref_to_path_adapter(dev_t device, ino_t directory, const char *name,
|
||||
char *buffer, size_t size)
|
||||
#include <syscalls.h>
|
||||
|
||||
|
||||
extern "C" status_t
|
||||
_kern_dir_node_ref_to_path(dev_t device, ino_t inode, char *buffer, size_t size)
|
||||
{
|
||||
status_t error = (name && buffer ? B_OK : B_BAD_VALUE);
|
||||
if (buffer == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
node_ref nodeRef;
|
||||
nodeRef.device = device;
|
||||
nodeRef.node = inode;
|
||||
|
||||
BDirectory directory;
|
||||
status_t error = directory.SetTo(&nodeRef);
|
||||
|
||||
BEntry entry;
|
||||
if (error == B_OK) {
|
||||
entry_ref ref(device, directory, name);
|
||||
error = entry.SetTo(&ref);
|
||||
}
|
||||
if (error == B_OK)
|
||||
error = directory.GetEntry(&entry);
|
||||
|
||||
BPath path;
|
||||
if (error == B_OK)
|
||||
error = entry.GetPath(&path);
|
||||
|
||||
if (error == B_OK) {
|
||||
if (size >= strlen(path.Path()) + 1)
|
||||
strcpy(buffer, path.Path());
|
||||
@ -28,3 +38,42 @@ entry_ref_to_path_adapter(dev_t device, ino_t directory, const char *name,
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
// Syscall mapping between R5 and us
|
||||
|
||||
// private libroot.so functions
|
||||
|
||||
extern "C" status_t _kstart_watching_vnode_(dev_t device, ino_t node,
|
||||
uint32 flags, port_id port,
|
||||
int32 handlerToken);
|
||||
|
||||
extern "C" status_t _kstop_watching_vnode_(dev_t device, ino_t node,
|
||||
port_id port, int32 handlerToken);
|
||||
|
||||
|
||||
extern "C" status_t _kstop_notifying_(port_id port, int32 handlerToken);
|
||||
|
||||
|
||||
status_t
|
||||
_kern_stop_notifying(port_id port, uint32 token)
|
||||
{
|
||||
return _kstop_notifying_(port, token);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
_kern_start_watching(dev_t device, ino_t node, uint32 flags,
|
||||
port_id port, uint32 token)
|
||||
{
|
||||
return _kstart_watching_vnode_(device, node, flags, port, token);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
_kern_stop_watching(dev_t device, ino_t node, uint32 flags,
|
||||
port_id port, uint32 token)
|
||||
{
|
||||
(void)flags;
|
||||
return _kstop_watching_vnode_(device, node, port, token);
|
||||
}
|
||||
|
||||
|
@ -8,55 +8,10 @@
|
||||
#include <Messenger.h>
|
||||
#include <NodeMonitor.h>
|
||||
|
||||
#include <syscalls.h>
|
||||
|
||||
// TODO: Tests!
|
||||
|
||||
// private libroot.so functions
|
||||
|
||||
/*! \brief Subscribes a target to node and/or mount watching.
|
||||
|
||||
Depending on \a flags, different actions are performed. If flags is \c 0,
|
||||
mount watching is requested. \a device and \a node must be \c -1 in this
|
||||
case. Otherwise node watching is requested. \a device and \a node must
|
||||
refer to a valid node, and \a flags must note contain the flag
|
||||
\c B_WATCH_MOUNT, but at least one of the other valid flags.
|
||||
|
||||
\param device The device the node resides on (node_ref::device). \c -1, if
|
||||
only mount watching is requested.
|
||||
\param node The node ID of the node (node_ref::device). \c -1, if
|
||||
only mount watching is requested.
|
||||
\param flags A bit mask composed of the values specified in
|
||||
<NodeMonitor.h>.
|
||||
\param port The port of the target (a looper port).
|
||||
\param handlerToken The token of the target handler. \c -2, if the
|
||||
preferred handler of the looper is the target.
|
||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||
*/
|
||||
extern "C" status_t _kstart_watching_vnode_(dev_t device, ino_t node,
|
||||
uint32 flags, port_id port,
|
||||
int32 handlerToken);
|
||||
|
||||
/*! \brief Unsubscribes a target from watching a node.
|
||||
\param device The device the node resides on (node_ref::device).
|
||||
\param node The node ID of the node (node_ref::device).
|
||||
\param port The port of the target (a looper port).
|
||||
\param handlerToken The token of the target handler. \c -2, if the
|
||||
preferred handler of the looper is the target.
|
||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||
*/
|
||||
extern "C" status_t _kstop_watching_vnode_(dev_t device, ino_t node,
|
||||
port_id port, int32 handlerToken);
|
||||
|
||||
|
||||
/*! \brief Unsubscribes a target from node and mount monitoring.
|
||||
\param port The port of the target (a looper port).
|
||||
\param handlerToken The token of the target handler. \c -2, if the
|
||||
preferred handler of the looper is the target.
|
||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||
*/
|
||||
extern "C" status_t _kstop_notifying_(port_id port, int32 handlerToken);
|
||||
|
||||
|
||||
// actual implementation
|
||||
|
||||
// watch_node
|
||||
/*! \brief Subscribes a target to node and/or mount watching, or unsubscribes
|
||||
@ -142,23 +97,20 @@ watch_node(const node_ref *node, uint32 flags, const BHandler *handler,
|
||||
port_id port = _get_looper_port_(looper);
|
||||
if (flags == B_STOP_WATCHING) {
|
||||
// unsubscribe from node node watching
|
||||
if (node) {
|
||||
error = _kstop_watching_vnode_(node->device, node->node, port,
|
||||
handlerToken);
|
||||
} else
|
||||
if (node)
|
||||
error = _kern_stop_watching(node->device, node->node, flags, port, handlerToken);
|
||||
else
|
||||
error = B_BAD_VALUE;
|
||||
} else {
|
||||
// subscribe to...
|
||||
// mount watching
|
||||
if (flags & B_WATCH_MOUNT) {
|
||||
error = _kstart_watching_vnode_((dev_t)-1, (ino_t)-1, 0, port, handlerToken);
|
||||
error = _kern_start_watching((dev_t)-1, (ino_t)-1, 0, port, handlerToken);
|
||||
flags &= ~B_WATCH_MOUNT;
|
||||
}
|
||||
// node watching
|
||||
if (error == B_OK && flags) {
|
||||
error = _kstart_watching_vnode_(node->device, node->node,
|
||||
flags, port, handlerToken);
|
||||
}
|
||||
if (error == B_OK && flags)
|
||||
error = _kern_start_watching(node->device, node->node, flags, port, handlerToken);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
@ -210,7 +162,7 @@ stop_watching(const BHandler *handler, const BLooper *looper)
|
||||
// unsubscribe
|
||||
if (error == B_OK) {
|
||||
port_id port = _get_looper_port_(looper);
|
||||
error = _kstop_notifying_(port, handlerToken);
|
||||
error = _kern_stop_notifying(port, handlerToken);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -12,19 +12,21 @@
|
||||
#include "kernel_interface.h"
|
||||
#include "storage_support.h"
|
||||
|
||||
#include "LibBeAdapter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fsproto.h>
|
||||
#include <errno.h> // errno
|
||||
#include <new>
|
||||
#include <OS.h>
|
||||
#include <image.h> // used by get_app_path()
|
||||
#include <fs_info.h> // File sytem information functions, structs, defines
|
||||
#include <fs_attr.h> // BeOS's C-based attribute functions
|
||||
#include <fs_query.h> // BeOS's C-based query functions
|
||||
#include <Entry.h> // entry_ref
|
||||
#include <image.h> // used by get_app_path()
|
||||
#include <utime.h> // for utime() and struct utimbuf
|
||||
#include <OS.h>
|
||||
|
||||
#include <fsproto.h> // this is probably not compatible with our version and should be replaced
|
||||
#include <syscalls.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <new>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// This is just for cout while developing; shouldn't need it
|
||||
// when all is said and done.
|
||||
@ -991,13 +993,21 @@ BPrivate::Storage::entry_ref_to_path( const struct entry_ref *ref, char *result,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPrivate::Storage::entry_ref_to_path( dev_t device, ino_t directory, const char *name,
|
||||
char *result, size_t size )
|
||||
BPrivate::Storage::entry_ref_to_path(dev_t device, ino_t directory, const char *name,
|
||||
char *path, size_t size)
|
||||
{
|
||||
return entry_ref_to_path_adapter(device, directory, name, result, size);
|
||||
status_t status = _kern_dir_node_ref_to_path(device, directory, path, size);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
strlcat(path, "/", size);
|
||||
strlcat(path, name, size);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPrivate::Storage::dir_to_self_entry_ref( FileDescriptor dir, entry_ref *result )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user