MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _try_readlink

Function _try_readlink

components/dfs/dfs_v2/src/dfs_file.c:124–142  ·  view source on GitHub ↗

* @brief Attempt to read the target of a symbolic link * * This function tries to read the contents of a symbolic link file. It first looks up * the dentry for the given path, checks if it's a symlink, and then calls the filesystem's * readlink operation if available. * * @param[in] path The path of the symbolic link to read * @param[in] mnt The mount point containing the symbolic link * @

Source from the content-addressed store, hash-verified

122 * @return int Length of the link target on success, -1 on failure
123 */
124static int _try_readlink(const char *path, struct dfs_mnt *mnt, char *link)
125{
126 int ret = -1;
127 struct dfs_dentry *dentry = dfs_dentry_lookup(mnt, path, 0);
128
129 if (dentry && dentry->vnode->type == FT_SYMLINK)
130 {
131 if (mnt->fs_ops->readlink)
132 {
133 if (dfs_is_mounted(mnt) == 0)
134 {
135 ret = mnt->fs_ops->readlink(dentry, link, DFS_PATH_MAX);
136 }
137 }
138 }
139 dfs_dentry_unref(dentry);
140
141 return ret;
142}
143
144/**
145 * @brief Normalize a path by combining base path and link path

Callers 1

dfs_file_realpathFunction · 0.85

Calls 3

dfs_dentry_lookupFunction · 0.85
dfs_is_mountedFunction · 0.85
dfs_dentry_unrefFunction · 0.85

Tested by

no test coverage detected