summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/VFS/audit.c163
-rw-r--r--examples/VFS/skel.c122
2 files changed, 150 insertions, 135 deletions
diff --git a/examples/VFS/audit.c b/examples/VFS/audit.c
index 8f0aaac4be..036438e90e 100644
--- a/examples/VFS/audit.c
+++ b/examples/VFS/audit.c
@@ -1,5 +1,5 @@
/*
- * Auditing VFS module for samba. Log select file operations to syslog
+ * Auditing VFS module for samba. Log selected file operations to syslog
* facility.
*
* Copyright (C) Tim Potter, 1999-2000
@@ -17,8 +17,6 @@
* 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: audit.c,v 1.2 2000/02/04 05:08:16 tpot Exp $
*/
#include "config.h"
@@ -65,35 +63,37 @@ extern struct vfs_ops default_vfs_ops; /* For passthrough operation */
struct vfs_ops audit_ops = {
- /* Disk operations */
-
- audit_connect,
- audit_disconnect,
- NULL, /* disk free */
-
- /* Directory operations */
-
- audit_opendir,
- NULL, /* readdir */
- audit_mkdir,
- audit_rmdir,
- NULL, /* closedir */
-
- /* File operations */
-
- audit_open,
- audit_close,
- NULL, /* read */
- NULL, /* write */
- NULL, /* lseek */
- audit_rename,
- NULL, /* fsync */
- NULL, /* stat */
- NULL, /* fstat */
- NULL, /* lstat */
- audit_unlink,
- NULL, /* chmod */
- NULL /* utime */
+ /* Disk operations */
+
+ audit_connect,
+ audit_disconnect,
+ NULL, /* disk free */
+
+ /* Directory operations */
+
+ audit_opendir,
+ NULL, /* readdir */
+ audit_mkdir,
+ audit_rmdir,
+ NULL, /* closedir */
+
+ /* File operations */
+
+ audit_open,
+ audit_close,
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* lseek */
+ audit_rename,
+ NULL, /* fsync */
+ NULL, /* stat */
+ NULL, /* fstat */
+ NULL, /* lstat */
+ audit_unlink,
+ NULL, /* chmod */
+ NULL, /* utime */
+ NULL, /* ftruncate */
+ NULL /* lock */
};
/* VFS initialisation function. Return initialised vfs_ops structure
@@ -101,8 +101,8 @@ struct vfs_ops audit_ops = {
struct vfs_ops *vfs_init(void)
{
- openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
- return(&audit_ops);
+ openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
+ return(&audit_ops);
}
/* Implementation of vfs_ops. Pass everything on to the default
@@ -110,98 +110,99 @@ struct vfs_ops *vfs_init(void)
int audit_connect(struct vfs_connection_struct *conn, char *svc, char *user)
{
- syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n", svc, user);
+ syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n",
+ svc, user);
- return default_vfs_ops.connect(conn, svc, user);
+ return default_vfs_ops.connect(conn, svc, user);
}
void audit_disconnect(void)
{
- syslog(SYSLOG_PRIORITY, "disconnected\n");
- default_vfs_ops.disconnect();
+ syslog(SYSLOG_PRIORITY, "disconnected\n");
+ default_vfs_ops.disconnect();
}
DIR *audit_opendir(char *fname)
{
- DIR *result = default_vfs_ops.opendir(fname);
+ DIR *result = default_vfs_ops.opendir(fname);
- syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n",
- fname,
- (result == NULL) ? "failed: " : "",
- (result == NULL) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n",
+ fname,
+ (result == NULL) ? "failed: " : "",
+ (result == NULL) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_mkdir(char *path, mode_t mode)
{
- int result = default_vfs_ops.mkdir(path, mode);
+ int result = default_vfs_ops.mkdir(path, mode);
- syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n",
- path,
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n",
+ path,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_rmdir(char *path)
{
- int result = default_vfs_ops.rmdir(path);
+ int result = default_vfs_ops.rmdir(path);
- syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n",
- path,
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n",
+ path,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_open(char *fname, int flags, mode_t mode)
{
- int result = default_vfs_ops.open(fname, flags, mode);
+ int result = default_vfs_ops.open(fname, flags, mode);
- syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n",
- fname, result,
- ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "",
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n",
+ fname, result,
+ ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "",
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_close(int fd)
{
- int result = default_vfs_ops.close(fd);
+ int result = default_vfs_ops.close(fd);
- syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n",
- fd,
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n",
+ fd,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_rename(char *old, char *new)
{
- int result = default_vfs_ops.rename(old, new);
+ int result = default_vfs_ops.rename(old, new);
- syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n",
- old, new,
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n",
+ old, new,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
int audit_unlink(char *path)
{
- int result = default_vfs_ops.unlink(path);
+ int result = default_vfs_ops.unlink(path);
- syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n",
- path,
- (result < 0) ? "failed: " : "",
- (result < 0) ? strerror(errno) : "");
+ syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n",
+ path,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
- return result;
+ return result;
}
diff --git a/examples/VFS/skel.c b/examples/VFS/skel.c
index 1873e4a479..90f16f952f 100644
--- a/examples/VFS/skel.c
+++ b/examples/VFS/skel.c
@@ -1,5 +1,6 @@
/*
- * Skeleton VFS module.
+ * Skeleton VFS module. Implements passthrough operation of all VFS
+ * calls to disk functions.
*
* Copyright (C) Tim Potter, 1999-2000
*
@@ -16,8 +17,6 @@
* 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.3 2000/04/05 22:42:26 tpot Exp $
*/
#include "config.h"
@@ -64,47 +63,51 @@ 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
+ /* 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);
+ return(&skel_ops);
}
/* Implementation of VFS functions. Insert your useful stuff here */
@@ -113,106 +116,117 @@ 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);
+ return default_vfs_ops.connect(conn, svc, user);
}
void skel_disconnect(void)
{
- default_vfs_ops.disconnect();
+ 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);
+ return default_vfs_ops.disk_free(path, small_query, bsize,
+ dfree, dsize);
}
DIR *skel_opendir(char *fname)
{
- return default_vfs_ops.opendir(fname);
+ return default_vfs_ops.opendir(fname);
}
struct dirent *skel_readdir(DIR *dirp)
{
- return default_vfs_ops.readdir(dirp);
+ return default_vfs_ops.readdir(dirp);
}
int skel_mkdir(char *path, mode_t mode)
{
- return default_vfs_ops.mkdir(path, mode);
+ return default_vfs_ops.mkdir(path, mode);
}
int skel_rmdir(char *path)
{
- return default_vfs_ops.rmdir(path);
+ return default_vfs_ops.rmdir(path);
}
int skel_closedir(DIR *dir)
{
- return default_vfs_ops.closedir(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);
+ return default_vfs_ops.open(fname, flags, mode);
}
int skel_close(int fd)
{
- return default_vfs_ops.close(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);
+ 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);
+ 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);
+ return default_vfs_ops.lseek(filedes, offset, whence);
}
int skel_rename(char *old, char *new)
{
- return default_vfs_ops.rename(old, new);
+ return default_vfs_ops.rename(old, new);
}
int skel_fsync(int fd)
{
- default_vfs_ops.fsync(fd);
+ return default_vfs_ops.fsync(fd);
}
int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf)
{
- return default_vfs_ops.stat(fname, sbuf);
+ return default_vfs_ops.stat(fname, sbuf);
}
int skel_fstat(int fd, SMB_STRUCT_STAT *sbuf)
{
- return default_vfs_ops.fstat(fd, sbuf);
+ return default_vfs_ops.fstat(fd, sbuf);
}
int skel_lstat(char *path, SMB_STRUCT_STAT *sbuf)
{
- return default_vfs_ops.lstat(path, sbuf);
+ return default_vfs_ops.lstat(path, sbuf);
}
int skel_unlink(char *path)
{
- return default_vfs_ops.unlink(path);
+ return default_vfs_ops.unlink(path);
}
int skel_chmod(char *path, mode_t mode)
{
- return default_vfs_ops.chmod(path, mode);
+ return default_vfs_ops.chmod(path, mode);
}
int skel_utime(char *path, struct utimbuf *times)
{
- return default_vfs_ops.utime(path, 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);
}