1 /* VTreeFS - link.c - support for symbolic links and device nodes */
6 * Retrieve a symbolic link target.
9 fs_rdlink(ino_t ino_nr
, struct fsdriver_data
* data
, size_t bytes
)
16 if ((node
= find_inode(ino_nr
)) == NULL
)
19 /* The hook should be provided for any FS that adds symlink inodes.. */
20 if (vtreefs_hooks
->rdlink_hook
== NULL
)
23 assert(!is_inode_deleted(node
)); /* symlinks cannot be opened */
25 r
= vtreefs_hooks
->rdlink_hook(node
, path
, sizeof(path
),
26 get_inode_cbdata(node
));
27 if (r
!= OK
) return r
;
30 assert(len
> 0 && len
< sizeof(path
));
35 /* Copy out the result. */
36 if ((r
= fsdriver_copyout(data
, 0, path
, len
)) != OK
)
43 * Create a symbolic link.
46 fs_slink(ino_t dir_nr
, char * name
, uid_t uid
, gid_t gid
,
47 struct fsdriver_data
* data
, size_t bytes
)
51 struct inode_stat istat
;
54 if ((node
= find_inode(dir_nr
)) == NULL
)
57 if (vtreefs_hooks
->slink_hook
== NULL
)
60 if (get_inode_by_name(node
, name
) != NULL
)
63 if (bytes
>= sizeof(path
))
66 if ((r
= fsdriver_copyin(data
, 0, path
, bytes
)) != OK
)
70 memset(&istat
, 0, sizeof(istat
));
71 istat
.mode
= S_IFLNK
| RWX_MODES
;
74 istat
.size
= strlen(path
);
77 return vtreefs_hooks
->slink_hook(node
, name
, &istat
, path
,
78 get_inode_cbdata(node
));
82 * Create a device node.
85 fs_mknod(ino_t dir_nr
, char * name
, mode_t mode
, uid_t uid
, gid_t gid
,
89 struct inode_stat istat
;
91 if ((node
= find_inode(dir_nr
)) == NULL
)
94 if (get_inode_by_name(node
, name
) != NULL
)
97 if (vtreefs_hooks
->mknod_hook
== NULL
)
100 memset(&istat
, 0, sizeof(istat
));
107 return vtreefs_hooks
->mknod_hook(node
, name
, &istat
,
108 get_inode_cbdata(node
));
115 fs_unlink(ino_t dir_nr
, char * name
, int __unused call
)
117 struct inode
*dir_node
, *node
;
119 if ((dir_node
= find_inode(dir_nr
)) == NULL
)
122 if ((node
= get_inode_by_name(dir_node
, name
)) == NULL
)
125 if (vtreefs_hooks
->unlink_hook
== NULL
)
128 return vtreefs_hooks
->unlink_hook(node
, get_inode_cbdata(node
));