kernel: Correctly register file times for more file systems and file types
This commit is contained in:
parent
b619f717c8
commit
9b01b5a5db
@ -35,6 +35,19 @@ namespace VFS
|
||||
struct timespec atime;
|
||||
struct timespec mtime;
|
||||
struct timespec ctime;
|
||||
|
||||
void initialize_times()
|
||||
{
|
||||
g_realtime_clock.get_time(atime);
|
||||
g_realtime_clock.get_time(ctime);
|
||||
g_realtime_clock.get_time(mtime);
|
||||
}
|
||||
|
||||
void update_mtime()
|
||||
{
|
||||
g_realtime_clock.get_time(mtime);
|
||||
g_realtime_clock.get_time(ctime);
|
||||
}
|
||||
};
|
||||
|
||||
class Inode;
|
||||
|
@ -27,12 +27,14 @@ Result<SharedPtr<VFS::Inode>> MasterPTY::create_pair(int index)
|
||||
master->m_settings.c_cc[VQUIT] = '\x1c';
|
||||
master->m_window.ws_col = 80;
|
||||
master->m_window.ws_row = 25;
|
||||
master->m_metadata.initialize_times();
|
||||
|
||||
slave->m_master = master.ptr();
|
||||
slave->m_metadata.devid = luna_dev_makedev(DeviceRegistry::Terminal, index + 2);
|
||||
slave->m_metadata.uid = Scheduler::current()->auth.euid;
|
||||
slave->m_metadata.gid = Scheduler::current()->auth.egid;
|
||||
slave->m_metadata.mode = 0620;
|
||||
slave->m_metadata.initialize_times();
|
||||
|
||||
return (SharedPtr<VFS::Inode>)master;
|
||||
}
|
||||
@ -193,6 +195,8 @@ Result<usize> MasterPTY::write(const u8* buf, usize, usize length)
|
||||
{
|
||||
for (usize i = 0; i < length; i++) { TRY(handle_input(buf[i])); }
|
||||
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ PTYMultiplexer::PTYMultiplexer()
|
||||
{
|
||||
m_metadata.devid = luna_dev_makedev(DeviceRegistry::Terminal, 0);
|
||||
m_metadata.mode = 0666;
|
||||
m_metadata.initialize_times();
|
||||
}
|
||||
|
||||
Result<SharedPtr<VFS::Inode>> PTYMultiplexer::open()
|
||||
|
@ -31,6 +31,8 @@ Result<usize> SlavePTY::write(const u8* buf, usize, usize length)
|
||||
|
||||
TRY(m_master->m_buffer.append_data(buf, length));
|
||||
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ TTYLink::TTYLink()
|
||||
{
|
||||
m_metadata.devid = luna_dev_makedev(DeviceRegistry::Terminal, 1);
|
||||
m_metadata.mode = 0666;
|
||||
m_metadata.initialize_times();
|
||||
}
|
||||
|
||||
Result<SharedPtr<VFS::Inode>> TTYLink::open()
|
||||
|
@ -21,9 +21,7 @@ namespace DevPTS
|
||||
root->set_fs(*fs, {});
|
||||
root->set_inode_number();
|
||||
root->m_metadata.mode = 0755;
|
||||
g_realtime_clock.get_time(root->m_metadata.ctime);
|
||||
g_realtime_clock.get_time(root->m_metadata.atime);
|
||||
g_realtime_clock.get_time(root->m_metadata.mtime);
|
||||
root->m_metadata.initialize_times();
|
||||
fs->set_root(root);
|
||||
|
||||
TRY(g_devpts_instances.try_append(fs.ptr()));
|
||||
|
@ -43,7 +43,7 @@ namespace DevPTS
|
||||
|
||||
inode->did_link();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -61,7 +61,7 @@ namespace DevPTS
|
||||
|
||||
inode->did_unlink();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -27,9 +27,7 @@ namespace TmpFS
|
||||
inode->set_fs(*this, {});
|
||||
inode->set_inode_number(m_next_inode_number++, {});
|
||||
inode->m_metadata.mode = mode;
|
||||
g_realtime_clock.get_time(inode->m_metadata.mtime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.atime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.ctime);
|
||||
inode->m_metadata.initialize_times();
|
||||
return (SharedPtr<VFS::Inode>)inode;
|
||||
}
|
||||
|
||||
@ -39,9 +37,7 @@ namespace TmpFS
|
||||
inode->set_fs(*this, {});
|
||||
TRY(inode->set_link(link, {}));
|
||||
inode->set_inode_number(m_next_inode_number++, {});
|
||||
g_realtime_clock.get_time(inode->m_metadata.mtime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.atime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.ctime);
|
||||
inode->m_metadata.initialize_times();
|
||||
return (SharedPtr<VFS::Inode>)inode;
|
||||
}
|
||||
|
||||
@ -56,9 +52,7 @@ namespace TmpFS
|
||||
inode->set_fs(*this, {});
|
||||
inode->set_inode_number(m_next_inode_number++, {});
|
||||
inode->m_metadata.mode = mode;
|
||||
g_realtime_clock.get_time(inode->m_metadata.mtime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.atime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.ctime);
|
||||
inode->m_metadata.initialize_times();
|
||||
|
||||
return (SharedPtr<VFS::Inode>)inode;
|
||||
}
|
||||
@ -75,9 +69,7 @@ namespace TmpFS
|
||||
// device ID atm.
|
||||
inode->set_device_id(luna_dev_makedev(major, minor), {});
|
||||
inode->m_metadata.mode = mode;
|
||||
g_realtime_clock.get_time(inode->m_metadata.mtime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.atime);
|
||||
g_realtime_clock.get_time(inode->m_metadata.ctime);
|
||||
inode->m_metadata.initialize_times();
|
||||
inode->m_metadata.size = device->size();
|
||||
|
||||
return (SharedPtr<VFS::Inode>)inode;
|
||||
|
@ -45,7 +45,7 @@ namespace TmpFS
|
||||
|
||||
inode->did_link();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -63,7 +63,7 @@ namespace TmpFS
|
||||
|
||||
inode->did_unlink();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -118,7 +118,7 @@ namespace TmpFS
|
||||
|
||||
m_metadata.size = m_data_buffer.size();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -133,7 +133,7 @@ namespace TmpFS
|
||||
|
||||
m_metadata.size = m_data_buffer.size();
|
||||
|
||||
g_realtime_clock.get_time(m_metadata.mtime);
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -5,10 +5,12 @@
|
||||
|
||||
UnixSocket::UnixSocket()
|
||||
{
|
||||
m_metadata.initialize_times();
|
||||
}
|
||||
|
||||
UnixSocket::UnixSocket(UnixSocket* peer) : m_state(State::Connected), m_peer(peer)
|
||||
{
|
||||
m_metadata.initialize_times();
|
||||
}
|
||||
|
||||
UnixSocket::~UnixSocket()
|
||||
@ -41,6 +43,8 @@ Result<usize> UnixSocket::send(const u8* buf, usize length, int)
|
||||
|
||||
TRY(m_peer->m_data.append_data(buf, length));
|
||||
|
||||
m_peer->m_metadata.update_mtime();
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -209,5 +213,7 @@ Result<SharedPtr<OpenFileDescription>> UnixSocket::accept(Registers* regs, int f
|
||||
*addr = (struct sockaddr*)&peer->m_addr;
|
||||
*addrlen = peer->m_addrlen;
|
||||
|
||||
m_metadata.update_mtime();
|
||||
|
||||
return description;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user