From: Sungbae Yoo Date: Fri, 25 Nov 2016 06:34:51 +0000 (+0900) Subject: Add getting inode and device number function in filesystem X-Git-Tag: submit/tizen_3.0/20161205.022817~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1742062e7ea8be6fb6b45fe273ec545a01000270;p=platform%2Fcore%2Fsecurity%2Fklay.git Add getting inode and device number function in filesystem Signed-off-by: Sungbae Yoo Change-Id: I6b42941cf9e610168f6ba46a083b316d924640a2 --- diff --git a/include/klay/filesystem.h b/include/klay/filesystem.h index 75e35b9..32fdf6f 100644 --- a/include/klay/filesystem.h +++ b/include/klay/filesystem.h @@ -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; diff --git a/src/filesystem.cpp b/src/filesystem.cpp index a5cb7fa..fff5d4c 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -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;