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 deba81feed82a59427b69ff0fa53a663cf0f6989..f3abb61d80367f0da211c856802220c59e4f648a 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) {