| 345 | } |
| 346 | |
| 347 | static 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 | |
| 386 | static int devtmpfs_readlink(struct dfs_dentry *dentry, char *buf, int len) |
| 387 | { |
nothing calls this directly
no test coverage detected