summaryrefslogtreecommitdiffstats
path: root/examples/VFS/skel.c
blob: 90f16f952f69fe374dd051d371a180a87d1addc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/* 
 * Skeleton VFS module.  Implements passthrough operation of all VFS
 * calls to disk functions.
 *
 * Copyright (C) Tim Potter, 1999-2000
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *  
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "config.h"

#include <stdio.h>
#include <sys/stat.h>
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#include <string.h>

#include <vfs.h>

/* Function prototypes */

int skel_connect(struct vfs_connection_struct *conn, char *svc, char *user);
void skel_disconnect(void);
SMB_BIG_UINT skel_disk_free(char *path, BOOL smallquery, SMB_BIG_UINT *bsize, 
			    SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);

DIR *skel_opendir(char *fname);
struct dirent *skel_readdir(DIR *dirp);
int skel_mkdir(char *path, mode_t mode);
int skel_rmdir(char *path);
int skel_closedir(DIR *dir);

int skel_open(char *fname, int flags, mode_t mode);
int skel_close(int fd);
ssize_t skel_read(int fd, char *data, size_t n);
ssize_t skel_write(int fd, char *data, size_t n);
SMB_OFF_T skel_lseek(int filedes, SMB_OFF_T offset, int whence);
int skel_rename(char *old, char *new);
int skel_fsync(int fd);
int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf);
int skel_fstat(int fd, SMB_STRUCT_STAT *sbuf);
int skel_lstat(char *path, SMB_STRUCT_STAT *sbuf);
int skel_unlink(char *path);
int skel_chmod(char *path, mode_t mode);
int skel_utime(char *path, struct utimbuf *times);
int skel_ftruncate(int fd, SMB_OFF_T offset);
BOOL skel_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);

/* VFS operations structure */

struct vfs_ops skel_ops = {

	/* Disk operations */

	skel_connect,
	skel_disconnect,
	skel_disk_free,
	
	/* Directory operations */

	skel_opendir,
	skel_readdir,
	skel_mkdir,
	skel_rmdir,
	skel_closedir,

	/* File operations */

	skel_open,
	skel_close,
	skel_read,
	skel_write,
	skel_lseek,
	skel_rename,
	skel_fsync,
	skel_stat,
	skel_fstat,
	skel_lstat,
	skel_unlink,
	skel_chmod,
	skel_utime,
	skel_ftruncate,
	skel_lock
};

/* VFS initialisation - return vfs_ops function pointer structure */

struct vfs_ops *vfs_init(void)
{
	return(&skel_ops);
}

/* Implementation of VFS functions.  Insert your useful stuff here */

extern struct vfs_ops default_vfs_ops;   /* For passthrough operation */

int skel_connect(struct vfs_connection_struct *conn, char *svc, char *user)
{
	return default_vfs_ops.connect(conn, svc, user);
}

void skel_disconnect(void)
{
	default_vfs_ops.disconnect();
}

SMB_BIG_UINT skel_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
			    SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
	return default_vfs_ops.disk_free(path, small_query, bsize, 
					 dfree, dsize);
}

DIR *skel_opendir(char *fname)
{
	return default_vfs_ops.opendir(fname);
}

struct dirent *skel_readdir(DIR *dirp)
{
	return default_vfs_ops.readdir(dirp);
}

int skel_mkdir(char *path, mode_t mode)
{
	return default_vfs_ops.mkdir(path, mode);
}

int skel_rmdir(char *path)
{
	return default_vfs_ops.rmdir(path);
}

int skel_closedir(DIR *dir)
{
	return default_vfs_ops.closedir(dir);
}

int skel_open(char *fname, int flags, mode_t mode)
{
	return default_vfs_ops.open(fname, flags, mode);
}

int skel_close(int fd)
{
	return default_vfs_ops.close(fd);
}

ssize_t skel_read(int fd, char *data, size_t n)
{
	return default_vfs_ops.read(fd, data, n);
}

ssize_t skel_write(int fd, char *data, size_t n)
{
	return default_vfs_ops.write(fd, data, n);
}

SMB_OFF_T skel_lseek(int filedes, SMB_OFF_T offset, int whence)
{
	return default_vfs_ops.lseek(filedes, offset, whence);
}

int skel_rename(char *old, char *new)
{
	return default_vfs_ops.rename(old, new);
}

int skel_fsync(int fd)
{
	return default_vfs_ops.fsync(fd);
}

int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf)
{
	return default_vfs_ops.stat(fname, sbuf);
}

int skel_fstat(int fd, SMB_STRUCT_STAT *sbuf)
{
	return default_vfs_ops.fstat(fd, sbuf);
}

int skel_lstat(char *path, SMB_STRUCT_STAT *sbuf)
{
	return default_vfs_ops.lstat(path, sbuf);
}

int skel_unlink(char *path)
{
	return default_vfs_ops.unlink(path);
}

int skel_chmod(char *path, mode_t mode)
{
	return default_vfs_ops.chmod(path, mode);
}

int skel_utime(char *path, struct utimbuf *times)
{
	return default_vfs_ops.utime(path, times);
}

int skel_ftruncate(int fd, SMB_OFF_T offset)
{
	return default_vfs_ops.ftruncate(fd, offset);
}

BOOL skel_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
	return default_vfs_ops.lock(fd, op, offset, count, type);
}