summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorgeniusgogo <[email protected]>2023-08-12 10:49:26 +0800
committerGitHub <[email protected]>2023-08-12 10:49:26 +0800
commitdeb0b031fc290fc5c366fcc31aba0de87aa79db6 (patch)
tree188f07da5d6f33a01b8eb1aa64c3827d983032d2 /components
parent5308cc47161d8e2f9fdb680738e023ef16af1e2b (diff)
fix dfs_file_open error code (#7942)
Diffstat (limited to 'components')
-rw-r--r--components/dfs/dfs_v2/src/dfs_file.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/components/dfs/dfs_v2/src/dfs_file.c b/components/dfs/dfs_v2/src/dfs_file.c
index ac18caefc1..b7fd4bdcad 100644
--- a/components/dfs/dfs_v2/src/dfs_file.c
+++ b/components/dfs/dfs_v2/src/dfs_file.c
@@ -429,7 +429,8 @@ int dfs_file_open(struct dfs_file *file, const char *path, int oflags, mode_t mo
oflags &= ~O_EXCL;
/* the dentry already exists */
dfs_dentry_unref(dentry);
- dentry = RT_NULL;
+ ret = -EEXIST;
+ goto _ERR_RET;
}
}
else
@@ -536,6 +537,7 @@ int dfs_file_open(struct dfs_file *file, const char *path, int oflags, mode_t mo
{
DLOG(msg, "dfs_file", mnt->fs_ops->name, DLOG_MSG, "no permission or fops->open");
dfs_file_unref(file);
+ ret = -EPERM;
}
}
else
@@ -544,8 +546,6 @@ int dfs_file_open(struct dfs_file *file, const char *path, int oflags, mode_t mo
ret = -ENOENT;
}
}
-
- rt_free(fullpath);
}
if (ret >= 0 && (oflags & O_TRUNC))
@@ -584,6 +584,11 @@ int dfs_file_open(struct dfs_file *file, const char *path, int oflags, mode_t mo
}
}
+_ERR_RET:
+ if (fullpath != NULL)
+ {
+ rt_free(fullpath);
+ }
return ret;
}