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 664751ddab..1447076a03 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -741,7 +741,11 @@ bfs_write_stat(void *_ns, void *_node, const struct stat *stat, uint32 mask) node.gid = HOST_ENDIAN_TO_BFS_INT32(stat->st_gid); if (mask & B_STAT_MODIFICATION_TIME) { - if (!inode->IsDeleted()) { + if (inode->IsDirectory()) { + // directory modification times are not part of the index + node.last_modified_time = HOST_ENDIAN_TO_BFS_INT64( + (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + } else if (!inode->IsDeleted()) { // Index::UpdateLastModified() will set the new time in the inode Index index(volume); index.UpdateLastModified(transaction, inode, @@ -749,7 +753,8 @@ bfs_write_stat(void *_ns, void *_node, const struct stat *stat, uint32 mask) } } if (mask & B_STAT_CREATION_TIME) { - node.create_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)stat->st_crtime << INODE_TIME_SHIFT); + node.create_time = HOST_ENDIAN_TO_BFS_INT64( + (bigtime_t)stat->st_crtime << INODE_TIME_SHIFT); } if ((status = inode->WriteBack(transaction)) == B_OK) diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h index b53473cd95..f9cef977fa 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h @@ -98,6 +98,8 @@ class Inode : public CachedBlock { bool IsIndex() const { return (Mode() & (S_INDEX_DIR | 0777)) == S_INDEX_DIR; } // that's a stupid check, but AFAIK the only possible method... + bool IsDeleted() const { return (Flags() & INODE_DELETED) != 0; } + bool IsAttributeDirectory() const { return (Mode() & S_ATTR_DIR) != 0; } bool IsAttribute() const { return Mode() & S_ATTR; } bool IsFile() const { return (Mode() & (S_IFMT | S_ATTR)) == S_FILE; } diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/kernel_interface_r5.cpp b/src/tests/add-ons/kernel/file_systems/bfs/r5/kernel_interface_r5.cpp index 511a852407..fd882cdf4a 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/kernel_interface_r5.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/kernel_interface_r5.cpp @@ -1,6 +1,6 @@ /* kernel_interface - file system interface to BeOS' vnode layer * - * Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de + * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de * This file may be used under the terms of the MIT License. */ @@ -967,13 +967,20 @@ bfs_write_stat(void *_ns, void *_node, struct stat *stat, long mask) node->gid = stat->st_gid; if (mask & WSTAT_MTIME) { - // Index::UpdateLastModified() will set the new time in the inode - Index index(volume); - index.UpdateLastModified(&transaction, inode, - (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + if (inode->IsDirectory()) { + // directory modification times are not part of the index + node->last_modified_time = HOST_ENDIAN_TO_BFS_INT64( + (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + } else if (!inode->IsDeleted()) { + // Index::UpdateLastModified() will set the new time in the inode + Index index(volume); + index.UpdateLastModified(&transaction, inode, + (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + } } if (mask & WSTAT_CRTIME) { - node->create_time = (bigtime_t)stat->st_crtime << INODE_TIME_SHIFT; + node->create_time = HOST_ENDIAN_TO_BFS_INT64( + (bigtime_t)stat->st_crtime << INODE_TIME_SHIFT); } if ((status = inode->WriteBack(&transaction)) == B_OK)