* @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 * @
| 122 | * @return int Length of the link target on success, -1 on failure |
| 123 | */ |
| 124 | static 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 |
no test coverage detected