VM: full munmap
[minix.git] / lib / libsffs / util.c
blob6537416914d7830118c060ef226fc2b1211486b6
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 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);
32 if (r != OK) return r;
34 if (name[len-1] != 0) {
35 printf("%s: VFS did not zero-terminate path component!\n", sffs_name);
37 return EINVAL;
40 return OK;
43 /*===========================================================================*
44 * do_noop *
45 *===========================================================================*/
46 int do_noop()
48 /* Generic handler for no-op system calls.
51 return OK;
54 /*===========================================================================*
55 * no_sys *
56 *===========================================================================*/
57 int no_sys()
59 /* Generic handler for unimplemented system calls.
62 return ENOSYS;