summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-06 03:38:23 +0000
committerJeremy Allison <jra@samba.org>2000-10-06 03:38:23 +0000
commit186bbe3c47f245817df817d0e49cf91b8d7911d1 (patch)
tree11959640f834f6fb5022a1fc7f7c825e6abfd0fa
parent7a4ba209156b420eb4b34c974ab080d71ded32a8 (diff)
downloadsamba-186bbe3c47f245817df817d0e49cf91b8d7911d1.tar.gz
samba-186bbe3c47f245817df817d0e49cf91b8d7911d1.tar.xz
samba-186bbe3c47f245817df817d0e49cf91b8d7911d1.zip
Restructuring of vfs layer to include a "this" pointer - can be an fsp or
a conn struct depending on the call. We need this to have a clean NT ACL call interface. This will break any existing VFS libraries (that's why this is pre-release code). In addition - added Herb's WITH_PROFILE changes - Herb - please examine the changes I've made to the smbd/reply.c code you added. The original code was very ugly and I have replaced it with a START_PROFILE(x)/END_PROFILE(x) pair using the preprocessor. Please check this compiles ok with the --with-profile switch. Jeremy.
-rw-r--r--source/include/includes.h3
-rw-r--r--source/include/profile.h14
-rw-r--r--source/include/proto.h55
-rw-r--r--source/include/smb.h3
-rw-r--r--source/include/vfs.h259
-rw-r--r--source/locking/posix.c12
-rw-r--r--source/printing/printfsp.c8
-rw-r--r--source/smbd/close.c2
-rw-r--r--source/smbd/conn.c14
-rw-r--r--source/smbd/dir.c8
-rw-r--r--source/smbd/dosmode.c4
-rw-r--r--source/smbd/fileio.c8
-rw-r--r--source/smbd/filename.c6
-rw-r--r--source/smbd/nttrans.c10
-rw-r--r--source/smbd/open.c14
-rw-r--r--source/smbd/reply.c1209
-rw-r--r--source/smbd/service.c44
-rw-r--r--source/smbd/statcache.c2
-rw-r--r--source/smbd/trans2.c28
-rw-r--r--source/smbd/unix_acls.c16
-rw-r--r--source/smbd/vfs-wrap.c52
-rw-r--r--source/smbd/vfs.c62
22 files changed, 435 insertions, 1398 deletions
diff --git a/source/include/includes.h b/source/include/includes.h
index da16ae16320..ad2771665a3 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -637,6 +637,9 @@ extern int errno;
#ifdef WITH_PROFILE
#include "profile.h"
+#else
+#define START_PROFILE(x)
+#define END_PROFILE(x)
#endif
#ifndef MAXCODEPAGELINES
diff --git a/source/include/profile.h b/source/include/profile.h
index 2323b1e7db6..9b6ec462df8 100644
--- a/source/include/profile.h
+++ b/source/include/profile.h
@@ -1,3 +1,5 @@
+#ifndef _PROFILE_H_
+#define _PROFILE_H_
/*
Unix SMB/Netbios implementation.
Version 1.9.
@@ -310,3 +312,15 @@ extern struct profile_struct *profile_p;
#define INC_PROFILE_COUNT(x) if (profile_p) profile_p->x++
#define DEC_PROFILE_COUNT(x) if (profile_p) profile_p->x--
#define ADD_PROFILE_COUNT(x,y) if (profile_p) profile_p->x += (y)
+
+#define START_PROFILE(x) \
+ struct timeval starttime; \
+ struct timeval endtime; \
+ GetTimeOfDay(&starttime); \
+ INC_PROFILE_COUNT(x##_count)
+
+#define END_PROFILE(y) \
+ GetTimeOfDay(&endtime); \
+ ADD_PROFILE_COUNT((y##_time),TvalDiff(&starttime,&endtime))
+
+#endif
diff --git a/source/include/proto.h b/source/include/proto.h
index 11934c32ad4..f6e4ce7fa89 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -3831,44 +3831,43 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd);
/*The following definitions come from smbd/vfs-wrap.c */
-int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
- char *user);
+int vfswrap_dummy_connect(connection_struct *conn, char *service, char *user);
void vfswrap_dummy_disconnect(void);
-SMB_BIG_UINT vfswrap_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize,
+SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
-DIR *vfswrap_opendir(char *fname);
-struct dirent *vfswrap_readdir(DIR *dirp);
-int vfswrap_mkdir(char *path, mode_t mode);
-int vfswrap_rmdir(char *path);
-int vfswrap_closedir(DIR *dirp);
-int vfswrap_open(char *fname, int flags, mode_t mode);
-int vfswrap_close(int fd);
-ssize_t vfswrap_read(int fd, char *data, size_t n);
-ssize_t vfswrap_write(int fd, char *data, size_t n);
-SMB_OFF_T vfswrap_lseek(int filedes, SMB_OFF_T offset, int whence);
-int vfswrap_rename(char *old, char *new);
-int vfswrap_fsync(int fd);
-int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf);
-int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf);
-int vfswrap_lstat(char *path,
- SMB_STRUCT_STAT *sbuf);
-int vfswrap_unlink(char *path);
-int vfswrap_chmod(char *path, mode_t mode);
-int vfswrap_chown(char *path, uid_t uid, gid_t gid);
-int vfswrap_chdir(char *path);
-char *vfswrap_getwd(char *path);
-int vfswrap_utime(char *path, struct utimbuf *times);
-int vfswrap_ftruncate(int fd, SMB_OFF_T offset);
-BOOL vfswrap_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
+DIR *vfswrap_opendir(connection_struct *conn, char *fname);
+struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp);
+int vfswrap_mkdir(connection_struct *conn, char *path, mode_t mode);
+int vfswrap_rmdir(connection_struct *conn, char *path);
+int vfswrap_closedir(connection_struct *conn, DIR *dirp);
+int vfswrap_open(connection_struct *conn, char *fname, int flags, mode_t mode);
+int vfswrap_close(files_struct *fsp, int fd);
+ssize_t vfswrap_read(files_struct *fsp, int fd, char *data, size_t n);
+ssize_t vfswrap_write(files_struct *fsp, int fd, char *data, size_t n);
+SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int whence);
+int vfswrap_rename(connection_struct *conn, char *old, char *new);
+int vfswrap_fsync(files_struct *fsp, int fd);
+int vfswrap_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf);
+int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf);
+int vfswrap_lstat(connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf);
+int vfswrap_unlink(connection_struct *conn, char *path);
+int vfswrap_chmod(connection_struct *conn, char *path, mode_t mode);
+int vfswrap_chown(connection_struct *conn, char *path, uid_t uid, gid_t gid);
+int vfswrap_chdir(connection_struct *conn, char *path);
+char *vfswrap_getwd(connection_struct *conn, char *path);
+int vfswrap_utime(connection_struct *conn, char *path, struct utimbuf *times);
+int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T offset);
+BOOL vfswrap_lock(files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
/*The following definitions come from smbd/vfs.c */
int vfs_init_default(connection_struct *conn);
BOOL vfs_init_custom(connection_struct *conn);
int vfs_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *st);
-int vfs_fstat(connection_struct *conn, int fd, SMB_STRUCT_STAT *st);
+int vfs_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *st);
BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
+int vfs_rmdir(connection_struct *conn, char *fname);
int vfs_unlink(connection_struct *conn, char *fname);
int vfs_chmod(connection_struct *conn, char *fname,mode_t mode);
int vfs_chown(connection_struct *conn, char *fname, uid_t uid, gid_t gid);
diff --git a/source/include/smb.h b/source/include/smb.h
index 02ef9400850..24211b0d50d 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -580,7 +580,8 @@ typedef struct connection_struct
char *origpath;
struct vfs_ops vfs_ops; /* Filesystem operations */
- struct vfs_connection_struct *vfs_conn; /* VFS specific connection stuff */
+ /* Handle on dlopen() call */
+ void *dl_handle;
char *user; /* name of user who *opened* this connection */
uid_t uid; /* uid of user who *opened* this connection */
diff --git a/source/include/vfs.h b/source/include/vfs.h
index bb2239bf285..fb089c86cc7 100644
--- a/source/include/vfs.h
+++ b/source/include/vfs.h
@@ -22,246 +22,65 @@
#ifndef _VFS_H
#define _VFS_H
-/* Types used in the definition of VFS operations. These are included
- here so the vfs.h file can be included by VFS modules without
- having to pull in unnecessary amounts of other stuff. Note to VFS
- writers: you must include config.h before including this file.
- The following type definitions reference the HAVE_* symbols which
- are defined in config.h */
-
-#ifndef SMB_OFF_T
-# ifdef HAVE_OFF64_T
-# define SMB_OFF_T off64_t
-# else
-# define SMB_OFF_T off_t
-# endif
-#endif
-
-#ifndef SMB_STRUCT_STAT
-# if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
-# define SMB_STRUCT_STAT struct stat64
-# else
-# define SMB_STRUCT_STAT struct stat
-# endif
-#endif
-
-#ifndef _BOOL
-typedef int BOOL;
-#endif
-
-#ifndef _PSTRING
-#define PSTRING_LEN 1024
-#define FSTRING_LEN 128
-
-typedef char pstring[PSTRING_LEN];
-typedef char fstring[FSTRING_LEN];
-#define _PSTRING
-#endif
-
-#if defined(HAVE_LONGLONG)
-#define SMB_BIG_UINT unsigned long long
-#else
-#define SMB_BIG_UINT unsigned long
-#endif
-
-#ifndef MAXSUBAUTHS
-#define MAXSUBAUTHS 15 /* max sub authorities in a SID */
-#endif
-
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-#if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
-#if (SIZEOF_INT == 4)
-#define uint32 unsigned int
-#elif (SIZEOF_LONG == 4)
-#define uint32 unsigned long
-#elif (SIZEOF_SHORT == 4)
-#define uint32 unsigned short
-#endif
-#endif
-
-#ifndef _DOM_SID
-/* DOM_SID - security id */
-typedef struct sid_info
-{
- uint8 sid_rev_num; /* SID revision number */
- uint8 num_auths; /* number of sub-authorities */
- uint8 id_auth[6]; /* Identifier Authority */
- /*
- * Note that the values in these uint32's are in *native* byteorder,
- * not neccessarily little-endian...... JRA.
- */
- uint32 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
-
-} DOM_SID;
-#define _DOM_SID
-#endif
-
-#ifndef _SEC_ACCESS
-/* SEC_ACCESS */
-typedef struct security_info_info
-{
- uint32 mask;
-
-} SEC_ACCESS;
-#define _SEC_ACCESS
-#endif
-
-#ifndef _SEC_ACE
-/* SEC_ACE */
-typedef struct security_ace_info
-{
- uint8 type; /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */
- uint8 flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */
- uint16 size;
-
- SEC_ACCESS info;
- DOM_SID sid;
-
-} SEC_ACE;
-#define _SEC_ACE
-#endif
-
-#ifndef ACL_REVISION
-#define ACL_REVISION 0x3
-#endif
-
-#ifndef _SEC_ACL
-/* SEC_ACL */
-typedef struct security_acl_info
-{
- uint16 revision; /* 0x0003 */
- uint16 size; /* size in bytes of the entire ACL structure */
- uint32 num_aces; /* number of Access Control Entries */
-
- SEC_ACE *ace;
-
-} SEC_ACL;
-#define _SEC_ACL
-#endif
-
-#ifndef SEC_DESC_REVISION
-#define SEC_DESC_REVISION 0x1
-#endif
-
-#ifndef _SEC_DESC
-/* SEC_DESC */
-typedef struct security_descriptor_info
-{
- uint16 revision; /* 0x0001 */
- uint16 type; /* SEC_DESC_xxxx flags */
-
- uint32 off_owner_sid; /* offset to owner sid */
- uint32 off_grp_sid ; /* offset to group sid */
- uint32 off_sacl ; /* offset to system list of permissions */
- uint32 off_dacl ; /* offset to list of permissions */
-
- SEC_ACL *dacl; /* user ACL */
- SEC_ACL *sacl; /* system ACL */
- DOM_SID *owner_sid;
- DOM_SID *grp_sid;
-
-} SEC_DESC;
-#define _SEC_DESC
-#endif
-
-/*
- * The complete list of SIDS belonging to this user.
- * Created when a vuid is registered.
- */
-
-#ifndef _NT_USER_TOKEN
-typedef struct _nt_user_token {
- size_t num_sids;
- DOM_SID *user_sids;
-} NT_USER_TOKEN;
-#define _NT_USER_TOKEN
-#endif
-
/* Avoid conflict with an AIX include file */
#ifdef vfs_ops
#undef vfs_ops
#endif
-/* Information from the connection_struct passed to the vfs layer */
-
-struct vfs_connection_struct {
-
- /* Connection information */
-
- BOOL printer;
- BOOL ipc;
- BOOL read_only;
- BOOL admin_user;
-
- /* Handle on dlopen() call */
-
- void *dl_handle;
-
- /* Paths */
-
- pstring dirpath;
- pstring connectpath;
- pstring origpath;
- pstring service;
-
- /* Information on user who *opened* this connection */
-
- pstring user;
- uid_t uid;
- gid_t gid;
- int ngroups;
- gid_t *groups;
- NT_USER_TOKEN *nt_user_token;
-};
+/*
+ * As we're now (thanks Andrew ! :-) using file_structs and connection
+ * structs in the vfs - then anyone writing a vfs must include includes.h...
+ */
/* VFS operations structure */
+struct connection_struct;
+struct files_struct;
+struct security_descriptor_info;
+
struct vfs_ops {
/* Disk operations */
- int (*connect)(struct vfs_connection_struct *conn, char *service, char *user);
- void (*disconnect)(void);
- SMB_BIG_UINT (*disk_free)(char *path, BOOL small_query, SMB_BIG_UINT *bsize,
+ int (*connect)(struct connection_struct *conn, char *service, char *user);
+ void (*disconnect)(struct connection_struct *conn);
+ SMB_BIG_UINT (*disk_free)(struct connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
/* Directory operations */
- DIR *(*opendir)(char *fname);
- struct dirent *(*readdir)(DIR *dirp);
- int (*mkdir)(char *path, mode_t mode);
- int (*rmdir)(char *path);
- int (*closedir)(DIR *dir);
+ DIR *(*opendir)(struct connection_struct *conn, char *fname);
+ struct dirent *(*readdir)(struct connection_struct *conn, DIR *dirp);
+ int (*mkdir)(struct connection_struct *conn, char *path, mode_t mode);
+ int (*rmdir)(struct connection_struct *conn, char *path);
+ int (*closedir)(struct connection_struct *conn, DIR *dir);
/* File operations */
- int (*open)(char *fname, int flags, mode_t mode);
- int (*close)(int fd);
- ssize_t (*read)(int fd, char *data, size_t n);
- ssize_t (*write)(int fd, char *data, size_t n);
- SMB_OFF_T (*lseek)(int filedes, SMB_OFF_T offset, int whence);
- int (*rename)(char *old, char *new);
- int (*fsync)(int fd);
- int (*stat)(char *fname, SMB_STRUCT_STAT *sbuf);
- int (*fstat)(int fd, SMB_STRUCT_STAT *sbuf);
- int (*lstat)(char *path, SMB_STRUCT_STAT *sbuf);
- int (*unlink)(char *path);
- int (*chmod)(char *path, mode_t mode);
- int (*chown)(char *path, uid_t uid, gid_t gid);
- int (*chdir)(char *path);
- char *(*getwd)(char *buf);
- int (*utime)(char *path, struct utimbuf *times);
- int (*ftruncate)(int fd, SMB_OFF_T offset);
- BOOL (*lock)(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
-
- size_t (*fget_nt_acl)(int fd, SEC_DESC **ppdesc);
- size_t (*get_nt_acl)(char *name, SEC_DESC **ppdesc);
- BOOL (*fset_nt_acl)(int fd, uint32 security_info_sent, SEC_DESC *psd);
- BOOL (*set_nt_acl)(char *name, uint32 security_info_sent, SEC_DESC *psd);
+ int (*open)(struct connection_struct *conn, char *fname, int flags, mode_t mode);
+ int (*close)(struct files_struct *fsp, int fd);
+ ssize_t (*read)(struct files_struct *fsp, int fd, char *data, size_t n);
+ ssize_t (*write)(struct files_struct *fsp, int fd, char *data, size_t n);
+ SMB_OFF_T (*lseek)(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence);
+ int (*rename)(struct connection_struct *conn, char *old, char *new);
+ int (*fsync)(struct files_struct *fsp, int fd);
+ int (*stat)(struct connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf);
+ int (*fstat)(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf);
+ int (*lstat)(struct connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf);
+ int (*unlink)(struct connection_struct *conn, char *path);
+ int (*chmod)(struct connection_struct *conn, char *path, mode_t mode);
+ int (*chown)(struct connection_struct *conn, char *path, uid_t uid, gid_t gid);
+ int (*chdir)(struct connection_struct *conn, char *path);
+ char *(*getwd)(struct connection_struct *conn, char *buf);
+ int (*utime)(struct connection_struct *conn, char *path, struct utimbuf *times);
+ int (*ftruncate)(struct files_struct *fsp, int fd, SMB_OFF_T offset);
+ BOOL (*lock)(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
+
+ size_t (*fget_nt_acl)(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc);
+ size_t (*get_nt_acl)(struct connection_struct *conn, char *name, struct security_descriptor_info **ppdesc);
+ BOOL (*fset_nt_acl)(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd);
+ BOOL (*set_nt_acl)(struct connection_struct *conn, char *name, uint32 security_info_sent, struct security_descriptor_info *psd);
};
struct vfs_options {
diff --git a/source/locking/posix.c b/source/locking/posix.c
index 69df55ba3ca..7bac1ffe379 100644
--- a/source/locking/posix.c
+++ b/source/locking/posix.c
@@ -204,7 +204,7 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
/*
* No POSIX to worry about, just close.
*/
- ret = conn->vfs_ops.close(fsp->fd);
+ ret = conn->vfs_ops.close(fsp,fsp->fd);
fsp->fd = -1;
return ret;
}
@@ -259,7 +259,7 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", (unsigned int)count ));
for(i = 0; i < count; i++) {
- if (conn->vfs_ops.close(fd_array[i]) == -1) {
+ if (conn->vfs_ops.close(fsp,fd_array[i]) == -1) {
saved_errno = errno;
}
}
@@ -279,7 +279,7 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
* Finally close the fd associated with this fsp.
*/
- ret = conn->vfs_ops.close(fsp->fd);
+ ret = conn->vfs_ops.close(fsp,fsp->fd);
if (saved_errno != 0) {
errno = saved_errno;
@@ -688,7 +688,7 @@ static BOOL posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OF
DEBUG(8,("posix_fcntl_lock %d %d %.0f %.0f %d\n",fsp->fd,op,(double)offset,(double)count,type));
- ret = conn->vfs_ops.lock(fsp->fd,op,offset,count,type);
+ ret = conn->vfs_ops.lock(fsp,fsp->fd,op,offset,count,type);
if (!ret && (errno == EFBIG)) {
if( DEBUGLVL( 0 )) {
@@ -699,7 +699,7 @@ static BOOL posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OF
/* 32 bit NFS file system, retry with smaller offset */
errno = 0;
count &= 0x7fffffff;
- ret = conn->vfs_ops.lock(fsp->fd,op,offset,count,type);
+ ret = conn->vfs_ops.lock(fsp,fsp->fd,op,offset,count,type);
}
/* A lock query - just return. */
@@ -727,7 +727,7 @@ static BOOL posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OF
count = (orig_count & 0x7FFFFFFF);
offset = (SMB_OFF_T)map_lock_offset(off_high, off_low);
- ret = conn->vfs_ops.lock(fsp->fd,op,offset,count,type);
+ ret = conn->vfs_ops.lock(fsp,fsp->fd,op,offset,count,type);
if (!ret) {
if (errno == EINVAL) {
DEBUG(3,("posix_fcntl_lock: locking not supported? returning True\n"));
diff --git a/source/printing/printfsp.c b/source/printing/printfsp.c
index a1303eb4416..9b5a4877ee2 100644
--- a/source/printing/printfsp.c
+++ b/source/printing/printfsp.c
@@ -50,10 +50,6 @@ files_struct *print_fsp_open(connection_struct *conn,char *jobname)
/* setup a full fsp */
fsp->print_jobid = jobid;
fsp->fd = print_job_fd(jobid);
- conn->vfs_ops.fstat(fsp->fd, &sbuf);
- fsp->mode = sbuf.st_mode;
- fsp->inode = sbuf.st_ino;
- fsp->dev = sbuf.st_dev;
GetTimeOfDay(&fsp->open_time);
fsp->vuid = current_user.vuid;
fsp->size = 0;
@@ -73,6 +69,10 @@ files_struct *print_fsp_open(connection_struct *conn,char *jobname)
string_set(&fsp->fsp_name,print_job_fname(jobid));
fsp->wbmpx_ptr = NULL;
fsp->wcp = NULL;
+ conn->vfs_ops.fstat(fsp,fsp->fd, &sbuf);
+ fsp->mode = sbuf.st_mode;
+ fsp->inode = sbuf.st_ino;
+ fsp->dev = sbuf.st_dev;
conn->num_files_open++;
diff --git a/source/smbd/close.c b/source/smbd/close.c
index f71b6b04f11..62194f73a5c 100644
--- a/source/smbd/close.c
+++ b/source/smbd/close.c
@@ -146,7 +146,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
if (normal_close && delete_on_close) {
DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n",
fsp->fsp_name));
- if(fsp->conn->vfs_ops.unlink(dos_to_unix(fsp->fsp_name, False)) != 0) {
+ if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix(fsp->fsp_name, False)) != 0) {
/*
* This call can potentially fail as another smbd may have
* had the file open with delete on close set and deleted
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index c1f42be0989..cd4ca9ded4d 100644
--- a/source/smbd/conn.c
+++ b/source/smbd/conn.c
@@ -170,19 +170,11 @@ void conn_free(connection_struct *conn)
/* Free vfs_connection_struct */
#ifdef HAVE_LIBDL
- if (conn->vfs_conn != NULL) {
+ if (conn->dl_handle != NULL) {
/* Close dlopen() handle */
- if (conn->vfs_conn->dl_handle) {
- dlclose(conn->vfs_conn->dl_handle);
- }
-#endif /* HAVE_LIBDL */
-
- if (conn->vfs_conn->groups != NULL) {
- free(conn->vfs_conn->groups);
- }
- delete_nt_token(&conn->vfs_conn->nt_user_token);
- free(conn->vfs_conn);
+ dlclose(conn->dl_handle);
}
+#endif /* HAVE_LIBDL */
DLIST_REMOVE(Connections, conn);
diff --git a/source/smbd/dir.c b/source/smbd/dir.c
index aaab206a26d..bf15be2f1cf 100644
--- a/source/smbd/dir.c
+++ b/source/smbd/dir.c
@@ -627,7 +627,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
pstrcpy(pathreal,path);
pstrcat(path,fname);
pstrcat(pathreal,dname);
- if (conn->vfs_ops.stat(dos_to_unix(pathreal, False), &sbuf) != 0)
+ if (conn->vfs_ops.stat(conn,dos_to_unix(pathreal, False), &sbuf) != 0)
{
DEBUG(5,("Couldn't stat 1 [%s]. Error = %s\n",path, strerror(errno) ));
continue;
@@ -673,13 +673,13 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
{
Dir *dirp;
char *n;
- DIR *p = conn->vfs_ops.opendir(dos_to_unix(name,False));
+ DIR *p = conn->vfs_ops.opendir(conn,dos_to_unix(name,False));
int used=0;
if (!p) return(NULL);
dirp = (Dir *)malloc(sizeof(Dir));
if (!dirp) {
- conn->vfs_ops.closedir(p);
+ conn->vfs_ops.closedir(conn,p);
return(NULL);
}
dirp->pos = dirp->numentries = dirp->mallocsize = 0;
@@ -714,7 +714,7 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
dirp->numentries++;
}
- conn->vfs_ops.closedir(p);
+ conn->vfs_ops.closedir(conn,p);
return((void *)dirp);
}
diff --git a/source/smbd/dosmode.c b/source/smbd/dosmode.c
index 269d2865176..377cfbb7cfd 100644
--- a/source/smbd/dosmode.c
+++ b/source/smbd/dosmode.c
@@ -243,7 +243,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
errno = 0;
- if(conn->vfs_ops.utime(dos_to_unix(fname, False), times) == 0)
+ if(conn->vfs_ops.utime(conn,dos_to_unix(fname, False), times) == 0)
return 0;
if((errno != EPERM) && (errno != EACCES))
@@ -271,7 +271,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
current_user.ngroups,current_user.groups)))) {
/* We are allowed to become root and change the filetime. */
become_root();
- ret = conn->vfs_ops.utime(dos_to_unix(fname, False), times);
+ ret = conn->vfs_ops.utime(conn,dos_to_unix(fname, False), times);
unbecome_root();
}
}
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c
index 0c43a255dce..b8a0585d90e 100644
--- a/source/smbd/fileio.c
+++ b/source/smbd/fileio.c
@@ -38,7 +38,7 @@ SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
if (fsp->print_file && lp_postscript(fsp->conn->service))
offset = 3;
- seek_ret = fsp->conn->vfs_ops.lseek(fsp->fd,pos+offset,SEEK_SET);
+ seek_ret = fsp->conn->vfs_ops.lseek(fsp,fsp->fd,pos+offset,SEEK_SET);
/*
* We want to maintain the fiction that we can seek
@@ -117,7 +117,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
}
if (n > 0) {
- readret = fsp->conn->vfs_ops.read(fsp->fd,data,n);
+ readret = fsp->conn->vfs_ops.read(fsp,fsp->fd,data,n);
if (readret == -1)
return -1;
if (readret > 0) ret += readret;
@@ -164,7 +164,7 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
SMB_STRUCT_STAT st;
fsp->modified = True;
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&st) == 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp,fsp->fd,&st) == 0) {
int dosmode = dos_mode(fsp->conn,fsp->fsp_name,&st);
if (MAP_ARCHIVE(fsp->conn) && !IS_DOS_ARCHIVE(dosmode)) {
file_chmod(fsp->conn,fsp->fsp_name,dosmode | aARCH,&st);
@@ -683,7 +683,7 @@ void sync_file(connection_struct *conn, files_struct *fsp)
{
if(lp_strict_sync(SNUM(conn)) && fsp->fd != -1) {
flush_write_cache(fsp, SYNC_FLUSH);
- conn->vfs_ops.fsync(fsp->fd);
+ conn->vfs_ops.fsync(fsp,fsp->fd);
}
}
#undef OLD_NTDOMAIN
diff --git a/source/smbd/filename.c b/source/smbd/filename.c
index 67fa85d9cbd..9ac82386f92 100644
--- a/source/smbd/filename.c
+++ b/source/smbd/filename.c
@@ -211,7 +211,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component,
* stat the name - if it exists then we are all done!
*/
- if (conn->vfs_ops.stat(dos_to_unix(name,False),&st) == 0) {
+ if (conn->vfs_ops.stat(conn,dos_to_unix(name,False),&st) == 0) {
stat_cache_add(orig_path, name);
DEBUG(5,("conversion finished %s -> %s\n",orig_path, name));
if(pst)
@@ -277,7 +277,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component,
* Check if the name exists up to this point.
*/
- if (conn->vfs_ops.stat(dos_to_unix(name,False), &st) == 0) {
+ if (conn->vfs_ops.stat(conn,dos_to_unix(name,False), &st) == 0) {
/*
* It exists. it must either be a directory or this must be
* the last part of the path for it to be OK.
@@ -429,7 +429,7 @@ BOOL check_name(char *name,connection_struct *conn)
if (!lp_symlinks(SNUM(conn)))
{
SMB_STRUCT_STAT statbuf;
- if ( (conn->vfs_ops.lstat(dos_to_unix(name,False),&statbuf) != -1) &&
+ if ( (conn->vfs_ops.lstat(conn,dos_to_unix(name,False),&statbuf) != -1) &&
(S_ISLNK(statbuf.st_mode)) )
{
DEBUG(3,("check_name: denied: file path name %s is a symlink\n",name));
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 95010cddc84..86b85ea766e 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -892,13 +892,13 @@ int reply_ntcreate_and_X(connection_struct *conn,
}
if(fsp->is_directory) {
- if(conn->vfs_ops.stat(dos_to_unix(fsp->fsp_name, False), &sbuf) != 0) {
+ if(conn->vfs_ops.stat(conn,dos_to_unix(fsp->fsp_name, False), &sbuf) != 0) {
close_file(fsp,True);
restore_case_semantics(file_attributes);
return(ERROR(ERRDOS,ERRnoaccess));
}
} else {
- if (conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
restore_case_semantics(file_attributes);
return(ERROR(ERRDOS,ERRnoaccess));
@@ -1223,7 +1223,7 @@ static int call_nt_transact_create(connection_struct *conn,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if(conn->vfs_ops.stat(dos_to_unix(fsp->fsp_name, False),
+ if(conn->vfs_ops.stat(conn,dos_to_unix(fsp->fsp_name, False),
&sbuf) != 0) {
close_file(fsp,True);
restore_case_semantics(file_attributes);
@@ -1293,13 +1293,13 @@ static int call_nt_transact_create(connection_struct *conn,
}
if(fsp->is_directory) {
- if(conn->vfs_ops.stat(dos_to_unix(fsp->fsp_name,False), &sbuf) != 0) {
+ if(conn->vfs_ops.stat(conn,dos_to_unix(fsp->fsp_name,False), &sbuf) != 0) {
close_file(fsp,True);
restore_case_semantics(file_attributes);
return(ERROR(ERRDOS,ERRnoaccess));
}
} else {
- if (!fsp->stat_open && conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (!fsp->stat_open && conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
restore_case_semantics(file_attributes);
return(ERROR(ERRDOS,ERRnoaccess));
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 4964e15e010..edd94bd8653 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -41,13 +41,13 @@ static int fd_open(struct connection_struct *conn, char *fname,
flags |= O_NONBLOCK;
#endif
- fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode);
+ fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),flags,mode);
/* Fix for files ending in '.' */
if((fd == -1) && (errno == ENOENT) &&
(strchr(fname,'.')==NULL)) {
pstrcat(fname,".");
- fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode);
+ fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),flags,mode);
}
DEBUG(10,("fd_open: name %s, mode = %d, fd = %d. %s\n", fname, (int)mode, fd,
@@ -138,7 +138,7 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
return False;
}
- if (conn->vfs_ops.fstat(fsp->fd, &sbuf) == -1) {
+ if (conn->vfs_ops.fstat(fsp,fsp->fd, &sbuf) == -1) {
DEBUG(0,("Error doing fstat on open file %s (%s)\n", fname,strerror(errno) ));
fd_close(conn, fsp);
return False;
@@ -213,7 +213,7 @@ static int truncate_unless_locked(struct connection_struct *conn, files_struct *
unix_ERR_code = ERRlock;
return -1;
} else {
- return conn->vfs_ops.ftruncate(fsp->fd,0);
+ return conn->vfs_ops.ftruncate(fsp,fsp->fd,0);
}
}
@@ -792,7 +792,7 @@ files_struct *open_file_stat(connection_struct *conn,
if(!fsp)
return NULL;
- if(conn->vfs_ops.stat(dos_to_unix(fname, False), pst) < 0) {
+ if(conn->vfs_ops.stat(conn,dos_to_unix(fname, False), pst) < 0) {
DEBUG(0,("open_file_stat: unable to stat name = %s. Error was %s\n",
fname, strerror(errno) ));
file_free(fsp);
@@ -862,7 +862,7 @@ files_struct *open_directory(connection_struct *conn,
if(!fsp)
return NULL;
- if(conn->vfs_ops.stat(dos_to_unix(fname, False), &st) == 0) {
+ if(conn->vfs_ops.stat(conn,dos_to_unix(fname, False), &st) == 0) {
got_stat = True;
}
@@ -983,7 +983,7 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
SMB_DEV_T dev;
SMB_INO_T inode;
- if (conn->vfs_ops.stat(dos_to_unix(fname,False),&sbuf) == -1)
+ if (conn->vfs_ops.stat(conn,dos_to_unix(fname,False),&sbuf) == -1)
return(True);
dev = sbuf.st_dev;
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index a554e319e26..e64875a8058 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -214,13 +214,7 @@ int reply_tcon(connection_struct *conn,
uint16 vuid = SVAL(inbuf,smb_uid);
int pwlen=0;
int ecode = -1;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBtcon_count);
-#endif
+ START_PROFILE(SMBtcon);
*service = *user = *password = *dev = 0;
@@ -249,10 +243,7 @@ int reply_tcon(connection_struct *conn,
conn = make_connection(service,user,password,pwlen,dev,vuid,&ecode);
if (!conn) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtcon_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtcon);
return(connection_error(inbuf,outbuf,ecode));
}
@@ -264,10 +255,7 @@ int reply_tcon(connection_struct *conn,
DEBUG(3,("tcon service=%s user=%s cnum=%d\n",
service, user, conn->cnum));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtcon_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtcon);
return(outsize);
}
@@ -286,13 +274,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
int passlen = SVAL(inbuf,smb_vwv3);
char *path;
char *p;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBtconX_count);
-#endif
+ START_PROFILE(SMBtconX);
*service = *user = *password = *devicename = 0;
@@ -317,10 +299,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
p = strchr(path+2,'\\');
if (!p) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtconX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtconX);
return(ERROR(ERRDOS,ERRnosuchshare));
}
fstrcpy(service,p+1);
@@ -355,10 +334,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
conn = make_connection(service,user,password,passlen,devicename,vuid,&ecode);
if (!conn) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtconX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtconX);
return(connection_error(inbuf,outbuf,ecode));
}
@@ -391,10 +367,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
SSVAL(inbuf,smb_tid,conn->cnum);
SSVAL(outbuf,smb_tid,conn->cnum);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtconX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtconX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -426,13 +399,7 @@ int reply_ioctl(connection_struct *conn,
int replysize, outsize;
char *p;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBioctl_count);
-#endif
+ START_PROFILE(SMBioctl);
DEBUG(4, ("Received IOCTL (code 0x%x)\n", ioctl_code));
@@ -442,10 +409,7 @@ int reply_ioctl(connection_struct *conn,
replysize = 32;
break;
default:
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBioctl_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBioctl);
return(ERROR(ERRSRV,ERRnosupport));
}
@@ -464,10 +428,7 @@ int reply_ioctl(connection_struct *conn,
break;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBioctl_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBioctl);
return outsize;
}
@@ -704,13 +665,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
static BOOL done_sesssetup = False;
BOOL doencrypt = SMBENCRYPT();
char *domain = "";
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsesssetupX_count);
-#endif
+ START_PROFILE(SMBsesssetupX);
*smb_apasswd = 0;
*smb_ntpasswd = 0;
@@ -859,10 +814,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
/* say yes to everything ending in $. */
if (*user && (user[strlen(user) - 1] == '$') && (smb_apasslen == 24) && (smb_ntpasslen == 24)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return session_trust_account(conn, inbuf, outbuf, user,
smb_apasswd, smb_apasslen,
smb_ntpasswd, smb_ntpasslen);
@@ -878,10 +830,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
*/
if (!*user && !*smb_apasswd && !*domain) {
DEBUG(0, ("restrict anonymous is True and anonymous connection attempted. Denying access.\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return(ERROR(ERRDOS,ERRnoaccess));
}
}
@@ -979,10 +928,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
if (lp_map_to_guest() == NEVER_MAP_TO_GUEST)
{
DEBUG(1,("Rejecting user '%s': authentication failed\n", user));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return bad_password_error(inbuf,outbuf);
}
@@ -991,10 +937,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
if (smb_getpwnam(user,True))
{
DEBUG(1,("Rejecting user '%s': bad password\n", user));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return bad_password_error(inbuf,outbuf);
}
}
@@ -1050,10 +993,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
const struct passwd *pw = smb_getpwnam(user,False);
if (!pw) {
DEBUG(1,("Username %s is invalid on this system\n",user));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return bad_password_error(inbuf,outbuf);
}
gid = pw->pw_gid;
@@ -1078,10 +1018,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
done_sesssetup = True;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsesssetupX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsesssetupX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -1097,13 +1034,7 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
BOOL ok = False;
BOOL bad_path = False;
SMB_STRUCT_STAT st;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBchkpth_count);
-#endif
+ START_PROFILE(SMBchkpth_count);
pstrcpy(name,smb_buf(inbuf) + 1);
@@ -1150,10 +1081,7 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
DEBUG(3,("chkpth %s mode=%d\n", name, mode));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBchkpth_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBchkpth);
return(outsize);
}
@@ -1171,13 +1099,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
SMB_OFF_T size=0;
time_t mtime=0;
BOOL bad_path = False;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBgetatr_count);
-#endif
+ START_PROFILE(SMBgetatr);
pstrcpy(fname,smb_buf(inbuf) + 1);
@@ -1222,10 +1144,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBgetatr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBgetatr);
return(UNIXERROR(ERRDOS,ERRbadfile));
}
@@ -1248,10 +1167,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
DEBUG( 3, ( "getatr name=%s mode=%d size=%d\n", fname, mode, (uint32)size ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBgetatr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBgetatr);
return(outsize);
}
@@ -1268,13 +1184,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
time_t mtime;
SMB_STRUCT_STAT st;
BOOL bad_path = False;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsetatr_count);
-#endif
+ START_PROFILE(SMBsetatr);
pstrcpy(fname,smb_buf(inbuf) + 1);
unix_convert(fname,conn,0,&bad_path,&st);
@@ -1297,10 +1207,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsetatr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsetatr);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -1308,10 +1215,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
DEBUG( 3, ( "setatr name=%s mode=%d\n", fname, mode ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsetatr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsetatr);
return(outsize);
}
@@ -1323,15 +1227,9 @@ int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
{
int outsize = 0;
SMB_BIG_UINT dfree,dsize,bsize;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBdskattr_count);
-#endif
+ START_PROFILE(SMBdskattr);
- conn->vfs_ops.disk_free(".",True,&bsize,&dfree,&dsize);
+ conn->vfs_ops.disk_free(conn,".",True,&bsize,&dfree,&dsize);
outsize = set_message(outbuf,5,0,True);
@@ -1342,10 +1240,7 @@ int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
DEBUG(3,("dskattr dfree=%d\n", (unsigned int)dfree));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBdskattr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBdskattr);
return(outsize);
}
@@ -1378,13 +1273,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
BOOL expect_close = False;
BOOL can_open = True;
BOOL bad_path = False;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsearch_count);
-#endif
+ START_PROFILE(SMBsearch);
*mask = *directory = *fname = 0;
@@ -1465,16 +1354,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsearch_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsearch);
return (UNIXERROR(ERRDOS,ERRnofids));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsearch_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsearch);
return(ERROR(ERRDOS,ERRnofids));
}
dptr_set_wcard(dptr_num, strdup(mask));
@@ -1565,10 +1448,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
smb_fn_name(CVAL(inbuf,smb_com)),
mask, directory, dirtype, numentries, maxentries ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsearch_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsearch);
return(outsize);
}
@@ -1583,13 +1463,7 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
char *path;
char status[21];
int dptr_num= -2;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBfclose_count);
-#endif
+ START_PROFILE(SMBfclose);
outsize = set_message(outbuf,1,0,True);
path = smb_buf(inbuf) + 1;
@@ -1597,10 +1471,7 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
if (status_len == 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBfclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBfclose);
return(ERROR(ERRSRV,ERRsrverror));
}
@@ -1615,10 +1486,7 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
DEBUG(3,("search close\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBfclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBfclose);
return(outsize);
}
@@ -1641,13 +1509,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
BOOL bad_path = False;
files_struct *fsp;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBopen_count);
-#endif
+ START_PROFILE(SMBopen);
share_mode = SVAL(inbuf,smb_vwv0);
@@ -1669,19 +1531,13 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopen);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (vfs_fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopen);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1692,10 +1548,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if (fmode & aDIR) {
DEBUG(3,("attempt to open a directory %s\n",fname));
close_file(fsp,False);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopen);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1715,10 +1568,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if(EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type))
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopen);
return(outsize);
}
@@ -1749,27 +1599,15 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
int smb_action = 0;
BOOL bad_path = False;
files_struct *fsp;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBopenX_count);
-#endif
+ START_PROFILE(SMBopenX);
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(conn)) {
if (lp_nt_pipe_support()) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return reply_open_pipe_and_X(conn, inbuf,outbuf,length,bufsize);
} else {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return (ERROR(ERRSRV,ERRaccess));
}
}
@@ -1794,19 +1632,13 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (vfs_fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1815,10 +1647,7 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
close_file(fsp,False);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1859,10 +1688,7 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
SSVAL(outbuf,smb_vwv8,rmode);
SSVAL(outbuf,smb_vwv11,smb_action);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBopenX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBopenX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -1874,13 +1700,7 @@ int reply_ulogoffX(connection_struct *conn, char *inbuf,char *outbuf,int length,
{
uint16 vuid = SVAL(inbuf,smb_uid);
user_struct *vuser = get_valid_user_struct(vuid);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBulogoffX_count);
-#endif
+ START_PROFILE(SMBulogoffX);
if(vuser == 0) {
DEBUG(3,("ulogoff, vuser id %d does not map to user.\n", vuid));
@@ -1898,10 +1718,7 @@ int reply_ulogoffX(connection_struct *conn, char *inbuf,char *outbuf,int length,
DEBUG( 3, ( "ulogoffX vuid=%d\n", vuid ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBulogoffX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBulogoffX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -1920,13 +1737,7 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
BOOL bad_path = False;
files_struct *fsp;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBcreate_count);
-#endif
+ START_PROFILE(SMBcreate);
com = SVAL(inbuf,smb_com);
@@ -1966,10 +1777,7 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcreate_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcreate);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -1987,10 +1795,7 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 3, ( "mknew %s fd=%d dmode=%d umode=%o\n",
fname, fsp->fd, createmode, (int)unixmode ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcreate_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcreate);
return(outsize);
}
@@ -2008,13 +1813,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
BOOL bad_path = False;
files_struct *fsp;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBctemp_count);
-#endif
+ START_PROFILE(SMBctemp);
createmode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
@@ -2040,10 +1839,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBctemp_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBctemp);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2063,10 +1859,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 3, ( "ctemp %s fd=%d dmode=%d umode=%o\n",
fname2, fsp->fd, createmode, (int)unixmode ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBctemp_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBctemp);
return(outsize);
}
@@ -2081,7 +1874,7 @@ static BOOL can_delete(char *fname,connection_struct *conn, int dirtype)
if (!CAN_WRITE(conn)) return(False);
- if (conn->vfs_ops.lstat(dos_to_unix(fname,False),&sbuf) != 0) return(False);
+ if (conn->vfs_ops.lstat(conn,dos_to_unix(fname,False),&sbuf) != 0) return(False);
fmode = dos_mode(conn,fname,&sbuf);
if (fmode & aDIR) return(False);
if (!lp_delete_readonly(SNUM(conn))) {
@@ -2111,13 +1904,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
BOOL exists=False;
BOOL bad_path = False;
BOOL rc = True;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBunlink_count);
-#endif
+ START_PROFILE(SMBunlink);
*directory = *mask = 0;
@@ -2191,7 +1978,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
error = ERRnoaccess;
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
if (!can_delete(fname,conn,dirtype)) continue;
- if (!conn->vfs_ops.unlink(dos_to_unix(fname,False))) count++;
+ if (!vfs_unlink(conn,fname)) count++;
DEBUG(3,("reply_unlink : doing unlink on %s\n",fname));
}
CloseDir(dirptr);
@@ -2200,10 +1987,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
if (count == 0) {
if (exists) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBunlink_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBunlink);
return(ERROR(ERRDOS,error));
} else
{
@@ -2212,20 +1996,14 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBunlink_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBunlink);
return(UNIXERROR(ERRDOS,error));
}
}
outsize = set_message(outbuf,0,0,True);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBunlink_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBunlink);
return(outsize);
}
@@ -2242,13 +2020,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
char *header = outbuf;
ssize_t ret=0;
files_struct *fsp;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBreadbraw_count);
-#endif
+ START_PROFILE(SMBreadbraw);
/*
* Special check if an oplock break has been issued
@@ -2261,10 +2033,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
_smb_setlen(header,0);
transfer_file(0,smbd_server_fd(),(SMB_OFF_T)0,header,4,0);
DEBUG(5,("readbraw - oplock break finished\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadbraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadbraw);
return -1;
}
@@ -2277,10 +2046,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
DEBUG(3,("fnum %d not open in readbraw - cache prime?\n",(int)SVAL(inbuf,smb_vwv0)));
_smb_setlen(header,0);
transfer_file(0,smbd_server_fd(),(SMB_OFF_T)0,header,4,0);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadbraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadbraw);
return(-1);
}
@@ -2308,10 +2074,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
64 bit offsets.\n", (unsigned int)IVAL(inbuf,smb_vwv8) ));
_smb_setlen(header,0);
transfer_file(0,smbd_server_fd(),(SMB_OFF_T)0,header,4,0);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadbraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadbraw);
return(-1);
}
@@ -2322,10 +2085,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
(double)startpos ));
_smb_setlen(header,0);
transfer_file(0,smbd_server_fd(),(SMB_OFF_T)0,header,4,0);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadbraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadbraw);
return(-1);
}
}
@@ -2344,7 +2104,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (size < sizeneeded)
{
SMB_STRUCT_STAT st;
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&st) == 0)
+ if (vfs_fstat(fsp,fsp->fd,&st) == 0)
size = st.st_size;
if (!fsp->can_write)
fsp->size = size;
@@ -2367,7 +2127,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
_smb_setlen(header,nread);
if ((nread-predict) > 0) {
- if(conn->vfs_ops.seek(fsp,startpos + predict) == -1) {
+ if(conn->vfs_ops.seek(fsp,fsp->fd,startpos + predict) == -1) {
DEBUG(0,("reply_readbraw: ERROR: seek_file failed.\n"));
ret = 0;
seek_fail = True;
@@ -2375,7 +2135,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
}
if(!seek_fail)
- ret = (ssize_t)vfs_transfer_file(-1, fsp->fd, Client, NULL,
+ ret = (ssize_t)vfs_transfer_file(-1, fsp, fsp->fd, Client, NULL,
(SMB_OFF_T)(nread-predict),header,4+predict,
startpos+predict);
}
@@ -2393,10 +2153,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
#endif /* UNSAFE_READRAW */
DEBUG(5,("readbraw finished\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadbraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadbraw);
return -1;
}
@@ -2414,13 +2171,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBlockread_count);
-#endif
+ START_PROFILE(SMBlockread);
CHECK_FSP(fsp,conn);
CHECK_READ(fsp);
@@ -2448,26 +2199,17 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
* onto the blocking lock queue.
*/
if(push_blocking_lock_request(inbuf, length, -1, 0))
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockread);
return -1;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockread);
return (ERROR(eclass,ecode));
}
nread = read_file(fsp,data,startpos,numtoread);
if (nread < 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockread);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2479,10 +2221,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
DEBUG( 3, ( "lockread fnum=%d num=%d nread=%d\n",
fsp->fnum, (int)numtoread, (int)nread ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockread);
return(outsize);
}
@@ -2499,13 +2238,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int
SMB_OFF_T startpos;
int outsize = 0;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBread_count);
-#endif
+ START_PROFILE(SMBread);
CHECK_FSP(fsp,conn);
CHECK_READ(fsp);
@@ -2519,10 +2252,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int
data = smb_buf(outbuf) + 3;
if (is_locked(fsp,conn,(SMB_BIG_UINT)numtoread,(SMB_BIG_UINT)startpos, READ_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBread);
return(ERROR(ERRDOS,ERRlock));
}
@@ -2530,10 +2260,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int
nread = read_file(fsp,data,startpos,numtoread);
if (nread < 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBread);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2546,10 +2273,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int
DEBUG( 3, ( "read fnum=%d num=%d nread=%d\n",
fsp->fnum, (int)numtoread, (int)nread ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBread_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBread);
return(outsize);
}
@@ -2565,20 +2289,11 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
size_t smb_mincnt = SVAL(inbuf,smb_vwv6);
ssize_t nread = -1;
char *data;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBreadX_count);
-#endif
+ START_PROFILE(SMBreadX);
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadX);
return reply_pipe_read_and_X(inbuf,outbuf,length,bufsize);
}
@@ -2605,10 +2320,7 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
if(IVAL(inbuf,smb_vwv10) != 0) {
DEBUG(0,("reply_read_and_X - large offset (%x << 32) used and we don't support \
64 bit offsets.\n", (unsigned int)IVAL(inbuf,smb_vwv10) ));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadX);
return(ERROR(ERRDOS,ERRbadaccess));
}
@@ -2617,19 +2329,13 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
}
if (is_locked(fsp,conn,(SMB_BIG_UINT)smb_maxcnt,(SMB_BIG_UINT)startpos, READ_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadX);
return(ERROR(ERRDOS,ERRlock));
}
nread = read_file(fsp,data,startpos,smb_maxcnt);
if (nread < 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2640,10 +2346,7 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
DEBUG( 3, ( "readX fnum=%d min=%d max=%d nread=%d\n",
fsp->fnum, (int)smb_mincnt, (int)smb_maxcnt, (int)nread ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -2662,13 +2365,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
BOOL write_through;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwritebraw_count);
-#endif
+ START_PROFILE(SMBwritebraw);
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@@ -2693,10 +2390,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
CVAL(outbuf,smb_com) = SMBwritec;
if (is_locked(fsp,conn,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwritebraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwritebraw);
return(ERROR(ERRDOS,ERRlock));
}
@@ -2707,10 +2401,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
fsp->fnum, (double)startpos, (int)numtowrite, (int)nwritten, (int)write_through));
if (nwritten < numtowrite) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwritebraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwritebraw);
return(UNIXERROR(ERRHRD,ERRdiskfull));
}
@@ -2761,10 +2452,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
/* we won't return a status if write through is not selected - this
follows what WfWg does */
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwritebraw_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwritebraw);
if (!write_through && total_written==tcount) {
return(-1);
}
@@ -2786,13 +2474,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwriteunlock_count);
-#endif
+ START_PROFILE(SMBwriteunlock);
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@@ -2803,10 +2485,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz
data = smb_buf(inbuf) + 3;
if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteunlock);
return(ERROR(ERRDOS,ERRlock));
}
@@ -2822,18 +2501,12 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz
sync_file(conn,fsp);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteunlock);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
if(!do_unlock(fsp, conn, (SMB_BIG_UINT)numtowrite, (SMB_BIG_UINT)startpos, &eclass, &ecode)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteunlock);
return(ERROR(eclass,ecode));
}
@@ -2844,10 +2517,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz
DEBUG( 3, ( "writeunlock fnum=%d num=%d wrote=%d\n",
fsp->fnum, (int)numtowrite, (int)nwritten ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteunlock);
return(outsize);
}
@@ -2862,20 +2532,11 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
char *data;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwrite_count);
-#endif
+ START_PROFILE(SMBwrite);
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwrite_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwrite);
return reply_pipe_write(inbuf,outbuf,size,dum_buffsize);
}
@@ -2888,10 +2549,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
data = smb_buf(inbuf) + 3;
if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwrite_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwrite);
return(ERROR(ERRDOS,ERRlock));
}
@@ -2908,10 +2566,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
sync_file(conn,fsp);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwrite_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwrite);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2927,10 +2582,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
DEBUG(3,("write fnum=%d num=%d wrote=%d\n",
fsp->fnum, (int)numtowrite, (int)nwritten));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwrite_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwrite);
return(outsize);
}
@@ -2947,20 +2599,11 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
ssize_t nwritten = -1;
unsigned int smb_doff = SVAL(inbuf,smb_vwv11);
char *data;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwriteX_count);
-#endif
+ START_PROFILE(SMBwriteX);
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return reply_pipe_write_and_X(inbuf,outbuf,length,bufsize);
}
@@ -2969,10 +2612,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
CHECK_ERROR(fsp);
if(smb_doff > smb_len(inbuf)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return(ERROR(ERRDOS,ERRbadmem));
}
@@ -2994,10 +2634,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
if(IVAL(inbuf,smb_vwv12) != 0) {
DEBUG(0,("reply_write_and_X - large offset (%x << 32) used and we don't support \
64 bit offsets.\n", (unsigned int)IVAL(inbuf,smb_vwv12) ));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return(ERROR(ERRDOS,ERRbadaccess));
}
@@ -3005,10 +2642,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
}
if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return(ERROR(ERRDOS,ERRlock));
}
@@ -3022,10 +2656,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
nwritten = write_file(fsp,data,startpos,numtowrite);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -3044,10 +2675,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
if (lp_syncalways(SNUM(conn)) || write_through)
sync_file(conn,fsp);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -3063,13 +2691,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
int mode,umode;
int outsize = 0;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBlseek_count);
-#endif
+ START_PROFILE(SMBlseek);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
@@ -3087,7 +2709,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
umode = SEEK_SET; break;
}
- if((res = conn->vfs_ops.lseek(fsp->fd,startpos,umode)) == -1) {
+ if((res = conn->vfs_ops.lseek(fsp,fsp->fd,startpos,umode)) == -1) {
/*
* Check for the special case where a seek before the start
* of the file sets the offset to zero. Added in the CIFS spec,
@@ -3099,11 +2721,8 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if(umode == SEEK_CUR) {
- if((current_pos = conn->vfs_ops.lseek(fsp->fd,0,SEEK_CUR)) == -1) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlseek_time,TvalDiff(&starttime,&endtime));
-#endif
+ if((current_pos = conn->vfs_ops.lseek(fsp,fsp->fd,0,SEEK_CUR)) == -1) {
+ END_PROFILE(SMBlseek);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -3113,11 +2732,8 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
SMB_STRUCT_STAT sbuf;
- if(conn->vfs_ops.fstat(fsp->fd, &sbuf) == -1) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlseek_time,TvalDiff(&starttime,&endtime));
-#endif
+ if(vfs_fstat(fsp,fsp->fd, &sbuf) == -1) {
+ END_PROFILE(SMBlseek);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -3125,14 +2741,11 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
}
if(current_pos < 0)
- res = conn->vfs_ops.lseek(fsp->fd,0,SEEK_SET);
+ res = conn->vfs_ops.lseek(fsp,fsp->fd,0,SEEK_SET);
}
if(res == -1) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlseek_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlseek);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
}
@@ -3145,10 +2758,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
DEBUG(3,("lseek fnum=%d ofs=%.0f newpos = %.0f mode=%d\n",
fsp->fnum, (double)startpos, (double)res, mode));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlseek_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlseek);
return(outsize);
}
@@ -3160,13 +2770,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int
{
int outsize = set_message(outbuf,0,0,True);
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBflush_count);
-#endif
+ START_PROFILE(SMBflush);
if (fsp) {
CHECK_FSP(fsp,conn);
@@ -3180,10 +2784,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int
}
DEBUG(3,("flush\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBflush_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBflush);
return(outsize);
}
@@ -3195,21 +2796,12 @@ int reply_exit(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBexit_count);
-#endif
+ START_PROFILE(SMBexit);
outsize = set_message(outbuf,0,0,True);
DEBUG(3,("exit\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBexit_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBexit);
return(outsize);
}
@@ -3224,22 +2816,13 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
time_t mtime;
int32 eclass = 0, err = 0;
files_struct *fsp = NULL;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBclose_count);
-#endif
+ START_PROFILE(SMBclose);
outsize = set_message(outbuf,0,0,True);
/* If it's an IPC, pass off to the pipe handler. */
if (IS_IPC(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBclose);
return reply_pipe_close(conn, inbuf,outbuf);
}
@@ -3250,10 +2833,7 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
*/
if(!fsp || (fsp->conn != conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBclose);
return(ERROR(ERRDOS,ERRbadfid));
}
@@ -3302,27 +2882,18 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
if((close_err = close_file(fsp,True)) != 0) {
errno = close_err;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBclose);
return (UNIXERROR(ERRHRD,ERRgeneral));
}
}
/* We have a cached error */
if(eclass || err) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBclose);
return(ERROR(eclass,err));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBclose);
return(outsize);
}
@@ -3342,13 +2913,7 @@ int reply_writeclose(connection_struct *conn,
char *data;
time_t mtime;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwriteclose_count);
-#endif
+ START_PROFILE(SMBwriteclose);
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@@ -3360,10 +2925,7 @@ int reply_writeclose(connection_struct *conn,
data = smb_buf(inbuf) + 1;
if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteclose);
return(ERROR(ERRDOS,ERRlock));
}
@@ -3378,29 +2940,20 @@ int reply_writeclose(connection_struct *conn,
conn->num_files_open));
if (nwritten <= 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteclose);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
if(close_err != 0) {
errno = close_err;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteclose);
return(UNIXERROR(ERRHRD,ERRgeneral));
}
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,nwritten);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteclose);
return(outsize);
}
@@ -3416,13 +2969,7 @@ int reply_lock(connection_struct *conn,
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBlock_count);
-#endif
+ START_PROFILE(SMBlock);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
@@ -3441,24 +2988,15 @@ int reply_lock(connection_struct *conn,
* onto the blocking lock queue.
*/
if(push_blocking_lock_request(inbuf, length, -1, 0)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlock);
return -1;
}
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlock);
return (ERROR(eclass,ecode));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlock);
return(outsize);
}
@@ -3473,13 +3011,7 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, in
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBunlock_count);
-#endif
+ START_PROFILE(SMBunlock);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
@@ -3488,20 +3020,14 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, in
offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3);
if(!do_unlock(fsp, conn, count, offset, &eclass, &ecode)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBunlock);
return (ERROR(eclass,ecode));
}
DEBUG( 3, ( "unlock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fd, fsp->fnum, (double)offset, (double)count ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBunlock_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBunlock);
return(outsize);
}
@@ -3514,22 +3040,13 @@ int reply_tdis(connection_struct *conn,
{
int outsize = set_message(outbuf,0,0,True);
uint16 vuid;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBtdis_count);
-#endif
+ START_PROFILE(SMBtdis);
vuid = SVAL(inbuf,smb_uid);
if (!conn) {
DEBUG(4,("Invalid connection in tdis\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtdis_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtdis);
return(ERROR(ERRSRV,ERRinvnid));
}
@@ -3537,10 +3054,7 @@ int reply_tdis(connection_struct *conn,
close_cnum(conn,vuid);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBtdis_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBtdis);
return outsize;
}
@@ -3556,13 +3070,7 @@ int reply_echo(connection_struct *conn,
int seq_num;
unsigned int data_len = smb_buflen(inbuf);
int outsize = set_message(outbuf,1,data_len,True);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBecho_count);
-#endif
+ START_PROFILE(SMBecho);
data_len = MIN(data_len, (sizeof(inbuf)-(smb_buf(inbuf)-inbuf)));
@@ -3587,10 +3095,7 @@ int reply_echo(connection_struct *conn,
smb_echo_count++;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBecho_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBecho);
return -1;
}
@@ -3603,19 +3108,10 @@ int reply_printopen(connection_struct *conn,
{
int outsize = 0;
files_struct *fsp;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsplopen_count);
-#endif
+ START_PROFILE(SMBsplopen);
if (!CAN_PRINT(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplopen);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -3623,10 +3119,7 @@ int reply_printopen(connection_struct *conn,
fsp = print_fsp_open(conn,"dos.prn");
if (!fsp) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplopen);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -3636,10 +3129,7 @@ int reply_printopen(connection_struct *conn,
DEBUG(3,("openprint fd=%d fnum=%d\n",
fsp->fd, fsp->fnum));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplopen_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplopen);
return(outsize);
}
@@ -3653,22 +3143,13 @@ int reply_printclose(connection_struct *conn,
int outsize = set_message(outbuf,0,0,True);
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int close_err = 0;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsplclose_count);
-#endif
+ START_PROFILE(SMBsplclose);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
if (!CAN_PRINT(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplclose);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -3679,17 +3160,11 @@ int reply_printclose(connection_struct *conn,
if(close_err != 0) {
errno = close_err;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplclose);
return(UNIXERROR(ERRHRD,ERRgeneral));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplclose_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplclose);
return(outsize);
}
@@ -3703,23 +3178,14 @@ int reply_printqueue(connection_struct *conn,
int outsize = set_message(outbuf,2,3,True);
int max_count = SVAL(inbuf,smb_vwv0);
int start_index = SVAL(inbuf,smb_vwv1);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsplretq_count);
-#endif
+ START_PROFILE(SMBsplretq);
/* we used to allow the client to get the cnum wrong, but that
is really quite gross and only worked when there was only
one printer - I think we should now only accept it if they
get it right (tridge) */
if (!CAN_PRINT(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplretq_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplretq);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -3768,10 +3234,7 @@ int reply_printqueue(connection_struct *conn,
DEBUG(3,("%d entries returned in queue\n",count));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplretq_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplretq);
return(outsize);
}
@@ -3785,19 +3248,10 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_
int outsize = set_message(outbuf,0,0,True);
char *data;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsplwr_count);
-#endif
+ START_PROFILE(SMBsplwr);
if (!CAN_PRINT(conn)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplwr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplwr);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -3809,19 +3263,13 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_
data = smb_buf(inbuf) + 3;
if (write_file(fsp,data,-1,numtowrite) != numtowrite) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplwr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplwr);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
DEBUG( 3, ( "printwrite fnum=%d num=%d\n", fsp->fnum, numtowrite ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsplwr_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsplwr);
return(outsize);
}
@@ -3838,8 +3286,7 @@ int mkdir_internal(connection_struct *conn, char *inbuf, char *outbuf, pstring d
unix_convert(directory,conn,0,&bad_path,NULL);
if (check_name(directory, conn))
- ret = conn->vfs_ops.mkdir(dos_to_unix(directory,False),
- unix_mode(conn,aDIR,directory));
+ ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory));
if (ret < 0)
{
@@ -3861,13 +3308,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
{
pstring directory;
int outsize;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBmkdir_count);
-#endif
+ START_PROFILE(SMBmkdir);
pstrcpy(directory,smb_buf(inbuf) + 1);
@@ -3877,10 +3318,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBmkdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBmkdir);
return(outsize);
}
@@ -3917,7 +3355,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
pstrcat(fullname, "/");
pstrcat(fullname, dname);
- if(conn->vfs_ops.lstat(dos_to_unix(fullname,False), &st) != 0)
+ if(conn->vfs_ops.lstat(conn,dos_to_unix(fullname,False), &st) != 0)
{
ret = True;
break;
@@ -3930,13 +3368,13 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
ret = True;
break;
}
- if(conn->vfs_ops.rmdir(dos_to_unix(fullname,False)) != 0)
+ if(vfs_rmdir(conn,fullname) != 0)
{
ret = True;
break;
}
}
- else if(conn->vfs_ops.unlink(dos_to_unix(fullname,False)) != 0)
+ else if(vfs_unlink(conn,fullname) != 0)
{
ret = True;
break;
@@ -3954,7 +3392,7 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
{
BOOL ok;
- ok = (conn->vfs_ops.rmdir(dos_to_unix(directory, False)) == 0);
+ ok = (vfs_rmdir(conn,directory) == 0);
if(!ok && ((errno == ENOTEMPTY)||(errno == EEXIST)) && lp_veto_files(SNUM(conn)))
{
/*
@@ -4001,7 +3439,7 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
pstrcat(fullname, "/");
pstrcat(fullname, dname);
- if(conn->vfs_ops.lstat(dos_to_unix(fullname, False), &st) != 0)
+ if(conn->vfs_ops.lstat(conn,dos_to_unix(fullname, False), &st) != 0)
break;
if(st.st_mode & S_IFDIR)
{
@@ -4010,15 +3448,15 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
if(recursive_rmdir(conn, fullname) != 0)
break;
}
- if(conn->vfs_ops.rmdir(dos_to_unix(fullname, False)) != 0)
+ if(vfs_rmdir(conn,fullname) != 0)
break;
}
- else if(conn->vfs_ops.unlink(dos_to_unix(fullname, False)) != 0)
+ else if(vfs_unlink(conn,fullname) != 0)
break;
}
CloseDir(dirptr);
/* Retry the rmdir */
- ok = (conn->vfs_ops.rmdir(dos_to_unix(directory, False)) == 0);
+ ok = (vfs_rmdir(conn,directory) == 0);
}
else
CloseDir(dirptr);
@@ -4044,13 +3482,7 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
int outsize = 0;
BOOL ok = False;
BOOL bad_path = False;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBrmdir_count);
-#endif
+ START_PROFILE(SMBrmdir);
pstrcpy(directory,smb_buf(inbuf) + 1);
@@ -4071,10 +3503,7 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBrmdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBrmdir);
return(UNIXERROR(ERRDOS,ERRbadpath));
}
@@ -4082,10 +3511,7 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 3, ( "rmdir %s\n", directory ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBrmdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBrmdir);
return(outsize);
}
@@ -4163,7 +3589,7 @@ static BOOL can_rename(char *fname,connection_struct *conn)
if (!CAN_WRITE(conn)) return(False);
- if (conn->vfs_ops.lstat(dos_to_unix(fname,False),&sbuf) != 0) return(False);
+ if (conn->vfs_ops.lstat(conn,dos_to_unix(fname,False),&sbuf) != 0) return(False);
if (!check_file_sharing(conn,fname,True)) return(False);
return(True);
@@ -4295,14 +3721,14 @@ int rename_internals(connection_struct *conn,
*/
if(resolve_wildcards(directory,newname) &&
can_rename(directory,conn) &&
- !conn->vfs_ops.rename(zdirectory,
+ !conn->vfs_ops.rename(conn,zdirectory,
dos_to_unix(newname,False)))
count++;
} else {
if (resolve_wildcards(directory,newname) &&
can_rename(directory,conn) &&
!vfs_file_exist(conn,newname,NULL) &&
- !conn->vfs_ops.rename(zdirectory,
+ !conn->vfs_ops.rename(conn,zdirectory,
dos_to_unix(newname,False)))
count++;
}
@@ -4361,7 +3787,7 @@ int rename_internals(connection_struct *conn,
continue;
}
- if (!conn->vfs_ops.rename(dos_to_unix(fname,False),
+ if (!conn->vfs_ops.rename(conn,dos_to_unix(fname,False),
dos_to_unix(destname,False)))
count++;
DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
@@ -4394,13 +3820,7 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, in
int outsize = 0;
pstring name;
pstring newname;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBmv_count);
-#endif
+ START_PROFILE(SMBmv);
pstrcpy(name,smb_buf(inbuf) + 1);
pstrcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
@@ -4423,10 +3843,7 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, in
outsize = set_message(outbuf,0,0,True);
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBmv_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBmv);
return(outsize);
}
@@ -4478,7 +3895,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
}
if ((ofun&3) == 1) {
- if(conn->vfs_ops.lseek(fsp2->fd,0,SEEK_END) == -1) {
+ if(conn->vfs_ops.lseek(fsp2,fsp2->fd,0,SEEK_END) == -1) {
DEBUG(0,("copy_file: error - sys_lseek returned error %s\n",
strerror(errno) ));
/*
@@ -4528,13 +3945,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
BOOL bad_path1 = False;
BOOL bad_path2 = False;
BOOL rc = True;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBcopy_count);
-#endif
+ START_PROFILE(SMBcopy);
*directory = *mask = 0;
@@ -4546,10 +3957,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if (tid2 != conn->cnum) {
/* can't currently handle inter share copies XXXX */
DEBUG(3,("Rejecting inter-share copy\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(ERROR(ERRSRV,ERRinvdevice));
}
@@ -4562,28 +3970,19 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
target_is_directory = vfs_directory_exist(conn,False,NULL);
if ((flags&1) && target_is_directory) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(ERROR(ERRDOS,ERRbadfile));
}
if ((flags&2) && !target_is_directory) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(ERROR(ERRDOS,ERRbadpath));
}
if ((flags&(1<<5)) && vfs_directory_exist(conn,name,NULL)) {
/* wants a tree copy! XXXX */
DEBUG(3,("Rejecting tree copy\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(ERROR(ERRSRV,ERRerror));
}
@@ -4619,10 +4018,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
count,target_is_directory,&err)) count++;
if(!count && err) {
errno = err;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(UNIXERROR(ERRHRD,ERRgeneral));
}
if (!count) exists = vfs_file_exist(conn,directory,NULL);
@@ -4663,18 +4059,12 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if(err) {
/* Error on close... */
errno = err;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(UNIXERROR(ERRHRD,ERRgeneral));
}
if (exists) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(ERROR(ERRDOS,error));
} else
{
@@ -4683,10 +4073,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(UNIXERROR(ERRDOS,error));
}
}
@@ -4694,10 +4081,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,count);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBcopy_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBcopy);
return(outsize);
}
@@ -4710,20 +4094,11 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
int outsize = 0;
BOOL ok = False;
pstring newdir;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(pathworks_setdir_count);
-#endif
+ START_PROFILE(pathworks_setdir);
snum = SNUM(conn);
if (!CAN_SETDIR(snum)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(pathworks_setdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(pathworks_setdir);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -4740,10 +4115,7 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
}
if (!ok) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(pathworks_setdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(pathworks_setdir);
return(ERROR(ERRDOS,ERRbadpath));
}
@@ -4752,10 +4124,7 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
DEBUG(3,("setdir %s\n", newdir));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(pathworks_setdir_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(pathworks_setdir);
return(outsize);
}
@@ -4867,13 +4236,7 @@ int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,
int eclass=0, dummy1;
BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES)?True:False;
BOOL err;
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBlockingX_count);
-#endif
+ START_PROFILE(SMBlockingX);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
@@ -4899,16 +4262,10 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
/* if this is a pure oplock break request then don't send a reply */
if (num_locks == 0 && num_ulocks == 0) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return -1;
} else {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(ERRDOS,ERRlock);
}
}
@@ -4926,10 +4283,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
if(CVAL(inbuf,smb_vwv0) != 0xff)
DEBUG(0,("reply_lockingX: Error : pure oplock break is a chained %d request !\n",
(unsigned int)CVAL(inbuf,smb_vwv0) ));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return -1;
}
}
@@ -4944,10 +4298,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
* There is no error code marked "stupid client bug".... :-).
*/
if(err) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(ERRDOS,ERRnoaccess);
}
@@ -4955,10 +4306,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
(double)offset, (double)count, fsp->fsp_name ));
if(!do_unlock(fsp,conn,count,offset, &eclass, &ecode)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(eclass,ecode);
}
}
@@ -4980,10 +4328,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
* There is no error code marked "stupid client bug".... :-).
*/
if(err) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(ERRDOS,ERRnoaccess);
}
@@ -4999,10 +4344,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
* onto the blocking lock queue.
*/
if(push_blocking_lock_request(inbuf, length, lock_timeout, i)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return -1;
}
}
@@ -5026,19 +4368,13 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
* There is no error code marked "stupid client bug".... :-).
*/
if(err) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(ERRDOS,ERRnoaccess);
}
do_unlock(fsp,conn,count,offset,&dummy1,&dummy2);
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return ERROR(eclass,ecode);
}
@@ -5047,10 +4383,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name));
DEBUG( 3, ( "lockingX fnum=%d type=%d num_locks=%d num_ulocks=%d\n",
fsp->fnum, (unsigned int)locktype, num_locks, num_ulocks ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBlockingX_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBlockingX);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -5070,20 +4403,11 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
size_t tcount;
int pad;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBreadBmpx_count);
-#endif
+ START_PROFILE(SMBreadBmpx);
/* this function doesn't seem to work - disable by default */
if (!lp_readbmpx()) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadBmpx);
return(ERROR(ERRSRV,ERRuseSTD));
}
@@ -5106,10 +4430,7 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
total_read = 0;
if (is_locked(fsp,conn,(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadBmpx);
return(ERROR(ERRDOS,ERRlock));
}
@@ -5137,10 +4458,7 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
}
while (total_read < (ssize_t)tcount);
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBreadBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBreadBmpx);
return(-1);
}
@@ -5159,13 +4477,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
int smb_doff;
char *data;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwriteBmpx_count);
-#endif
+ START_PROFILE(SMBwriteBmpx);
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@@ -5184,10 +4496,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
CVAL(outbuf,smb_com) = SMBwritec;
if (is_locked(fsp,conn,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos,WRITE_LOCK)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBmpx);
return(ERROR(ERRDOS,ERRlock));
}
@@ -5197,10 +4506,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
sync_file(conn,fsp);
if(nwritten < (ssize_t)numtowrite) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBmpx);
return(UNIXERROR(ERRHRD,ERRdiskfull));
}
@@ -5218,10 +4524,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
if(!wbms)
{
DEBUG(0,("Out of memory in reply_readmpx\n"));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBmpx);
return(ERROR(ERRSRV,ERRnoresource));
}
wbms->wr_mode = write_through;
@@ -5254,10 +4557,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
SSVAL(outbuf,smb_vwv0,nwritten);
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBmpx_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBmpx);
return(outsize);
}
@@ -5278,13 +4578,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
write_bmpx_struct *wbms;
BOOL send_response = False;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBwriteBs_count);
-#endif
+ START_PROFILE(SMBwriteBs);
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@@ -5303,10 +4597,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
check that it does */
wbms = fsp->wbmpx_ptr;
if(!wbms) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return(-1);
}
@@ -5316,10 +4607,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
/* Check for an earlier error */
if(wbms->wr_discard) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return -1; /* Just discard the packet */
}
@@ -5335,16 +4623,10 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
/* We are returning an error - we can delete the aux struct */
if (wbms) free((char *)wbms);
fsp->wbmpx_ptr = NULL;
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return(ERROR(ERRHRD,ERRdiskfull));
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return(CACHE_ERROR(wbms,ERRHRD,ERRdiskfull));
}
@@ -5365,17 +4647,11 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
}
if(send_response) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return(outsize);
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBwriteBs_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBwriteBs);
return(-1);
}
@@ -5389,13 +4665,7 @@ int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
struct utimbuf unix_times;
int outsize = 0;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBsetattrE_count);
-#endif
+ START_PROFILE(SMBsetattrE);
outsize = set_message(outbuf,0,0,True);
@@ -5421,10 +4691,7 @@ int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
dbgtext( "reply_setattrE fnum=%d ", fsp->fnum);
dbgtext( "ignoring zero request - not setting timestamps of 0\n" );
}
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsetattrE_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsetattrE);
return(outsize);
}
else if ((unix_times.actime != 0) && (unix_times.modtime == 0))
@@ -5435,20 +4702,14 @@ int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
/* Set the date on this file */
if(file_utime(conn, fsp->fsp_name, &unix_times)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsetattrE_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsetattrE);
return(ERROR(ERRDOS,ERRnoaccess));
}
DEBUG( 3, ( "reply_setattrE fnum=%d actime=%d modtime=%d\n",
fsp->fnum, (int)unix_times.actime, (int)unix_times.modtime ) );
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBsetattrE_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBsetattrE);
return(outsize);
}
@@ -5463,13 +4724,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
int outsize = 0;
int mode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
-#ifdef WITH_PROFILE
- struct timeval starttime;
- struct timeval endtime;
-
- GetTimeOfDay(&starttime);
- INC_PROFILE_COUNT(SMBgetattrE_count);
-#endif
+ START_PROFILE(SMBgetattrE);
outsize = set_message(outbuf,11,0,True);
@@ -5477,11 +4732,8 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
CHECK_ERROR(fsp);
/* Do an fstat on this file */
- if(fsp->conn->vfs_ops.fstat(fsp->fd, &sbuf)) {
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBgetattrE_time,TvalDiff(&starttime,&endtime));
-#endif
+ if(vfs_fstat(fsp,fsp->fd, &sbuf)) {
+ END_PROFILE(SMBgetattrE);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -5507,10 +4759,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
DEBUG( 3, ( "reply_getattrE fnum=%d\n", fsp->fnum));
-#ifdef WITH_PROFILE
- GetTimeOfDay(&endtime);
- ADD_PROFILE_COUNT(SMBgetattrE_time,TvalDiff(&starttime,&endtime));
-#endif
+ END_PROFILE(SMBgetattrE);
return(outsize);
}
#undef OLD_NTDOMAIN
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 6cc87e23bdd..27e2492e40b 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -481,46 +481,6 @@ connection_struct *make_connection(char *service,char *user,char *password, int
conn->nt_user_token = create_nt_token(conn->uid, conn->gid, conn->ngroups, conn->groups);
- /*
- * Now initialize the vfs layer.
- */
-
- conn->vfs_conn = (struct vfs_connection_struct *)
- malloc(sizeof(struct vfs_connection_struct));
-
- if (conn->vfs_conn == NULL) {
- DEBUG(0, ("No memory to create vfs_connection_struct"));
- return NULL;
- }
-
- ZERO_STRUCTP(conn->vfs_conn);
-
- /* Copy across relevant data from connection struct */
-
- conn->vfs_conn->printer = conn->printer;
- conn->vfs_conn->ipc = conn->ipc;
- conn->vfs_conn->read_only = conn->read_only;
- conn->vfs_conn->admin_user = conn->admin_user;
-
- pstrcpy(conn->vfs_conn->dirpath, conn->dirpath);
- pstrcpy(conn->vfs_conn->connectpath, conn->connectpath);
- pstrcpy(conn->vfs_conn->origpath, conn->origpath);
-
- pstrcpy(conn->vfs_conn->service, service);
- pstrcpy(conn->vfs_conn->user, conn->user);
-
- conn->vfs_conn->uid = conn->uid;
- conn->vfs_conn->gid = conn->gid;
- conn->vfs_conn->ngroups = conn->ngroups;
- if (conn->vfs_conn->ngroups != 0) {
- conn->vfs_conn->groups = (gid_t *)memdup(conn->groups,
- conn->ngroups * sizeof(gid_t));
- } else {
- conn->vfs_conn->groups = NULL;
- }
-
- conn->vfs_conn->nt_user_token = dup_nt_token(conn->nt_user_token);
-
/* Initialise VFS function pointers */
#if USING_VFS
@@ -646,7 +606,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
/* Invoke VFS make connection hook */
if (conn->vfs_ops.connect) {
- if (conn->vfs_ops.connect(conn->vfs_conn, service, user) < 0)
+ if (conn->vfs_ops.connect(conn, service, user) < 0)
return NULL;
}
@@ -671,7 +631,7 @@ void close_cnum(connection_struct *conn, uint16 vuid)
/* Call VFS disconnect hook */
- conn->vfs_ops.disconnect();
+ conn->vfs_ops.disconnect(conn);
}
diff --git a/source/smbd/statcache.c b/source/smbd/statcache.c
index fdfcc86d741..741cce33980 100644
--- a/source/smbd/statcache.c
+++ b/source/smbd/statcache.c
@@ -203,7 +203,7 @@ BOOL stat_cache_lookup(connection_struct *conn, char *name, char *dirpath,
INC_PROFILE_COUNT(statcache_hits);
#endif
trans_name = scp->names+scp->name_len+1;
- if(conn->vfs_ops.stat(dos_to_unix(trans_name,False), pst) != 0) {
+ if(conn->vfs_ops.stat(conn,dos_to_unix(trans_name,False), pst) != 0) {
/* Discard this entry - it doesn't exist in the filesystem. */
hash_remove(&stat_cache, hash_elem);
return False;
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 2366fceae7c..7df1c09fa00 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -251,7 +251,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -407,7 +407,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
if(needslash)
pstrcat(pathreal,"/");
pstrcat(pathreal,dname);
- if (conn->vfs_ops.stat(dos_to_unix(pathreal,False),&sbuf) != 0)
+ if (conn->vfs_ops.stat(conn,dos_to_unix(pathreal,False),&sbuf) != 0)
{
/* Needed to show the msdfs symlinks as directories */
if(!lp_host_msdfs() || !lp_msdfs_root(SNUM(conn))
@@ -1112,7 +1112,7 @@ static int call_trans2qfsinfo(connection_struct *conn,
DEBUG(3,("call_trans2qfsinfo: level = %d\n", info_level));
- if(conn->vfs_ops.stat(".",&st)!=0) {
+ if(conn->vfs_ops.stat(conn,".",&st)!=0) {
DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n", strerror(errno)));
return (ERROR(ERRSRV,ERRinvdevice));
}
@@ -1126,7 +1126,7 @@ static int call_trans2qfsinfo(connection_struct *conn,
{
SMB_BIG_UINT dfree,dsize,bsize;
data_len = 18;
- conn->vfs_ops.disk_free(".",False,&bsize,&dfree,&dsize);
+ conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);
SIVAL(pdata,l1_idFileSystem,st.st_dev);
SIVAL(pdata,l1_cSectorUnit,bsize/512);
SIVAL(pdata,l1_cUnit,dsize);
@@ -1208,7 +1208,7 @@ static int call_trans2qfsinfo(connection_struct *conn,
{
SMB_BIG_UINT dfree,dsize,bsize;
data_len = 24;
- conn->vfs_ops.disk_free(".",False,&bsize,&dfree,&dsize);
+ conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);
SBIG_UINT(pdata,0,dsize);
SBIG_UINT(pdata,8,dfree);
SIVAL(pdata,16,bsize/512);
@@ -1308,7 +1308,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
fname = fsp->fsp_name;
unix_convert(fname,conn,0,&bad_path,&sbuf);
if (!check_name(fname,conn) ||
- (!VALID_STAT(sbuf) && conn->vfs_ops.stat(dos_to_unix(fname,False),&sbuf))) {
+ (!VALID_STAT(sbuf) && conn->vfs_ops.stat(conn,dos_to_unix(fname,False),&sbuf))) {
DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
if((errno == ENOENT) && bad_path)
{
@@ -1328,11 +1328,11 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
CHECK_ERROR(fsp);
fname = fsp->fsp_name;
- if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
return(UNIXERROR(ERRDOS,ERRbadfid));
}
- if((pos = fsp->conn->vfs_ops.lseek(fsp->fd,0,SEEK_CUR)) == -1)
+ if((pos = fsp->conn->vfs_ops.lseek(fsp,fsp->fd,0,SEEK_CUR)) == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
delete_pending = fsp->delete_on_close;
@@ -1350,7 +1350,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
unix_convert(fname,conn,0,&bad_path,&sbuf);
if (!check_name(fname,conn) ||
- (!VALID_STAT(sbuf) && conn->vfs_ops.stat(dos_to_unix(fname,False),&sbuf))) {
+ (!VALID_STAT(sbuf) && conn->vfs_ops.stat(conn,dos_to_unix(fname,False),&sbuf))) {
DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
if((errno == ENOENT) && bad_path)
{
@@ -1590,7 +1590,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
fname = fsp->fsp_name;
unix_convert(fname,conn,0,&bad_path,&st);
if (!check_name(fname,conn) ||
- (!VALID_STAT(st) && conn->vfs_ops.stat(dos_to_unix(fname,False),&st))) {
+ (!VALID_STAT(st) && conn->vfs_ops.stat(conn,dos_to_unix(fname,False),&st))) {
DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
if((errno == ENOENT) && bad_path)
{
@@ -1609,7 +1609,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
fname = fsp->fsp_name;
fd = fsp->fd;
- if (fsp->conn->vfs_ops.fstat(fd,&st) != 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp,fd,&st) != 0) {
DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
return(UNIXERROR(ERRDOS,ERRbadfid));
}
@@ -1630,7 +1630,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
return(UNIXERROR(ERRDOS,ERRbadpath));
}
- if(!VALID_STAT(st) && conn->vfs_ops.stat(dos_to_unix(fname,False),&st)!=0) {
+ if(!VALID_STAT(st) && conn->vfs_ops.stat(conn,dos_to_unix(fname,False),&st)!=0) {
DEBUG(3,("stat of %s failed (%s)\n", fname, strerror(errno)));
if((errno == ENOENT) && bad_path)
{
@@ -1974,11 +1974,11 @@ dev = %x, inode = %.0f\n", iterate_fsp->fnum, (unsigned int)dev, (double)inode))
fname, (double)size ));
if (fd == -1) {
- fd = conn->vfs_ops.open(dos_to_unix(fname,False),O_RDWR,0);
+ fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),O_RDWR,0);
if (fd == -1)
return(UNIXERROR(ERRDOS,ERRbadpath));
set_filelen(fd, size); /* tpot vfs */
- conn->vfs_ops.close(fd);
+ conn->vfs_ops.close(fsp,fd);
} else {
set_filelen(fd, size); /* tpot vfs */
}
diff --git a/source/smbd/unix_acls.c b/source/smbd/unix_acls.c
index a564ec9ee5a..d32f1cfaae4 100644
--- a/source/smbd/unix_acls.c
+++ b/source/smbd/unix_acls.c
@@ -357,16 +357,16 @@ size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc)
*/
if ((fsp->is_directory || fsp->fd == -1) && fsp->conn->vfs_ops.get_nt_acl)
- return fsp->conn->vfs_ops.get_nt_acl(dos_to_unix(fsp->fsp_name, False), ppdesc);
+ return fsp->conn->vfs_ops.get_nt_acl(fsp->conn,dos_to_unix(fsp->fsp_name, False), ppdesc);
else if (fsp->conn->vfs_ops.fget_nt_acl)
- return fsp->conn->vfs_ops.fget_nt_acl(fsp->fd, ppdesc);
+ return fsp->conn->vfs_ops.fget_nt_acl(fsp,fsp->fd, ppdesc);
if(fsp->is_directory || fsp->fd == -1) {
if(vfs_stat(fsp->conn,fsp->fsp_name, &sbuf) != 0) {
return 0;
}
} else {
- if(fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
+ if(fsp->conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
return 0;
}
}
@@ -467,9 +467,9 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
*/
if ((fsp->is_directory || fsp->fd == -1) && fsp->conn->vfs_ops.set_nt_acl)
- return fsp->conn->vfs_ops.set_nt_acl(dos_to_unix(fsp->fsp_name, False), security_info_sent, psd);
+ return fsp->conn->vfs_ops.set_nt_acl(conn,dos_to_unix(fsp->fsp_name, False), security_info_sent, psd);
else if (fsp->conn->vfs_ops.fset_nt_acl)
- return fsp->conn->vfs_ops.fset_nt_acl(fsp->fd, security_info_sent, psd);
+ return fsp->conn->vfs_ops.fset_nt_acl(fsp,fsp->fd, security_info_sent, psd);
/*
* Get the current state of the file.
@@ -479,7 +479,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
if(vfs_stat(fsp->conn,fsp->fsp_name, &sbuf) != 0)
return False;
} else {
- if(conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0)
+ if(conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0)
return False;
}
@@ -524,7 +524,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
if(fsp->fd == -1)
ret = vfs_stat(fsp->conn, fsp->fsp_name, &sbuf);
else
- ret = conn->vfs_ops.fstat(fsp->fd,&sbuf);
+ ret = conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf);
if(ret != 0)
return False;
@@ -570,7 +570,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
DEBUG(3,("call_nt_transact_set_security_desc: chmod %s. perms = 0%o.\n",
fsp->fsp_name, (unsigned int)perms ));
- if(conn->vfs_ops.chmod(dos_to_unix(fsp->fsp_name, False), perms) == -1) {
+ if(conn->vfs_ops.chmod(conn,dos_to_unix(fsp->fsp_name, False), perms) == -1) {
DEBUG(3,("call_nt_transact_set_security_desc: chmod %s, 0%o failed. Error = %s.\n",
fsp->fsp_name, (unsigned int)perms, strerror(errno) ));
return False;
diff --git a/source/smbd/vfs-wrap.c b/source/smbd/vfs-wrap.c
index 407a0c65f44..d5b0127cad6 100644
--- a/source/smbd/vfs-wrap.c
+++ b/source/smbd/vfs-wrap.c
@@ -29,8 +29,7 @@
is sure to try and execute them. These stubs are used to prevent
this possibility. */
-int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
- char *user)
+int vfswrap_dummy_connect(connection_struct *conn, char *service, char *user)
{
return 0; /* Return >= 0 for success */
}
@@ -41,7 +40,7 @@ void vfswrap_dummy_disconnect(void)
/* Disk operations */
-SMB_BIG_UINT vfswrap_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize,
+SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
SMB_BIG_UINT result;
@@ -60,7 +59,7 @@ SMB_BIG_UINT vfswrap_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize
/* Directory operations */
-DIR *vfswrap_opendir(char *fname)
+DIR *vfswrap_opendir(connection_struct *conn, char *fname)
{
DIR *result;
@@ -78,7 +77,7 @@ DIR *vfswrap_opendir(char *fname)
return result;
}
-struct dirent *vfswrap_readdir(DIR *dirp)
+struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp)
{
struct dirent *result;
@@ -96,7 +95,7 @@ struct dirent *vfswrap_readdir(DIR *dirp)
return result;
}
-int vfswrap_mkdir(char *path, mode_t mode)
+int vfswrap_mkdir(connection_struct *conn, char *path, mode_t mode)
{
int result;
@@ -114,7 +113,7 @@ int vfswrap_mkdir(char *path, mode_t mode)
return result;
}
-int vfswrap_rmdir(char *path)
+int vfswrap_rmdir(connection_struct *conn, char *path)
{
int result;
@@ -132,7 +131,7 @@ int vfswrap_rmdir(char *path)
return result;
}
-int vfswrap_closedir(DIR *dirp)
+int vfswrap_closedir(connection_struct *conn, DIR *dirp)
{
int result;
@@ -152,7 +151,7 @@ int vfswrap_closedir(DIR *dirp)
/* File operations */
-int vfswrap_open(char *fname, int flags, mode_t mode)
+int vfswrap_open(connection_struct *conn, char *fname, int flags, mode_t mode)
{
int result;
@@ -170,7 +169,7 @@ int vfswrap_open(char *fname, int flags, mode_t mode)
return result;
}
-int vfswrap_close(int fd)
+int vfswrap_close(files_struct *fsp, int fd)
{
int result;
@@ -182,7 +181,7 @@ int vfswrap_close(int fd)
return result;
}
-ssize_t vfswrap_read(int fd, char *data, size_t n)
+ssize_t vfswrap_read(files_struct *fsp, int fd, char *data, size_t n)
{
ssize_t result;
@@ -201,7 +200,7 @@ ssize_t vfswrap_read(int fd, char *data, size_t n)
return result;
}
-ssize_t vfswrap_write(int fd, char *data, size_t n)
+ssize_t vfswrap_write(files_struct *fsp, int fd, char *data, size_t n)
{
ssize_t result;
@@ -220,7 +219,7 @@ ssize_t vfswrap_write(int fd, char *data, size_t n)
return result;
}
-SMB_OFF_T vfswrap_lseek(int filedes, SMB_OFF_T offset, int whence)
+SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
{
SMB_OFF_T result;
@@ -232,7 +231,7 @@ SMB_OFF_T vfswrap_lseek(int filedes, SMB_OFF_T offset, int whence)
return result;
}
-int vfswrap_rename(char *old, char *new)
+int vfswrap_rename(connection_struct *conn, char *old, char *new)
{
int result;
@@ -250,7 +249,7 @@ int vfswrap_rename(char *old, char *new)
return result;
}
-int vfswrap_fsync(int fd)
+int vfswrap_fsync(files_struct *fsp, int fd)
{
#ifdef HAVE_FSYNC
#ifdef WITH_PROFILE
@@ -263,7 +262,7 @@ int vfswrap_fsync(int fd)
#endif
}
-int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf)
+int vfswrap_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -281,7 +280,7 @@ int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf)
return result;
}
-int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf)
+int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -299,8 +298,7 @@ int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf)
return result;
}
-int vfswrap_lstat(char *path,
- SMB_STRUCT_STAT *sbuf)
+int vfswrap_lstat(connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -318,7 +316,7 @@ int vfswrap_lstat(char *path,
return result;
}
-int vfswrap_unlink(char *path)
+int vfswrap_unlink(connection_struct *conn, char *path)
{
int result;
@@ -336,7 +334,7 @@ int vfswrap_unlink(char *path)
return result;
}
-int vfswrap_chmod(char *path, mode_t mode)
+int vfswrap_chmod(connection_struct *conn, char *path, mode_t mode)
{
int result;
@@ -354,7 +352,7 @@ int vfswrap_chmod(char *path, mode_t mode)
return result;
}
-int vfswrap_chown(char *path, uid_t uid, gid_t gid)
+int vfswrap_chown(connection_struct *conn, char *path, uid_t uid, gid_t gid)
{
int result;
@@ -372,7 +370,7 @@ int vfswrap_chown(char *path, uid_t uid, gid_t gid)
return result;
}
-int vfswrap_chdir(char *path)
+int vfswrap_chdir(connection_struct *conn, char *path)
{
#ifdef WITH_PROFILE
INC_PROFILE_COUNT(syscall_chdir_count);
@@ -387,7 +385,7 @@ int vfswrap_chdir(char *path)
return chdir(path);
}
-char *vfswrap_getwd(char *path)
+char *vfswrap_getwd(connection_struct *conn, char *path)
{
#ifdef WITH_PROFILE
INC_PROFILE_COUNT(syscall_getwd_count);
@@ -402,7 +400,7 @@ char *vfswrap_getwd(char *path)
return sys_getwd(path);
}
-int vfswrap_utime(char *path, struct utimbuf *times)
+int vfswrap_utime(connection_struct *conn, char *path, struct utimbuf *times)
{
int result;
@@ -420,7 +418,7 @@ int vfswrap_utime(char *path, struct utimbuf *times)
return result;
}
-int vfswrap_ftruncate(int fd, SMB_OFF_T offset)
+int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T offset)
{
int result;
@@ -432,7 +430,7 @@ int vfswrap_ftruncate(int fd, SMB_OFF_T offset)
return result;
}
-BOOL vfswrap_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+BOOL vfswrap_lock(files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
#ifdef WITH_PROFILE
INC_PROFILE_COUNT(syscall_fcntl_lock_count);
diff --git a/source/smbd/vfs.c b/source/smbd/vfs.c
index 4a4b1b2cfa4..91172401bc4 100644
--- a/source/smbd/vfs.c
+++ b/source/smbd/vfs.c
@@ -83,7 +83,7 @@ int vfs_init_default(connection_struct *conn)
{
DEBUG(3, ("Initialising default vfs hooks\n"));
- memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(conn->vfs_ops));
+ memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops));
return True;
}
@@ -94,7 +94,6 @@ int vfs_init_default(connection_struct *conn)
#ifdef HAVE_LIBDL
BOOL vfs_init_custom(connection_struct *conn)
{
- void *handle;
struct vfs_ops *ops, *(*fptr)(struct vfs_options *options);
DEBUG(3, ("Initialising custom vfs hooks from %s\n",
@@ -102,19 +101,15 @@ BOOL vfs_init_custom(connection_struct *conn)
/* Open object file */
- handle = dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL);
- conn->vfs_conn->dl_handle = handle;
-
- if (!handle) {
- DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)),
- dlerror()));
- return False;
+ if ((conn->dl_handle = dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) {
+ DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), dlerror()));
+ return False;
}
/* Get handle on vfs_init() symbol */
fptr = (struct vfs_ops *(*)(struct vfs_options *))
- dlsym(handle, "vfs_init");
+ dlsym(conn->dl_handle, "vfs_init");
if (fptr == NULL) {
DEBUG(0, ("No vfs_init() symbol found in %s\n",
@@ -133,7 +128,7 @@ BOOL vfs_init_custom(connection_struct *conn)
There's probably a neater way to do this then a whole bunch of
if statements. */
- memcpy(&conn->vfs_ops, ops, sizeof(conn->vfs_ops));
+ memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops));
if (conn->vfs_ops.connect == NULL) {
conn->vfs_ops.connect = default_vfs_ops.connect;
@@ -265,16 +260,16 @@ BOOL vfs_init_custom(connection_struct *conn)
int vfs_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *st)
{
- return(conn->vfs_ops.stat(dos_to_unix(fname,False),st));
+ return(conn->vfs_ops.stat(conn, dos_to_unix(fname,False),st));
}
/*******************************************************************
vfs fstat wrapper that calls dos_to_unix.
********************************************************************/
-int vfs_fstat(connection_struct *conn, int fd, SMB_STRUCT_STAT *st)
+int vfs_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *st)
{
- return(conn->vfs_ops.fstat(fd,st));
+ return(fsp->conn->vfs_ops.fstat(fsp,fd,st));
}
/*******************************************************************
@@ -310,7 +305,7 @@ int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode)
SMB_STRUCT_STAT sbuf;
pstrcpy(name,dos_to_unix(fname,False)); /* paranoia copy */
- if(!(ret=conn->vfs_ops.mkdir(name,mode))) {
+ if(!(ret=conn->vfs_ops.mkdir(conn,name,mode))) {
/*
* Check if high bits should have been set,
* then (if bits are missing): add them.
@@ -324,12 +319,21 @@ int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode)
}
/*******************************************************************
+ vfs rmdir wrapper that calls dos_to_unix.
+********************************************************************/
+
+int vfs_rmdir(connection_struct *conn, char *fname)
+{
+ return(conn->vfs_ops.rmdir(conn,dos_to_unix(fname,False)));
+}
+
+/*******************************************************************
vfs Unlink wrapper that calls dos_to_unix.
********************************************************************/
int vfs_unlink(connection_struct *conn, char *fname)
{
- return(conn->vfs_ops.unlink(dos_to_unix(fname,False)));
+ return(conn->vfs_ops.unlink(conn,dos_to_unix(fname,False)));
}
/*******************************************************************
@@ -338,7 +342,7 @@ int vfs_unlink(connection_struct *conn, char *fname)
int vfs_chmod(connection_struct *conn, char *fname,mode_t mode)
{
- return(conn->vfs_ops.chmod(dos_to_unix(fname,False), mode));
+ return(conn->vfs_ops.chmod(conn,dos_to_unix(fname,False), mode));
}
/*******************************************************************
@@ -347,7 +351,7 @@ int vfs_chmod(connection_struct *conn, char *fname,mode_t mode)
int vfs_chown(connection_struct *conn, char *fname, uid_t uid, gid_t gid)
{
- return(conn->vfs_ops.chown(dos_to_unix(fname,False), uid, gid));
+ return(conn->vfs_ops.chown(conn,dos_to_unix(fname,False), uid, gid));
}
/*******************************************************************
@@ -356,7 +360,7 @@ int vfs_chown(connection_struct *conn, char *fname, uid_t uid, gid_t gid)
int vfs_chdir(connection_struct *conn, char *fname)
{
- return(conn->vfs_ops.chdir(dos_to_unix(fname,False)));
+ return(conn->vfs_ops.chdir(conn,dos_to_unix(fname,False)));
}
/*******************************************************************
@@ -366,7 +370,7 @@ int vfs_chdir(connection_struct *conn, char *fname)
char *vfs_getwd(connection_struct *conn, char *unix_path)
{
char *wd;
- wd = conn->vfs_ops.getwd(unix_path);
+ wd = conn->vfs_ops.getwd(conn,unix_path);
if (wd)
unix_to_dos(wd, True);
return wd;
@@ -400,7 +404,7 @@ ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N)
while (total < N)
{
- ret = fsp->conn->vfs_ops.write(fsp->fd,buffer + total,N - total);
+ ret = fsp->conn->vfs_ops.write(fsp,fsp->fd,buffer + total,N - total);
if (ret == -1) return -1;
if (ret == 0) return total;
@@ -477,16 +481,14 @@ SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp,
if (s > ret) {
ret += in_fsp ?
- in_fsp->conn->vfs_ops.read(in_fsp->fd,buf1+ret,s-ret) : read(in_fd,buf1+ret,s-ret);
+ in_fsp->conn->vfs_ops.read(in_fsp,in_fsp->fd,buf1+ret,s-ret) : read(in_fd,buf1+ret,s-ret);
}
- if (ret > 0)
- {
- if (out_fsp) {
- ret2 = out_fsp->conn->vfs_ops.write(out_fsp->fd,buf1,ret);
- } else {
- ret2= (out_fd != -1) ? write_data(out_fd,buf1,ret) : ret;
- }
+ if (ret > 0) {
+ if (out_fsp)
+ ret2 = out_fsp->conn->vfs_ops.write(out_fsp,out_fsp->fd,buf1,ret);
+ else
+ ret2= (out_fd != -1) ? write_data(out_fd,buf1,ret) : ret;
}
if (ret2 > 0) total += ret2;
@@ -513,7 +515,7 @@ char *vfs_readdirname(connection_struct *conn, void *p)
if (!p)
return(NULL);
- ptr = (struct dirent *)conn->vfs_ops.readdir(p);
+ ptr = (struct dirent *)conn->vfs_ops.readdir(conn,p);
if (!ptr)
return(NULL);