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

Function devtmpfs_symlink

components/dfs/dfs_v2/filesystems/devfs/devtmpfs.c:347–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347static int devtmpfs_symlink(struct dfs_dentry *parent_dentry, const char *target, const char *linkpath)
348{
349 int ret = RT_EOK;
350 struct devtmpfs_file *p_file, *l_file;
351 struct devtmpfs_sb *superblock;
352
353 RT_ASSERT(parent_dentry);
354 RT_ASSERT(parent_dentry->mnt);
355
356 superblock = (struct devtmpfs_sb *)parent_dentry->mnt->data;
357 RT_ASSERT(superblock);
358
359 p_file = devtmpfs_file_lookup(superblock, parent_dentry->pathname);
360 if (p_file)
361 {
362 l_file = (struct devtmpfs_file *)rt_calloc(1, sizeof(struct devtmpfs_file));
363 if (l_file)
364 {
365 superblock->df_size += sizeof(struct devtmpfs_file);
366
367 strncpy(l_file->name, linkpath, DIRENT_NAME_MAX - 1);
368
369 dfs_vfs_init_node(&l_file->node);
370 l_file->sb = superblock;
371 l_file->type = TMPFS_TYPE_FILE;
372 l_file->mode = p_file->mode;
373 l_file->mode &= ~S_IFMT;
374 l_file->mode |= S_IFLNK;
375 l_file->link = rt_strdup(target);
376
377 rt_spin_lock(&superblock->lock);
378 dfs_vfs_append_node(&p_file->node, &l_file->node);
379 rt_spin_unlock(&superblock->lock);
380 }
381 }
382
383 return ret;
384}
385
386static int devtmpfs_readlink(struct dfs_dentry *dentry, char *buf, int len)
387{

Callers

nothing calls this directly

Calls 7

devtmpfs_file_lookupFunction · 0.85
rt_callocFunction · 0.85
dfs_vfs_init_nodeFunction · 0.85
rt_strdupFunction · 0.85
dfs_vfs_append_nodeFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected