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

Function dfs_file_lstat

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

* @brief Get file status information without following symbolic links * * @param[in] path The file path to get status for (does not follow symlinks) * @param[out] buf Pointer to stat structure to store the status information * * @return int Operation result: * - 0 on success * -ENOENT if file not found * -ENOMEM if memory allocation failed * Other negative

Source from the content-addressed store, hash-verified

1316 * @see dfs_file_stat()
1317 */
1318int dfs_file_lstat(const char *path, struct stat *buf)
1319{
1320 int ret = -ENOENT;
1321 char *fullpath = RT_NULL;
1322 struct dfs_mnt *mnt = RT_NULL;
1323 struct dfs_dentry *dentry = RT_NULL;
1324
1325 fullpath = dfs_normalize_path(NULL, path);
1326 if (fullpath)
1327 {
1328 DLOG(msg, "dfs_file", "mnt", DLOG_MSG, "dfs_mnt_lookup(%s)", fullpath);
1329 mnt = dfs_mnt_lookup(fullpath);
1330 if (mnt)
1331 {
1332 char *tmp = dfs_file_realpath(&mnt, fullpath, DFS_REALPATH_EXCEPT_LAST);
1333 if (tmp)
1334 {
1335 rt_free(fullpath);
1336 fullpath = tmp;
1337 }
1338
1339 DLOG(msg, "dfs_file", "dentry", DLOG_MSG, "dentry = dfs_dentry_lookup(mnt, %s)", fullpath);
1340 dentry = dfs_dentry_lookup(mnt, fullpath, 0);
1341 if (dentry)
1342 {
1343 DLOG(msg, "dentry", "dfs_file", DLOG_MSG_RET, "return dentry");
1344 if (mnt->fs_ops->stat)
1345 {
1346 DLOG(msg, "dfs_file", mnt->fs_ops->name, DLOG_MSG, "fs_ops->stat(dentry, buf)");
1347
1348 if (dfs_is_mounted(mnt) == 0)
1349 {
1350 ret = mnt->fs_ops->stat(dentry, buf);
1351 }
1352 }
1353
1354 /* unref dentry */
1355 DLOG(msg, "dfs_file", "dentry", DLOG_MSG, "dfs_dentry_unref(dentry)");
1356 dfs_dentry_unref(dentry);
1357 dentry = RT_NULL;
1358 }
1359 }
1360
1361 rt_free(fullpath);
1362 fullpath = RT_NULL;
1363 }
1364 else
1365 {
1366 ret = -ENOMEM;
1367 }
1368
1369 rt_set_errno(-ret);
1370
1371 return ret;
1372}
1373
1374/**
1375 * @brief Get file status information using file descriptor

Callers 10

msh_file.cFile · 0.85
sys_lstatFunction · 0.85
utimensatFunction · 0.85
unlinkFunction · 0.85
mkdirFunction · 0.85
rmdirFunction · 0.85
dfs_file_linkFunction · 0.85
lsFunction · 0.85
copydirFunction · 0.85
copyFunction · 0.85

Calls 8

dfs_mnt_lookupFunction · 0.85
dfs_file_realpathFunction · 0.85
rt_freeFunction · 0.85
dfs_dentry_lookupFunction · 0.85
dfs_is_mountedFunction · 0.85
dfs_dentry_unrefFunction · 0.85
rt_set_errnoFunction · 0.85
dfs_normalize_pathFunction · 0.70

Tested by

no test coverage detected