Add getting inode and device number function in filesystem 54/100354/3
authorSungbae Yoo <sungbae.yoo@samsung.com>
Fri, 25 Nov 2016 06:34:51 +0000 (15:34 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 28 Nov 2016 11:23:32 +0000 (03:23 -0800)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I6b42941cf9e610168f6ba46a083b316d924640a2

include/klay/filesystem.h
src/filesystem.cpp

index 75e35b9945ee664bb2d7ece05fc020538c7aebef..32fdf6fc48ff5b9b732fc1faade5ca2c9e2fe4cd 100644 (file)
@@ -90,6 +90,8 @@ public:
        mode_t getMode() const;
        uid_t getUid() const;
        gid_t getGid() const;
+       ino_t getInode() const;
+       dev_t getDevice() const;
 
        size_t size() const;
 
index a5cb7fa59f4b7bbf3ca723aecf61ac1e094154ae..fff5d4cf9bd6323093d3440552a22619186897f4 100644 (file)
@@ -148,6 +148,26 @@ gid_t File::getGid() const
        return st.st_gid;
 }
 
+ino_t File::getInode() const
+{
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
+
+       return st.st_ino;
+}
+
+dev_t File::getDevice() const
+{
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
+
+       return st.st_dev;
+}
+
 size_t File::size() const
 {
        struct stat st;