From 1546a4c683da043af4796acf47dd109c778e2e8a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 4 Feb 2000 05:08:16 +0000 Subject: [PATCH] Hopefully these changes will actually stick. (This used to be commit a2782097db258a164bf43d814e8832a27d0eb3f1) --- examples/VFS/Makefile | 25 ++++++++++++++++++------- examples/VFS/README | 18 +++++++++++------- examples/VFS/audit.c | 13 ++++++------- examples/VFS/skel.c | 25 +++++++++---------------- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/examples/VFS/Makefile b/examples/VFS/Makefile index fb9976893b4..c4c9479c7d3 100644 --- a/examples/VFS/Makefile +++ b/examples/VFS/Makefile @@ -1,21 +1,32 @@ # # Makefile for samba-vfs examples # -# $Id: Makefile,v 1.1 2000/02/03 04:40:56 tpot Exp $ +# $Id: Makefile,v 1.2 2000/02/04 05:08:16 tpot Exp $ # # Variables -SAMBA_SRC = ../../source - -CFLAGS = -I$(SAMBA_SRC)/include CC = gcc +LIBTOOL = libtool -VFS_OBJS = audit.o skel.o +SAMBA_SRC = ../../source/include +CFLAGS = -I$(SAMBA_SRC) +VFS_OBJS = audit.so skel.so -# Targets +# Default target default: $(VFS_OBJS) +# Pattern rules + +%.so: %.lo + $(LIBTOOL) $(CC) -shared -o $@ $< $(LDFLAGS) + +%.lo: %.c + $(LIBTOOL) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< + +# Misc targets + clean: - rm -f core $(VFS_OBJS) *~ *% *.bak + rm -rf .libs + rm -f core $(VFS_OBJS) $(VFS_OBJS:.so=.lo) *~ *% *.bak diff --git a/examples/VFS/README b/examples/VFS/README index dc7398892df..c2f39f9727d 100644 --- a/examples/VFS/README +++ b/examples/VFS/README @@ -17,15 +17,19 @@ construction. The following VFS modules are given: connect/disconnect, directory opens/create/remove, file open/close/rename/unlink/chmod. - streamer - Stream file writes to a network address instead of to - disk. +The libtool program, available from your favourite GNU software +archive, is required to compile these programs. - perlfs - A wrapper for writing Samba VFS modules in Perl. +To use the VFS modules, create a share similar to the one below. The +important parameter is the 'vfs object' parameter which must point to +the exact pathname of the shared library object. -The modules need only to be compiled with -I/samba/source/dir added to -CFLAGS. + [audit] + comment = Audited /data directory + path = /data + vfs object = /path/to/audit.so + writeable = yes + browseable = yes Further documentation on writing VFS modules for Samba can be found in docs directory of the Samba source distribution. diff --git a/examples/VFS/audit.c b/examples/VFS/audit.c index 3d84c579c7b..8f0aaac4be3 100644 --- a/examples/VFS/audit.c +++ b/examples/VFS/audit.c @@ -2,7 +2,7 @@ * Auditing VFS module for samba. Log select file operations to syslog * facility. * - * Copyright (C) Tim Potter, 1999 + * 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 @@ -18,7 +18,7 @@ * 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.1 2000/02/03 04:40:56 tpot Exp $ + * $Id: audit.c,v 1.2 2000/02/04 05:08:16 tpot Exp $ */ #include "config.h" @@ -83,15 +83,14 @@ struct vfs_ops audit_ops = { audit_open, audit_close, - NULL, /* read */ + NULL, /* read */ NULL, /* write */ NULL, /* lseek */ audit_rename, - NULL, /* sync */ - NULL, /* stat */ + NULL, /* fsync */ + NULL, /* stat */ NULL, /* fstat */ NULL, /* lstat */ - NULL, /* fcntl_lock */ audit_unlink, NULL, /* chmod */ NULL /* utime */ @@ -164,7 +163,7 @@ int audit_open(char *fname, int flags, mode_t mode) syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n", fname, result, - ((mode & O_WRONLY) || (mode & O_RDWR)) ? "for writing " : "", + ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); diff --git a/examples/VFS/skel.c b/examples/VFS/skel.c index fae2bc51df9..da5ef7b3104 100644 --- a/examples/VFS/skel.c +++ b/examples/VFS/skel.c @@ -1,7 +1,7 @@ /* * Skeleton VFS module. * - * Copyright (C) Tim Potter, 1999 + * 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 @@ -17,7 +17,7 @@ * 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 $ + * $Id: skel.c,v 1.2 2000/02/04 05:08:16 tpot Exp $ */ #include "config.h" @@ -42,7 +42,7 @@ 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 skel_disk_free(char *path, BOOL smallquery, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); DIR *skel_opendir(char *fname); @@ -57,11 +57,10 @@ 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); +void 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); -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); @@ -92,11 +91,10 @@ struct vfs_ops skel_ops = { skel_write, skel_lseek, skel_rename, - skel_sync, + skel_fsync, skel_stat, skel_fstat, skel_lstat, - skel_lock, skel_unlink, skel_chmod, skel_utime @@ -123,10 +121,10 @@ void skel_disconnect(void) default_vfs_ops.disconnect(); } -SMB_BIG_UINT skel_disk_free(char *path, SMB_BIG_UINT *bsize, +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, bsize, dfree, dsize); + return default_vfs_ops.disk_free(path, small_query, bsize, dfree, dsize); } DIR *skel_opendir(char *fname) @@ -184,9 +182,9 @@ int skel_rename(char *old, char *new) return default_vfs_ops.rename(old, new); } -void skel_sync(int fd) +void skel_fsync(int fd) { - default_vfs_ops.sync(fd); + default_vfs_ops.fsync(fd); } int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf) @@ -204,11 +202,6 @@ 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); -- 2.34.1