* write_stat() should not add/update the last modification time of directories.

Reported by Robert Szeleney.
* Fixed an endian problem in write_stat() in the R5 version of BFS.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19121 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-10-25 15:21:28 +00:00
parent a9831b73ed
commit 297f89345f
3 changed files with 22 additions and 8 deletions

View File

@ -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)

View File

@ -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; }

View File

@ -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)