svn commit: samba r16848 - in trunk/source: include modules smbd
torture
jpeach at samba.org
jpeach at samba.org
Fri Jul 7 02:09:54 GMT 2006
Author: jpeach
Date: 2006-07-07 02:09:49 +0000 (Fri, 07 Jul 2006)
New Revision: 16848
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16848
Log:
Add an fsp parameter to the SMB_VFS_OPEN operation. This makes it
possible for modules to add per-fsp data on the open path.
Modified:
trunk/source/include/vfs.h
trunk/source/include/vfs_macros.h
trunk/source/modules/vfs_audit.c
trunk/source/modules/vfs_cap.c
trunk/source/modules/vfs_catia.c
trunk/source/modules/vfs_default.c
trunk/source/modules/vfs_extd_audit.c
trunk/source/modules/vfs_full_audit.c
trunk/source/smbd/open.c
trunk/source/torture/cmd_vfs.c
Changeset:
Modified: trunk/source/include/vfs.h
===================================================================
--- trunk/source/include/vfs.h 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/include/vfs.h 2006-07-07 02:09:49 UTC (rev 16848)
@@ -63,7 +63,8 @@
/* Changed to version 15 as we added the statvfs call. JRA */
/* Changed to version 16 as we added the getlock call. JRA */
/* Changed to version 17 as we removed redundant connection_struct parameters. --jpeach */
-#define SMB_VFS_INTERFACE_VERSION 17
+/* Changed to version 18 to add fsp parameter to the open call -- jpeach */
+#define SMB_VFS_INTERFACE_VERSION 18
/* to bug old modules which are trying to compile with the old functions */
@@ -242,7 +243,7 @@
/* File operations */
- int (*open)(struct vfs_handle_struct *handle, const char *fname, int flags, mode_t mode);
+ int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd);
ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, void *data, size_t n);
ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, void *data, size_t n, SMB_OFF_T offset);
Modified: trunk/source/include/vfs_macros.h
===================================================================
--- trunk/source/include/vfs_macros.h 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/include/vfs_macros.h 2006-07-07 02:09:49 UTC (rev 16848)
@@ -47,7 +47,7 @@
#define SMB_VFS_CLOSEDIR(conn, dir) ((conn)->vfs.ops.closedir((conn)->vfs.handles.closedir, dir))
/* File operations */
-#define SMB_VFS_OPEN(conn, fname, flags, mode) ((conn)->vfs.ops.open((conn)->vfs.handles.open, (fname), (flags), (mode)))
+#define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) ((conn)->vfs.ops.open((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_CLOSE(fsp, fd) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
#define SMB_VFS_READ(fsp, fd, data, n) ((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (fd), (data), (n)))
#define SMB_VFS_PREAD(fsp, fd, data, n, off) ((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (fd), (data), (n), (off)))
@@ -159,7 +159,7 @@
#define SMB_VFS_OPAQUE_CLOSEDIR(conn, dir) ((conn)->vfs_opaque.ops.closedir((conn)->vfs_opaque.handles.closedir, dir))
/* File operations */
-#define SMB_VFS_OPAQUE_OPEN(conn, fname, flags, mode) ((conn)->vfs_opaque.ops.open((conn)->vfs_opaque.handles.open, (fname), (flags), (mode)))
+#define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) ((conn)->vfs_opaque.ops.open((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp), (fd)))
#define SMB_VFS_OPAQUE_READ(fsp, fd, data, n) ((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), (fd), (data), (n)))
#define SMB_VFS_OPAQUE_PREAD(fsp, fd, data, n, off) ((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, (fsp), (fd), (data), (n), (off)))
@@ -272,7 +272,7 @@
#define SMB_VFS_NEXT_CLOSEDIR(handle, dir) ((handle)->vfs_next.ops.closedir((handle)->vfs_next.handles.closedir, dir))
/* File operations */
-#define SMB_VFS_NEXT_OPEN(handle, fname, flags, mode) ((handle)->vfs_next.ops.open((handle)->vfs_next.handles.open, (fname), (flags), (mode)))
+#define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) ((handle)->vfs_next.ops.open((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), (fd)))
#define SMB_VFS_NEXT_READ(handle, fsp, fd, data, n) ((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (fd), (data), (n)))
#define SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, off) ((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (fd), (data), (n), (off)))
Modified: trunk/source/modules/vfs_audit.c
===================================================================
--- trunk/source/modules/vfs_audit.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_audit.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -34,7 +34,7 @@
static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr);
static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode);
static int audit_rmdir(vfs_handle_struct *handle, const char *path);
-static int audit_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode);
+static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname);
static int audit_unlink(vfs_handle_struct *handle, const char *path);
@@ -184,11 +184,11 @@
return result;
}
-static int audit_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode)
+static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
{
int result;
- result = SMB_VFS_NEXT_OPEN(handle, fname, flags, mode);
+ result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n",
fname, result,
Modified: trunk/source/modules/vfs_cap.c
===================================================================
--- trunk/source/modules/vfs_cap.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_cap.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -71,12 +71,12 @@
return SMB_VFS_NEXT_RMDIR(handle, cappath);
}
-static int cap_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode)
+static int cap_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
{
pstring capname;
DEBUG(3,("cap: cap_open for %s\n", fname));
capencode(capname, fname);
- return SMB_VFS_NEXT_OPEN(handle, capname, flags, mode);
+ return SMB_VFS_NEXT_OPEN(handle, capname, fsp, flags, mode);
}
static int cap_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
Modified: trunk/source/modules/vfs_catia.c
===================================================================
--- trunk/source/modules/vfs_catia.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_catia.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -94,14 +94,14 @@
}
static int catia_open(vfs_handle_struct *handle,
- const char *fname, int flags, mode_t mode)
+ const char *fname, files_struct *fsp, int flags, mode_t mode)
{
pstring name;
pstrcpy(name, fname);
to_unix(name);
- return SMB_VFS_NEXT_OPEN(handle, name, flags, mode);
+ return SMB_VFS_NEXT_OPEN(handle, name, fsp, flags, mode);
}
static int catia_rename(vfs_handle_struct *handle,
Modified: trunk/source/modules/vfs_default.c
===================================================================
--- trunk/source/modules/vfs_default.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_default.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -186,7 +186,8 @@
/* File operations */
-static int vfswrap_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode)
+static int vfswrap_open(vfs_handle_struct *handle, const char *fname,
+ files_struct *fsp, int flags, mode_t mode)
{
int result;
Modified: trunk/source/modules/vfs_extd_audit.c
===================================================================
--- trunk/source/modules/vfs_extd_audit.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_extd_audit.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -37,7 +37,7 @@
static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr);
static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode);
static int audit_rmdir(vfs_handle_struct *handle, const char *path);
-static int audit_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode);
+static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname);
static int audit_unlink(vfs_handle_struct *handle, const char *path);
@@ -202,11 +202,11 @@
return result;
}
-static int audit_open(vfs_handle_struct *handle, const char *fname, int flags, mode_t mode)
+static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
{
int result;
- result = SMB_VFS_NEXT_OPEN(handle, fname, flags, mode);
+ result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n",
fname, result,
Modified: trunk/source/modules/vfs_full_audit.c
===================================================================
--- trunk/source/modules/vfs_full_audit.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/modules/vfs_full_audit.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -109,7 +109,7 @@
static int smb_full_audit_closedir(vfs_handle_struct *handle,
SMB_STRUCT_DIR *dirp);
static int smb_full_audit_open(vfs_handle_struct *handle,
- const char *fname, int flags, mode_t mode);
+ const char *fname, files_struct *fsp, int flags, mode_t mode);
static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
int fd, void *data, size_t n);
@@ -1007,11 +1007,11 @@
}
static int smb_full_audit_open(vfs_handle_struct *handle,
- const char *fname, int flags, mode_t mode)
+ const char *fname, files_struct *fsp, int flags, mode_t mode)
{
int result;
- result = SMB_VFS_NEXT_OPEN(handle, fname, flags, mode);
+ result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/smbd/open.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -38,24 +38,29 @@
fd support routines - attempt to do a dos_open.
****************************************************************************/
-static int fd_open(struct connection_struct *conn,
+static BOOL fd_open(struct connection_struct *conn,
const char *fname,
+ files_struct *fsp,
int flags,
mode_t mode)
{
- int fd;
+ int sav;
+
#ifdef O_NOFOLLOW
if (!lp_symlinks(SNUM(conn))) {
flags |= O_NOFOLLOW;
}
#endif
- fd = SMB_VFS_OPEN(conn,fname,flags,mode);
+ fsp->fh->fd = SMB_VFS_OPEN(conn,fname,fsp,flags,mode);
+ sav = errno;
- DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", fname,
- flags, (int)mode, fd, (fd == -1) ? strerror(errno) : "" ));
+ DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n",
+ fname, flags, (int)mode, fsp->fh->fd,
+ (fsp->fh->fd == -1) ? strerror(errno) : "" ));
- return fd;
+ errno = sav;
+ return fsp->fh->fd != -1;
}
/****************************************************************************
@@ -269,8 +274,7 @@
}
/* Actually do the open */
- fsp->fh->fd = fd_open(conn, fname, local_flags, unx_mode);
- if (fsp->fh->fd == -1) {
+ if (!fd_open(conn, fname, fsp, local_flags, unx_mode)) {
DEBUG(3,("Error opening file %s (%s) (local_flags=%d) "
"(flags=%d)\n",
fname,strerror(errno),local_flags,flags));
Modified: trunk/source/torture/cmd_vfs.c
===================================================================
--- trunk/source/torture/cmd_vfs.c 2006-07-07 02:03:04 UTC (rev 16847)
+++ trunk/source/torture/cmd_vfs.c 2006-07-07 02:09:49 UTC (rev 16848)
@@ -200,9 +200,10 @@
static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
- int flags, fd;
+ int flags;
mode_t mode;
const char *flagstr;
+ files_struct *fsp;
mode = 00400;
@@ -278,18 +279,21 @@
}
}
- fd = SMB_VFS_OPEN(vfs->conn, argv[1], flags, mode);
- if (fd == -1) {
+ fsp = SMB_MALLOC_P(struct files_struct);
+ fsp->fsp_name = SMB_STRDUP(argv[1]);
+ fsp->fh = SMB_MALLOC_P(struct fd_handle);
+ fsp->conn = vfs->conn;
+
+ fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, argv[1], fsp, flags, mode);
+ if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
+ SAFE_FREE(fsp->fh);
+ SAFE_FREE(fsp);
return NT_STATUS_UNSUCCESSFUL;
}
- vfs->files[fd] = SMB_MALLOC_P(struct files_struct);
- vfs->files[fd]->fsp_name = SMB_STRDUP(argv[1]);
- vfs->files[fd]->fh = SMB_MALLOC_P(struct fd_handle);
- vfs->files[fd]->fh->fd = fd;
- vfs->files[fd]->conn = vfs->conn;
- printf("open: fd=%d\n", fd);
+ vfs->files[fsp->fh->fd] = fsp;
+ printf("open: fd=%d\n", fsp->fh->fd);
return NT_STATUS_OK;
}
More information about the samba-cvs
mailing list