[haiku-commits] Change in haiku[master]: ufs2: Implementing read_stat function

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 22 May 2020 09:15:42 +0000

From <suhelmehta@xxxxxxxxxxx>:

suhelmehta@xxxxxxxxxxx has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2773 ;)


Change subject: ufs2: Implementing read_stat function
......................................................................

ufs2: Implementing read_stat function
---
M src/add-ons/kernel/file_systems/ufs2/Inode.h
M src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp
2 files changed, 40 insertions(+), 2 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/73/2773/1

diff --git a/src/add-ons/kernel/file_systems/ufs2/Inode.h 
b/src/add-ons/kernel/file_systems/ufs2/Inode.h
index 6fe1b77..9440ebe 100644
--- a/src/add-ons/kernel/file_systems/ufs2/Inode.h
+++ b/src/add-ons/kernel/file_systems/ufs2/Inode.h
@@ -12,6 +12,7 @@

 #define        UFS2_ROOT       ((ino_t)2)

+
 struct ufs2_inode {
        u_int16_t       fileMode;
        int16_t         linkCount;
@@ -57,6 +58,21 @@
        int64_t         unused2;
        int64_t         unused3;

+
+       static void _DecodeTime(struct timespec& timespec,
+               const ufs2_timespec& time)
+       {
+               timespec.tv_sec = B_LENDIAN_TO_HOST_INT64(time.seconds);
+               timespec.tv_nsec = B_LENDIAN_TO_HOST_INT32(time.nanoseconds);
+       }
+/*     void GetAccessTime(struct timespec& timespec) const
+               { _DecodeTime(timespec, access_time); }
+       void GetChangeTime(struct timespec& timespec) const
+               { _DecodeTime(timespec, change_time); }
+       void GetModificationTime(struct timespec& timespec) const
+               { _DecodeTime(timespec, modification_time); }
+       void GetCreationTime(struct timespec& timespec) const
+               { _DecodeTime(timespec, creation_time); }*/
 };

 class Inode {
diff --git a/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp
index cc8738f..3524aff 100644
--- a/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp
@@ -9,7 +9,9 @@
 #include "Volume.h"
 #include "Inode.h"

-#ifdef TRACE_ufs2
+
+#define TRACE_UFS2
+#ifdef TRACE_UFS2
 #define TRACE(x...) dprintf("\33[34mufs2:\33[0m " x)
 #else
 #define TRACE(x...) ;
@@ -198,7 +200,27 @@
 static status_t
 ufs2_read_stat(fs_volume *_volume, fs_vnode *_node, struct stat *stat)
 {
-       return B_NOT_SUPPORTED;
+       TRACE("Reading stat...\n");
+       Inode* inode = (Inode*)_node->private_node;
+       stat->st_dev = inode->GetVolume()->ID();
+       stat->st_ino = inode->ID();
+       stat->st_nlink = 1;
+       stat->st_blksize = 65536;
+
+       stat->st_uid = inode->UserID();
+       stat->st_gid = inode->GroupID();
+       stat->st_mode = inode->Mode();
+       stat->st_type = 0;
+
+//     inode->GetAccessTime(stat->st_atim);
+//     inode->GetModificationTime(stat->st_mtim);
+//     inode->GetChangeTime(stat->st_ctim);
+//     inode->GetCreationTime(stat->st_crtim);
+
+       stat->st_size = inode->Size();
+       stat->st_blocks = (inode->Size() + 511) / 512;
+
+       return B_OK;
 }
 


--
To view, visit https://review.haiku-os.org/c/haiku/+/2773
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I337c53c017f00f480af7ac94a5774b39eb5255db
Gerrit-Change-Number: 2773
Gerrit-PatchSet: 1
Gerrit-Owner: suhelmehta@xxxxxxxxxxx
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: ufs2: Implementing read_stat function - Gerrit