Fixes to allow versionless packages on cd
[minix3.git] / servers / hgfs / util.c
blobaf463c367b1a4f4bffaf0da438b8b24e977861cb
1 /* This file contains various utility functions.
3 * The entry points into this file are:
4 * get_name retrieve a path component string from VFS
5 * do_noop handle file system calls that do nothing and succeed
6 * no_sys handle file system calls that are not implemented
8 * Created:
9 * April 2009 (D.C. van Moolenbroek)
12 #include "inc.h"
14 /*===========================================================================*
15 * get_name *
16 *===========================================================================*/
17 PUBLIC int get_name(grant, len, name)
18 cp_grant_id_t grant; /* memory grant for the path component */
19 size_t len; /* length of the name, including '\0' */
20 char name[NAME_MAX+1]; /* buffer in which store the result */
22 /* Retrieve a path component from the caller, using a given grant.
24 int r;
26 /* Copy in the name of the directory entry. */
27 if (len <= 1) return EINVAL;
28 if (len > NAME_MAX+1) return ENAMETOOLONG;
30 r = sys_safecopyfrom(m_in.m_source, grant, 0, (vir_bytes) name, len, D);
32 if (r != OK) return r;
34 if (name[len-1] != 0) {
35 printf("HGFS: VFS did not zero-terminate path component!\n");
37 return EINVAL;
40 return OK;
43 /*===========================================================================*
44 * do_noop *
45 *===========================================================================*/
46 PUBLIC int do_noop()
48 /* Generic handler for no-op system calls.
51 return OK;
54 /*===========================================================================*
55 * no_sys *
56 *===========================================================================*/
57 PUBLIC int no_sys()
59 /* Generic handler for unimplemented system calls.
62 return ENOSYS;