From 58fb01528d1e8a998b0463e996593b62d0bb43eb Mon Sep 17 00:00:00 2001 From: liuzerun Date: Wed, 25 Sep 2024 09:36:36 +0000 Subject: [PATCH] getlocation change to ioctl Signed-off-by: liuzerun --- .../kits/js/src/mod_fs/class_stat/stat_n_exporter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/js/src/mod_fs/class_stat/stat_n_exporter.cpp b/interfaces/kits/js/src/mod_fs/class_stat/stat_n_exporter.cpp index deba81fee..f3abb61d8 100644 --- a/interfaces/kits/js/src/mod_fs/class_stat/stat_n_exporter.cpp +++ b/interfaces/kits/js/src/mod_fs/class_stat/stat_n_exporter.cpp @@ -22,6 +22,7 @@ #include #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) #include +#include #endif #include "file_utils.h" @@ -229,6 +230,9 @@ napi_value StatNExporter::GetCtime(napi_env env, napi_callback_info info) return NVal::CreateInt64(env, static_cast(statEntity->stat_.st_ctim.tv_sec)).val_; } +const unsigned HMDFS_IOC = 0xf2; +#define HMDFS_IOC_GET_LOCATION _IOR(HMDFS_IOC, 7, __u32) + #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) napi_value StatNExporter::GetLocation(napi_env env, napi_callback_info info) { @@ -255,7 +259,12 @@ napi_value StatNExporter::GetLocation(napi_env env, napi_callback_info info) if (statEntity->fileInfo_->isPath) { size = getxattr(statEntity->fileInfo_->path.get(), CLOUD_LOCATION_ATTR.c_str(), value.get(), MAX_ATTR_NAME); } else { - size = fgetxattr(statEntity->fileInfo_->fdg->GetFD(), CLOUD_LOCATION_ATTR.c_str(), value.get(), MAX_ATTR_NAME); + Location defaultLocation = LOCAL; + int err = ioctl(statEntity->fileInfo_->fdg->GetFD(), HMDFS_IOC_GET_LOCATION, &defaultLocation); + if (err < 0) { + HILOGE("Ioctl failed, errno is %{pubilc}d", errno); + } + return NVal::CreateInt32(env, static_cast(defaultLocation)).val_; } Location defaultLocation = LOCAL; if (size <= 0) { -- Gitee