da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* $Id$ */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/** @file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * VirtualBox File System for Solaris Guests, provider header.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Portions contributed by: Ronald.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright (C) 2009-2011 Oracle Corporation
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This file is part of VirtualBox Open Source Edition (OSE), as
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * available from http://www.virtualbox.org. This file is free software;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * you can redistribute it and/or modify it under the terms of the GNU
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * General Public License (GPL) as published by the Free Software
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Foundation, in version 2 as it comes in the "COPYING" file of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The contents of this file may alternatively be used under the terms
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * of the Common Development and Distribution License Version 1.0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * VirtualBox OSE distribution, in which case the provisions of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL are applicable instead of those of the GPL.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You may elect to license modified versions of this file under the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * terms and conditions of either the GPL or the CDDL or both.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef ___VBoxFS_prov_Solaris_h
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ___VBoxFS_prov_Solaris_h
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef __cplusplus
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern "C" {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * These are the provider interfaces used by sffs to access the underlying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * shared file system.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SFPROV_VERSION 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Initialization and termination.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * sfprov_connect() is called once before any other interfaces and returns
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * a handle used in further calls. The argument should be SFPROV_VERSION
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * from above. On failure it returns a NULL pointer.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * sfprov_disconnect() must only be called after all sf file systems have been
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * unmounted.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct sfp_connection sfp_connection_t;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern sfp_connection_t *sfprov_connect(int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern void sfprov_disconnect(sfp_connection_t *);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Mount / Unmount a shared folder.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * sfprov_mount() takes as input the connection pointer and the name of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the shared folder. On success, it returns zero and supplies an
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * sfp_mount_t handle. On failure it returns any relevant errno value.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * sfprov_unmount() unmounts the mounted file system. It returns 0 on
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * success and any relevant errno on failure.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * spf_mount_t is the representation of an active mount point.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct spf_mount_t {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin VBSFMAP map; /* guest<->host mapping */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin uid_t sf_uid; /* owner of the mount point */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin gid_t sf_gid; /* group of the mount point */
mode_t sf_dmode; /* mode of all directories if != ~0U */
mode_t sf_fmode; /* mode of all files if != ~0U */
mode_t sf_dmask; /* mask of all directories */
mode_t sf_fmask; /* mask of all files */
} sfp_mount_t;
extern int sfprov_mount(sfp_connection_t *, char *, sfp_mount_t **);
extern int sfprov_unmount(sfp_mount_t *);
/*
* query information about a mounted file system
*/
typedef struct sffs_fsinfo {
uint64_t blksize;
uint64_t blksused;
uint64_t blksavail;
uint32_t maxnamesize;
uint32_t readonly;
} sffs_fsinfo_t;
extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *);
/*
* File operations: open/close/read/write/etc.
*
* open/create can return any relevant errno, however ENOENT
* generally means that the host file didn't exist.
*/
typedef struct sffs_stat {
mode_t sf_mode;
off_t sf_size;
off_t sf_alloc;
timestruc_t sf_atime;
timestruc_t sf_mtime;
timestruc_t sf_ctime;
} sffs_stat_t;
typedef struct sfp_file sfp_file_t;
extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode,
sfp_file_t **fp, sffs_stat_t *stat);
extern int sfprov_diropen(sfp_mount_t *mnt, char *path, sfp_file_t **fp);
extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp, int flag);
extern int sfprov_close(sfp_file_t *fp);
extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
uint32_t *numbytes);
extern int sfprov_write(sfp_file_t *, char * buffer, uint64_t offset,
uint32_t *numbytes);
extern int sfprov_fsync(sfp_file_t *fp);
/*
* get/set information about a file (or directory) using pathname
*/
extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *);
extern int sfprov_get_size(sfp_mount_t *, char *, uint64_t *);
extern int sfprov_get_atime(sfp_mount_t *, char *, timestruc_t *);
extern int sfprov_get_mtime(sfp_mount_t *, char *, timestruc_t *);
extern int sfprov_get_ctime(sfp_mount_t *, char *, timestruc_t *);
extern int sfprov_get_attr(sfp_mount_t *, char *, sffs_stat_t *);
extern int sfprov_set_attr(sfp_mount_t *, char *, uint_t, mode_t,
timestruc_t, timestruc_t, timestruc_t);
extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t);
/*
* File/Directory operations
*/
extern int sfprov_remove(sfp_mount_t *, char *path, uint_t is_link);
extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode,
sfp_file_t **fp, sffs_stat_t *stat);
extern int sfprov_rmdir(sfp_mount_t *, char *path);
extern int sfprov_rename(sfp_mount_t *, char *from, char *to, uint_t is_dir);
/*
* Symbolic link operations
*/
extern int sfprov_set_show_symlinks(void);
extern int sfprov_readlink(sfp_mount_t *, char *path, char *target,
size_t tgt_size);
extern int sfprov_symlink(sfp_mount_t *, char *linkname, char *target,
sffs_stat_t *stat);
/*
* Read directory entries.
*/
/*
* a singly linked list of buffers, each containing an array of stat's+dirent's.
* sf_len is length of the sf_entries array, in bytes.
*/
typedef struct sffs_dirents {
struct sffs_dirents *sf_next;
len_t sf_len;
struct sffs_dirent {
sffs_stat_t sf_stat;
dirent64_t sf_entry; /* this is variable length */
} sf_entries[1];
} sffs_dirents_t;
#define SFFS_DIRENTS_SIZE 8192
#define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0]))
extern int sfprov_readdir(sfp_mount_t *mnt, char *path,
sffs_dirents_t **dirents, int flag);
#ifdef __cplusplus
}
#endif
#endif /* !___VBoxFS_prov_Solaris_h */