vboxfs_prov.c revision c161379f4055372228230517aa1700c47e3b9b7f
/** @file
* VirtualBox File System for Solaris Guests, provider implementation.
* Portions contributed by: Ronald.
*/
/*
* Copyright (C) 2008-2010 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*
* Provider interfaces for shared folder file system.
*/
#include <sys/sysmacros.h>
#include "vboxfs_prov.h"
#ifdef u
#undef u
#endif
#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h"
#define SFPROV_VERSION 1
static VBSFCLIENT vbox_client;
static int sfprov_vbox2errno(int rc)
{
if (rc == VERR_ACCESS_DENIED)
return (EACCES);
return (RTErrConvertToErrno(rc));
}
/*
* 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 (sfprov_vbox2errno(rc));
}
return (EEXIST);
return (ENOENT);
}
return (0);
}
int
{
int rc;
int size;
/*
* try read only.
*/
return (sfprov_vbox2errno(rc));
}
return (ENOENT);
}
if (RT_FAILURE(rc)) {
return (sfprov_vbox2errno(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);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (EIO);
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)
*/
static void
{
mode_t m = 0;
if (RTFS_IS_DIRECTORY(fMode))
m |= S_IFDIR;
else if (RTFS_IS_FILE(fMode))
m |= S_IFREG;
else if (RTFS_IS_FIFO(fMode))
m |= S_IFIFO;
else if (RTFS_IS_DEV_CHAR(fMode))
m |= S_IFCHR;
else if (RTFS_IS_DEV_BLOCK(fMode))
m |= S_IFBLK;
else if (RTFS_IS_SYMLINK(fMode))
m |= S_IFLNK;
else if (RTFS_IS_SOCKET(fMode))
m |= S_IFSOCK;
if (fMode & RTFS_UNIX_IRUSR)
m |= S_IRUSR;
if (fMode & RTFS_UNIX_IWUSR)
m |= S_IWUSR;
if (fMode & RTFS_UNIX_IXUSR)
m |= S_IXUSR;
if (fMode & RTFS_UNIX_IRGRP)
m |= S_IRGRP;
if (fMode & RTFS_UNIX_IWGRP)
m |= S_IWGRP;
if (fMode & RTFS_UNIX_IXGRP)
m |= S_IXGRP;
if (fMode & RTFS_UNIX_IROTH)
m |= S_IROTH;
if (fMode & RTFS_UNIX_IWOTH)
m |= S_IWOTH;
if (fMode & RTFS_UNIX_IXOTH)
m |= S_IXOTH;
if (fMode & RTFS_UNIX_ISUID)
m |= S_ISUID;
if (fMode & RTFS_UNIX_ISGID)
m |= S_ISGID;
if (fMode & RTFS_UNIX_ISTXT)
m |= S_ISVTX;
*mode = m;
}
/*
* get information about a file (or directory)
*/
int
{
int rc;
if (rc)
return (rc);
return (0);
}
int
{
int rc;
if (rc)
return (rc);
return (0);
}
static void
{
}
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
char *path,
{
int rc;
if (rc)
return (rc);
if (mode)
return (0);
}
static void
{
}
int
char *path,
{
int str_size;
if (RT_FAILURE(rc)) {
goto fail2;
}
goto fail1;
}
else
}
if (RT_FAILURE(rc)) {
{
}
goto fail1;
}
err = 0;
if (RT_FAILURE(rc)) {
}
return err;
}
int
{
int str_size;
if (RT_FAILURE(rc)) {
goto fail2;
}
goto fail1;
}
if (RT_FAILURE(rc)) {
goto fail1;
}
err = 0;
if (RT_FAILURE(rc)) {
}
return err;
}
/*
* Directory operations
*/
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (sfprov_vbox2errno(rc));
return (EEXIST);
return (ENOENT);
}
return (0);
}
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (sfprov_vbox2errno(rc));
return (0);
}
int
{
int rc;
int size;
if (RT_FAILURE(rc))
return (sfprov_vbox2errno(rc));
return (0);
}
int
{
int rc;
if (RT_FAILURE(rc))
return (sfprov_vbox2errno(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, *dirents points to a list of sffs_dirents_t;
* for each dirent, all fields except the d_ino will be set appropriately.
* The caller is responsible for freeing the dirents buffer.
*/
int
char *path,
{
int error;
char *cp;
int len;
int mask_size;
sfp_file_t *fp;
unsigned short reclen;
if (error != 0)
return (ENOENT);
/*
* Allocate the first dirents and stats buffers.
*/
goto done;
}
goto done;
}
/*
* Create mask that VBox expects. This needs to be the directory path,
* plus a "*" wildcard to get all files.
*/
goto done;
}
/*
* Now loop using vboxCallDirInfo
*/
goto done;
}
cnt = 0;
for (;;) {
switch (error) {
case VINF_SUCCESS:
/* fallthrough */
case VERR_NO_MORE_FILES:
break;
case VERR_NO_TRANSLATION:
/* XXX ??? */
break;
default:
goto done;
}
/*
* Create the dirent_t's and save the stats for each name
*/
/* expand buffers if we need more space */
goto done;
}
}
goto done;
}
}
/* create the dirent with the name, offset, and len */
dirent = (dirent64_t *)
++cnt;
/* save the stats */
/* next info */
}
if (error == VERR_NO_MORE_FILES)
break;
}
error = 0;
done:
if (error != 0) {
while (*dirents) {
}
while (*stats) {
}
}
return (error);
}