vboxfs_prov.c revision e64031e20c39650a7bc902a3e1aba613b9415dee
/** @file
* VirtualBox File System for Solaris Guests, provider implementation.
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* Provider interfaces for shared folder file system.
*/
#include <sys/sysmacros.h>
#include "vboxfs_prov.h"
#ifdef u
#undef u
#endif
#include "../../common/VBoxGuestLib/VBoxCalls.h"
#define SFPROV_VERSION 1
static VBSFCLIENT vbox_client;
/*
* utility to create strings
*/
static SHFLSTRING *
{
return (str);
}
sfprov_connect(int version)
{
/*
* only one version for now, so must match
*/
int rc = -1;
if (version != SFPROV_VERSION)
{
return NULL;
}
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
return ((sfp_connection_t *)&vbox_client);
}
else
}
else
vboxUninit();
}
else
}
void
{
vboxUninit();
}
/*
* representation of an active mount point
*/
struct sfp_mount {
};
int
{
sfp_mount_t *m;
int size;
int rc;
m = kmem_zalloc(sizeof (*m), KM_SLEEP);
if (!RT_SUCCESS(rc)) {
kmem_free(m, sizeof (*m));
} else {
*mnt = m;
rc = 0;
}
return (rc);
}
int
{
int rc;
if (!RT_SUCCESS(rc)) {
} else {
rc = 0;
}
return (rc);
}
/*
* query information about a mounted file system
*/
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
*blksavail =
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
/*
*
* generally means that the host file didn't exist.
*/
struct sfp_file {
};
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (EINVAL);
return (EEXIST);
return (ENOENT);
}
return (0);
}
int
{
int rc;
int size;
/*
* try read only.
*/
return RTErrConvertToErrno(rc);
}
return (ENOENT);
}
if (RT_FAILURE(rc)) {
return RTErrConvertToErrno(rc);
}
return (ENOENT);
}
}
return (0);
}
int
{
int rc;
int size;
/*
*/
if (RT_FAILURE(rc)) {
return (EINVAL);
}
return (0);
}
int
{
int rc;
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
static int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (EINVAL);
return (ENOENT);
return (0);
}
/*
* get information about a file (or directory)
*/
int
{
int rc;
mode_t m = 0;
if (rc)
return (rc);
m |= S_IFDIR;
m |= S_IFREG;
m |= S_IFDIR;
m |= S_IFCHR;
m |= S_IFBLK;
m |= S_IFLNK;
m |= S_IFSOCK;
m |= S_IRUSR;
m |= S_IWUSR;
m |= S_IXUSR;
m |= S_IRGRP;
m |= S_IWGRP;
m |= S_IXGRP;
m |= S_IROTH;
m |= S_IWOTH;
m |= S_IXOTH;
*mode = m;
return (0);
}
int
{
int rc;
if (rc)
return (rc);
return (0);
}
int
{
int rc;
if (rc)
return (rc);
return (0);
}
int
{
int rc;
if (rc)
return (rc);
return (0);
}
int
{
int rc;
if (rc)
return (rc);
return (0);
}
/*
* Directory operations
*/
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (EINVAL);
return (EEXIST);
return (ENOENT);
}
return (0);
}
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (EINVAL);
return (0);
}
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (RTErrConvertToErrno(rc));
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (RTErrConvertToErrno(rc));
return (0);
}
/*
* Read all filenames in a directory.
*
* - success - all entries read and returned
* - ENOENT - Couldn't open the directory for reading
* - EINVAL - Internal error of some kind
*
* On successful return, buffer[0] is the start of an array of "char *"
* pointers to the filenames. The array ends with a NULL pointer.
* The remaining storage in buffer after that NULL pointer is where the
* filename strings actually are.
*
* On input nents is the max number of filenames the requestor can handle.
* On output nents is the number of entries at buff[0]
*
* The caller is responsible for freeing the returned buffer.
*/
int
char *path,
void **buffer,
{
int error;
char *cp;
int len;
int mask_size;
sfp_file_t *fp;
void *buff_start = NULL;
char **curr_b;
char *buff_end;
char **name_ptrs;
*buffersize = 0;
if (*nents == 0)
return (EINVAL);
if (error != 0)
return (ENOENT);
/*
* Create mask that VBox expects. This needs to be the directory path,
* plus a "*" wildcard to get all files.
*/
/*
* Allocate the buffer to use for return values. Each entry
* in the buffer will have a pointer and the string itself.
* The pointers go in the front of the buffer, the strings
* at the end.
*/
/*
* Now loop using vboxCallDirInfo to get one file name at a time
*/
cnt = 0;
for (;;) {
justone = 1;
&justone);
if (error == VERR_NO_MORE_FILES) {
break;
}
if (error == VERR_NO_TRANSLATION) {
continue; /* ?? just skip this one */
}
goto done;
}
/*
* Put this name in the buffer, stop if we run out of room.
*/
break;
++cnt;
}
error = 0;
*buffer = buff_start;
*buffersize = buff_size;
done:
if (error != 0)
return (error);
}