summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/conn.c39
-rw-r--r--source3/smbd/dir.c18
-rw-r--r--source3/smbd/dosmode.c14
-rw-r--r--source3/smbd/fileio.c14
-rw-r--r--source3/smbd/filename.c8
-rw-r--r--source3/smbd/notify_hash.c4
-rw-r--r--source3/smbd/nttrans.c4
-rw-r--r--source3/smbd/open.c26
-rw-r--r--source3/smbd/posix_acls.c134
-rw-r--r--source3/smbd/reply.c56
-rw-r--r--source3/smbd/service.c23
-rw-r--r--source3/smbd/statcache.c2
-rw-r--r--source3/smbd/trans2.c56
-rw-r--r--source3/smbd/vfs-wrap.c176
-rw-r--r--source3/smbd/vfs.c566
16 files changed, 500 insertions, 642 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 5cca85500f..a5d74cedb1 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -185,7 +185,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(conn,fsp->fsp_name) != 0) {
+ if(VFS_UNLINK(conn,fsp->fsp_name) != 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/source3/smbd/conn.c b/source3/smbd/conn.c
index b6c7aa1076..eb2d2bbcbf 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -93,6 +93,7 @@ thinking the server is still available.
****************************************************************************/
connection_struct *conn_new(void)
{
+ TALLOC_CTX *mem_ctx;
connection_struct *conn;
int i;
@@ -103,10 +104,16 @@ connection_struct *conn_new(void)
return NULL;
}
- conn = (connection_struct *)malloc(sizeof(*conn));
- if (!conn) return NULL;
+ if ((mem_ctx=talloc_init("connection_struct"))==NULL) {
+ DEBUG(0,("talloc_init(connection_struct) failed!\n"));
+ return NULL;
+ }
- ZERO_STRUCTP(conn);
+ if ((conn=(connection_struct *)talloc_zero(mem_ctx, sizeof(*conn)))==NULL) {
+ DEBUG(0,("talloc_zero() failed!\n"));
+ return NULL;
+ }
+ conn->mem_ctx = mem_ctx;
conn->cnum = i;
bitmap_set(bmap, i);
@@ -195,27 +202,16 @@ void conn_clear_vuid_cache(uint16 vuid)
void conn_free(connection_struct *conn)
{
- smb_vfs_handle_struct *handle, *thandle;
- void (*done_fptr)(connection_struct *the_conn);
+ vfs_handle_struct *handle = NULL, *thandle = NULL;
+ TALLOC_CTX *mem_ctx = NULL;
/* Free vfs_connection_struct */
- handle = conn->vfs_private;
+ handle = conn->vfs_handles;
while(handle) {
- /* Only call dlclose for the old modules */
- if (handle->handle) {
- /* Close dlopen() handle */
- done_fptr = (void (*)(connection_struct *))sys_dlsym(handle->handle, "vfs_done");
-
- if (done_fptr == NULL) {
- DEBUG(3, ("No vfs_done() symbol found in module with handle %p, ignoring\n", handle->handle));
- } else {
- done_fptr(conn);
- }
- sys_dlclose(handle->handle);
- }
- DLIST_REMOVE(conn->vfs_private, handle);
+ DLIST_REMOVE(conn->vfs_handles, handle);
thandle = handle->next;
- SAFE_FREE(handle);
+ if (handle->free_data)
+ handle->free_data(&handle->data);
handle = thandle;
}
@@ -238,8 +234,9 @@ void conn_free(connection_struct *conn)
bitmap_clear(bmap, conn->cnum);
num_open--;
+ mem_ctx = conn->mem_ctx;
ZERO_STRUCTP(conn);
- SAFE_FREE(conn);
+ talloc_destroy(mem_ctx);
}
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 6cf56fd373..48ddf86837 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -643,7 +643,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname
pstrcpy(pathreal,path);
pstrcat(path,fname);
pstrcat(pathreal,dname);
- if (conn->vfs_ops.stat(conn, pathreal, &sbuf) != 0) {
+ if (VFS_STAT(conn, pathreal, &sbuf) != 0) {
DEBUG(5,("Couldn't stat 1 [%s]. Error = %s\n",path, strerror(errno) ));
continue;
}
@@ -700,7 +700,7 @@ static BOOL user_can_read_file(connection_struct *conn, char *name, SMB_STRUCT_S
return True;
/* If we can't stat it does not show it */
- if (!VALID_STAT(*pst) && (vfs_stat(conn, name, pst) != 0))
+ if (!VALID_STAT(*pst) && (VFS_STAT(conn, name, pst) != 0))
return False;
/* Pseudo-open the file (note - no fd's created). */
@@ -715,7 +715,7 @@ static BOOL user_can_read_file(connection_struct *conn, char *name, SMB_STRUCT_S
return False;
/* Get NT ACL -allocated in main loop talloc context. No free needed here. */
- sd_size = conn->vfs_ops.fget_nt_acl(fsp, fsp->fd, &psd);
+ sd_size = VFS_FGET_NT_ACL(fsp, fsp->fd, &psd);
close_file(fsp, True);
/* No access if SD get failed. */
@@ -753,7 +753,7 @@ static BOOL user_can_write_file(connection_struct *conn, char *name, SMB_STRUCT_
return True;
/* If we can't stat it does not show it */
- if (!VALID_STAT(*pst) && (vfs_stat(conn, name, pst) != 0))
+ if (!VALID_STAT(*pst) && (VFS_STAT(conn, name, pst) != 0))
return False;
/* Pseudo-open the file (note - no fd's created). */
@@ -768,7 +768,7 @@ static BOOL user_can_write_file(connection_struct *conn, char *name, SMB_STRUCT_
return False;
/* Get NT ACL -allocated in main loop talloc context. No free needed here. */
- sd_size = conn->vfs_ops.fget_nt_acl(fsp, fsp->fd, &psd);
+ sd_size = VFS_FGET_NT_ACL(fsp, fsp->fd, &psd);
close_file(fsp, False);
/* No access if SD get failed. */
@@ -794,7 +794,7 @@ static BOOL file_is_special(connection_struct *conn, char *name, SMB_STRUCT_STAT
return True;
/* If we can't stat it does not show it */
- if (!VALID_STAT(*pst) && (vfs_stat(conn, name, pst) != 0))
+ if (!VALID_STAT(*pst) && (VFS_STAT(conn, name, pst) != 0))
return True;
if (S_ISREG(pst->st_mode) || S_ISDIR(pst->st_mode) || S_ISLNK(pst->st_mode))
@@ -811,7 +811,7 @@ void *OpenDir(connection_struct *conn, const char *name, BOOL use_veto)
{
Dir *dirp;
const char *n;
- DIR *p = conn->vfs_ops.opendir(conn,name);
+ DIR *p = VFS_OPENDIR(conn,name);
int used=0;
if (!p)
@@ -819,7 +819,7 @@ void *OpenDir(connection_struct *conn, const char *name, BOOL use_veto)
dirp = (Dir *)malloc(sizeof(Dir));
if (!dirp) {
DEBUG(0,("Out of memory in OpenDir\n"));
- conn->vfs_ops.closedir(conn,p);
+ VFS_CLOSEDIR(conn,p);
return(NULL);
}
dirp->pos = dirp->numentries = dirp->mallocsize = 0;
@@ -912,7 +912,7 @@ void *OpenDir(connection_struct *conn, const char *name, BOOL use_veto)
dirp->numentries++;
}
- conn->vfs_ops.closedir(conn,p);
+ VFS_CLOSEDIR(conn,p);
return((void *)dirp);
}
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 6c21dc04d0..6365db8f1e 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -56,7 +56,7 @@ mode_t unix_mode(connection_struct *conn,int dosmode,const char *fname)
dname = parent_dirname(fname);
DEBUG(2,("unix_mode(%s) inheriting from %s\n",fname,dname));
- if (vfs_stat(conn,dname,&sbuf) != 0) {
+ if (VFS_STAT(conn,dname,&sbuf) != 0) {
DEBUG(4,("unix_mode(%s) failed, [dir %s]: %s\n",fname,dname,strerror(errno)));
return(0); /* *** shouldn't happen! *** */
}
@@ -191,7 +191,7 @@ int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_ST
if (!st) {
st = &st1;
- if (vfs_stat(conn,fname,st))
+ if (VFS_STAT(conn,fname,st))
return(-1);
}
@@ -235,7 +235,7 @@ int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_ST
unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
}
- if ((ret = vfs_chmod(conn,fname,unixmode)) == 0)
+ if ((ret = VFS_CHMOD(conn,fname,unixmode)) == 0)
return 0;
if((errno != EPERM) && (errno != EACCES))
@@ -262,7 +262,7 @@ int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_ST
if (!fsp)
return -1;
become_root();
- ret = conn->vfs_ops.fchmod(fsp, fsp->fd, unixmode);
+ ret = VFS_FCHMOD(fsp, fsp->fd, unixmode);
unbecome_root();
close_file_fchmod(fsp);
}
@@ -283,7 +283,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
errno = 0;
- if(conn->vfs_ops.utime(conn,fname, times) == 0)
+ if(VFS_UTIME(conn,fname, times) == 0)
return 0;
if((errno != EPERM) && (errno != EACCES))
@@ -298,7 +298,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
(as DOS does).
*/
- if(vfs_stat(conn,fname,&sb) != 0)
+ if(VFS_STAT(conn,fname,&sb) != 0)
return -1;
/* Check if we have write access. */
@@ -311,7 +311,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(conn,fname, times);
+ ret = VFS_UTIME(conn,fname, times);
unbecome_root();
}
}
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index b612b1a451..5021f54fb4 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -32,7 +32,7 @@ static SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
{
SMB_OFF_T seek_ret;
- seek_ret = fsp->conn->vfs_ops.lseek(fsp,fsp->fd,pos,SEEK_SET);
+ seek_ret = VFS_LSEEK(fsp,fsp->fd,pos,SEEK_SET);
if(seek_ret == -1) {
DEBUG(0,("seek_file: (%s) sys_lseek failed. Error was %s\n",
@@ -101,7 +101,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
#ifdef DMF_FIX
int numretries = 3;
tryagain:
- readret = fsp->conn->vfs_ops.read(fsp,fsp->fd,data,n);
+ readret = VFS_READ(fsp,fsp->fd,data,n);
if (readret == -1) {
if ((errno == EAGAIN) && numretries) {
DEBUG(3,("read_file EAGAIN retry in 10 seconds\n"));
@@ -112,7 +112,7 @@ tryagain:
return -1;
}
#else /* NO DMF fix. */
- readret = fsp->conn->vfs_ops.read(fsp,fsp->fd,data,n);
+ readret = VFS_READ(fsp,fsp->fd,data,n);
if (readret == -1)
return -1;
#endif
@@ -181,7 +181,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,fsp->fd,&st) == 0) {
+ if (VFS_FSTAT(fsp,fsp->fd,&st) == 0) {
int dosmode = dos_mode(fsp->conn,fsp->fsp_name,&st);
fsp->size = (SMB_BIG_UINT)st.st_size;
if (MAP_ARCHIVE(fsp->conn) && !IS_DOS_ARCHIVE(dosmode))
@@ -760,7 +760,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,fsp->fd);
+ VFS_FSYNC(fsp,fsp->fd);
}
}
@@ -772,7 +772,7 @@ void sync_file(connection_struct *conn, files_struct *fsp)
int fsp_stat(files_struct *fsp, SMB_STRUCT_STAT *pst)
{
if (fsp->fd == -1)
- return vfs_stat(fsp->conn, fsp->fsp_name, pst);
+ return VFS_STAT(fsp->conn, fsp->fsp_name, pst);
else
- return vfs_fstat(fsp,fsp->fd, pst);
+ return VFS_FSTAT(fsp,fsp->fd, pst);
}
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index b9e33e8f93..6622a6ba63 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -178,7 +178,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* stat the name - if it exists then we are all done!
*/
- if (vfs_stat(conn,name,&st) == 0) {
+ if (VFS_STAT(conn,name,&st) == 0) {
stat_cache_add(orig_path, name);
DEBUG(5,("conversion finished %s -> %s\n",orig_path, name));
*pst = st;
@@ -234,7 +234,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* Check if the name exists up to this point.
*/
- if (vfs_stat(conn,name, &st) == 0) {
+ if (VFS_STAT(conn,name, &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.
@@ -342,7 +342,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* JRA.
*/
- if (vfs_stat(conn,name, &st) == 0) {
+ if (VFS_STAT(conn,name, &st) == 0) {
*pst = st;
} else {
ZERO_STRUCT(st);
@@ -418,7 +418,7 @@ BOOL check_name(pstring name,connection_struct *conn)
#ifdef S_ISLNK
if (!lp_symlinks(SNUM(conn))) {
SMB_STRUCT_STAT statbuf;
- if ( (conn->vfs_ops.lstat(conn,name,&statbuf) != -1) &&
+ if ( (VFS_LSTAT(conn,name,&statbuf) != -1) &&
(S_ISLNK(statbuf.st_mode)) ) {
DEBUG(3,("check_name: denied: file path name %s is a symlink\n",name));
ret=0;
diff --git a/source3/smbd/notify_hash.c b/source3/smbd/notify_hash.c
index d8b35462ac..913a4973f8 100644
--- a/source3/smbd/notify_hash.c
+++ b/source3/smbd/notify_hash.c
@@ -48,7 +48,7 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags,
ZERO_STRUCTP(data);
- if(vfs_stat(conn,path, &st) == -1)
+ if(VFS_STAT(conn,path, &st) == -1)
return False;
data->modify_time = st.st_mtime;
@@ -100,7 +100,7 @@ static BOOL notify_hash(connection_struct *conn, char *path, uint32 flags,
/*
* Do the stat - but ignore errors.
*/
- vfs_stat(conn,full_name, &st);
+ VFS_STAT(conn,full_name, &st);
/*
* Always sum the times.
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 9f7fabb75e..38de5586ea 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1032,7 +1032,7 @@ static NTSTATUS set_sd(files_struct *fsp, char *data, uint32 sd_len, uint32 secu
if (psd->off_dacl==0)
security_info_sent &= ~DACL_SECURITY_INFORMATION;
- ret = fsp->conn->vfs_ops.fset_nt_acl( fsp, fsp->fd, security_info_sent, psd);
+ ret = VFS_FSET_NT_ACL( fsp, fsp->fd, security_info_sent, psd);
if (!ret) {
talloc_destroy(mem_ctx);
@@ -1561,7 +1561,7 @@ static int call_nt_transact_query_security_desc(connection_struct *conn,
if (!lp_nt_acl_support(SNUM(conn)))
sd_size = get_null_nt_acl(mem_ctx, &psd);
else
- sd_size = conn->vfs_ops.fget_nt_acl(fsp, fsp->fd, &psd);
+ sd_size = VFS_FGET_NT_ACL(fsp, fsp->fd, &psd);
if (sd_size == 0) {
talloc_destroy(mem_ctx);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 906c4b40d9..412a0dfc50 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -38,13 +38,13 @@ static int fd_open(struct connection_struct *conn, char *fname,
flags |= O_NOFOLLOW;
#endif
- fd = conn->vfs_ops.open(conn,fname,flags,mode);
+ fd = VFS_OPEN(conn,fname,flags,mode);
/* Fix for files ending in '.' */
if((fd == -1) && (errno == ENOENT) &&
(strchr_m(fname,'.')==NULL)) {
pstrcat(fname,".");
- fd = conn->vfs_ops.open(conn,fname,flags,mode);
+ fd = VFS_OPEN(conn,fname,flags,mode);
}
DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", fname,
@@ -186,9 +186,9 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
int ret;
if (fsp->fd == -1)
- ret = vfs_stat(conn, fname, psbuf);
+ ret = VFS_STAT(conn, fname, psbuf);
else {
- ret = vfs_fstat(fsp,fsp->fd,psbuf);
+ ret = VFS_FSTAT(fsp,fsp->fd,psbuf);
/* If we have an fd, this stat should succeed. */
if (ret == -1)
DEBUG(0,("Error doing fstat on open file %s (%s)\n", fname,strerror(errno) ));
@@ -259,7 +259,7 @@ static int truncate_unless_locked(struct connection_struct *conn, files_struct *
unix_ERR_ntstatus = dos_to_ntstatus(ERRDOS, ERRlock);
return -1;
} else {
- return conn->vfs_ops.ftruncate(fsp,fsp->fd,0);
+ return VFS_FTRUNCATE(fsp,fsp->fd,0);
}
}
@@ -1071,7 +1071,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
/*
* We are modifing the file after open - update the stat struct..
*/
- if ((truncate_unless_locked(conn,fsp) == -1) || (vfs_fstat(fsp,fsp->fd,psbuf)==-1)) {
+ if ((truncate_unless_locked(conn,fsp) == -1) || (VFS_FSTAT(fsp,fsp->fd,psbuf)==-1)) {
unlock_share_entry_fsp(fsp);
fd_close(conn,fsp);
file_free(fsp);
@@ -1146,11 +1146,11 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
* selected.
*/
- if (!file_existed && !def_acl && (conn->vfs_ops.fchmod_acl != NULL)) {
+ if (!file_existed && !def_acl && (conn->vfs.ops.fchmod_acl != NULL)) {
int saved_errno = errno; /* We might get ENOSYS in the next call.. */
- if (conn->vfs_ops.fchmod_acl(fsp, fsp->fd, mode) == -1 && errno == ENOSYS)
+ if (VFS_FCHMOD_ACL(fsp, fsp->fd, mode) == -1 && errno == ENOSYS)
errno = saved_errno; /* Ignore ENOSYS */
} else if (new_mode) {
@@ -1159,9 +1159,9 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
/* Attributes need changing. File already existed. */
- if (conn->vfs_ops.fchmod_acl != NULL) {
+ if (conn->vfs.ops.fchmod_acl != NULL) {
int saved_errno = errno; /* We might get ENOSYS in the next call.. */
- ret = conn->vfs_ops.fchmod_acl(fsp, fsp->fd, new_mode);
+ ret = VFS_FCHMOD_ACL(fsp, fsp->fd, new_mode);
if (ret == -1 && errno == ENOSYS) {
errno = saved_errno; /* Ignore ENOSYS */
@@ -1172,7 +1172,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
}
}
- if ((ret == -1) && (conn->vfs_ops.fchmod(fsp, fsp->fd, new_mode) == -1))
+ if ((ret == -1) && (VFS_FCHMOD(fsp, fsp->fd, new_mode) == -1))
DEBUG(5, ("open_file_shared: failed to reset attributes of file %s to 0%o\n",
fname, (int)new_mode));
}
@@ -1278,14 +1278,14 @@ files_struct *open_directory(connection_struct *conn, char *fname, SMB_STRUCT_ST
return NULL;
}
- if(vfs_mkdir(conn,fname, unix_mode(conn,aDIR, fname)) < 0) {
+ if(vfs_MkDir(conn,fname, unix_mode(conn,aDIR, fname)) < 0) {
DEBUG(2,("open_directory: unable to create %s. Error was %s\n",
fname, strerror(errno) ));
file_free(fsp);
return NULL;
}
- if(vfs_stat(conn,fname, psbuf) != 0) {
+ if(VFS_STAT(conn,fname, psbuf) != 0) {
file_free(fsp);
return NULL;
}
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index a38acc437d..34c33af473 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -158,9 +158,9 @@ static mode_t convert_permset_to_mode_t(connection_struct *conn, SMB_ACL_PERMSET
{
mode_t ret = 0;
- ret |= (conn->vfs_ops.sys_acl_get_perm(conn, permset, SMB_ACL_READ) ? S_IRUSR : 0);
- ret |= (conn->vfs_ops.sys_acl_get_perm(conn, permset, SMB_ACL_WRITE) ? S_IWUSR : 0);
- ret |= (conn->vfs_ops.sys_acl_get_perm(conn, permset, SMB_ACL_EXECUTE) ? S_IXUSR : 0);
+ ret |= (VFS_SYS_ACL_GET_PERM(conn, permset, SMB_ACL_READ) ? S_IRUSR : 0);
+ ret |= (VFS_SYS_ACL_GET_PERM(conn, permset, SMB_ACL_WRITE) ? S_IWUSR : 0);
+ ret |= (VFS_SYS_ACL_GET_PERM(conn, permset, SMB_ACL_EXECUTE) ? S_IXUSR : 0);
return ret;
}
@@ -190,18 +190,18 @@ static mode_t unix_perms_to_acl_perms(mode_t mode, int r_mask, int w_mask, int x
static int map_acl_perms_to_permset(connection_struct *conn, mode_t mode, SMB_ACL_PERMSET_T *p_permset)
{
- if (conn->vfs_ops.sys_acl_clear_perms(conn, *p_permset) == -1)
+ if (VFS_SYS_ACL_CLEAR_PERMS(conn, *p_permset) == -1)
return -1;
if (mode & S_IRUSR) {
- if (conn->vfs_ops.sys_acl_add_perm(conn, *p_permset, SMB_ACL_READ) == -1)
+ if (VFS_SYS_ACL_ADD_PERM(conn, *p_permset, SMB_ACL_READ) == -1)
return -1;
}
if (mode & S_IWUSR) {
- if (conn->vfs_ops.sys_acl_add_perm(conn, *p_permset, SMB_ACL_WRITE) == -1)
+ if (VFS_SYS_ACL_ADD_PERM(conn, *p_permset, SMB_ACL_WRITE) == -1)
return -1;
}
if (mode & S_IXUSR) {
- if (conn->vfs_ops.sys_acl_add_perm(conn, *p_permset, SMB_ACL_EXECUTE) == -1)
+ if (VFS_SYS_ACL_ADD_PERM(conn, *p_permset, SMB_ACL_EXECUTE) == -1)
return -1;
}
return 0;
@@ -649,7 +649,7 @@ static BOOL ensure_canon_entry_valid(canon_ace **pp_ace,
/*
* When setting ACLs and missing one out of SMB_ACL_USER_OBJ,
* SMB_ACL_GROUP_OBJ, SMB_ACL_OTHER, try to retrieve current
- * values. For user and other a simple vfs_stat would do, but
+ * values. For user and other a simple VFS_STAT would do, but
* we would get mask instead of group. Let's do it via ACL.
*/
@@ -659,13 +659,13 @@ static BOOL ensure_canon_entry_valid(canon_ace **pp_ace,
int entry_id = SMB_ACL_FIRST_ENTRY;
if(fsp->is_directory || fsp->fd == -1) {
- current_posix_acl = conn->vfs_ops.sys_acl_get_file(conn, fsp->fsp_name, SMB_ACL_TYPE_ACCESS);
+ current_posix_acl = VFS_SYS_ACL_GET_FILE(conn, fsp->fsp_name, SMB_ACL_TYPE_ACCESS);
} else {
- current_posix_acl = conn->vfs_ops.sys_acl_get_fd(fsp, fsp->fd);
+ current_posix_acl = VFS_SYS_ACL_GET_FD(fsp, fsp->fd);
}
if (current_posix_acl) {
- while (conn->vfs_ops.sys_acl_get_entry(conn, current_posix_acl, entry_id, &entry) == 1) {
+ while (VFS_SYS_ACL_GET_ENTRY(conn, current_posix_acl, entry_id, &entry) == 1) {
SMB_ACL_TAG_T tagtype;
SMB_ACL_PERMSET_T permset;
@@ -674,10 +674,10 @@ static BOOL ensure_canon_entry_valid(canon_ace **pp_ace,
entry_id = SMB_ACL_NEXT_ENTRY;
/* Is this a MASK entry ? */
- if (conn->vfs_ops.sys_acl_get_tag_type(conn, entry, &tagtype) == -1)
+ if (VFS_SYS_ACL_GET_TAG_TYPE(conn, entry, &tagtype) == -1)
continue;
- if (conn->vfs_ops.sys_acl_get_permset(conn, entry, &permset) == -1)
+ if (VFS_SYS_ACL_GET_PERMSET(conn, entry, &permset) == -1)
continue;
switch(tagtype) {
@@ -695,7 +695,7 @@ static BOOL ensure_canon_entry_valid(canon_ace **pp_ace,
break;
}
}
- conn->vfs_ops.sys_acl_free_acl(conn, current_posix_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, current_posix_acl);
} else {
DEBUG(10,("ensure_canon_entry_valid: failed to retrieve current ACL of %s\n",
fsp->fsp_name));
@@ -1658,7 +1658,7 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
SMB_ACL_ENTRY_T entry;
size_t ace_count;
- while ( posix_acl && (conn->vfs_ops.sys_acl_get_entry(conn, posix_acl, entry_id, &entry) == 1)) {
+ while ( posix_acl && (VFS_SYS_ACL_GET_ENTRY(conn, posix_acl, entry_id, &entry) == 1)) {
SMB_ACL_TAG_T tagtype;
SMB_ACL_PERMSET_T permset;
DOM_SID sid;
@@ -1670,10 +1670,10 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
entry_id = SMB_ACL_NEXT_ENTRY;
/* Is this a MASK entry ? */
- if (conn->vfs_ops.sys_acl_get_tag_type(conn, entry, &tagtype) == -1)
+ if (VFS_SYS_ACL_GET_TAG_TYPE(conn, entry, &tagtype) == -1)
continue;
- if (conn->vfs_ops.sys_acl_get_permset(conn, entry, &permset) == -1)
+ if (VFS_SYS_ACL_GET_PERMSET(conn, entry, &permset) == -1)
continue;
/* Decide which SID to use based on the ACL type. */
@@ -1686,7 +1686,7 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
break;
case SMB_ACL_USER:
{
- uid_t *puid = (uid_t *)conn->vfs_ops.sys_acl_get_qualifier(conn, entry);
+ uid_t *puid = (uid_t *)VFS_SYS_ACL_GET_QUALIFIER(conn, entry);
if (puid == NULL) {
DEBUG(0,("canonicalise_acl: Failed to get uid.\n"));
continue;
@@ -1703,7 +1703,7 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
uid_to_sid( &sid, *puid);
unix_ug.uid = *puid;
owner_type = UID_ACE;
- conn->vfs_ops.sys_acl_free_qualifier(conn, (void *)puid,tagtype);
+ VFS_SYS_ACL_FREE_QUALIFIER(conn, (void *)puid,tagtype);
break;
}
case SMB_ACL_GROUP_OBJ:
@@ -1714,7 +1714,7 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
break;
case SMB_ACL_GROUP:
{
- gid_t *pgid = (gid_t *)conn->vfs_ops.sys_acl_get_qualifier(conn, entry);
+ gid_t *pgid = (gid_t *)VFS_SYS_ACL_GET_QUALIFIER(conn, entry);
if (pgid == NULL) {
DEBUG(0,("canonicalise_acl: Failed to get gid.\n"));
continue;
@@ -1722,7 +1722,7 @@ static canon_ace *canonicalise_acl( files_struct *fsp, SMB_ACL_T posix_acl, SMB_
gid_to_sid( &sid, *pgid);
unix_ug.gid = *pgid;
owner_type = GID_ACE;
- conn->vfs_ops.sys_acl_free_qualifier(conn, (void *)pgid,tagtype);
+ VFS_SYS_ACL_FREE_QUALIFIER(conn, (void *)pgid,tagtype);
break;
}
case SMB_ACL_MASK:
@@ -1807,7 +1807,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
{
connection_struct *conn = fsp->conn;
BOOL ret = False;
- SMB_ACL_T the_acl = conn->vfs_ops.sys_acl_init(conn, (int)count_canon_ace_list(the_ace) + 1);
+ SMB_ACL_T the_acl = VFS_SYS_ACL_INIT(conn, (int)count_canon_ace_list(the_ace) + 1);
canon_ace *p_ace;
int i;
SMB_ACL_ENTRY_T mask_entry;
@@ -1865,7 +1865,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
* Get the entry for this ACE.
*/
- if (conn->vfs_ops.sys_acl_create_entry(conn, &the_acl, &the_entry) == -1) {
+ if (VFS_SYS_ACL_CREATE_ENTRY(conn, &the_acl, &the_entry) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to create entry %d. (%s)\n",
i, strerror(errno) ));
goto done;
@@ -1891,7 +1891,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
* First tell the entry what type of ACE this is.
*/
- if (conn->vfs_ops.sys_acl_set_tag_type(conn, the_entry, p_ace->type) == -1) {
+ if (VFS_SYS_ACL_SET_TAG_TYPE(conn, the_entry, p_ace->type) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to set tag type on entry %d. (%s)\n",
i, strerror(errno) ));
goto done;
@@ -1903,7 +1903,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
*/
if ((p_ace->type == SMB_ACL_USER) || (p_ace->type == SMB_ACL_GROUP)) {
- if (conn->vfs_ops.sys_acl_set_qualifier(conn, the_entry,(void *)&p_ace->unix_ug.uid) == -1) {
+ if (VFS_SYS_ACL_SET_QUALIFIER(conn, the_entry,(void *)&p_ace->unix_ug.uid) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to set qualifier on entry %d. (%s)\n",
i, strerror(errno) ));
goto done;
@@ -1914,7 +1914,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
* Convert the mode_t perms in the canon_ace to a POSIX permset.
*/
- if (conn->vfs_ops.sys_acl_get_permset(conn, the_entry, &the_permset) == -1) {
+ if (VFS_SYS_ACL_GET_PERMSET(conn, the_entry, &the_permset) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to get permset on entry %d. (%s)\n",
i, strerror(errno) ));
goto done;
@@ -1930,7 +1930,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
* ..and apply them to the entry.
*/
- if (conn->vfs_ops.sys_acl_set_permset(conn, the_entry, the_permset) == -1) {
+ if (VFS_SYS_ACL_SET_PERMSET(conn, the_entry, the_permset) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to add permset on entry %d. (%s)\n",
i, strerror(errno) ));
goto done;
@@ -1941,17 +1941,17 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
}
if (needs_mask && !got_mask_entry) {
- if (conn->vfs_ops.sys_acl_create_entry(conn, &the_acl, &mask_entry) == -1) {
+ if (VFS_SYS_ACL_CREATE_ENTRY(conn, &the_acl, &mask_entry) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to create mask entry. (%s)\n", strerror(errno) ));
goto done;
}
- if (conn->vfs_ops.sys_acl_set_tag_type(conn, mask_entry, SMB_ACL_MASK) == -1) {
+ if (VFS_SYS_ACL_SET_TAG_TYPE(conn, mask_entry, SMB_ACL_MASK) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to set tag type on mask entry. (%s)\n",strerror(errno) ));
goto done;
}
- if (conn->vfs_ops.sys_acl_get_permset(conn, mask_entry, &mask_permset) == -1) {
+ if (VFS_SYS_ACL_GET_PERMSET(conn, mask_entry, &mask_permset) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to get mask permset. (%s)\n", strerror(errno) ));
goto done;
}
@@ -1961,7 +1961,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
goto done;
}
- if (conn->vfs_ops.sys_acl_set_permset(conn, mask_entry, mask_permset) == -1) {
+ if (VFS_SYS_ACL_SET_PERMSET(conn, mask_entry, mask_permset) == -1) {
DEBUG(0,("set_canon_ace_list: Failed to add mask permset. (%s)\n", strerror(errno) ));
goto done;
}
@@ -1971,7 +1971,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
* Check if the ACL is valid.
*/
- if (conn->vfs_ops.sys_acl_valid(conn, the_acl) == -1) {
+ if (VFS_SYS_ACL_VALID(conn, the_acl) == -1) {
DEBUG(0,("set_canon_ace_list: ACL type (%s) is invalid for set (%s).\n",
the_acl_type == SMB_ACL_TYPE_DEFAULT ? "directory default" : "file",
strerror(errno) ));
@@ -1983,7 +1983,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
*/
if(default_ace || fsp->is_directory || fsp->fd == -1) {
- if (conn->vfs_ops.sys_acl_set_file(conn, fsp->fsp_name, the_acl_type, the_acl) == -1) {
+ if (VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name, the_acl_type, the_acl) == -1) {
/*
* Some systems allow all the above calls and only fail with no ACL support
* when attempting to apply the acl. HPUX with HFS is an example of this. JRA.
@@ -2002,7 +2002,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
goto done;
}
} else {
- if (conn->vfs_ops.sys_acl_set_fd(fsp, fsp->fd, the_acl) == -1) {
+ if (VFS_SYS_ACL_SET_FD(fsp, fsp->fd, the_acl) == -1) {
/*
* Some systems allow all the above calls and only fail with no ACL support
* when attempting to apply the acl. HPUX with HFS is an example of this. JRA.
@@ -2026,7 +2026,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau
done:
if (the_acl != NULL)
- conn->vfs_ops.sys_acl_free_acl(conn, the_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, the_acl);
return ret;
}
@@ -2057,8 +2057,8 @@ SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T acl)
if (!acl)
return NULL;
- if (conn->vfs_ops.sys_acl_get_entry(conn, acl, SMB_ACL_FIRST_ENTRY, &entry) != 1) {
- conn->vfs_ops.sys_acl_free_acl(conn, acl);
+ if (VFS_SYS_ACL_GET_ENTRY(conn, acl, SMB_ACL_FIRST_ENTRY, &entry) != 1) {
+ VFS_SYS_ACL_FREE_ACL(conn, acl);
return NULL;
}
return acl;
@@ -2224,34 +2224,34 @@ size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc)
if(fsp->is_directory || fsp->fd == -1) {
/* Get the stat struct for the owner info. */
- if(vfs_stat(fsp->conn,fsp->fsp_name, &sbuf) != 0) {
+ if(VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf) != 0) {
return 0;
}
/*
* Get the ACL from the path.
*/
- posix_acl = conn->vfs_ops.sys_acl_get_file(conn, fsp->fsp_name, SMB_ACL_TYPE_ACCESS);
+ posix_acl = VFS_SYS_ACL_GET_FILE(conn, fsp->fsp_name, SMB_ACL_TYPE_ACCESS);
/*
* If it's a directory get the default POSIX ACL.
*/
if(fsp->is_directory) {
- dir_acl = conn->vfs_ops.sys_acl_get_file(conn, fsp->fsp_name, SMB_ACL_TYPE_DEFAULT);
+ dir_acl = VFS_SYS_ACL_GET_FILE(conn, fsp->fsp_name, SMB_ACL_TYPE_DEFAULT);
dir_acl = free_empty_sys_acl(conn, dir_acl);
}
} else {
/* Get the stat struct for the owner info. */
- if(vfs_fstat(fsp,fsp->fd,&sbuf) != 0) {
+ if(VFS_FSTAT(fsp,fsp->fd,&sbuf) != 0) {
return 0;
}
/*
* Get the ACL from the fd.
*/
- posix_acl = conn->vfs_ops.sys_acl_get_fd(fsp, fsp->fd);
+ posix_acl = VFS_SYS_ACL_GET_FD(fsp, fsp->fd);
}
DEBUG(5,("get_nt_acl : file ACL %s, directory ACL %s\n",
@@ -2479,9 +2479,9 @@ size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc)
done:
if (posix_acl)
- conn->vfs_ops.sys_acl_free_acl(conn, posix_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, posix_acl);
if (dir_acl)
- conn->vfs_ops.sys_acl_free_acl(conn, dir_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, dir_acl);
free_canon_ace_list(file_ace);
free_canon_ace_list(dir_ace);
SAFE_FREE(nt_ace_list);
@@ -2505,14 +2505,14 @@ static int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_
SMB_STRUCT_STAT st;
/* try the direct way first */
- ret = vfs_chown(conn, fname, uid, gid);
+ ret = VFS_CHOWN(conn, fname, uid, gid);
if (ret == 0)
return 0;
if(!CAN_WRITE(conn) || !lp_dos_filemode(SNUM(conn)))
return -1;
- if (vfs_stat(conn,fname,&st))
+ if (VFS_STAT(conn,fname,&st))
return -1;
fsp = open_file_fchmod(conn,fname,&st);
@@ -2527,7 +2527,7 @@ static int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_
become_root();
/* Keep the current file gid the same. */
- ret = vfswrap_fchown(fsp, fsp->fd, uid, (gid_t)-1);
+ ret = VFS_FCHOWN(fsp, fsp->fd, uid, (gid_t)-1);
unbecome_root();
close_file_fchmod(fsp);
@@ -2570,10 +2570,10 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
*/
if(fsp->is_directory || fsp->fd == -1) {
- if(vfs_stat(fsp->conn,fsp->fsp_name, &sbuf) != 0)
+ if(VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf) != 0)
return False;
} else {
- if(vfs_fstat(fsp,fsp->fd,&sbuf) != 0)
+ if(VFS_FSTAT(fsp,fsp->fd,&sbuf) != 0)
return False;
}
@@ -2619,7 +2619,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
*/
if(fsp->is_directory) {
- if(vfs_stat(fsp->conn, fsp->fsp_name, &sbuf) != 0) {
+ if(VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf) != 0) {
return False;
}
} else {
@@ -2627,9 +2627,9 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
int ret;
if(fsp->fd == -1)
- ret = vfs_stat(fsp->conn, fsp->fsp_name, &sbuf);
+ ret = VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf);
else
- ret = vfs_fstat(fsp,fsp->fd,&sbuf);
+ ret = VFS_FSTAT(fsp,fsp->fd,&sbuf);
if(ret != 0)
return False;
@@ -2697,7 +2697,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
* No default ACL - delete one if it exists.
*/
- if (conn->vfs_ops.sys_acl_delete_def_file(conn, fsp->fsp_name) == -1) {
+ if (VFS_SYS_ACL_DELETE_DEF_FILE(conn, fsp->fsp_name) == -1) {
DEBUG(3,("set_nt_acl: sys_acl_delete_def_file failed (%s)\n", strerror(errno)));
free_canon_ace_list(file_ace_list);
free_canon_ace_list(dir_ace_list);
@@ -2726,7 +2726,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n",
fsp->fsp_name, (unsigned int)posix_perms ));
- if(conn->vfs_ops.chmod(conn,fsp->fsp_name, posix_perms) == -1) {
+ if(VFS_CHMOD(conn,fsp->fsp_name, posix_perms) == -1) {
DEBUG(3,("set_nt_acl: chmod %s, 0%o failed. Error = %s.\n",
fsp->fsp_name, (unsigned int)posix_perms, strerror(errno) ));
free_canon_ace_list(file_ace_list);
@@ -2768,7 +2768,7 @@ static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mo
SMB_ACL_ENTRY_T entry;
int num_entries = 0;
- while ( conn->vfs_ops.sys_acl_get_entry(conn, posix_acl, entry_id, &entry) == 1) {
+ while ( VFS_SYS_ACL_GET_ENTRY(conn, posix_acl, entry_id, &entry) == 1) {
SMB_ACL_TAG_T tagtype;
SMB_ACL_PERMSET_T permset;
mode_t perms;
@@ -2777,10 +2777,10 @@ static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mo
if (entry_id == SMB_ACL_FIRST_ENTRY)
entry_id = SMB_ACL_NEXT_ENTRY;
- if (conn->vfs_ops.sys_acl_get_tag_type(conn, entry, &tagtype) == -1)
+ if (VFS_SYS_ACL_GET_TAG_TYPE(conn, entry, &tagtype) == -1)
return -1;
- if (conn->vfs_ops.sys_acl_get_permset(conn, entry, &permset) == -1)
+ if (VFS_SYS_ACL_GET_PERMSET(conn, entry, &permset) == -1)
return -1;
num_entries++;
@@ -2811,7 +2811,7 @@ static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mo
if (map_acl_perms_to_permset(conn, perms, &permset) == -1)
return -1;
- if (conn->vfs_ops.sys_acl_set_permset(conn, entry, permset) == -1)
+ if (VFS_SYS_ACL_SET_PERMSET(conn, entry, permset) == -1)
return -1;
}
@@ -2837,17 +2837,17 @@ static int copy_access_acl(connection_struct *conn, const char *from, const char
SMB_ACL_T posix_acl = NULL;
int ret = -1;
- if ((posix_acl = conn->vfs_ops.sys_acl_get_file(conn, from, SMB_ACL_TYPE_ACCESS)) == NULL)
+ if ((posix_acl = VFS_SYS_ACL_GET_FILE(conn, from, SMB_ACL_TYPE_ACCESS)) == NULL)
return -1;
if ((ret = chmod_acl_internals(conn, posix_acl, mode)) == -1)
goto done;
- ret = conn->vfs_ops.sys_acl_set_file(conn, to, SMB_ACL_TYPE_ACCESS, posix_acl);
+ ret = VFS_SYS_ACL_SET_FILE(conn, to, SMB_ACL_TYPE_ACCESS, posix_acl);
done:
- conn->vfs_ops.sys_acl_free_acl(conn, posix_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, posix_acl);
return ret;
}
@@ -2889,17 +2889,17 @@ int fchmod_acl(files_struct *fsp, int fd, mode_t mode)
SMB_ACL_T posix_acl = NULL;
int ret = -1;
- if ((posix_acl = conn->vfs_ops.sys_acl_get_fd(fsp, fd)) == NULL)
+ if ((posix_acl = VFS_SYS_ACL_GET_FD(fsp, fd)) == NULL)
return -1;
if ((ret = chmod_acl_internals(conn, posix_acl, mode)) == -1)
goto done;
- ret = conn->vfs_ops.sys_acl_set_fd(fsp, fd, posix_acl);
+ ret = VFS_SYS_ACL_SET_FD(fsp, fd, posix_acl);
done:
- conn->vfs_ops.sys_acl_free_acl(conn, posix_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, posix_acl);
return ret;
}
@@ -2909,14 +2909,14 @@ int fchmod_acl(files_struct *fsp, int fd, mode_t mode)
BOOL directory_has_default_acl(connection_struct *conn, const char *fname)
{
- SMB_ACL_T dir_acl = conn->vfs_ops.sys_acl_get_file( conn, fname, SMB_ACL_TYPE_DEFAULT);
+ SMB_ACL_T dir_acl = VFS_SYS_ACL_GET_FILE( conn, fname, SMB_ACL_TYPE_DEFAULT);
BOOL has_acl = False;
SMB_ACL_ENTRY_T entry;
- if (dir_acl != NULL && (conn->vfs_ops.sys_acl_get_entry(conn, dir_acl, SMB_ACL_FIRST_ENTRY, &entry) == 1))
+ if (dir_acl != NULL && (VFS_SYS_ACL_GET_ENTRY(conn, dir_acl, SMB_ACL_FIRST_ENTRY, &entry) == 1))
has_acl = True;
if (dir_acl)
- conn->vfs_ops.sys_acl_free_acl(conn, dir_acl);
+ VFS_SYS_ACL_FREE_ACL(conn, dir_acl);
return has_acl;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9577196bfe..49a9b934b0 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -399,7 +399,7 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
mode = SVAL(inbuf,smb_vwv0);
if (check_name(name,conn)) {
- if (VALID_STAT(sbuf) || vfs_stat(conn,name,&sbuf) == 0)
+ if (VALID_STAT(sbuf) || VFS_STAT(conn,name,&sbuf) == 0)
if (!(ok = S_ISDIR(sbuf.st_mode)))
errno = ENOTDIR;
}
@@ -458,7 +458,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
} else {
unix_convert(fname,conn,0,&bad_path,&sbuf);
if (check_name(fname,conn)) {
- if (VALID_STAT(sbuf) || vfs_stat(conn,fname,&sbuf) == 0) {
+ if (VALID_STAT(sbuf) || VFS_STAT(conn,fname,&sbuf) == 0) {
mode = dos_mode(conn,fname,&sbuf);
size = sbuf.st_size;
mtime = sbuf.st_mtime;
@@ -553,7 +553,7 @@ int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
SMB_BIG_UINT dfree,dsize,bsize;
START_PROFILE(SMBdskattr);
- conn->vfs_ops.disk_free(conn,".",True,&bsize,&dfree,&dsize);
+ VFS_DISK_FREE(conn,".",True,&bsize,&dfree,&dsize);
outsize = set_message(outbuf,5,0,True);
@@ -1128,7 +1128,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- vfs_stat(conn,fname,&sbuf);
+ VFS_STAT(conn,fname,&sbuf);
/* Open file in dos compatibility share mode. */
/* We should fail if file does not exist. */
@@ -1227,7 +1227,7 @@ static NTSTATUS can_delete(char *fname,connection_struct *conn, int dirtype)
if (!CAN_WRITE(conn))
return NT_STATUS_MEDIA_WRITE_PROTECTED;
- if (conn->vfs_ops.lstat(conn,fname,&sbuf) != 0)
+ if (VFS_LSTAT(conn,fname,&sbuf) != 0)
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
fmode = dos_mode(conn,fname,&sbuf);
@@ -1313,7 +1313,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
error = can_delete(directory,conn,dirtype);
if (!NT_STATUS_IS_OK(error)) return error;
- if (vfs_unlink(conn,directory) == 0) {
+ if (VFS_UNLINK(conn,directory) == 0) {
count++;
}
} else {
@@ -1343,7 +1343,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
error = can_delete(fname,conn,dirtype);
if (!NT_STATUS_IS_OK(error)) continue;
- if (vfs_unlink(conn,fname) == 0) count++;
+ if (VFS_UNLINK(conn,fname) == 0) count++;
DEBUG(3,("unlink_internals: succesful unlink [%s]\n",fname));
}
CloseDir(dirptr);
@@ -1429,7 +1429,7 @@ void send_file_readbraw(connection_struct *conn, files_struct *fsp, SMB_OFF_T st
header.length = 4;
header.free = NULL;
- if ( conn->vfs_ops.sendfile( smbd_server_fd(), fsp, fsp->fd, &header, startpos, nread) == -1) {
+ if ( VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fd, &header, startpos, nread) == -1) {
/*
* Special hack for broken Linux with no 64 bit clean sendfile. If we
* return ENOSYS then pretend we just got a normal read.
@@ -1554,7 +1554,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (size < sizeneeded) {
SMB_STRUCT_STAT st;
- if (vfs_fstat(fsp,fsp->fd,&st) == 0)
+ if (VFS_FSTAT(fsp,fsp->fd,&st) == 0)
size = st.st_size;
if (!fsp->can_write)
fsp->size = size;
@@ -1723,7 +1723,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
SMB_STRUCT_STAT sbuf;
DATA_BLOB header;
- if(vfs_fstat(fsp,fsp->fd, &sbuf) == -1)
+ if(VFS_FSTAT(fsp,fsp->fd, &sbuf) == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
if (startpos > sbuf.st_size)
@@ -1750,7 +1750,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
header.length = data - outbuf;
header.free = NULL;
- if ( conn->vfs_ops.sendfile( smbd_server_fd(), fsp, fsp->fd, &header, startpos, smb_maxcnt) == -1) {
+ if ( VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fd, &header, startpos, smb_maxcnt) == -1) {
/*
* Special hack for broken Linux with no 64 bit clean sendfile. If we
* return ENOSYS then pretend we just got a normal read.
@@ -2262,7 +2262,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
break;
}
- if((res = conn->vfs_ops.lseek(fsp,fsp->fd,startpos,umode)) == -1) {
+ if((res = VFS_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,
@@ -2274,7 +2274,7 @@ 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,fsp->fd,0,SEEK_CUR)) == -1) {
+ if((current_pos = VFS_LSEEK(fsp,fsp->fd,0,SEEK_CUR)) == -1) {
END_PROFILE(SMBlseek);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2285,7 +2285,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
SMB_STRUCT_STAT sbuf;
- if(vfs_fstat(fsp,fsp->fd, &sbuf) == -1) {
+ if(VFS_FSTAT(fsp,fsp->fd, &sbuf) == -1) {
END_PROFILE(SMBlseek);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2294,7 +2294,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
}
if(current_pos < 0)
- res = conn->vfs_ops.lseek(fsp,fsp->fd,0,SEEK_SET);
+ res = VFS_LSEEK(fsp,fsp->fd,0,SEEK_SET);
}
if(res == -1) {
@@ -2830,7 +2830,7 @@ NTSTATUS mkdir_internal(connection_struct *conn, pstring directory)
unix_convert(directory,conn,0,&bad_path,&sbuf);
if (check_name(directory, conn))
- ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory));
+ ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory));
if (ret == -1) {
NTSTATUS nterr = set_bad_path_error(errno, bad_path);
@@ -2901,7 +2901,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
pstrcat(fullname, "/");
pstrcat(fullname, dname);
- if(conn->vfs_ops.lstat(conn,fullname, &st) != 0) {
+ if(VFS_LSTAT(conn,fullname, &st) != 0) {
ret = True;
break;
}
@@ -2911,11 +2911,11 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
ret = True;
break;
}
- if(vfs_rmdir(conn,fullname) != 0) {
+ if(VFS_RMDIR(conn,fullname) != 0) {
ret = True;
break;
}
- } else if(vfs_unlink(conn,fullname) != 0) {
+ } else if(VFS_UNLINK(conn,fullname) != 0) {
ret = True;
break;
}
@@ -2932,7 +2932,7 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
{
BOOL ok;
- ok = (vfs_rmdir(conn,directory) == 0);
+ ok = (VFS_RMDIR(conn,directory) == 0);
if(!ok && ((errno == ENOTEMPTY)||(errno == EEXIST)) && lp_veto_files(SNUM(conn))) {
/*
* Check to see if the only thing in this directory are
@@ -2974,21 +2974,21 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
pstrcat(fullname, "/");
pstrcat(fullname, dname);
- if(conn->vfs_ops.lstat(conn,fullname, &st) != 0)
+ if(VFS_LSTAT(conn,fullname, &st) != 0)
break;
if(st.st_mode & S_IFDIR) {
if(lp_recursive_veto_delete(SNUM(conn))) {
if(recursive_rmdir(conn, fullname) != 0)
break;
}
- if(vfs_rmdir(conn,fullname) != 0)
+ if(VFS_RMDIR(conn,fullname) != 0)
break;
- } else if(vfs_unlink(conn,fullname) != 0)
+ } else if(VFS_UNLINK(conn,fullname) != 0)
break;
}
CloseDir(dirptr);
/* Retry the rmdir */
- ok = (vfs_rmdir(conn,directory) == 0);
+ ok = (VFS_RMDIR(conn,directory) == 0);
} else {
CloseDir(dirptr);
}
@@ -3284,7 +3284,7 @@ directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- if(conn->vfs_ops.rename(conn,directory, newname) == 0) {
+ if(VFS_RENAME(conn,directory, newname) == 0) {
DEBUG(3,("rename_internals: succeeded doing rename on %s -> %s\n",
directory,newname));
return NT_STATUS_OK;
@@ -3351,7 +3351,7 @@ directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
continue;
}
- if (!conn->vfs_ops.rename(conn,fname,destname))
+ if (!VFS_RENAME(conn,fname,destname))
count++;
DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
}
@@ -3445,7 +3445,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
if (!target_is_directory && count)
ofun = FILE_EXISTS_OPEN;
- if (vfs_stat(conn,dest,&sbuf2) == -1)
+ if (VFS_STAT(conn,dest,&sbuf2) == -1)
ZERO_STRUCTP(&sbuf2);
fsp2 = open_file_shared(conn,dest,&sbuf2,SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_WRONLY),
@@ -3457,7 +3457,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
}
if ((ofun&3) == 1) {
- if(conn->vfs_ops.lseek(fsp2,fsp2->fd,0,SEEK_END) == -1) {
+ if(VFS_LSEEK(fsp2,fsp2->fd,0,SEEK_END) == -1) {
DEBUG(0,("copy_file: error - vfs lseek returned error %s\n", strerror(errno) ));
/*
* Stop the copy from occurring.
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index cfb5e0e414..0e4c87c7fb 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -704,14 +704,12 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
/* Invoke VFS make connection hook */
- if (conn->vfs_ops.connect) {
- if (conn->vfs_ops.connect(conn, lp_servicename(snum), user) < 0) {
- DEBUG(0,("make_connection: VFS make connection failed!\n"));
- change_to_root_user();
- conn_free(conn);
- *status = NT_STATUS_UNSUCCESSFUL;
- return NULL;
- }
+ if (VFS_CONNECT(conn, lp_servicename(snum), user) < 0) {
+ DEBUG(0,("make_connection: VFS make connection failed!\n"));
+ change_to_root_user();
+ conn_free(conn);
+ *status = NT_STATUS_UNSUCCESSFUL;
+ return NULL;
}
/* we've finished with the user stuff - go back to root */
@@ -872,13 +870,8 @@ void close_cnum(connection_struct *conn, uint16 vuid)
get_remote_machine_name(),conn->client_address,
lp_servicename(SNUM(conn))));
- if (conn->vfs_ops.disconnect != NULL) {
-
- /* Call VFS disconnect hook */
-
- conn->vfs_ops.disconnect(conn);
-
- }
+ /* Call VFS disconnect hook */
+ VFS_DISCONNECT(conn);
yield_connection(conn, lp_servicename(SNUM(conn)));
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 44bae48990..5c77474fec 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -242,7 +242,7 @@ BOOL stat_cache_lookup(connection_struct *conn, pstring name, pstring dirpath,
} else {
scp = (stat_cache_entry *)(hash_elem->value);
DO_PROFILE_INC(statcache_hits);
- if(vfs_stat(conn,scp->translated_path, pst) != 0) {
+ if(VFS_STAT(conn,scp->translated_path, pst) != 0) {
/* Discard this entry - it doesn't exist in the filesystem. */
hash_remove(&stat_cache, hash_elem);
return False;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index de598d6713..c9eef637d9 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -549,12 +549,12 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
pstrcat(pathreal,dname);
if (INFO_LEVEL_IS_UNIX(info_level)) {
- if (vfs_lstat(conn,pathreal,&sbuf) != 0) {
+ if (VFS_LSTAT(conn,pathreal,&sbuf) != 0) {
DEBUG(5,("get_lanman2_dir_entry:Couldn't lstat [%s] (%s)\n",
pathreal,strerror(errno)));
continue;
}
- } else if (vfs_stat(conn,pathreal,&sbuf) != 0) {
+ } else if (VFS_STAT(conn,pathreal,&sbuf) != 0) {
/* Needed to show the msdfs symlinks as
* directories */
@@ -1321,7 +1321,7 @@ static int call_trans2qfsinfo(connection_struct *conn, char *inbuf, char *outbuf
DEBUG(3,("call_trans2qfsinfo: level = %d\n", info_level));
- if(vfs_stat(conn,".",&st)!=0) {
+ if(VFS_STAT(conn,".",&st)!=0) {
DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n", strerror(errno)));
return ERROR_DOS(ERRSRV,ERRinvdevice);
}
@@ -1338,7 +1338,7 @@ static int call_trans2qfsinfo(connection_struct *conn, char *inbuf, char *outbuf
{
SMB_BIG_UINT dfree,dsize,bsize;
data_len = 18;
- conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);
+ VFS_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);
@@ -1406,7 +1406,7 @@ static int call_trans2qfsinfo(connection_struct *conn, char *inbuf, char *outbuf
{
SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 24;
- conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);
+ VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize);
block_size = lp_block_size(snum);
if (bsize < block_size) {
SMB_BIG_UINT factor = block_size/bsize;
@@ -1436,7 +1436,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
{
SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 32;
- conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);
+ VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize);
block_size = lp_block_size(snum);
if (bsize < block_size) {
SMB_BIG_UINT factor = block_size/bsize;
@@ -1605,13 +1605,13 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
if (INFO_LEVEL_IS_UNIX(info_level)) {
/* Always do lstat for UNIX calls. */
- if (vfs_lstat(conn,fname,&sbuf)) {
- DEBUG(3,("call_trans2qfilepathinfo: vfs_lstat of %s failed (%s)\n",fname,strerror(errno)));
+ if (VFS_LSTAT(conn,fname,&sbuf)) {
+ DEBUG(3,("call_trans2qfilepathinfo: VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
set_bad_path_error(errno, bad_path);
return(UNIXERROR(ERRDOS,ERRbadpath));
}
- } else if (!VALID_STAT(sbuf) && vfs_stat(conn,fname,&sbuf)) {
- DEBUG(3,("call_trans2qfilepathinfo: vfs_stat of %s failed (%s)\n",fname,strerror(errno)));
+ } else if (!VALID_STAT(sbuf) && VFS_STAT(conn,fname,&sbuf)) {
+ DEBUG(3,("call_trans2qfilepathinfo: VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
set_bad_path_error(errno, bad_path);
return(UNIXERROR(ERRDOS,ERRbadpath));
}
@@ -1624,11 +1624,11 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
CHECK_FSP(fsp,conn);
pstrcpy(fname, fsp->fsp_name);
- if (vfs_fstat(fsp,fsp->fd,&sbuf) != 0) {
+ if (VFS_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,fsp->fd,0,SEEK_CUR)) == -1)
+ if((pos = VFS_LSEEK(fsp,fsp->fd,0,SEEK_CUR)) == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
delete_pending = fsp->delete_on_close;
@@ -1655,13 +1655,13 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
if (INFO_LEVEL_IS_UNIX(info_level)) {
/* Always do lstat for UNIX calls. */
- if (vfs_lstat(conn,fname,&sbuf)) {
- DEBUG(3,("call_trans2qfilepathinfo: vfs_lstat of %s failed (%s)\n",fname,strerror(errno)));
+ if (VFS_LSTAT(conn,fname,&sbuf)) {
+ DEBUG(3,("call_trans2qfilepathinfo: VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
set_bad_path_error(errno, bad_path);
return(UNIXERROR(ERRDOS,ERRbadpath));
}
- } else if (!VALID_STAT(sbuf) && vfs_stat(conn,fname,&sbuf)) {
- DEBUG(3,("call_trans2qfilepathinfo: vfs_stat of %s failed (%s)\n",fname,strerror(errno)));
+ } else if (!VALID_STAT(sbuf) && VFS_STAT(conn,fname,&sbuf)) {
+ DEBUG(3,("call_trans2qfilepathinfo: VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
set_bad_path_error(errno, bad_path);
return(UNIXERROR(ERRDOS,ERRbadpath));
}
@@ -2054,7 +2054,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
#else
return(UNIXERROR(ERRDOS,ERRbadlink));
#endif
- len = conn->vfs_ops.readlink(conn,fullpathname, buffer, sizeof(pstring)-1); /* read link */
+ len = VFS_READLINK(conn,fullpathname, buffer, sizeof(pstring)-1); /* read link */
if (len == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
buffer[len] = 0;
@@ -2178,7 +2178,7 @@ static int ensure_link_is_safe(connection_struct *conn, const char *link_dest_in
pstrcpy(link_dest, "./");
}
- if (conn->vfs_ops.realpath(conn,link_dest,resolved_name) == NULL)
+ if (VFS_REALPATH(conn,link_dest,resolved_name) == NULL)
return -1;
pstrcpy(link_dest, resolved_name);
@@ -2269,7 +2269,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
pstrcpy(fname, fsp->fsp_name);
fd = fsp->fd;
- if (vfs_fstat(fsp,fd,&sbuf) != 0) {
+ if (VFS_FSTAT(fsp,fd,&sbuf) != 0) {
DEBUG(3,("call_trans2setfilepathinfo: fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
return(UNIXERROR(ERRDOS,ERRbadfid));
}
@@ -2461,7 +2461,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
if (new_fsp == NULL)
return(UNIXERROR(ERRDOS,ERRbadpath));
ret = vfs_allocate_file_space(new_fsp, allocation_size);
- if (vfs_fstat(new_fsp,new_fsp->fd,&new_sbuf) != 0) {
+ if (VFS_FSTAT(new_fsp,new_fsp->fd,&new_sbuf) != 0) {
DEBUG(3,("call_trans2setfilepathinfo: fstat of fnum %d failed (%s)\n",
new_fsp->fnum, strerror(errno)));
ret = -1;
@@ -2469,7 +2469,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
close_file(new_fsp,True);
} else {
ret = vfs_allocate_file_space(fsp, allocation_size);
- if (vfs_fstat(fsp,fd,&new_sbuf) != 0) {
+ if (VFS_FSTAT(fsp,fd,&new_sbuf) != 0) {
DEBUG(3,("call_trans2setfilepathinfo: fstat of fnum %d failed (%s)\n",
fsp->fnum, strerror(errno)));
ret = -1;
@@ -2609,7 +2609,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
0%o for file %s\n", (double)dev, unixmode, fname ));
/* Ok - do the mknod. */
- if (conn->vfs_ops.mknod(conn,dos_to_unix_static(fname), unixmode, dev) != 0)
+ if (VFS_MKNOD(conn,dos_to_unix_static(fname), unixmode, dev) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
inherit_access_acl(conn, fname, unixmode);
@@ -2628,7 +2628,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
if (raw_unixmode != SMB_MODE_NO_CHANGE) {
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_BASIC setting mode 0%o for file %s\n",
(unsigned int)unixmode, fname ));
- if (vfs_chmod(conn,fname,unixmode) != 0)
+ if (VFS_CHMOD(conn,fname,unixmode) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2639,7 +2639,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
if ((set_owner != (uid_t)SMB_UID_NO_CHANGE) && (sbuf.st_uid != set_owner)) {
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_BASIC changing owner %u for file %s\n",
(unsigned int)set_owner, fname ));
- if (vfs_chown(conn,fname,set_owner, (gid_t)-1) != 0)
+ if (VFS_CHOWN(conn,fname,set_owner, (gid_t)-1) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -2650,7 +2650,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
if ((set_grp != (uid_t)SMB_GID_NO_CHANGE) && (sbuf.st_gid != set_grp)) {
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_BASIC changing group %u for file %s\n",
(unsigned int)set_owner, fname ));
- if (vfs_chown(conn,fname,(uid_t)-1, set_grp) != 0)
+ if (VFS_CHOWN(conn,fname,(uid_t)-1, set_grp) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
break;
@@ -2677,7 +2677,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
fname, link_dest ));
- if (conn->vfs_ops.symlink(conn,link_dest,fname) != 0)
+ if (VFS_SYMLINK(conn,link_dest,fname) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
SSVAL(params,0,0);
send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0);
@@ -2702,7 +2702,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
fname, link_dest ));
- if (conn->vfs_ops.link(conn,link_dest,fname) != 0)
+ if (VFS_LINK(conn,link_dest,fname) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
SSVAL(params,0,0);
send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0);
@@ -2854,7 +2854,7 @@ static int call_trans2mkdir(connection_struct *conn,
unix_convert(directory,conn,0,&bad_path,&sbuf);
if (check_name(directory,conn))
- ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory));
+ ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory));
if(ret < 0) {
DEBUG(5,("call_trans2mkdir error (%s)\n", strerror(errno)));
diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c
index 491fa70e68..4422666006 100644
--- a/source3/smbd/vfs-wrap.c
+++ b/source3/smbd/vfs-wrap.c
@@ -30,18 +30,18 @@
is sure to try and execute them. These stubs are used to prevent
this possibility. */
-int vfswrap_dummy_connect(connection_struct *conn, const char *service, const char *user)
+int vfswrap_dummy_connect(vfs_handle_struct *handle, connection_struct *conn, const char *service, const char *user)
{
return 0; /* Return >= 0 for success */
}
-void vfswrap_dummy_disconnect(connection_struct *conn)
+void vfswrap_dummy_disconnect(vfs_handle_struct *handle, connection_struct *conn)
{
}
/* Disk operations */
-SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize,
+SMB_BIG_UINT vfswrap_disk_free(vfs_handle_struct *handle, connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
SMB_BIG_UINT result;
@@ -52,7 +52,7 @@ SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, const char *path, BOOL s
/* Directory operations */
-DIR *vfswrap_opendir(connection_struct *conn, const char *fname)
+DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
{
DIR *result;
@@ -62,7 +62,7 @@ DIR *vfswrap_opendir(connection_struct *conn, const char *fname)
return result;
}
-struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp)
+struct dirent *vfswrap_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
{
struct dirent *result;
@@ -72,7 +72,7 @@ struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp)
return result;
}
-int vfswrap_mkdir(connection_struct *conn, const char *path, mode_t mode)
+int vfswrap_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode)
{
int result;
BOOL has_dacl = False;
@@ -93,8 +93,8 @@ int vfswrap_mkdir(connection_struct *conn, const char *path, mode_t mode)
* mess up any inherited ACL bits that were set. JRA.
*/
int saved_errno = errno; /* We may get ENOSYS */
- if (conn->vfs_ops.chmod_acl != NULL) {
- if ((conn->vfs_ops.chmod_acl(conn, path, mode) == -1) && (errno == ENOSYS))
+ if (conn->vfs.ops.chmod_acl != NULL) {
+ if ((VFS_CHMOD_ACL(conn, path, mode) == -1) && (errno == ENOSYS))
errno = saved_errno;
}
}
@@ -103,7 +103,7 @@ int vfswrap_mkdir(connection_struct *conn, const char *path, mode_t mode)
return result;
}
-int vfswrap_rmdir(connection_struct *conn, const char *path)
+int vfswrap_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path)
{
int result;
@@ -113,7 +113,7 @@ int vfswrap_rmdir(connection_struct *conn, const char *path)
return result;
}
-int vfswrap_closedir(connection_struct *conn, DIR *dirp)
+int vfswrap_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
{
int result;
@@ -125,7 +125,7 @@ int vfswrap_closedir(connection_struct *conn, DIR *dirp)
/* File operations */
-int vfswrap_open(connection_struct *conn, const char *fname, int flags, mode_t mode)
+int vfswrap_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode)
{
int result;
@@ -135,7 +135,7 @@ int vfswrap_open(connection_struct *conn, const char *fname, int flags, mode_t m
return result;
}
-int vfswrap_close(files_struct *fsp, int fd)
+int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
{
int result;
@@ -146,7 +146,7 @@ int vfswrap_close(files_struct *fsp, int fd)
return result;
}
-ssize_t vfswrap_read(files_struct *fsp, int fd, void *data, size_t n)
+ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
{
ssize_t result;
@@ -156,7 +156,7 @@ ssize_t vfswrap_read(files_struct *fsp, int fd, void *data, size_t n)
return result;
}
-ssize_t vfswrap_write(files_struct *fsp, int fd, const void *data, size_t n)
+ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
{
ssize_t result;
@@ -166,7 +166,7 @@ ssize_t vfswrap_write(files_struct *fsp, int fd, const void *data, size_t n)
return result;
}
-SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
+SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
{
SMB_OFF_T result = 0;
@@ -192,7 +192,7 @@ SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int wh
return result;
}
-ssize_t vfswrap_sendfile(int tofd, struct files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
+ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
SMB_OFF_T offset, size_t n)
{
ssize_t result;
@@ -203,7 +203,7 @@ ssize_t vfswrap_sendfile(int tofd, struct files_struct *fsp, int fromfd, const D
return result;
}
-int vfswrap_rename(connection_struct *conn, const char *old, const char *new)
+int vfswrap_rename(vfs_handle_struct *handle, connection_struct *conn, const char *old, const char *new)
{
int result;
@@ -213,7 +213,7 @@ int vfswrap_rename(connection_struct *conn, const char *old, const char *new)
return result;
}
-int vfswrap_fsync(files_struct *fsp, int fd)
+int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
{
#ifdef HAVE_FSYNC
int result;
@@ -228,7 +228,7 @@ int vfswrap_fsync(files_struct *fsp, int fd)
#endif
}
-int vfswrap_stat(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf)
+int vfswrap_stat(vfs_handle_struct *handle, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -238,7 +238,7 @@ int vfswrap_stat(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sb
return result;
}
-int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
+int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -248,7 +248,7 @@ int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
return result;
}
-int vfswrap_lstat(connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf)
+int vfswrap_lstat(vfs_handle_struct *handle, connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf)
{
int result;
@@ -258,7 +258,7 @@ int vfswrap_lstat(connection_struct *conn, const char *path, SMB_STRUCT_STAT *sb
return result;
}
-int vfswrap_unlink(connection_struct *conn, const char *path)
+int vfswrap_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *path)
{
int result;
@@ -268,7 +268,7 @@ int vfswrap_unlink(connection_struct *conn, const char *path)
return result;
}
-int vfswrap_chmod(connection_struct *conn, const char *path, mode_t mode)
+int vfswrap_chmod(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode)
{
int result;
@@ -281,9 +281,9 @@ int vfswrap_chmod(connection_struct *conn, const char *path, mode_t mode)
*/
- if (conn->vfs_ops.chmod_acl != NULL) {
+ if (conn->vfs.ops.chmod_acl != NULL) {
int saved_errno = errno; /* We might get ENOSYS */
- if ((result = conn->vfs_ops.chmod_acl(conn, path, mode)) == 0) {
+ if ((result = VFS_CHMOD_ACL(conn, path, mode)) == 0) {
END_PROFILE(syscall_chmod);
return result;
}
@@ -296,10 +296,10 @@ int vfswrap_chmod(connection_struct *conn, const char *path, mode_t mode)
return result;
}
-int vfswrap_fchmod(files_struct *fsp, int fd, mode_t mode)
+int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
{
int result;
- struct vfs_ops *vfs_ops = &fsp->conn->vfs_ops;
+ struct vfs_ops *vfs_ops = &fsp->conn->vfs;
START_PROFILE(syscall_fchmod);
@@ -309,9 +309,9 @@ int vfswrap_fchmod(files_struct *fsp, int fd, mode_t mode)
* group owner bits directly. JRA.
*/
- if (vfs_ops->fchmod_acl != NULL) {
+ if (vfs_ops->ops.fchmod_acl != NULL) {
int saved_errno = errno; /* We might get ENOSYS */
- if ((result = vfs_ops->fchmod_acl(fsp, fd, mode)) == 0) {
+ if ((result = VFS_FCHMOD_ACL(fsp, fd, mode)) == 0) {
END_PROFILE(syscall_chmod);
return result;
}
@@ -330,7 +330,7 @@ int vfswrap_fchmod(files_struct *fsp, int fd, mode_t mode)
return result;
}
-int vfswrap_chown(connection_struct *conn, const char *path, uid_t uid, gid_t gid)
+int vfswrap_chown(vfs_handle_struct *handle, connection_struct *conn, const char *path, uid_t uid, gid_t gid)
{
int result;
@@ -340,7 +340,7 @@ int vfswrap_chown(connection_struct *conn, const char *path, uid_t uid, gid_t gi
return result;
}
-int vfswrap_fchown(files_struct *fsp, int fd, uid_t uid, gid_t gid)
+int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid)
{
#ifdef HAVE_FCHOWN
int result;
@@ -356,7 +356,7 @@ int vfswrap_fchown(files_struct *fsp, int fd, uid_t uid, gid_t gid)
#endif
}
-int vfswrap_chdir(connection_struct *conn, const char *path)
+int vfswrap_chdir(vfs_handle_struct *handle, connection_struct *conn, const char *path)
{
int result;
@@ -366,7 +366,7 @@ int vfswrap_chdir(connection_struct *conn, const char *path)
return result;
}
-char *vfswrap_getwd(connection_struct *conn, char *path)
+char *vfswrap_getwd(vfs_handle_struct *handle, connection_struct *conn, char *path)
{
char *result;
@@ -376,7 +376,7 @@ char *vfswrap_getwd(connection_struct *conn, char *path)
return result;
}
-int vfswrap_utime(connection_struct *conn, const char *path, struct utimbuf *times)
+int vfswrap_utime(vfs_handle_struct *handle, connection_struct *conn, const char *path, struct utimbuf *times)
{
int result;
@@ -391,18 +391,17 @@ int vfswrap_utime(connection_struct *conn, const char *path, struct utimbuf *tim
allocate is set.
**********************************************************************/
-static int strict_allocate_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
+static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
{
- struct vfs_ops *vfs_ops = &fsp->conn->vfs_ops;
SMB_STRUCT_STAT st;
- SMB_OFF_T currpos = vfs_ops->lseek(fsp, fd, 0, SEEK_CUR);
+ SMB_OFF_T currpos = VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
unsigned char zero_space[4096];
SMB_OFF_T space_to_write;
if (currpos == -1)
return -1;
- if (vfs_ops->fstat(fsp, fd, &st) == -1)
+ if (VFS_FSTAT(fsp, fd, &st) == -1)
return -1;
space_to_write = len - st.st_size;
@@ -420,7 +419,7 @@ static int strict_allocate_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
return sys_ftruncate(fd, len);
/* Write out the real space on disk. */
- if (vfs_ops->lseek(fsp, fd, st.st_size, SEEK_SET) != st.st_size)
+ if (VFS_LSEEK(fsp, fd, st.st_size, SEEK_SET) != st.st_size)
return -1;
space_to_write = len - st.st_size;
@@ -430,7 +429,7 @@ static int strict_allocate_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
SMB_OFF_T retlen;
SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write);
- retlen = vfs_ops->write(fsp,fsp->fd,(char *)zero_space,current_len_to_write);
+ retlen = VFS_WRITE(fsp,fsp->fd,(char *)zero_space,current_len_to_write);
if (retlen <= 0)
return -1;
@@ -438,16 +437,15 @@ static int strict_allocate_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
}
/* Seek to where we were */
- if (vfs_ops->lseek(fsp, fd, currpos, SEEK_SET) != currpos)
+ if (VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
return -1;
return 0;
}
-int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
+int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
{
int result = -1;
- struct vfs_ops *vfs_ops = &fsp->conn->vfs_ops;
SMB_STRUCT_STAT st;
char c = 0;
SMB_OFF_T currpos;
@@ -455,7 +453,7 @@ int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
START_PROFILE(syscall_ftruncate);
if (lp_strict_allocate(SNUM(fsp->conn))) {
- result = strict_allocate_ftruncate(fsp, fd, len);
+ result = strict_allocate_ftruncate(handle, fsp, fd, len);
END_PROFILE(syscall_ftruncate);
return result;
}
@@ -473,7 +471,7 @@ int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
extend a file with ftruncate. Provide alternate implementation
for this */
- currpos = vfs_ops->lseek(fsp, fd, 0, SEEK_CUR);
+ currpos = VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
if (currpos == -1) {
goto done;
}
@@ -482,7 +480,7 @@ int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
size in which case the ftruncate above should have
succeeded or shorter, in which case seek to len - 1 and
write 1 byte of zero */
- if (vfs_ops->fstat(fsp, fd, &st) == -1) {
+ if (VFS_FSTAT(fsp, fd, &st) == -1) {
goto done;
}
@@ -503,14 +501,14 @@ int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
goto done;
}
- if (vfs_ops->lseek(fsp, fd, len-1, SEEK_SET) != len -1)
+ if (VFS_LSEEK(fsp, fd, len-1, SEEK_SET) != len -1)
goto done;
- if (vfs_ops->write(fsp, fd, &c, 1)!=1)
+ if (VFS_WRITE(fsp, fd, &c, 1)!=1)
goto done;
/* Seek to where we were */
- if (vfs_ops->lseek(fsp, fd, currpos, SEEK_SET) != currpos)
+ if (VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
goto done;
result = 0;
@@ -520,7 +518,7 @@ int vfswrap_ftruncate(files_struct *fsp, int fd, SMB_OFF_T len)
return result;
}
-BOOL vfswrap_lock(files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+BOOL vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
BOOL result;
@@ -531,7 +529,7 @@ BOOL vfswrap_lock(files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T
return result;
}
-int vfswrap_symlink(connection_struct *conn, const char *oldpath, const char *newpath)
+int vfswrap_symlink(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath)
{
int result;
@@ -541,7 +539,7 @@ int vfswrap_symlink(connection_struct *conn, const char *oldpath, const char *ne
return result;
}
-int vfswrap_readlink(connection_struct *conn, const char *path, char *buf, size_t bufsiz)
+int vfswrap_readlink(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *buf, size_t bufsiz)
{
int result;
@@ -551,7 +549,7 @@ int vfswrap_readlink(connection_struct *conn, const char *path, char *buf, size_
return result;
}
-int vfswrap_link(connection_struct *conn, const char *oldpath, const char *newpath)
+int vfswrap_link(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath)
{
int result;
@@ -561,7 +559,7 @@ int vfswrap_link(connection_struct *conn, const char *oldpath, const char *newpa
return result;
}
-int vfswrap_mknod(connection_struct *conn, const char *pathname, mode_t mode, SMB_DEV_T dev)
+int vfswrap_mknod(vfs_handle_struct *handle, connection_struct *conn, const char *pathname, mode_t mode, SMB_DEV_T dev)
{
int result;
@@ -571,7 +569,7 @@ int vfswrap_mknod(connection_struct *conn, const char *pathname, mode_t mode, SM
return result;
}
-char *vfswrap_realpath(connection_struct *conn, const char *path, char *resolved_path)
+char *vfswrap_realpath(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *resolved_path)
{
char *result;
@@ -581,7 +579,7 @@ char *vfswrap_realpath(connection_struct *conn, const char *path, char *resolved
return result;
}
-size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc)
+size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, SEC_DESC **ppdesc)
{
size_t result;
@@ -591,7 +589,7 @@ size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc)
return result;
}
-size_t vfswrap_get_nt_acl(files_struct *fsp, const char *name, SEC_DESC **ppdesc)
+size_t vfswrap_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, SEC_DESC **ppdesc)
{
size_t result;
@@ -601,7 +599,7 @@ size_t vfswrap_get_nt_acl(files_struct *fsp, const char *name, SEC_DESC **ppdesc
return result;
}
-BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
+BOOL vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
{
BOOL result;
@@ -611,7 +609,7 @@ BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, S
return result;
}
-BOOL vfswrap_set_nt_acl(files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd)
+BOOL vfswrap_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd)
{
BOOL result;
@@ -621,7 +619,7 @@ BOOL vfswrap_set_nt_acl(files_struct *fsp, const char *name, uint32 security_inf
return result;
}
-int vfswrap_chmod_acl(connection_struct *conn, const char *name, mode_t mode)
+int vfswrap_chmod_acl(vfs_handle_struct *handle, connection_struct *conn, const char *name, mode_t mode)
{
int result;
@@ -631,7 +629,7 @@ int vfswrap_chmod_acl(connection_struct *conn, const char *name, mode_t mode)
return result;
}
-int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode)
+int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
{
int result;
@@ -641,112 +639,124 @@ int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode)
return result;
}
-int vfswrap_sys_acl_get_entry(struct connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
+int vfswrap_sys_acl_get_entry(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
{
return sys_acl_get_entry(theacl, entry_id, entry_p);
}
-int vfswrap_sys_acl_get_tag_type(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
+int vfswrap_sys_acl_get_tag_type(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
{
return sys_acl_get_tag_type(entry_d, tag_type_p);
}
-int vfswrap_sys_acl_get_permset(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
+int vfswrap_sys_acl_get_permset(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
{
return sys_acl_get_permset(entry_d, permset_p);
}
-void * vfswrap_sys_acl_get_qualifier(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d)
+void * vfswrap_sys_acl_get_qualifier(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d)
{
return sys_acl_get_qualifier(entry_d);
}
-SMB_ACL_T vfswrap_sys_acl_get_file(struct connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type)
+SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle, connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type)
{
return sys_acl_get_file(path_p, type);
}
-SMB_ACL_T vfswrap_sys_acl_get_fd(struct files_struct *fsp, int fd)
+SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
{
return sys_acl_get_fd(fd);
}
-int vfswrap_sys_acl_clear_perms(struct connection_struct *conn, SMB_ACL_PERMSET_T permset)
+int vfswrap_sys_acl_clear_perms(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset)
{
return sys_acl_clear_perms(permset);
}
-int vfswrap_sys_acl_add_perm(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
+int vfswrap_sys_acl_add_perm(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
{
return sys_acl_add_perm(permset, perm);
}
-char * vfswrap_sys_acl_to_text(struct connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen)
+char * vfswrap_sys_acl_to_text(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen)
{
return sys_acl_to_text(theacl, plen);
}
-SMB_ACL_T vfswrap_sys_acl_init(struct connection_struct *conn, int count)
+SMB_ACL_T vfswrap_sys_acl_init(vfs_handle_struct *handle, connection_struct *conn, int count)
{
return sys_acl_init(count);
}
-int vfswrap_sys_acl_create_entry(struct connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
+int vfswrap_sys_acl_create_entry(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
{
return sys_acl_create_entry(pacl, pentry);
}
-int vfswrap_sys_acl_set_tag_type(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype)
+int vfswrap_sys_acl_set_tag_type(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype)
{
return sys_acl_set_tag_type(entry, tagtype);
}
-int vfswrap_sys_acl_set_qualifier(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual)
+int vfswrap_sys_acl_set_qualifier(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual)
{
return sys_acl_set_qualifier(entry, qual);
}
-int vfswrap_sys_acl_set_permset(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset)
+int vfswrap_sys_acl_set_permset(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset)
{
return sys_acl_set_permset(entry, permset);
}
-int vfswrap_sys_acl_valid(struct connection_struct *conn, SMB_ACL_T theacl )
+int vfswrap_sys_acl_valid(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl )
{
return sys_acl_valid(theacl );
}
-int vfswrap_sys_acl_set_file(struct connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
{
return sys_acl_set_file(name, acltype, theacl);
}
-int vfswrap_sys_acl_set_fd(struct files_struct *fsp, int fd, SMB_ACL_T theacl)
+int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
{
return sys_acl_set_fd(fd, theacl);
}
-int vfswrap_sys_acl_delete_def_file(struct connection_struct *conn, const char *path)
+int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, connection_struct *conn, const char *path)
{
return sys_acl_delete_def_file(path);
}
-int vfswrap_sys_acl_get_perm(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
+int vfswrap_sys_acl_get_perm(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
{
return sys_acl_get_perm(permset, perm);
}
-int vfswrap_sys_acl_free_text(struct connection_struct *conn, char *text)
+int vfswrap_sys_acl_free_text(vfs_handle_struct *handle, connection_struct *conn, char *text)
{
return sys_acl_free_text(text);
}
-int vfswrap_sys_acl_free_acl(struct connection_struct *conn, SMB_ACL_T posix_acl)
+int vfswrap_sys_acl_free_acl(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T posix_acl)
{
return sys_acl_free_acl(posix_acl);
}
-int vfswrap_sys_acl_free_qualifier(struct connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype)
+int vfswrap_sys_acl_free_qualifier(vfs_handle_struct *handle, connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype)
{
return sys_acl_free_qualifier(qualifier, tagtype);
}
+
+int vfswrap_get_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+int vfswrap_set_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 5fcf9a575e..7bae2ccc80 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -28,9 +28,9 @@
#define DBGC_CLASS DBGC_VFS
struct vfs_init_function_entry {
- char *name;
- vfs_op_tuple *ops, *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *);
- struct vfs_init_function_entry *prev, *next;
+ char *name;
+ vfs_op_tuple *vfs_op_tuples;
+ struct vfs_init_function_entry *prev, *next;
};
static struct vfs_init_function_entry *backends = NULL;
@@ -42,96 +42,94 @@ struct vfs_syminfo {
void *fptr;
};
-/*
- Opaque (final) vfs operations. This is a combination of first-met opaque vfs operations
- across all currently processed modules. */
-
-static vfs_op_tuple vfs_opaque_ops[SMB_VFS_OP_LAST];
-
/* Default vfs hooks. WARNING: The order of these initialisers is
very important. They must be in the same order as defined in
vfs.h. Change at your own peril. */
-static struct vfs_ops default_vfs_ops = {
-
- /* Disk operations */
-
- vfswrap_dummy_connect,
- vfswrap_dummy_disconnect,
- vfswrap_disk_free,
-
- /* Directory operations */
-
- vfswrap_opendir,
- vfswrap_readdir,
- vfswrap_mkdir,
- vfswrap_rmdir,
- vfswrap_closedir,
-
- /* File operations */
-
- vfswrap_open,
- vfswrap_close,
- vfswrap_read,
- vfswrap_write,
- vfswrap_lseek,
- vfswrap_sendfile,
- vfswrap_rename,
- vfswrap_fsync,
- vfswrap_stat,
- vfswrap_fstat,
- vfswrap_lstat,
- vfswrap_unlink,
- vfswrap_chmod,
- vfswrap_fchmod,
- vfswrap_chown,
- vfswrap_fchown,
- vfswrap_chdir,
- vfswrap_getwd,
- vfswrap_utime,
- vfswrap_ftruncate,
- vfswrap_lock,
- vfswrap_symlink,
- vfswrap_readlink,
- vfswrap_link,
- vfswrap_mknod,
- vfswrap_realpath,
-
- vfswrap_fget_nt_acl,
- vfswrap_get_nt_acl,
- vfswrap_fset_nt_acl,
- vfswrap_set_nt_acl,
-
- /* POSIX ACL operations. */
+static struct vfs_ops default_vfs = {
+
+ ops: {
+ /* Disk operations */
+
+ vfswrap_dummy_connect,
+ vfswrap_dummy_disconnect,
+ vfswrap_disk_free,
+ vfswrap_get_quota,
+ vfswrap_set_quota,
+
+ /* Directory operations */
+
+ vfswrap_opendir,
+ vfswrap_readdir,
+ vfswrap_mkdir,
+ vfswrap_rmdir,
+ vfswrap_closedir,
+
+ /* File operations */
+
+ vfswrap_open,
+ vfswrap_close,
+ vfswrap_read,
+ vfswrap_write,
+ vfswrap_lseek,
+ vfswrap_sendfile,
+ vfswrap_rename,
+ vfswrap_fsync,
+ vfswrap_stat,
+ vfswrap_fstat,
+ vfswrap_lstat,
+ vfswrap_unlink,
+ vfswrap_chmod,
+ vfswrap_fchmod,
+ vfswrap_chown,
+ vfswrap_fchown,
+ vfswrap_chdir,
+ vfswrap_getwd,
+ vfswrap_utime,
+ vfswrap_ftruncate,
+ vfswrap_lock,
+ vfswrap_symlink,
+ vfswrap_readlink,
+ vfswrap_link,
+ vfswrap_mknod,
+ vfswrap_realpath,
+
+ vfswrap_fget_nt_acl,
+ vfswrap_get_nt_acl,
+ vfswrap_fset_nt_acl,
+ vfswrap_set_nt_acl,
+
+ /* POSIX ACL operations. */
#if defined(HAVE_NO_ACLS)
- NULL,
- NULL,
+ NULL,
+ NULL,
#else
- vfswrap_chmod_acl,
- vfswrap_fchmod_acl,
+ vfswrap_chmod_acl,
+ vfswrap_fchmod_acl,
#endif
- vfswrap_sys_acl_get_entry,
- vfswrap_sys_acl_get_tag_type,
- vfswrap_sys_acl_get_permset,
- vfswrap_sys_acl_get_qualifier,
- vfswrap_sys_acl_get_file,
- vfswrap_sys_acl_get_fd,
- vfswrap_sys_acl_clear_perms,
- vfswrap_sys_acl_add_perm,
- vfswrap_sys_acl_to_text,
- vfswrap_sys_acl_init,
- vfswrap_sys_acl_create_entry,
- vfswrap_sys_acl_set_tag_type,
- vfswrap_sys_acl_set_qualifier,
- vfswrap_sys_acl_set_permset,
- vfswrap_sys_acl_valid,
- vfswrap_sys_acl_set_file,
- vfswrap_sys_acl_set_fd,
- vfswrap_sys_acl_delete_def_file,
- vfswrap_sys_acl_get_perm,
- vfswrap_sys_acl_free_text,
- vfswrap_sys_acl_free_acl,
- vfswrap_sys_acl_free_qualifier
+ vfswrap_sys_acl_get_entry,
+ vfswrap_sys_acl_get_tag_type,
+ vfswrap_sys_acl_get_permset,
+ vfswrap_sys_acl_get_qualifier,
+ vfswrap_sys_acl_get_file,
+ vfswrap_sys_acl_get_fd,
+ vfswrap_sys_acl_clear_perms,
+ vfswrap_sys_acl_add_perm,
+ vfswrap_sys_acl_to_text,
+ vfswrap_sys_acl_init,
+ vfswrap_sys_acl_create_entry,
+ vfswrap_sys_acl_set_tag_type,
+ vfswrap_sys_acl_set_qualifier,
+ vfswrap_sys_acl_set_permset,
+ vfswrap_sys_acl_valid,
+ vfswrap_sys_acl_set_file,
+ vfswrap_sys_acl_set_fd,
+ vfswrap_sys_acl_delete_def_file,
+ vfswrap_sys_acl_get_perm,
+ vfswrap_sys_acl_free_text,
+ vfswrap_sys_acl_free_acl,
+ vfswrap_sys_acl_free_qualifier
+ }
};
/****************************************************************************
@@ -140,52 +138,49 @@ static struct vfs_ops default_vfs_ops = {
static struct vfs_init_function_entry *vfs_find_backend_entry(const char *name)
{
- struct vfs_init_function_entry *entry = backends;
- pstring stripped;
-
- module_path_get_name(name, stripped);
+ struct vfs_init_function_entry *entry = backends;
+ pstring stripped;
- while(entry) {
- if (strequal(entry->name, stripped)) return entry;
- entry = entry->next;
- }
+ module_path_get_name(name, stripped);
+
+ while(entry) {
+ if (strequal(entry->name, stripped)) return entry;
+ entry = entry->next;
+ }
- return NULL;
+ return NULL;
}
-NTSTATUS smb_register_vfs(int version, const char *name, vfs_op_tuple *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *))
+NTSTATUS smb_register_vfs(int version, const char *name, vfs_op_tuple *vfs_op_tuples)
{
- struct vfs_init_function_entry *entry = backends;
-
- if ((version < SMB_VFS_INTERFACE_CASCADED)) {
- DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n",
- version, SMB_VFS_INTERFACE_VERSION ));
- return NT_STATUS_OBJECT_TYPE_MISMATCH;
- }
-
- if ((version < SMB_VFS_INTERFACE_VERSION)) {
- DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\
- Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n",
- version, SMB_VFS_INTERFACE_VERSION, version ));
- return NT_STATUS_OBJECT_TYPE_MISMATCH;
- }
-
- if (!name || !init) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (vfs_find_backend_entry(name)) {
- DEBUG(0,("VFS module %s already loaded!\n", name));
- return NT_STATUS_OBJECT_NAME_COLLISION;
- }
-
- entry = smb_xmalloc(sizeof(struct vfs_init_function_entry));
- entry->name = smb_xstrdup(name);
- entry->init = init;
-
- DLIST_ADD(backends, entry);
- DEBUG(5, ("Successfully added vfs backend '%s'\n", name));
- return NT_STATUS_OK;
+ struct vfs_init_function_entry *entry = backends;
+
+ if ((version != SMB_VFS_INTERFACE_VERSION)) {
+ DEBUG(0, ("Failed to register vfs module.\n"
+ "The module was compiled against SMB_VFS_INTERFACE_VERSION %d,\n"
+ "current SMB_VFS_INTERFACE_VERSION is %d.\n"
+ "Please recompile against the current Samba Version!\n",
+ version, SMB_VFS_INTERFACE_VERSION));
+ return NT_STATUS_OBJECT_TYPE_MISMATCH;
+ }
+
+ if (!name || !name[0] || !vfs_op_tuples) {
+ DEBUG(0,("smb_register_vfs() called with NULL pointer or empty name!\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (vfs_find_backend_entry(name)) {
+ DEBUG(0,("VFS module %s already loaded!\n", name));
+ return NT_STATUS_OBJECT_NAME_COLLISION;
+ }
+
+ entry = smb_xmalloc(sizeof(struct vfs_init_function_entry));
+ entry->name = smb_xstrdup(name);
+ entry->vfs_op_tuples = vfs_op_tuples;
+
+ DLIST_ADD(backends, entry);
+ DEBUG(5, ("Successfully added vfs backend '%s'\n", name));
+ return NT_STATUS_OK;
}
/****************************************************************************
@@ -196,62 +191,10 @@ static void vfs_init_default(connection_struct *conn)
{
DEBUG(3, ("Initialising default vfs hooks\n"));
- memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops));
- conn->vfs_private = NULL;
+ memcpy(&conn->vfs.ops, &default_vfs.ops, sizeof(default_vfs.ops));
+ memcpy(&conn->vfs_opaque.ops, &default_vfs.ops, sizeof(default_vfs.ops));
}
-/***************************************************************************
- Function to load old VFS modules. Should go away after a while.
- **************************************************************************/
-
-static vfs_op_tuple *vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
-{
- int vfs_version = -1;
- vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *);
- /* Open object file */
-
- if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) {
- DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror()));
- return NULL;
- }
-
- /* Get handle on vfs_init() symbol */
-
- init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init");
-
- if (init_fptr == NULL) {
- DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object));
- sys_dlclose(conn->vfs_private->handle);
- return NULL;
- }
-
- /* Initialise vfs_ops structure */
- if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) {
- DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object));
- sys_dlclose(conn->vfs_private->handle);
- return NULL;
- }
-
- if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) {
- DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n",
- vfs_version, SMB_VFS_INTERFACE_VERSION ));
- sys_dlclose(conn->vfs_private->handle);
- return NULL;
- }
-
- if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) {
- DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\
- Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n",
- vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version ));
- sys_dlclose(conn->vfs_private->handle);
- return NULL;
- }
-
- return ops;
-}
-
-
-
/****************************************************************************
initialise custom vfs hooks
****************************************************************************/
@@ -259,51 +202,82 @@ static vfs_op_tuple *vfs_load_old_plugin(connection_struct *conn, const char *vf
BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
{
vfs_op_tuple *ops;
+ char *module_name = NULL;
+ char *module_param = NULL, *p;
int i;
+ vfs_handle_struct *handle;
struct vfs_init_function_entry *entry;
-
- DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object));
+
+ if (!conn||!vfs_object||!vfs_object[0]) {
+ DEBUG(0,("vfs_init_custon() called with NULL pointer or emtpy vfs_object!\n"));
+ return False;
+ }
if(!backends) static_init_vfs;
+ DEBUG(3, ("Initialising custom vfs hooks from [%s]\n", vfs_object));
+
+ module_name = smb_xstrdup(vfs_object);
+
+ p = strchr(module_name, ':');
+
+ if (p) {
+ *p = 0;
+ module_param = p+1;
+ trim_string(module_param, " ", " ");
+ }
+
+ trim_string(module_name, " ", " ");
+
/* First, try to load the module with the new module system */
- if((entry = vfs_find_backend_entry(vfs_object)) ||
- (NT_STATUS_IS_OK(smb_probe_module("vfs", vfs_object)) &&
- (entry = vfs_find_backend_entry(vfs_object)))) {
+ if((entry = vfs_find_backend_entry(module_name)) ||
+ (NT_STATUS_IS_OK(smb_probe_module("vfs", module_name)) &&
+ (entry = vfs_find_backend_entry(module_name)))) {
- DEBUG(3,("Successfully loaded %s with the new modules system\n", vfs_object));
+ DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object));
- if ((ops = entry->init(&conn->vfs_ops, conn->vfs_private)) == NULL) {
- DEBUG(0, ("vfs init function from %s failed\n", vfs_object));
- return False;
- }
+ if ((ops = entry->vfs_op_tuples) == NULL) {
+ DEBUG(0, ("entry->vfs_op_tuples==NULL for [%s] failed\n", vfs_object));
+ SAFE_FREE(module_name);
+ return False;
+ }
} else {
- /* If that doesn't work, fall back to the old system
- * (This part should go away after a while, it's only here
- * for backwards compatibility) */
- DEBUG(2, ("Can't load module %s with new modules system, falling back to compatibility\n",
- vfs_object));
- if ((ops = vfs_load_old_plugin(conn, vfs_object)) == NULL) {
- DEBUG(0, ("vfs init function from %s failed\n", vfs_object));
- return False;
- }
+ DEBUG(0,("Can't find a vfs module [%s]\n",vfs_object));
+ SAFE_FREE(module_name);
+ return False;
+ }
+
+ handle = (vfs_handle_struct *)talloc_zero(conn->mem_ctx,sizeof(vfs_handle_struct));
+ if (!handle) {
+ DEBUG(0,("talloc_zero() failed!\n"));
+ SAFE_FREE(module_name);
+ return False;
}
+ memcpy(&handle->vfs_next, &conn->vfs, sizeof(struct vfs_ops));
+ handle->conn = conn;
+ if (module_param) {
+ handle->param = talloc_strdup(conn->mem_ctx, module_param);
+ }
+ DLIST_ADD(conn->vfs_handles, handle);
for(i=0; ops[i].op != NULL; i++) {
- DEBUG(3, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer));
+ DEBUG(5, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer));
if(ops[i].layer == SMB_VFS_LAYER_OPAQUE) {
/* Check whether this operation was already made opaque by different module */
- if(vfs_opaque_ops[ops[i].type].op == ((void**)&default_vfs_ops)[ops[i].type]) {
+ if(((void**)&conn->vfs_opaque.ops)[ops[i].type] == ((void**)&default_vfs.ops)[ops[i].type]) {
/* No, it isn't overloaded yet. Overload. */
- DEBUG(3, ("Making operation type %d opaque [module %s]\n", ops[i].type, vfs_object));
- vfs_opaque_ops[ops[i].type] = ops[i];
+ DEBUGADD(5, ("Making operation type %d opaque [module %s]\n", ops[i].type, vfs_object));
+ ((void**)&conn->vfs_opaque.ops)[ops[i].type] = ops[i].op;
+ ((vfs_handle_struct **)&conn->vfs_opaque.handles)[ops[i].type] = handle;
}
}
/* Change current VFS disposition*/
- DEBUG(3, ("Accepting operation type %d from module %s\n", ops[i].type, vfs_object));
- ((void**)&conn->vfs_ops)[ops[i].type] = ops[i].op;
+ DEBUGADD(5, ("Accepting operation type %d from module %s\n", ops[i].type, vfs_object));
+ ((void**)&conn->vfs.ops)[ops[i].type] = ops[i].op;
+ ((vfs_handle_struct **)&conn->vfs.handles)[ops[i].type] = handle;
}
+ SAFE_FREE(module_name);
return True;
}
@@ -314,71 +288,31 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
BOOL smbd_vfs_init(connection_struct *conn)
{
const char **vfs_objects;
- char *vfs_module, *vfs_path;
unsigned int i = 0;
int j = 0;
- struct smb_vfs_handle_struct *handle;
/* Normal share - initialise with disk access functions */
vfs_init_default(conn);
- vfs_objects = lp_vfsobj(SNUM(conn));
+ vfs_objects = lp_vfs_objects(SNUM(conn));
/* Override VFS functions if 'vfs object' was not specified*/
if (!vfs_objects || !vfs_objects[0])
return True;
-
- for(i=0; i<SMB_VFS_OP_LAST; i++) {
- vfs_opaque_ops[i].op = ((void**)&default_vfs_ops)[i];
- vfs_opaque_ops[i].type = i;
- vfs_opaque_ops[i].layer = SMB_VFS_LAYER_OPAQUE;
+
+ for (i=0; vfs_objects[i] ;) {
+ i++;
}
- vfs_path = lp_vfs_path(SNUM(conn));
-
- for (i=0; vfs_objects[i]; i++); /* count passed modules */
-
for (j=i-1; j >= 0; j--) {
- conn->vfs_private = NULL;
- handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct));
- /* Loadable object file */
- handle->handle = NULL;
- DLIST_ADD(conn->vfs_private, handle);
- vfs_module = NULL;
- if (vfs_path && *vfs_path) {
- asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[j]);
- } else {
- asprintf(&vfs_module, "%s", vfs_objects[j]);
- }
- if (!vfs_init_custom(conn, vfs_module)) {
- DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_module));
- SAFE_FREE(vfs_module);
- DLIST_REMOVE(conn->vfs_private, handle);
- SAFE_FREE(handle);
+ if (!vfs_init_custom(conn, vfs_objects[j])) {
+ DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_objects[j]));
return False;
}
- SAFE_FREE(vfs_module);
}
return True;
}
/*******************************************************************
- Create vfs_ops reflecting current vfs_opaque_ops
-*******************************************************************/
-
-struct vfs_ops *smb_vfs_get_opaque_ops(void)
-{
- int i;
- struct vfs_ops *ops;
-
- ops = smb_xmalloc(sizeof(struct vfs_ops));
-
- for(i=0; i<SMB_VFS_OP_LAST; i++) {
- ((void**)ops)[i] = vfs_opaque_ops[i].op;
- }
- return ops;
-}
-
-/*******************************************************************
Check if directory exists.
********************************************************************/
@@ -390,7 +324,7 @@ BOOL vfs_directory_exist(connection_struct *conn, const char *dname, SMB_STRUCT_
if (!st)
st = &st2;
- if (vfs_stat(conn,dname,st) != 0)
+ if (VFS_STAT(conn,dname,st) != 0)
return(False);
ret = S_ISDIR(st->st_mode);
@@ -401,24 +335,15 @@ BOOL vfs_directory_exist(connection_struct *conn, const char *dname, SMB_STRUCT_
}
/*******************************************************************
- vfs getwd wrapper
-********************************************************************/
-
-static char *vfs_getwd(connection_struct *conn, char *path)
-{
- return conn->vfs_ops.getwd(conn,path);
-}
-
-/*******************************************************************
vfs mkdir wrapper
********************************************************************/
-int vfs_mkdir(connection_struct *conn, const char *name, mode_t mode)
+int vfs_MkDir(connection_struct *conn, const char *name, mode_t mode)
{
int ret;
SMB_STRUCT_STAT sbuf;
- if(!(ret=conn->vfs_ops.mkdir(conn,name,mode))) {
+ if(!(ret=VFS_MKDIR(conn, name, mode))) {
inherit_access_acl(conn, name, mode);
@@ -428,8 +353,8 @@ int vfs_mkdir(connection_struct *conn, const char *name, mode_t mode)
* Consider bits automagically set by UNIX, i.e. SGID bit from parent dir.
*/
if(mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) &&
- !vfs_stat(conn,name,&sbuf) && (mode & ~sbuf.st_mode))
- vfs_chmod(conn,name,sbuf.st_mode | (mode & ~sbuf.st_mode));
+ !VFS_STAT(conn,name,&sbuf) && (mode & ~sbuf.st_mode))
+ VFS_CHMOD(conn,name,sbuf.st_mode | (mode & ~sbuf.st_mode));
}
return ret;
}
@@ -447,7 +372,7 @@ BOOL vfs_object_exist(connection_struct *conn,const char *fname,SMB_STRUCT_STAT
ZERO_STRUCTP(sbuf);
- if (vfs_stat(conn,fname,sbuf) == -1)
+ if (VFS_STAT(conn,fname,sbuf) == -1)
return(False);
return True;
}
@@ -465,7 +390,7 @@ BOOL vfs_file_exist(connection_struct *conn, const char *fname,SMB_STRUCT_STAT *
ZERO_STRUCTP(sbuf);
- if (vfs_stat(conn,fname,sbuf) == -1)
+ if (VFS_STAT(conn,fname,sbuf) == -1)
return False;
return(S_ISREG(sbuf->st_mode));
}
@@ -480,7 +405,7 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count)
while (total < byte_count)
{
- ssize_t ret = fsp->conn->vfs_ops.read(fsp, fsp->fd, buf + total,
+ ssize_t ret = VFS_READ(fsp, fsp->fd, buf + total,
byte_count - total);
if (ret == 0) return total;
@@ -505,7 +430,7 @@ ssize_t vfs_write_data(files_struct *fsp,const char *buffer,size_t N)
ssize_t ret;
while (total < N) {
- ret = fsp->conn->vfs_ops.write(fsp,fsp->fd,buffer + total,N - total);
+ ret = VFS_WRITE(fsp,fsp->fd,buffer + total,N - total);
if (ret == -1)
return -1;
@@ -528,7 +453,6 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
int ret;
SMB_STRUCT_STAT st;
connection_struct *conn = fsp->conn;
- struct vfs_ops *vfs_ops = &conn->vfs_ops;
SMB_BIG_UINT space_avail;
SMB_BIG_UINT bsize,dfree,dsize;
@@ -545,7 +469,7 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
return -1;
}
- ret = vfs_fstat(fsp,fsp->fd,&st);
+ ret = VFS_FSTAT(fsp,fsp->fd,&st);
if (ret == -1)
return ret;
@@ -559,7 +483,7 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
fsp->fsp_name, (double)st.st_size ));
flush_write_cache(fsp, SIZECHANGE_FLUSH);
- if ((ret = vfs_ops->ftruncate(fsp, fsp->fd, (SMB_OFF_T)len)) != -1) {
+ if ((ret = VFS_FTRUNCATE(fsp, fsp->fd, (SMB_OFF_T)len)) != -1) {
set_filelen_write_cache(fsp, len);
}
return ret;
@@ -572,7 +496,7 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
len -= st.st_size;
len /= 1024; /* Len is now number of 1k blocks needed. */
- space_avail = conn->vfs_ops.disk_free(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
+ space_avail = VFS_DISK_FREE(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, needed blocks = %.0f, space avail = %.0f\n",
fsp->fsp_name, (double)st.st_size, (double)len, (double)space_avail ));
@@ -598,7 +522,7 @@ int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len)
release_level_2_oplocks_on_change(fsp);
DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n", fsp->fsp_name, (double)len));
flush_write_cache(fsp, SIZECHANGE_FLUSH);
- if ((ret = fsp->conn->vfs_ops.ftruncate(fsp, fsp->fd, len)) != -1)
+ if ((ret = VFS_FTRUNCATE(fsp, fsp->fd, len)) != -1)
set_filelen_write_cache(fsp, len);
return ret;
@@ -613,12 +537,12 @@ static files_struct *out_fsp;
static ssize_t read_fn(int fd, void *buf, size_t len)
{
- return in_fsp->conn->vfs_ops.read(in_fsp, fd, buf, len);
+ return VFS_READ(in_fsp, fd, buf, len);
}
static ssize_t write_fn(int fd, const void *buf, size_t len)
{
- return out_fsp->conn->vfs_ops.write(out_fsp, fd, buf, len);
+ return VFS_WRITE(out_fsp, fd, buf, len);
}
SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n)
@@ -635,13 +559,13 @@ SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n)
char *vfs_readdirname(connection_struct *conn, void *p)
{
- struct dirent *ptr;
+ struct dirent *ptr= NULL;
char *dname;
if (!p)
return(NULL);
- ptr = (struct dirent *)conn->vfs_ops.readdir(conn,p);
+ ptr = (struct dirent *)VFS_READDIR(conn,p);
if (!ptr)
return(NULL);
@@ -660,72 +584,6 @@ char *vfs_readdirname(connection_struct *conn, void *p)
return(dname);
}
-/* VFS options not quite working yet */
-
-#if 0
-
-/***************************************************************************
- handle the interpretation of the vfs option parameter
- *************************************************************************/
-static BOOL handle_vfs_option(char *pszParmValue, char **ptr)
-{
- struct vfs_options *new_option, **options = (struct vfs_options **)ptr;
- int i;
-
- /* Create new vfs option */
-
- new_option = (struct vfs_options *)malloc(sizeof(*new_option));
- if (new_option == NULL) {
- return False;
- }
-
- ZERO_STRUCTP(new_option);
-
- /* Get name and value */
-
- new_option->name = strtok(pszParmValue, "=");
-
- if (new_option->name == NULL) {
- return False;
- }
-
- while(isspace(*new_option->name)) {
- new_option->name++;
- }
-
- for (i = strlen(new_option->name); i > 0; i--) {
- if (!isspace(new_option->name[i - 1])) break;
- }
-
- new_option->name[i] = '\0';
- new_option->name = strdup(new_option->name);
-
- new_option->value = strtok(NULL, "=");
-
- if (new_option->value != NULL) {
-
- while(isspace(*new_option->value)) {
- new_option->value++;
- }
-
- for (i = strlen(new_option->value); i > 0; i--) {
- if (!isspace(new_option->value[i - 1])) break;
- }
-
- new_option->value[i] = '\0';
- new_option->value = strdup(new_option->value);
- }
-
- /* Add to list */
-
- DLIST_ADD(*options, new_option);
-
- return True;
-}
-
-#endif
-
-
/*******************************************************************
A wrapper for vfs_chdir().
********************************************************************/
@@ -741,9 +599,9 @@ int vfs_ChDir(connection_struct *conn, const char *path)
if (*path == '/' && strcsequal(LastDir,path))
return(0);
- DEBUG(3,("vfs_ChDir to %s\n",path));
+ DEBUG(4,("vfs_ChDir to %s\n",path));
- res = vfs_chdir(conn,path);
+ res = VFS_CHDIR(conn,path);
if (!res)
pstrcpy(LastDir,path);
return(res);
@@ -800,7 +658,7 @@ char *vfs_GetWd(connection_struct *conn, char *path)
*s = 0;
if (!use_getwd_cache)
- return(vfs_getwd(conn,path));
+ return(VFS_GETWD(conn,path));
/* init the cache */
if (!getwd_cache_init) {
@@ -814,9 +672,9 @@ char *vfs_GetWd(connection_struct *conn, char *path)
/* Get the inode of the current directory, if this doesn't work we're
in trouble :-) */
- if (vfs_stat(conn, ".",&st) == -1) {
+ if (VFS_STAT(conn, ".",&st) == -1) {
DEBUG(0,("Very strange, couldn't stat \".\" path=%s\n", path));
- return(vfs_getwd(conn,path));
+ return(VFS_GETWD(conn,path));
}
@@ -830,7 +688,7 @@ char *vfs_GetWd(connection_struct *conn, char *path)
the same...) */
if (st.st_ino == ino_list[i].inode && st.st_dev == ino_list[i].dev) {
- if (vfs_stat(conn,ino_list[i].dos_path,&st2) == 0) {
+ if (VFS_STAT(conn,ino_list[i].dos_path,&st2) == 0) {
if (st.st_ino == st2.st_ino && st.st_dev == st2.st_dev &&
(st2.st_mode & S_IFMT) == S_IFDIR) {
pstrcpy (path, ino_list[i].dos_path);
@@ -852,8 +710,8 @@ char *vfs_GetWd(connection_struct *conn, char *path)
The very slow getcwd, which spawns a process on some systems, or the
not quite so bad getwd. */
- if (!vfs_getwd(conn,s)) {
- DEBUG(0,("vfs_GetWd: vfs_getwd call failed, errno %s\n",strerror(errno)));
+ if (!VFS_GETWD(conn,s)) {
+ DEBUG(0,("vfs_GetWd: VFS_GETWD call failed, errno %s\n",strerror(errno)));
return (NULL);
}
@@ -909,7 +767,7 @@ static BOOL readlink_check(connection_struct *conn, const char *dir, char *name)
realdir[reallen] = 0;
}
- if (conn->vfs_ops.readlink(conn, name, flink, sizeof(pstring) -1) != -1) {
+ if (VFS_READLINK(conn, name, flink, sizeof(pstring) -1) != -1) {
DEBUG(3,("reduce_name: file path name %s is a symlink\nChecking it's path\n", name));
if (*flink == '/') {
pstrcpy(cleanlink, flink);