1 | /* $Id: vboxfs_prov.h 39297 2011-11-14 16:46:52Z 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 | typedef struct sffs_fsinfo {
|
---|
75 | uint64_t blksize;
|
---|
76 | uint64_t blksused;
|
---|
77 | uint64_t blksavail;
|
---|
78 | uint32_t maxnamesize;
|
---|
79 | uint32_t readonly;
|
---|
80 | } sffs_fsinfo_t;
|
---|
81 |
|
---|
82 | extern int sfprov_get_fsinfo(sfp_mount_t *, sffs_fsinfo_t *);
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * File operations: open/close/read/write/etc.
|
---|
86 | *
|
---|
87 | * open/create can return any relevant errno, however ENOENT
|
---|
88 | * generally means that the host file didn't exist.
|
---|
89 | */
|
---|
90 | typedef struct sffs_stat {
|
---|
91 | mode_t sf_mode;
|
---|
92 | off_t sf_size;
|
---|
93 | off_t sf_alloc;
|
---|
94 | timestruc_t sf_atime;
|
---|
95 | timestruc_t sf_mtime;
|
---|
96 | timestruc_t sf_ctime;
|
---|
97 | } sffs_stat_t;
|
---|
98 |
|
---|
99 | typedef struct sfp_file sfp_file_t;
|
---|
100 |
|
---|
101 | extern int sfprov_create(sfp_mount_t *, char *path, mode_t mode,
|
---|
102 | sfp_file_t **fp, sffs_stat_t *stat);
|
---|
103 | extern int sfprov_open(sfp_mount_t *, char *path, sfp_file_t **fp);
|
---|
104 | extern int sfprov_close(sfp_file_t *fp);
|
---|
105 | extern int sfprov_read(sfp_file_t *, char * buffer, uint64_t offset,
|
---|
106 | uint32_t *numbytes);
|
---|
107 | extern int sfprov_write(sfp_file_t *, char * buffer, uint64_t offset,
|
---|
108 | uint32_t *numbytes);
|
---|
109 | extern int sfprov_fsync(sfp_file_t *fp);
|
---|
110 |
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * get/set information about a file (or directory) using pathname
|
---|
114 | */
|
---|
115 | extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *);
|
---|
116 | extern int sfprov_get_size(sfp_mount_t *, char *, uint64_t *);
|
---|
117 | extern int sfprov_get_atime(sfp_mount_t *, char *, timestruc_t *);
|
---|
118 | extern int sfprov_get_mtime(sfp_mount_t *, char *, timestruc_t *);
|
---|
119 | extern int sfprov_get_ctime(sfp_mount_t *, char *, timestruc_t *);
|
---|
120 | extern int sfprov_get_attr(sfp_mount_t *, char *, sffs_stat_t *);
|
---|
121 | extern int sfprov_set_attr(sfp_mount_t *, char *, uint_t, mode_t,
|
---|
122 | timestruc_t, timestruc_t, timestruc_t);
|
---|
123 | extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t);
|
---|
124 |
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * File/Directory operations
|
---|
128 | */
|
---|
129 | extern int sfprov_trunc(sfp_mount_t *, char *);
|
---|
130 | extern int sfprov_remove(sfp_mount_t *, char *path, uint_t is_link);
|
---|
131 | extern int sfprov_mkdir(sfp_mount_t *, char *path, mode_t mode,
|
---|
132 | sfp_file_t **fp, sffs_stat_t *stat);
|
---|
133 | extern int sfprov_rmdir(sfp_mount_t *, char *path);
|
---|
134 | extern int sfprov_rename(sfp_mount_t *, char *from, char *to, uint_t is_dir);
|
---|
135 |
|
---|
136 |
|
---|
137 | /*
|
---|
138 | * Symbolic link operations
|
---|
139 | */
|
---|
140 | extern int sfprov_set_show_symlinks(void);
|
---|
141 | extern int sfprov_readlink(sfp_mount_t *, char *path, char *target,
|
---|
142 | size_t tgt_size);
|
---|
143 | extern int sfprov_symlink(sfp_mount_t *, char *linkname, char *target,
|
---|
144 | sffs_stat_t *stat);
|
---|
145 |
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * Read directory entries.
|
---|
149 | */
|
---|
150 | /*
|
---|
151 | * a singly linked list of buffers, each containing an array of stat's+dirent's.
|
---|
152 | * sf_len is length of the sf_entries array, in bytes.
|
---|
153 | */
|
---|
154 | typedef struct sffs_dirents {
|
---|
155 | struct sffs_dirents *sf_next;
|
---|
156 | len_t sf_len;
|
---|
157 | struct sffs_dirent {
|
---|
158 | sffs_stat_t sf_stat;
|
---|
159 | dirent64_t sf_entry; /* this is variable length */
|
---|
160 | } sf_entries[1];
|
---|
161 | } sffs_dirents_t;
|
---|
162 |
|
---|
163 | #define SFFS_DIRENTS_SIZE 8192
|
---|
164 | #define SFFS_DIRENTS_OFF (offsetof(sffs_dirents_t, sf_entries[0]))
|
---|
165 |
|
---|
166 | extern int sfprov_readdir(sfp_mount_t *mnt, char *path,
|
---|
167 | sffs_dirents_t **dirents);
|
---|
168 |
|
---|
169 | #ifdef __cplusplus
|
---|
170 | }
|
---|
171 | #endif
|
---|
172 |
|
---|
173 | #endif /* !___VBoxFS_prov_Solaris_h */
|
---|