[Haiku-commits] r31059 - in haiku/trunk/src/system/kernel: device_manager fs
axeld at BerliOS
axeld at mail.berlios.de
Mon Jun 15 16:03:28 CEST 2009
Author: axeld
Date: 2009-06-15 16:03:24 +0200 (Mon, 15 Jun 2009)
New Revision: 31059
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31059&view=rev
Modified:
haiku/trunk/src/system/kernel/device_manager/devfs.cpp
haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp
haiku/trunk/src/system/kernel/fs/fifo.cpp
haiku/trunk/src/system/kernel/fs/rootfs.cpp
haiku/trunk/src/system/kernel/fs/socket.cpp
Log:
* Made the internal file systems correctly handle the timespec struct stat
times.
Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-15 10:51:29 UTC (rev 31058)
+++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-15 14:03:24 UTC (rev 31059)
@@ -84,8 +84,8 @@
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 @@
// #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 @@
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 @@
}
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 @@
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 @@
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 @@
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;
Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2009-06-15 10:51:29 UTC (rev 31058)
+++ haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2009-06-15 14:03:24 UTC (rev 31059)
@@ -89,7 +89,7 @@
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 @@
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 @@
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);
Modified: haiku/trunk/src/system/kernel/fs/fifo.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/fifo.cpp 2009-06-15 10:51:29 UTC (rev 31058)
+++ haiku/trunk/src/system/kernel/fs/fifo.cpp 2009-06-15 14:03:24 UTC (rev 31059)
@@ -1,6 +1,6 @@
/*
* Copyright 2007-2008, Ingo Weinhold, ingo_weinhold at gmx.de.
- * Copyright 2003-2007, Axel Dörfler, axeld at pinc-software.de.
+ * Copyright 2003-2009, Axel Dörfler, axeld at pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -137,11 +137,11 @@
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 @@
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 @@
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 @@
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;
}
Modified: haiku/trunk/src/system/kernel/fs/rootfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/rootfs.cpp 2009-06-15 10:51:29 UTC (rev 31058)
+++ haiku/trunk/src/system/kernel/fs/rootfs.cpp 2009-06-15 14:03:24 UTC (rev 31059)
@@ -60,8 +60,8 @@
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 @@
#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 @@
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 @@
}
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 @@
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 @@
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 @@
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);
Modified: haiku/trunk/src/system/kernel/fs/socket.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/socket.cpp 2009-06-15 10:51:29 UTC (rev 31058)
+++ haiku/trunk/src/system/kernel/fs/socket.cpp 2009-06-15 14:03:24 UTC (rev 31059)
@@ -288,13 +288,17 @@
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;
}
More information about the Haiku-commits
mailing list