1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix st_blksize and st_blocks kernel values.

This commit is contained in:
Jonas 'Sortie' Termansen 2018-03-31 00:07:19 +02:00
parent 13658db632
commit d393b67d72
9 changed files with 5 additions and 9 deletions

View file

@ -123,7 +123,8 @@ void StatInode(Inode* inode, struct stat* st)
st->st_mtim.tv_sec = inode->data->i_mtime; st->st_mtim.tv_sec = inode->data->i_mtime;
st->st_mtim.tv_nsec = 0; st->st_mtim.tv_nsec = 0;
st->st_blksize = inode->filesystem->block_size; st->st_blksize = inode->filesystem->block_size;
st->st_blocks = inode->data->i_blocks; st->st_blocks = ((uint64_t) inode->data->i_blocks *
(uint64_t) inode->filesystem->block_size) / 512;
} }
static void compact_arguments(int* argc, char*** argv) static void compact_arguments(int* argc, char*** argv)

View file

@ -44,7 +44,6 @@ Full::Full(dev_t dev, ino_t ino, uid_t owner, gid_t group, mode_t mode)
this->stat_gid = group; this->stat_gid = group;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_size = 0; this->stat_size = 0;
this->stat_blksize = 1;
this->dev = dev; this->dev = dev;
this->ino = ino; this->ino = ino;
} }

View file

@ -122,7 +122,6 @@ File::File(InodeType inode_type, mode_t type, dev_t dev, ino_t ino, uid_t owner,
this->stat_gid = group; this->stat_gid = group;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_size = 0; this->stat_size = 0;
this->stat_blksize = 1;
this->dev = dev; this->dev = dev;
this->ino = ino; this->ino = ino;
this->supports_iovec = true; this->supports_iovec = true;

View file

@ -41,7 +41,6 @@ Null::Null(dev_t dev, ino_t ino, uid_t owner, gid_t group, mode_t mode)
this->stat_gid = group; this->stat_gid = group;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_size = 0; this->stat_size = 0;
this->stat_blksize = 1;
this->dev = dev; this->dev = dev;
this->ino = ino; this->ino = ino;
} }

View file

@ -44,7 +44,6 @@ DevRandom::DevRandom(dev_t dev, ino_t ino, uid_t owner, gid_t group,
this->stat_gid = group; this->stat_gid = group;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_size = 0; this->stat_size = 0;
this->stat_blksize = 1;
this->dev = dev; this->dev = dev;
this->ino = ino; this->ino = ino;
} }

View file

@ -46,7 +46,6 @@ UtilMemoryBuffer::UtilMemoryBuffer(dev_t dev, ino_t ino, uid_t owner,
this->stat_gid = group; this->stat_gid = group;
this->type = S_IFREG; this->type = S_IFREG;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_blksize = 1;
this->stat_size = bufsize; this->stat_size = bufsize;
this->dev = dev; this->dev = dev;
this->ino = ino ? ino : (ino_t) this; this->ino = ino ? ino : (ino_t) this;

View file

@ -43,7 +43,6 @@ Zero::Zero(dev_t dev, ino_t ino, uid_t owner, gid_t group, mode_t mode)
this->stat_gid = group; this->stat_gid = group;
this->stat_mode = (mode & S_SETABLE) | this->type; this->stat_mode = (mode & S_SETABLE) | this->type;
this->stat_size = 0; this->stat_size = 0;
this->stat_blksize = 1;
this->dev = dev; this->dev = dev;
this->ino = ino; this->ino = ino;
} }

View file

@ -33,6 +33,7 @@
#include <sortix/kernel/ioctx.h> #include <sortix/kernel/ioctx.h>
#include <sortix/kernel/kernel.h> #include <sortix/kernel/kernel.h>
#include <sortix/kernel/kthread.h> #include <sortix/kernel/kthread.h>
#include <sortix/kernel/memorymanagement.h>
#include <sortix/kernel/refcount.h> #include <sortix/kernel/refcount.h>
#include <sortix/kernel/time.h> #include <sortix/kernel/time.h>
@ -50,7 +51,7 @@ AbstractInode::AbstractInode()
stat_atim = Time::Get(CLOCK_REALTIME); stat_atim = Time::Get(CLOCK_REALTIME);
stat_ctim = Time::Get(CLOCK_REALTIME); stat_ctim = Time::Get(CLOCK_REALTIME);
stat_mtim = Time::Get(CLOCK_REALTIME); stat_mtim = Time::Get(CLOCK_REALTIME);
stat_blksize = 0; stat_blksize = Page::Size();
stat_blocks = 0; stat_blocks = 0;
supports_iovec = false; supports_iovec = false;
} }

View file

@ -119,7 +119,7 @@ int Partition::stat(ioctx_t* ctx, struct stat* st)
if ( !ctx->copy_from_src(&myst, st, sizeof(myst)) ) if ( !ctx->copy_from_src(&myst, st, sizeof(myst)) )
return -1; return -1;
myst.st_size = length; myst.st_size = length;
myst.st_blocks = length / (myst.st_blksize ? myst.st_blksize : 1); myst.st_blocks = length / 512;
if ( !ctx->copy_to_dest(st, &myst, sizeof(myst)) ) if ( !ctx->copy_to_dest(st, &myst, sizeof(myst)) )
return -1; return -1;
return 0; return 0;