retire BIOS_SEG and umap_bios
[minix3.git] / lib / libvtreefs / link.c
blob39aa2ed3ef2b397afb68d587d98367d2278bfb74
1 /* VTreeFS - link.c - by Alen Stojanov and David van Moolenbroek */
3 #include "inc.h"
5 /*===========================================================================*
6 * fs_rdlink *
7 *===========================================================================*/
8 int fs_rdlink(void)
10 /* Retrieve symbolic link target.
12 char path[PATH_MAX];
13 struct inode *node;
14 size_t len;
15 int r;
17 if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL)
18 return EINVAL;
20 /* Call the rdlink hook. */
21 assert(vtreefs_hooks->rdlink_hook != NULL);
22 assert(!is_inode_deleted(node)); /* symlinks cannot be opened */
24 r = vtreefs_hooks->rdlink_hook(node, path, sizeof(path),
25 get_inode_cbdata(node));
26 if (r != OK) return r;
28 len = strlen(path);
29 assert(len > 0 && len < sizeof(path));
31 if (len > fs_m_in.REQ_MEM_SIZE)
32 len = fs_m_in.REQ_MEM_SIZE;
34 /* Copy out the result. */
35 r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,
36 (vir_bytes) path, len, D);
37 if (r != OK) return r;
39 fs_m_out.RES_NBYTES = len;
40 return OK;