diff --git a/src/system/kernel/device_manager/devfs.cpp b/src/system/kernel/device_manager/devfs.cpp index ef7a055cf7..7d121bece3 100644 --- a/src/system/kernel/device_manager/devfs.cpp +++ b/src/system/kernel/device_manager/devfs.cpp @@ -84,8 +84,8 @@ struct devfs_vnode { struct devfs_vnode* all_next; ino_t id; char* name; - time_t modification_time; - time_t creation_time; + timespec modification_time; + timespec creation_time; uid_t uid; gid_t gid; struct devfs_vnode* parent; @@ -151,6 +151,18 @@ static struct devfs* sDeviceFileSystem = NULL; // #pragma mark - devfs private +static timespec +current_timespec() +{ + bigtime_t time = real_time_clock_usecs(); + + timespec tv; + tv.tv_sec = time / 1000000; + tv.tv_nsec = (time % 1000000) * 1000; + return tv; +} + + static int32 scan_mode(void) { @@ -228,7 +240,7 @@ devfs_create_vnode(struct devfs* fs, devfs_vnode* parent, const char* name) return NULL; } - vnode->creation_time = vnode->modification_time = time(NULL); + vnode->creation_time = vnode->modification_time = current_timespec(); vnode->uid = geteuid(); vnode->gid = parent ? parent->gid : getegid(); // inherit group from parent if possible @@ -333,7 +345,7 @@ devfs_insert_in_dir(struct devfs_vnode* dir, struct devfs_vnode* vnode) } vnode->parent = dir; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_entry_created(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); @@ -360,7 +372,7 @@ devfs_remove_from_dir(struct devfs_vnode* dir, struct devfs_vnode* removeNode) else dir->stream.u.dir.dir_head = vnode->dir_next; vnode->dir_next = NULL; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_entry_removed(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); @@ -1796,11 +1808,11 @@ devfs_read_stat(fs_volume* _volume, fs_vnode* _vnode, struct stat* stat) stat->st_uid = vnode->uid; stat->st_gid = vnode->gid; - stat->st_atime = time(NULL); - stat->st_mtime = stat->st_ctime = vnode->modification_time; - stat->st_crtime = vnode->creation_time; + stat->st_atim = current_timespec(); + stat->st_mtim = stat->st_ctim = vnode->modification_time; + stat->st_crtim = vnode->creation_time; - // ToDo: this only works for partitions right now - if we should decide + // TODO: this only works for partitions right now - if we should decide // to keep this feature, we should have a better solution if (S_ISCHR(vnode->stream.type)) { //device_geometry geometry; @@ -1854,9 +1866,9 @@ devfs_write_stat(fs_volume* _volume, fs_vnode* _vnode, const struct stat* stat, vnode->gid = stat->st_gid; if (statMask & B_STAT_MODIFICATION_TIME) - vnode->modification_time = stat->st_mtime; + vnode->modification_time = stat->st_mtim; if (statMask & B_STAT_CREATION_TIME) - vnode->creation_time = stat->st_crtime; + vnode->creation_time = stat->st_crtim; notify_stat_changed(fs->id, vnode->id, statMask); return B_OK; diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp b/src/system/kernel/device_manager/legacy_drivers.cpp index c1e11b324f..bf473bfd61 100644 --- a/src/system/kernel/device_manager/legacy_drivers.cpp +++ b/src/system/kernel/device_manager/legacy_drivers.cpp @@ -89,7 +89,7 @@ struct legacy_driver { const char* name; dev_t device; ino_t node; - time_t last_modified; + timespec last_modified; image_id image; uint32 devices_used; bool binary_updated; @@ -567,7 +567,7 @@ add_driver(const char *path, image_id image) driver->device = stat.st_dev; driver->node = stat.st_ino; driver->image = image; - driver->last_modified = stat.st_mtime; + driver->last_modified = stat.st_mtim; driver->devices_used = 0; driver->binary_updated = false; driver->priority = priority; @@ -756,7 +756,8 @@ dump_driver(int argc, char** argv) kprintf(" image: %ld\n", driver->image); kprintf(" device: %ld\n", driver->device); kprintf(" node: %Ld\n", driver->node); - kprintf(" last modified: %ld\n", driver->last_modified); + kprintf(" last modified: %ld.%lu\n", driver->last_modified.tv_sec, + driver->last_modified.tv_nsec); kprintf(" devs used: %ld\n", driver->devices_used); kprintf(" devs published: %ld\n", driver->devices.Count()); kprintf(" binary updated: %d\n", driver->binary_updated); diff --git a/src/system/kernel/fs/fifo.cpp b/src/system/kernel/fs/fifo.cpp index a852bfa2a0..4ace0cf7b9 100644 --- a/src/system/kernel/fs/fifo.cpp +++ b/src/system/kernel/fs/fifo.cpp @@ -1,6 +1,6 @@ /* * Copyright 2007-2008, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -137,11 +137,11 @@ class Inode { status_t InitCheck(); bool IsActive() const { return fActive; } - time_t CreationTime() const { return fCreationTime; } - void SetCreationTime(time_t creationTime) + timespec CreationTime() const { return fCreationTime; } + void SetCreationTime(timespec creationTime) { fCreationTime = creationTime; } - time_t ModificationTime() const { return fModificationTime; } - void SetModificationTime(time_t modificationTime) + timespec ModificationTime() const { return fModificationTime; } + void SetModificationTime(timespec modificationTime) { fModificationTime = modificationTime; } mutex *RequestLock() { return &fRequestLock; } @@ -171,8 +171,8 @@ class Inode { status_t Deselect(uint8 event, selectsync *sync, int openMode); private: - time_t fCreationTime; - time_t fModificationTime; + timespec fCreationTime; + timespec fModificationTime; RingBuffer fBuffer; @@ -319,7 +319,10 @@ Inode::Inode() fWriteCondition.Publish(this, "pipe"); mutex_init(&fRequestLock, "pipe request"); - fCreationTime = fModificationTime = time(NULL); + bigtime_t time = real_time_clock(); + fModificationTime.tv_sec = time / 1000000; + fModificationTime.tv_nsec = (time % 1000000) * 1000; + fCreationTime = fModificationTime; } @@ -855,10 +858,10 @@ fifo_read_stat(fs_volume *volume, fs_vnode *vnode, struct ::stat *st) st->st_blksize = 4096; -// TODO: Just pass the changes to our modification time on to the super node. - st->st_atime = time(NULL); - st->st_mtime = st->st_ctime = fifo->ModificationTime(); -// st->st_crtime = inode->CreationTime(); + // TODO: Just pass the changes to our modification time on to the super node. + st->st_atim.tv_sec = time(NULL); + st->st_atim.tv_nsec = 0; + st->st_mtim = st->st_ctim = fifo->ModificationTime(); return B_OK; } diff --git a/src/system/kernel/fs/rootfs.cpp b/src/system/kernel/fs/rootfs.cpp index 0d4dd5b8cf..b0147ec39b 100644 --- a/src/system/kernel/fs/rootfs.cpp +++ b/src/system/kernel/fs/rootfs.cpp @@ -60,8 +60,8 @@ struct rootfs_vnode { struct rootfs_vnode* all_next; ino_t id; char* name; - time_t modification_time; - time_t creation_time; + timespec modification_time; + timespec creation_time; uid_t uid; gid_t gid; struct rootfs_vnode* parent; @@ -102,6 +102,18 @@ namespace { #define ROOTFS_HASH_SIZE 16 +static timespec +current_timespec() +{ + bigtime_t time = real_time_clock_usecs(); + + timespec tv; + tv.tv_sec = time / 1000000; + tv.tv_nsec = (time % 1000000) * 1000; + return tv; +} + + static uint32 rootfs_vnode_hash_func(void* _v, const void* _key, uint32 range) { @@ -150,7 +162,7 @@ rootfs_create_vnode(struct rootfs* fs, struct rootfs_vnode* parent, vnode->id = fs->next_vnode_id++; vnode->stream.type = type; - vnode->creation_time = vnode->modification_time = time(NULL); + vnode->creation_time = vnode->modification_time = current_timespec(); vnode->uid = geteuid(); vnode->gid = parent ? parent->gid : getegid(); // inherit group from parent if possible @@ -235,7 +247,7 @@ rootfs_insert_in_dir(struct rootfs* fs, struct rootfs_vnode* dir, } vnode->parent = dir; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_stat_changed(fs->id, dir->id, B_STAT_MODIFICATION_TIME); return B_OK; @@ -261,7 +273,7 @@ rootfs_remove_from_dir(struct rootfs* fs, struct rootfs_vnode* dir, dir->stream.dir.dir_head = vnode->dir_next; vnode->dir_next = NULL; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_stat_changed(fs->id, dir->id, B_STAT_MODIFICATION_TIME); return B_OK; } @@ -1002,9 +1014,10 @@ rootfs_read_stat(fs_volume* _volume, fs_vnode* _v, struct stat* stat) stat->st_uid = vnode->uid; stat->st_gid = vnode->gid; - stat->st_atime = time(NULL); - stat->st_mtime = stat->st_ctime = vnode->modification_time; - stat->st_crtime = vnode->creation_time; + stat->st_atim.tv_sec = real_time_clock(); + stat->st_atim.tv_nsec = 0; + stat->st_mtim = stat->st_ctim = vnode->modification_time; + stat->st_crtim = vnode->creation_time; return B_OK; } @@ -1037,9 +1050,9 @@ rootfs_write_stat(fs_volume* _volume, fs_vnode* _vnode, const struct stat* stat, vnode->gid = stat->st_gid; if ((statMask & B_STAT_MODIFICATION_TIME) != 0) - vnode->modification_time = stat->st_mtime; + vnode->modification_time = stat->st_mtim; if ((statMask & B_STAT_CREATION_TIME) != 0) - vnode->creation_time = stat->st_crtime; + vnode->creation_time = stat->st_crtim; mutex_unlock(&fs->lock); diff --git a/src/system/kernel/fs/socket.cpp b/src/system/kernel/fs/socket.cpp index 8d0895a04e..ec0821808b 100644 --- a/src/system/kernel/fs/socket.cpp +++ b/src/system/kernel/fs/socket.cpp @@ -288,13 +288,17 @@ socket_read_stat(struct file_descriptor *descriptor, struct stat *st) st->st_size = 0; st->st_rdev = 0; st->st_blksize = 1024; // use MTU for datagram sockets? - time_t now = time(NULL); - st->st_atime = now; - st->st_mtime = now; - st->st_ctime = now; - st->st_crtime = now; st->st_type = 0; + timespec now; + now.tv_sec = time(NULL); + now.tv_nsec = 0; + + st->st_atim = now; + st->st_mtim = now; + st->st_ctim = now; + st->st_crtim = now; + return B_OK; }