Author: korli Date: 2010-10-13 20:49:03 +0200 (Wed, 13 Oct 2010) New Revision: 38965 Changeset: http://dev.haiku-os.org/changeset/38965 Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * renamed bfs_inode::ToUsecs() to bfs_inode::ToNsecs, as it really converts to nanoseconds. * added a comment explaining the nanoseconds conversion Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2010-10-13 17:17:45 UTC (rev 38964) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2010-10-13 18:49:03 UTC (rev 38965) @@ -121,13 +121,13 @@ kprintf(" flags = %08x\n", (int)inode->Flags()); kprintf(" create_time = %" B_PRIx64 " (%" B_PRIdTIME ".%u)\n", inode->CreateTime(), bfs_inode::ToSecs(inode->CreateTime()), - (unsigned)bfs_inode::ToUsecs(inode->CreateTime())); + (unsigned)bfs_inode::ToNsecs(inode->CreateTime())); kprintf(" last_modified_time = %" B_PRIx64 " (%" B_PRIdTIME ".%u)\n", inode->LastModifiedTime(), bfs_inode::ToSecs(inode->LastModifiedTime()), - (unsigned)bfs_inode::ToUsecs(inode->LastModifiedTime())); + (unsigned)bfs_inode::ToNsecs(inode->LastModifiedTime())); kprintf(" status_change_time = %" B_PRIx64 " (%" B_PRIdTIME ".%u)\n", inode->StatusChangeTime(), bfs_inode::ToSecs(inode->StatusChangeTime()), - (unsigned)bfs_inode::ToUsecs(inode->StatusChangeTime())); + (unsigned)bfs_inode::ToNsecs(inode->StatusChangeTime())); dump_block_run( " parent = ", inode->parent); dump_block_run( " attributes = ", inode->attributes); kprintf(" type = %u\n", (unsigned)inode->Type()); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2010-10-13 17:17:45 UTC (rev 38964) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2010-10-13 18:49:03 UTC (rev 38965) @@ -238,10 +238,12 @@ { return ((int64)tv.tv_sec << INODE_TIME_SHIFT) + unique_from_nsec(tv.tv_nsec); } - static time_t ToSecs(bigtime_t time) + static time_t ToSecs(int64 time) { return time >> INODE_TIME_SHIFT; } - static uint32 ToUsecs(bigtime_t time) + static uint32 ToNsecs(int64 time) { return (time & INODE_TIME_MASK) << 14; } + // the 16 bits internal resolution shifted by 14 gives us 2^30 + // which is roughly 10^9, the maximum value in nanoseconds } _PACKED; enum inode_flags { Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2010-10-13 17:17:45 UTC (rev 38964) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2010-10-13 18:49:03 UTC (rev 38965) @@ -35,13 +35,14 @@ static void fill_stat_time(const bfs_inode& node, struct stat& stat) { - stat.st_atim.tv_sec = real_time_clock(); - stat.st_atim.tv_nsec = real_time_clock_usecs() % 1000000; + bigtime_t now = real_time_clock_usecs(); + stat.st_atim.tv_sec = now / 1000000LL; + stat.st_atim.tv_nsec = (now % 1000000LL) * 1000; stat.st_mtim.tv_sec = bfs_inode::ToSecs(node.LastModifiedTime()); - stat.st_mtim.tv_nsec = bfs_inode::ToUsecs(node.LastModifiedTime()); + stat.st_mtim.tv_nsec = bfs_inode::ToNsecs(node.LastModifiedTime()); stat.st_crtim.tv_sec = bfs_inode::ToSecs(node.CreateTime()); - stat.st_crtim.tv_nsec = bfs_inode::ToUsecs(node.CreateTime()); + stat.st_crtim.tv_nsec = bfs_inode::ToNsecs(node.CreateTime()); // For BeOS compatibility, if on-disk ctime is invalid, fall back to mtime: bigtime_t changeTime = node.StatusChangeTime(); @@ -49,7 +50,7 @@ stat.st_ctim = stat.st_mtim; else { stat.st_ctim.tv_sec = bfs_inode::ToSecs(changeTime); - stat.st_ctim.tv_nsec = bfs_inode::ToUsecs(changeTime); + stat.st_ctim.tv_nsec = bfs_inode::ToNsecs(changeTime); } }