Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bfs_status() SDK API,activate FSImpl::ChangeReplicaNum() #930

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ thirdparty
output
.build
src/version.cc
.DS_Store
13 changes: 11 additions & 2 deletions src/sdk/bfs_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ int bfs_du(bfs_fs_t* fs, const char* path) {
int bfs_rm_dir(bfs_fs_t* fs, const char* path, bool recursive) {
return fs->bfs_fs->DeleteDirectory(path, recursive);
}

int bfs_change_bfs_fslica_num(bfs_fs_t* fs, const char* path,
int bfs_change_replica_num(bfs_fs_t* fs, const char* path,
const char* bfs_fslica_num) {
if (!isdigit(*bfs_fslica_num)) {
return -1;
Expand Down Expand Up @@ -374,5 +374,14 @@ int bfs_location(bfs_fs_t* fs, const char* path) {
return 0;
}

int bfs_status(bfs_fs_t* fs, const char* &status){
std::string stat_name("StatAll");
std::string result;
int32_t ret = fs->bfs_fs->SysStat(stat_name, &result);
status=result.c_str();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里返回后,result析构,status中有野指针吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我把前一个return删了,您看这样能解决问题吗

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不解,result是栈上的变量

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我重写了status接口,能请您看看还会有野指针的问题吗?

return ret;

}

}
/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
1 change: 1 addition & 0 deletions src/sdk/bfs_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int bfs_rm_dir(bfs_fs_t* fs, const char* path, bool recursive);
int bfs_change_replica_num(bfs_fs_t* fs, const char* path, const char* replica_num);
int bfs_chmod(bfs_fs_t* fs, const char* str_mode, const char* path);
int bfs_location(bfs_fs_t* fs, const char* path);
int bfs_status(bfs_fs_t* fs, const char* &status);

#ifdef __cplusplus
}/*end extern "C" */
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/fs_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ int32_t FSImpl::Rename(const char* oldpath, const char* newpath) {
return OK;
}
int32_t FSImpl::ChangeReplicaNum(const char* file_name, int32_t replica_num) {
/*

ChangeReplicaNumRequest request;
ChangeReplicaNumResponse response;
request.set_file_name(file_name);
Expand All @@ -471,8 +471,8 @@ int32_t FSImpl::ChangeReplicaNum(const char* file_name, int32_t replica_num) {
file_name, replica_num, StatusCode_Name(response.status()).c_str());
return GetErrorCode(response.status());
}
*/
return PERMISSION_DENIED;

return OK;
}

int32_t FSImpl::Symlink(const char* src, const char* dst)
Expand Down