diff --git a/src/kits/storage/LibBeAdapter.cpp b/src/kits/storage/LibBeAdapter.cpp index f7c16d2d88..57cef33c4a 100644 --- a/src/kits/storage/LibBeAdapter.cpp +++ b/src/kits/storage/LibBeAdapter.cpp @@ -1,24 +1,34 @@ // LibBeAdapter.cpp -#include +#include #include -#include #include #include -status_t -entry_ref_to_path_adapter(dev_t device, ino_t directory, const char *name, - char *buffer, size_t size) +#include + + +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); +} + diff --git a/src/kits/storage/NodeMonitor.cpp b/src/kits/storage/NodeMonitor.cpp index 28cff23ce9..48dad562bb 100644 --- a/src/kits/storage/NodeMonitor.cpp +++ b/src/kits/storage/NodeMonitor.cpp @@ -8,55 +8,10 @@ #include #include +#include + // 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 - . - \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; } diff --git a/src/kits/storage/kernel_interface.POSIX.cpp b/src/kits/storage/kernel_interface.POSIX.cpp index ec016b59db..ccceb599cb 100644 --- a/src/kits/storage/kernel_interface.POSIX.cpp +++ b/src/kits/storage/kernel_interface.POSIX.cpp @@ -12,19 +12,21 @@ #include "kernel_interface.h" #include "storage_support.h" -#include "LibBeAdapter.h" - -#include -#include -#include // errno -#include +#include +#include // used by get_app_path() #include // File sytem information functions, structs, defines #include // BeOS's C-based attribute functions #include // BeOS's C-based query functions #include // entry_ref -#include // used by get_app_path() -#include // for utime() and struct utimbuf -#include + +#include // this is probably not compatible with our version and should be replaced +#include + +#include +#include +#include +#include +#include // 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 ) {