summaryrefslogtreecommitdiff
path: root/examples/VFS/skel.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/VFS/skel.c')
-rw-r--r--examples/VFS/skel.c225
1 files changed, 225 insertions, 0 deletions
diff --git a/examples/VFS/skel.c b/examples/VFS/skel.c
new file mode 100644
index 0000000000..fae2bc51df
--- /dev/null
+++ b/examples/VFS/skel.c
@@ -0,0 +1,225 @@
+/*
+ * Skeleton VFS module.
+ *
+ * Copyright (C) Tim Potter, 1999
+ *
+ * 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.
+ *
+ * $Id: skel.c,v 1.1 2000/02/03 04:40:56 tpot Exp $
+ */
+
+#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, 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);
+void skel_sync(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);
+BOOL skel_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
+int skel_unlink(char *path);
+int skel_chmod(char *path, mode_t mode);
+int skel_utime(char *path, struct utimbuf *times);
+
+/* 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_sync,
+ skel_stat,
+ skel_fstat,
+ skel_lstat,
+ skel_lock,
+ skel_unlink,
+ skel_chmod,
+ skel_utime
+};
+
+/* 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, SMB_BIG_UINT *bsize,
+ SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
+{
+ return default_vfs_ops.disk_free(path, 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);
+}
+
+void skel_sync(int fd)
+{
+ default_vfs_ops.sync(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);
+}
+
+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);
+}
+
+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);
+}