1 | /* $Id: vboxfs_prov.h 31691 2010-08-16 12:59:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox File System for Solaris Guests, provider header.
|
---|
4 | * Portions contributed by: Ronald.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009-2010 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * The contents of this file may alternatively be used under the terms
|
---|
19 | * of the Common Development and Distribution License Version 1.0
|
---|
20 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
21 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
22 | * CDDL are applicable instead of those of the GPL.
|
---|
23 | *
|
---|
24 | * You may elect to license modified versions of this file under the
|
---|
25 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef ___VBoxFS_prov_Solaris_h
|
---|
29 | #define ___VBoxFS_prov_Solaris_h
|
---|
30 |
|
---|
31 | #ifdef __cplusplus
|
---|
32 | extern "C" {
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * These are the provider interfaces used by sffs to access the underlying
|
---|
37 | * shared file system.
|
---|
38 | */
|
---|
39 | #define SFPROV_VERSION 1
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * Initialization and termination.
|
---|
43 | * sfprov_connect() is called once before any other interfaces and returns
|
---|
44 | * a handle used in further calls. The argument should be SFPROV_VERSION
|
---|
45 | * from above. On failure it returns a NULL pointer.
|
---|
46 | *
|
---|
47 | * sfprov_disconnect() must only be called after all sf file systems have been
|
---|
48 | * unmounted.
|
---|
49 | */
|
---|
50 | typedef struct sfp_connection sfp_connection_t;
|
---|
51 |
|
---|
52 | extern sfp_connection_t *sfprov_connect(int);
|
---|
53 | extern void sfprov_disconnect(sfp_connection_t *);
|
---|
54 |
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Mount / Unmount a shared folder.
|
---|
58 | *
|
---|
59 | * sfprov_mount() takes as input the connection pointer and the name of
|
---|
60 | * the shared folder. On success, it returns zero and supplies an
|
---|
61 | * sfp_mount_t handle. On failure it returns any relevant errno value.
|
---|
62 | *
|
---|
63 | * sfprov_unmount() unmounts the mounted file system. It returns 0 on
|
---|
64 | * success and any relevant errno on failure.
|
---|
65 | */
|
---|
66 | typedef struct sfp_mount sfp_mount_t;
|
---|
67 |
|
---|
68 | extern int sfprov_mount(sfp_connection_t *, char *, sfp_mount_t **);
|
---|
69 | extern int sfprov_unmount(sfp_mount_t *);
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * query information about a mounted file system
|
---|
73 | */
|
---|
74 | extern int sfprov_get_blksize(sfp_mount_t *, uint64_t *);
|
---|
75 | extern int sfprov_get_blksused(sfp_mount_t *, uint64_t *);
|
---|
76 | extern int sfprov_get_blksavail(sfp_mount_t *, uint64_t *);
|
---|
77 | extern int sfprov_get_maxnamesize(sfp_mount_t *, uint32_t *);
|
---|
78 | extern int sfprov_get_readonly(sfp_mount_t *, uint32_t *);
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * File operations: open/close/read/write/etc.
|
---|
82 | *
|
---|
83 | * open/create can return any relevant errno, however ENOENT
|
---|
84 | * generally means that the host file didn't exist.
|
---|
85 | */
|
---|
86 | typedef struct sfp_file sfp_file_t;
|
---|
87 |
|
---|
88 | extern int sfprov_create(sfp_mount_t *, char *path, sfp_file_t **fp);
|
---|
89 | extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp);
|
---|
90 | extern int sfprov_close(sfp_file_t *fp);
|
---|
91 | extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
|
---|
92 | uint32_t *numbytes);
|
---|
93 | extern int sfprov_write(sfp_file_t *, char * buffer, uint64_t offset,
|
---|
94 | uint32_t *numbytes);
|
---|
95 | extern int sfprov_fsync(sfp_file_t *fp);
|
---|
96 |
|
---|
97 |
|
---|
98 | /*
|
---|
99 | * get/set information about a file (or directory) using pathname
|
---|
100 | */
|
---|
101 | extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *);
|
---|
102 | extern int sfprov_get_size(sfp_mount_t *, char *, uint64_t *);
|
---|
103 | extern int sfprov_get_atime(sfp_mount_t *, char *, timestruc_t *);
|
---|
104 | extern int sfprov_get_mtime(sfp_mount_t *, char *, timestruc_t *);
|
---|
105 | extern int sfprov_get_ctime(sfp_mount_t *, char *, timestruc_t *);
|
---|
106 | extern int sfprov_get_attr(sfp_mount_t *, char *, mode_t *, uint64_t *,
|
---|
107 | timestruc_t *, timestruc_t *, timestruc_t *);
|
---|
108 | extern int sfprov_set_attr(sfp_mount_t *, char *, uint_t, mode_t,
|
---|
109 | timestruc_t, timestruc_t, timestruc_t);
|
---|
110 | extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t);
|
---|
111 |
|
---|
112 |
|
---|
113 | /*
|
---|
114 | * File/Directory operations
|
---|
115 | */
|
---|
116 | extern int sfprov_trunc(sfp_mount_t *, char *);
|
---|
117 | extern int sfprov_remove(sfp_mount_t *, char *path);
|
---|
118 | extern int sfprov_mkdir(sfp_mount_t *, char *path, sfp_file_t **fp);
|
---|
119 | extern int sfprov_rmdir(sfp_mount_t *, char *path);
|
---|
120 | extern int sfprov_rename(sfp_mount_t *, char *from, char *to, uint_t is_dir);
|
---|
121 |
|
---|
122 | /*
|
---|
123 | * Read directory entries.
|
---|
124 | */
|
---|
125 | /*
|
---|
126 | * a singly linked list of buffers, each containing an array of dirent's.
|
---|
127 | * sf_len is length of the sf_entries array, in bytes.
|
---|
128 | */
|
---|
129 | typedef struct sffs_dirents {
|
---|
130 | struct sffs_dirents *sf_next;
|
---|
131 | len_t sf_len;
|
---|
132 | dirent64_t sf_entries[1];
|
---|
133 | } sffs_dirents_t;
|
---|
134 |
|
---|
135 | #define SFFS_DIRENTS_SIZE 8192
|
---|
136 | #define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0]))
|
---|
137 | #define SFFS_STATS_LEN 100
|
---|
138 |
|
---|
139 | typedef struct sffs_stat {
|
---|
140 | mode_t sf_mode;
|
---|
141 | off_t sf_size;
|
---|
142 | timestruc_t sf_atime;
|
---|
143 | timestruc_t sf_mtime;
|
---|
144 | timestruc_t sf_ctime;
|
---|
145 | } sffs_stat_t;
|
---|
146 |
|
---|
147 | typedef struct sffs_stats {
|
---|
148 | struct sffs_stats *sf_next;
|
---|
149 | len_t sf_num;
|
---|
150 | sffs_stat_t sf_stats[SFFS_STATS_LEN];
|
---|
151 | } sffs_stats_t;
|
---|
152 |
|
---|
153 | extern int sfprov_readdir(sfp_mount_t *mnt, char *path, sffs_dirents_t **dirents,
|
---|
154 | sffs_stats_t **stats);
|
---|
155 |
|
---|
156 | #ifdef __cplusplus
|
---|
157 | }
|
---|
158 | #endif
|
---|
159 |
|
---|
160 | #endif /* !___VBoxFS_prov_Solaris_h */
|
---|