Kernel: fix stat command and device numbers

This commit is contained in:
Bananymous 2023-03-30 10:43:08 +03:00
parent ab3cdea548
commit 78ea4b2207
4 changed files with 9 additions and 6 deletions

View File

@ -76,7 +76,7 @@ namespace Kernel
virtual timespec ctime() const override { return { 0, 0 }; }
virtual blksize_t blksize() const override { return 0; }
virtual blkcnt_t blocks() const override { return 0; }
virtual dev_t dev() const override { return 0x4935; }
virtual dev_t dev() const override { return 0x4900; }
virtual dev_t rdev() const override { return 0x7854; }
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) { ASSERT_NOT_REACHED(); }

View File

@ -13,7 +13,7 @@ namespace Kernel::Input
virtual void on_byte(uint8_t) = 0;
public:
virtual ino_t ino() const { return m_ino; }
virtual ino_t ino() const override { return m_ino; }
virtual mode_t mode() const override { return Mode::IFCHR | Mode::IRUSR | Mode::IRGRP; }
virtual nlink_t nlink() const override { return 1; }
virtual uid_t uid() const override { return 0; }

View File

@ -104,13 +104,13 @@ namespace Kernel
TRY(validate_fd(fd));
const auto& open_fd = open_file_description(fd);
out->st_dev = 0;
out->st_dev = open_fd.inode->dev();
out->st_ino = open_fd.inode->ino();
out->st_mode = open_fd.inode->mode();
out->st_nlink = open_fd.inode->nlink();
out->st_uid = open_fd.inode->uid();
out->st_gid = open_fd.inode->gid();
out->st_rdev = 0;
out->st_rdev = open_fd.inode->rdev();
out->st_size = open_fd.inode->size();
out->st_atim = open_fd.inode->atime();
out->st_mtim = open_fd.inode->mtime();

View File

@ -447,8 +447,11 @@ argument_done:
TTY_PRINTLN(" File: {}", arguments[1]);
TTY_PRINTLN(" Size: {}\tBlocks: {}\tIO Block: {}\t {}", st.st_size, st.st_blocks, st.st_blksize, type);
TTY_PRINTLN("Device: {},{}\tInode: {}\tLinks: {}", st.st_dev, st.st_rdev, st.st_ino, st.st_nlink);
TTY_PRINTLN("Access: ({}/{})\tUid: {}\tGid: {}", st.st_mode, mode_string(st.st_mode), st.st_uid, st.st_gid);
TTY_PRINT("Device: {},{}\tInode: {}\tLinks: {}", st.st_dev >> 8, st.st_dev & 0xFF, st.st_ino, st.st_nlink);
if (st.st_rdev)
TTY_PRINT("\tDevice type: {},{}", st.st_rdev >> 8, st.st_rdev & 0xFF);
TTY_PRINTLN("");
TTY_PRINTLN("Access: ({4O}/{})\tUid: {}\tGid: {}", st.st_mode & 0777, mode_string(st.st_mode), st.st_uid, st.st_gid);
TTY_PRINTLN("Access: {}", BAN::from_unix_time(st.st_atime));
TTY_PRINTLN("Modify: {}", BAN::from_unix_time(st.st_mtime));
TTY_PRINTLN("Change: {}", BAN::from_unix_time(st.st_ctime));