2010-01-26 00:18:02 +01:00
|
|
|
/* This file contains various utility functions.
|
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
|
|
|
* get_name retrieve a path component string from VFS
|
|
|
|
* do_noop handle file system calls that do nothing and succeed
|
|
|
|
* no_sys handle file system calls that are not implemented
|
|
|
|
*
|
|
|
|
* Created:
|
|
|
|
* April 2009 (D.C. van Moolenbroek)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inc.h"
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* get_name *
|
|
|
|
*===========================================================================*/
|
2014-02-24 14:00:17 +01:00
|
|
|
int get_name(
|
|
|
|
cp_grant_id_t grant, /* memory grant for the path component */
|
|
|
|
size_t len, /* length of the name, including '\0' */
|
|
|
|
char name[NAME_MAX+1] /* buffer in which store the result */
|
|
|
|
)
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Retrieve a path component from the caller, using a given grant.
|
|
|
|
*/
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* Copy in the name of the directory entry. */
|
|
|
|
if (len <= 1) return EINVAL;
|
|
|
|
if (len > NAME_MAX+1) return ENAMETOOLONG;
|
|
|
|
|
2012-06-16 03:46:15 +02:00
|
|
|
r = sys_safecopyfrom(m_in.m_source, grant, 0, (vir_bytes) name, len);
|
2010-01-26 00:18:02 +01:00
|
|
|
|
|
|
|
if (r != OK) return r;
|
|
|
|
|
|
|
|
if (name[len-1] != 0) {
|
2012-04-09 18:08:26 +02:00
|
|
|
printf("%s: VFS did not zero-terminate path component!\n", sffs_name);
|
2010-01-26 00:18:02 +01:00
|
|
|
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_noop *
|
|
|
|
*===========================================================================*/
|
2014-02-24 14:00:17 +01:00
|
|
|
int do_noop(void)
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Generic handler for no-op system calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* no_sys *
|
|
|
|
*===========================================================================*/
|
2014-02-24 14:00:17 +01:00
|
|
|
int no_sys(void)
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Generic handler for unimplemented system calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return ENOSYS;
|
|
|
|
}
|