mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add utimens support to inodes.
This commit is contained in:
parent
1940d9560e
commit
27bdbf1c9d
9 changed files with 66 additions and 30 deletions
|
@ -271,9 +271,11 @@ ssize_t Descriptor::pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t
|
|||
return vnode->pwrite(ctx, buf, count, off);
|
||||
}
|
||||
|
||||
int Descriptor::utimens(ioctx_t* ctx, const struct timespec times[2])
|
||||
int Descriptor::utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime)
|
||||
{
|
||||
return vnode->utimens(ctx, times);
|
||||
return vnode->utimens(ctx, atime, ctime, mtime);
|
||||
}
|
||||
|
||||
int Descriptor::isatty(ioctx_t* ctx)
|
||||
|
|
|
@ -22,21 +22,31 @@
|
|||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <sortix/kernel/platform.h>
|
||||
#include <sortix/kernel/interlock.h>
|
||||
#include <sortix/kernel/kthread.h>
|
||||
#include <sortix/kernel/refcount.h>
|
||||
#include <sortix/kernel/fsfunc.h>
|
||||
#include <sortix/kernel/ioctx.h>
|
||||
#include <sortix/kernel/inode.h>
|
||||
#include <sortix/kernel/string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sortix/clock.h>
|
||||
#include <sortix/dirent.h>
|
||||
#include <sortix/fcntl.h>
|
||||
#include <sortix/stat.h>
|
||||
#include <sortix/seek.h>
|
||||
#include <sortix/stat.h>
|
||||
|
||||
#include <sortix/kernel/platform.h>
|
||||
#include <sortix/kernel/fsfunc.h>
|
||||
#include <sortix/kernel/inode.h>
|
||||
#include <sortix/kernel/interlock.h>
|
||||
#include <sortix/kernel/ioctx.h>
|
||||
#include <sortix/kernel/kthread.h>
|
||||
#include <sortix/kernel/refcount.h>
|
||||
#include <sortix/kernel/string.h>
|
||||
#include <sortix/kernel/time.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "kram.h"
|
||||
|
||||
namespace Sortix {
|
||||
|
@ -70,6 +80,7 @@ int File::truncate(ioctx_t* ctx, off_t length)
|
|||
{
|
||||
ScopedLock lock(&metalock);
|
||||
stat_size = fcache.GetFileSize();
|
||||
stat_mtim = Time::Get(CLOCK_REALTIME);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -91,6 +102,7 @@ ssize_t File::pwrite(ioctx_t* ctx, const uint8_t* src, size_t count, off_t off)
|
|||
{
|
||||
ScopedLock lock(&metalock);
|
||||
stat_size = fcache.GetFileSize();
|
||||
stat_mtim = Time::Get(CLOCK_REALTIME);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <timespec.h>
|
||||
|
||||
#include <sortix/dirent.h>
|
||||
#include <sortix/fcntl.h>
|
||||
|
@ -193,7 +194,9 @@ public:
|
|||
virtual ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count);
|
||||
virtual ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count,
|
||||
off_t off);
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec times[2]);
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime);
|
||||
virtual int isatty(ioctx_t* ctx);
|
||||
virtual ssize_t readdirents(ioctx_t* ctx, struct kernel_dirent* dirent,
|
||||
size_t size, off_t start, size_t maxcount);
|
||||
|
@ -840,7 +843,10 @@ ssize_t Unode::pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t off)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int Unode::utimens(ioctx_t* /*ctx*/, const struct timespec times[2])
|
||||
int Unode::utimens(ioctx_t* /*ctx*/,
|
||||
const struct timespec* atime,
|
||||
const struct timespec* /*ctime*/,
|
||||
const struct timespec* mtime)
|
||||
{
|
||||
Channel* channel = server->Connect();
|
||||
if ( !channel )
|
||||
|
@ -848,8 +854,8 @@ int Unode::utimens(ioctx_t* /*ctx*/, const struct timespec times[2])
|
|||
int ret = -1;
|
||||
struct fsm_req_utimens msg;
|
||||
msg.ino = ino;
|
||||
msg.times[0] = times[0];
|
||||
msg.times[1] = times[1];
|
||||
msg.times[0] = atime ? *atime : timespec_nul();
|
||||
msg.times[1] = mtime ? *mtime : timespec_nul();
|
||||
if ( SendMessage(channel, FSM_REQ_UTIMENS, &msg, sizeof(msg)) &&
|
||||
RecvMessage(channel, FSM_RESP_SUCCESS, NULL, 0) )
|
||||
ret = 0;
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
ssize_t pread(ioctx_t* ctx, uint8_t* buf, size_t count, off_t off);
|
||||
ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count);
|
||||
ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t off);
|
||||
int utimens(ioctx_t* ctx, const struct timespec timespec[2]);
|
||||
int utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime, const struct timespec* mtime);
|
||||
int isatty(ioctx_t* ctx);
|
||||
ssize_t readdirents(ioctx_t* ctx, struct kernel_dirent* dirent, size_t size,
|
||||
size_t maxcount);
|
||||
|
|
|
@ -68,7 +68,9 @@ public:
|
|||
virtual ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count) = 0;
|
||||
virtual ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count,
|
||||
off_t off) = 0;
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec timespec[2]) = 0;
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime) = 0;
|
||||
virtual int isatty(ioctx_t* ctx) = 0;
|
||||
virtual ssize_t readdirents(ioctx_t* ctx, struct kernel_dirent* dirent,
|
||||
size_t size, off_t start, size_t maxcount) = 0;
|
||||
|
@ -142,7 +144,9 @@ public:
|
|||
virtual ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count);
|
||||
virtual ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count,
|
||||
off_t off);
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec timespec[2]);
|
||||
virtual int utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime);
|
||||
virtual int isatty(ioctx_t* ctx);
|
||||
virtual ssize_t readdirents(ioctx_t* ctx, struct kernel_dirent* dirent,
|
||||
size_t size, off_t start, size_t maxcount);
|
||||
|
|
|
@ -61,7 +61,8 @@ public:
|
|||
ssize_t pread(ioctx_t* ctx, uint8_t* buf, size_t count, off_t off);
|
||||
ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count);
|
||||
ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t off);
|
||||
int utimens(ioctx_t* ctx, const struct timespec timespec[2]);
|
||||
int utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime, const struct timespec* mtime);
|
||||
int isatty(ioctx_t* ctx);
|
||||
ssize_t readdirents(ioctx_t* ctx, struct kernel_dirent* dirent,
|
||||
size_t size, off_t start, size_t maxcount);
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <timespec.h>
|
||||
|
||||
#include <sortix/clock.h>
|
||||
#include <sortix/stat.h>
|
||||
|
||||
#include <sortix/kernel/platform.h>
|
||||
|
@ -34,6 +34,7 @@
|
|||
#include <sortix/kernel/refcount.h>
|
||||
#include <sortix/kernel/inode.h>
|
||||
#include <sortix/kernel/ioctx.h>
|
||||
#include <sortix/kernel/time.h>
|
||||
|
||||
namespace Sortix {
|
||||
|
||||
|
@ -46,9 +47,9 @@ AbstractInode::AbstractInode()
|
|||
stat_uid = 0;
|
||||
stat_gid = 0;
|
||||
stat_size = 0;
|
||||
stat_atim = timespec_nul();
|
||||
stat_ctim = timespec_nul();
|
||||
stat_mtim = timespec_nul();
|
||||
stat_atim = Time::Get(CLOCK_REALTIME);
|
||||
stat_ctim = Time::Get(CLOCK_REALTIME);
|
||||
stat_mtim = Time::Get(CLOCK_REALTIME);
|
||||
stat_blksize = 0;
|
||||
stat_blocks = 0;
|
||||
}
|
||||
|
@ -152,10 +153,17 @@ ssize_t AbstractInode::pwrite(ioctx_t* /*ctx*/, const uint8_t* /*buf*/,
|
|||
return errno = EBADF, -1;
|
||||
}
|
||||
|
||||
|
||||
int AbstractInode::utimens(ioctx_t* /*ctx*/, const struct timespec /*times*/[2])
|
||||
int AbstractInode::utimens(ioctx_t* /*ctx*/, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime)
|
||||
{
|
||||
// TODO: Implement this!
|
||||
ScopedLock lock(&metalock);
|
||||
if ( atime )
|
||||
stat_atim = *atime;
|
||||
if ( ctime )
|
||||
stat_ctim = *ctime;
|
||||
if ( mtime )
|
||||
stat_mtim = *mtime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -461,7 +461,7 @@ static int sys_futimens(int fd, const struct timespec user_times[2])
|
|||
if ( !desc )
|
||||
return -1;
|
||||
ioctx_t ctx; SetupUserIOCtx(&ctx);
|
||||
return desc->utimens(&ctx, times);
|
||||
return desc->utimens(&ctx, ×[0], NULL, ×[1]);
|
||||
}
|
||||
|
||||
static int sys_utimensat(int dirfd, const char* path,
|
||||
|
@ -484,7 +484,7 @@ static int sys_utimensat(int dirfd, const char* path,
|
|||
delete[] pathcopy;
|
||||
if ( !desc )
|
||||
return -1;
|
||||
return desc->utimens(&ctx, times);
|
||||
return desc->utimens(&ctx, ×[0], NULL, ×[1]);
|
||||
}
|
||||
|
||||
static int sys_linkat(int olddirfd, const char* oldpath,
|
||||
|
|
|
@ -144,9 +144,11 @@ ssize_t Vnode::pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t off)
|
|||
return inode->pwrite(ctx, buf, count, off);
|
||||
}
|
||||
|
||||
int Vnode::utimens(ioctx_t* ctx, const struct timespec times[2])
|
||||
int Vnode::utimens(ioctx_t* ctx, const struct timespec* atime,
|
||||
const struct timespec* ctime,
|
||||
const struct timespec* mtime)
|
||||
{
|
||||
return inode->utimens(ctx, times);
|
||||
return inode->utimens(ctx, atime, ctime, mtime);
|
||||
}
|
||||
|
||||
int Vnode::isatty(ioctx_t* ctx)
|
||||
|
|
Loading…
Add table
Reference in a new issue