[haiku-commits] r39131 - in haiku/trunk: headers/os/drivers headers/private/fs_shell headers/private/storage src/add-ons/kernel/file_systems/bfs src/kits/storage ...

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 24 Oct 2010 22:47:47 +0200 (CEST)

Author: czeidler
Date: 2010-10-24 22:47:46 +0200 (Sun, 24 Oct 2010)
New Revision: 39131
Changeset: http://dev.haiku-os.org/changeset/39131

Added:
   haiku/trunk/headers/private/storage/query_private.h
Modified:
   haiku/trunk/headers/os/drivers/fs_interface.h
   haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h
   haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h
   haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.cpp
   haiku/trunk/src/kits/storage/NodeMonitor.cpp
   haiku/trunk/src/kits/storage/Query.cpp
   haiku/trunk/src/system/kernel/fs/node_monitor.cpp
   haiku/trunk/src/tools/bfs_shell/Jamfile
   haiku/trunk/src/tools/fs_shell/node_monitor.cpp
Log:
Add a private B_ATTR_CHANGE_NOTIFICATION flag to the open query syscall to tell 
the query to send notifications when an entry attribute changed and the entry 
stays in the query. Previously you only get created and removed messages, now 
you can also get updated messages. Only implement it for bfs.
Fix copy right.



Modified: haiku/trunk/headers/os/drivers/fs_interface.h
===================================================================
--- haiku/trunk/headers/os/drivers/fs_interface.h       2010-10-24 16:55:33 UTC 
(rev 39130)
+++ haiku/trunk/headers/os/drivers/fs_interface.h       2010-10-24 20:47:46 UTC 
(rev 39131)
@@ -356,6 +356,9 @@
 extern status_t notify_query_entry_removed(port_id port, int32 token,
                                        dev_t device, ino_t directory, const 
char* name,
                                        ino_t node);
+extern status_t notify_query_attr_changed(port_id port, int32 token,
+                                       dev_t device, ino_t directory, const 
char* name,
+                                       ino_t node);
 
 #ifdef __cplusplus
 }

Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h
===================================================================
--- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h     2010-10-24 
16:55:33 UTC (rev 39130)
+++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h     2010-10-24 
20:47:46 UTC (rev 39131)
@@ -945,6 +945,7 @@
 
 #define notify_query_entry_created     fssh_notify_query_entry_created
 #define notify_query_entry_removed     fssh_notify_query_entry_removed
+#define notify_query_attr_changed      fssh_notify_query_attr_changed
 
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h
===================================================================
--- haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h    2010-10-24 
16:55:33 UTC (rev 39130)
+++ haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h    2010-10-24 
20:47:46 UTC (rev 39131)
@@ -402,6 +402,10 @@
                                int32_t token, fssh_mount_id device,
                                fssh_vnode_id directory, const char *name,
                                fssh_vnode_id node);
+extern fssh_status_t fssh_notify_query_attr_changed(fssh_port_id port,
+                               int32_t token, fssh_mount_id device,
+                               fssh_vnode_id directory, const char *name,
+                               fssh_vnode_id node);
 
 #ifdef __cplusplus
 }

Added: haiku/trunk/headers/private/storage/query_private.h
===================================================================
--- haiku/trunk/headers/private/storage/query_private.h                         
(rev 0)
+++ haiku/trunk/headers/private/storage/query_private.h 2010-10-24 20:47:46 UTC 
(rev 39131)
@@ -0,0 +1,10 @@
+#ifndef QUERY_PRIVATE_H
+#define QUERY_PRIVATE_H
+
+
+// If an entry is already in a query and a attribute changed
+// B_ATTR_CHANGE_NOTIFICATION tells the query to send B_ATTR_CHANGED
+// notifications if the entry stays in the query.
+#define B_ATTR_CHANGE_NOTIFICATION             0x0000F000
+
+#endif

Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.cpp   2010-10-24 
16:55:33 UTC (rev 39130)
+++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.cpp   2010-10-24 
20:47:46 UTC (rev 39131)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2001-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Copyright 2010, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  * This file may be used under the terms of the MIT License.
  */
 
@@ -11,14 +12,16 @@
 */
 
 #include "Query.h"
+
+#include <query_private.h>
+
+#include "BPlusTree.h"
 #include "bfs.h"
 #include "Debug.h"
+#include "Index.h"
+#include "Inode.h"
 #include "Volume.h"
-#include "Inode.h"
-#include "BPlusTree.h"
-#include "Index.h"
 
-
 // The parser has a very static design, but it will do what is required.
 //
 // ParseOr(), ParseAnd(), ParseEquation() are guarantying the operator
@@ -1620,7 +1623,8 @@
        status_t newStatus = fExpression->Root()->Match(inode, attribute, type,
                newKey, newLength);
 
-       bool entryCreated;
+       bool entryCreated = false;
+       bool stillInQuery = false;
 
        if (oldStatus != MATCH_OK) {
                if (newStatus != MATCH_OK) {
@@ -1631,10 +1635,11 @@
        } else if (newStatus != MATCH_OK) {
                // entry got removed
                entryCreated = false;
-       } else {
+       } else if ((fFlags & B_ATTR_CHANGE_NOTIFICATION) != 0) {
                // The entry stays in the query
+               stillInQuery = true;
+       } else
                return;
-       }
 
        // we may need to get the name of the inode
 
@@ -1652,7 +1657,10 @@
 
        // notify query listeners
 
