diff --git a/headers/os/storage/NodeMonitor.h b/headers/os/storage/NodeMonitor.h index d3e5999fad..0d7cfdda44 100644 --- a/headers/os/storage/NodeMonitor.h +++ b/headers/os/storage/NodeMonitor.h @@ -1,9 +1,9 @@ +/* + * Copyright 2003-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _NODE_MONITOR_H #define _NODE_MONITOR_H -/* Node monitor calls for kernel add-ons -** -** Distributed under the terms of the OpenBeOS License. -*/ #include @@ -16,14 +16,15 @@ */ enum { - B_STOP_WATCHING = 0x0000, - B_WATCH_NAME = 0x0001, - B_WATCH_STAT = 0x0002, - B_WATCH_ATTR = 0x0004, - B_WATCH_DIRECTORY = 0x0008, - B_WATCH_ALL = 0x000f, + B_STOP_WATCHING = 0x0000, + B_WATCH_NAME = 0x0001, + B_WATCH_STAT = 0x0002, + B_WATCH_ATTR = 0x0004, + B_WATCH_DIRECTORY = 0x0008, + B_WATCH_ALL = 0x000f, - B_WATCH_MOUNT = 0x0010 + B_WATCH_MOUNT = 0x0010, + B_WATCH_INTERIM_STAT = 0x0020 }; @@ -53,14 +54,16 @@ enum { // messages, specifying what parts of the stat data have actually been // changed. (Haiku only) enum { - B_STAT_MODE = 0x01, - B_STAT_UID = 0x02, - B_STAT_GID = 0x04, - B_STAT_SIZE = 0x08, - B_STAT_ACCESS_TIME = 0x10, - B_STAT_MODIFICATION_TIME = 0x20, - B_STAT_CREATION_TIME = 0x40, - B_STAT_CHANGE_TIME = 0x80, + B_STAT_MODE = 0x0001, + B_STAT_UID = 0x0002, + B_STAT_GID = 0x0004, + B_STAT_SIZE = 0x0008, + B_STAT_ACCESS_TIME = 0x0010, + B_STAT_MODIFICATION_TIME = 0x0020, + B_STAT_CREATION_TIME = 0x0040, + B_STAT_CHANGE_TIME = 0x0080, + + B_STAT_INTERIM_UPDATE = 0x1000 }; diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 9dd9353565..c684c9b121 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1429,6 +1429,10 @@ Inode::WriteAt(Transaction &transaction, off_t pos, const uint8 *buffer, *_length = 0; RETURN_ERROR(status); } + // TODO: In theory we would need to update the file size + // index here as part of the current transaction - this might just + // be a bit too expensive, but worth a try. + // If the position of the write was beyond the file size, we // have to fill the gap between that position and the old file // size with zeros. diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index 70dacb66d8..23d2ab23a9 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1233,7 +1233,7 @@ bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer, if (!inode->IsDeleted() && cookie->last_size != inode->Size() && system_time() > cookie->last_notification + INODE_NOTIFICATION_INTERVAL) { notify_stat_changed(volume->ID(), inode->ID(), - B_STAT_MODIFICATION_TIME | B_STAT_SIZE); + B_STAT_MODIFICATION_TIME | B_STAT_SIZE | B_STAT_INTERIM_UPDATE); cookie->last_size = inode->Size(); cookie->last_notification = system_time(); } @@ -1306,7 +1306,7 @@ bfs_free_cookie(void *_ns, void *_node, void *_cookie) status = B_OK; } } - if (needsTrimming || inode->OldSize() != inode->Size()) { + if (inode->OldSize() != inode->Size()) { index.UpdateSize(transaction, inode); changedSize = true; } diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 522931de56..5a7a15faee 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -1038,7 +1038,11 @@ BPoseView::InitDirentIterator(const entry_ref *ref) uint32 BPoseView::WatchNewNodeMask() { +#ifdef __HAIKU__ + return B_WATCH_STAT | B_WATCH_INTERIM_STAT | B_WATCH_ATTR; +#else return B_WATCH_STAT | B_WATCH_ATTR; +#endif } diff --git a/src/system/kernel/fs/node_monitor.cpp b/src/system/kernel/fs/node_monitor.cpp index 168be5478c..dd2b94bcff 100644 --- a/src/system/kernel/fs/node_monitor.cpp +++ b/src/system/kernel/fs/node_monitor.cpp @@ -1,5 +1,7 @@ /* * Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2005-2008, Ingo Weinhold, bonefish@users.sf.net. + * * Distributed under the terms of the MIT License. */ @@ -620,8 +622,10 @@ NodeMonitorService::NotifyStatChanged(dev_t device, ino_t node, // get the lists of all interested listeners interested_monitor_listener_list interestedListeners[3]; int32 interestedListenerCount = 0; - // ... for the node - _GetInterestedMonitorListeners(device, node, B_WATCH_STAT, + // ... for the node, depending on wether its an interim update or not + _GetInterestedMonitorListeners(device, node, + (statFields & B_STAT_INTERIM_UPDATE) != 0 + ? B_WATCH_INTERIM_STAT : B_WATCH_STAT, interestedListeners, interestedListenerCount); if (interestedListenerCount == 0)