提交 8581cdaa 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!519 fix create mtab bug to use lstat

Merge pull request !519 from gaohuatao/ci_master
......@@ -51,6 +51,24 @@ bool util_dir_exists(const char *path)
return S_ISDIR(s.st_mode);
}
// This function is identical to "util_file_exists",except that if f is a symbolic file, return true
bool util_fileself_exists(const char *f)
{
struct stat buf;
int nret;
if (f == NULL) {
return false;
}
nret = lstat(f, &buf);
if (nret < 0) {
return false;
}
return true;
}
// When f is a symbolic file, if the file that it refers to not exits ,return false
bool util_file_exists(const char *f)
{
struct stat buf;
......
......@@ -27,6 +27,8 @@ extern "C" {
bool util_dir_exists(const char *path);
bool util_fileself_exists(const char *f);
bool util_file_exists(const char *f);
int util_path_remove(const char *path);
......
......@@ -822,7 +822,7 @@ static int create_mtab_link(const oci_runtime_spec *oci_spec)
WARN("Failed to delete \"%s\": %s", dir, strerror(errno));
}
if (util_file_exists(slink)) {
if (util_fileself_exists(slink)) {
goto out;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册