-       if (entryCreated) {
+       if (stillInQuery)
+               notify_query_attr_changed(fPort, fToken, fVolume->ID(),
+                       fVolume->ToVnode(inode->Parent()), name, inode->ID());
+       else if (entryCreated) {
                notify_query_entry_created(fPort, fToken, fVolume->ID(),
                        fVolume->ToVnode(inode->Parent()), name, inode->ID());
        } else {

Modified: haiku/trunk/src/kits/storage/NodeMonitor.cpp
===================================================================
--- haiku/trunk/src/kits/storage/NodeMonitor.cpp        2010-10-24 16:55:33 UTC 
(rev 39130)
+++ haiku/trunk/src/kits/storage/NodeMonitor.cpp        2010-10-24 20:47:46 UTC 
(rev 39131)
@@ -1,10 +1,11 @@
 /*
- * Copyright 2001-2005, Haiku.
+ * Copyright 2001-2010, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Ingo Weinhold, bonefish@@users.sf.net
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  */
 
 

Modified: haiku/trunk/src/kits/storage/Query.cpp
===================================================================
--- haiku/trunk/src/kits/storage/Query.cpp      2010-10-24 16:55:33 UTC (rev 
39130)
+++ haiku/trunk/src/kits/storage/Query.cpp      2010-10-24 20:47:46 UTC (rev 
39131)
@@ -22,10 +22,12 @@
 
 #include <MessengerPrivate.h>
 #include <syscalls.h>
+#include <query_private.h>
 
 #include "QueryPredicate.h"
 #include "storage_support.h"
 
+
 using namespace std;
 using namespace BPrivate::Storage;
 

Modified: haiku/trunk/src/system/kernel/fs/node_monitor.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/node_monitor.cpp   2010-10-24 16:55:33 UTC 
(rev 39130)
+++ haiku/trunk/src/system/kernel/fs/node_monitor.cpp   2010-10-24 20:47:46 UTC 
(rev 39131)
@@ -219,8 +219,9 @@
 
 
 /*!    \brief Notifies the listener of a live query that an entry has been 
added
-                  to or removed from the query (for whatever reason).
-       \param opcode \c B_ENTRY_CREATED or \c B_ENTRY_REMOVED.
+                  to or removed from or updated and still in the query (for 
whatever
+                  reason).
+       \param opcode \c B_ENTRY_CREATED or \c B_ENTRY_REMOVED or \c 
B_ATTR_CHANGED.
        \param port The target port of the listener.
        \param token The BHandler token of the listener.
        \param device The ID of the mounted FS, the entry lives in.
@@ -232,7 +233,7 @@
        - another error code otherwise.
 */
 static status_t
-notify_query_entry_created_or_removed(int32 opcode, port_id port, int32 token,
+notify_query_entry_event(int32 opcode, port_id port, int32 token,
        dev_t device, ino_t directory, const char *name, ino_t node)
 {
        if (!name)
@@ -1195,7 +1196,7 @@
 notify_query_entry_created(port_id port, int32 token, dev_t device,
        ino_t directory, const char *name, ino_t node)
 {
-       return notify_query_entry_created_or_removed(B_ENTRY_CREATED, port, 
token,
+       return notify_query_entry_event(B_ENTRY_CREATED, port, token,
                device, directory, name, node);
 }
 
@@ -1216,11 +1217,32 @@
 notify_query_entry_removed(port_id port, int32 token, dev_t device,
        ino_t directory, const char *name, ino_t node)
 {
-       return notify_query_entry_created_or_removed(B_ENTRY_REMOVED, port, 
token,
+       return notify_query_entry_event(B_ENTRY_REMOVED, port, token,
                device, directory, name, node);
 }
 
 
+/*!    \brief Notifies the listener of a live query that an entry has been 
changed
+                  and is still in the query (for whatever reason).
+       \param port The target port of the listener.
+       \param token The BHandler token of the listener.
+       \param device The ID of the mounted FS, the entry lives in.
+       \param directory The entry's parent directory ID.
+       \param name The entry's name.
+       \param node The ID of the node the entry refers to.
+       \return
+       - \c B_OK, if everything went fine,
+       - another error code otherwise.
+*/
+status_t
+notify_query_attr_changed(port_id port, int32 token, dev_t device,
+       ino_t directory, const char* name, ino_t node)
+{
+       return notify_query_entry_event(B_ATTR_CHANGED, port, token,
+               device, directory, name, node);
+}
+
+
 //     #pragma mark - User syscalls
 
 

Modified: haiku/trunk/src/tools/bfs_shell/Jamfile
===================================================================
--- haiku/trunk/src/tools/bfs_shell/Jamfile     2010-10-24 16:55:33 UTC (rev 
39130)
+++ haiku/trunk/src/tools/bfs_shell/Jamfile     2010-10-24 20:47:46 UTC (rev 
39131)
@@ -33,6 +33,8 @@
        fsShellCommandLibs = $(HOST_NETWORK_LIBS) ;
 }
 
+UsePrivateHeaders storage ;
+
 UsePrivateHeaders fs_shell ;
 
 local bfsSource =

Modified: haiku/trunk/src/tools/fs_shell/node_monitor.cpp
===================================================================
--- haiku/trunk/src/tools/fs_shell/node_monitor.cpp     2010-10-24 16:55:33 UTC 
(rev 39130)
+++ haiku/trunk/src/tools/fs_shell/node_monitor.cpp     2010-10-24 20:47:46 UTC 
(rev 39131)
@@ -64,3 +64,12 @@
 {
        return FSSH_B_OK;
 }
+
+
+fssh_status_t
+fssh_notify_query_attr_changed(fssh_port_id port, int32_t token,
+       fssh_mount_id device, fssh_vnode_id directory, const char *name,
+       fssh_vnode_id node)
+{
+       return FSSH_B_OK;
+}
\ No newline at end of file


Other related posts:

  • » [haiku-commits] r39131 - in haiku/trunk: headers/os/drivers headers/private/fs_shell headers/private/storage src/add-ons/kernel/file_systems/bfs src/kits/storage ... - clemens . zeidler