diff options
author | Jeremy Allison <jra@samba.org> | 2011-02-08 15:07:48 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-02-09 00:55:22 +0100 |
commit | a674a56a97c78a44bf43f1c175d106fbe70c7485 (patch) | |
tree | 78d6bab766e79d4e66de86d94d972cc96bb2a245 /source3/modules/vfs_shadow_copy.c | |
parent | 224fc03cb56b0d76f6ad7f18dd0528d6b0e57fb1 (diff) | |
download | samba-a674a56a97c78a44bf43f1c175d106fbe70c7485.tar.gz samba-a674a56a97c78a44bf43f1c175d106fbe70c7485.tar.bz2 samba-a674a56a97c78a44bf43f1c175d106fbe70c7485.zip |
Add fdopendir to the VFS. We will use this to reuse a directory fd already open by NtCreateX.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Wed Feb 9 00:55:22 CET 2011 on sn-devel-104
Diffstat (limited to 'source3/modules/vfs_shadow_copy.c')
-rw-r--r-- | source3/modules/vfs_shadow_copy.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c index 6bad1686d9..b597644869 100644 --- a/source3/modules/vfs_shadow_copy.c +++ b/source3/modules/vfs_shadow_copy.c @@ -118,6 +118,58 @@ static SMB_STRUCT_DIR *shadow_copy_opendir(vfs_handle_struct *handle, const char return((SMB_STRUCT_DIR *)dirp); } +static SMB_STRUCT_DIR *shadow_copy_fdopendir(vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32 attr) +{ + shadow_copy_Dir *dirp; + SMB_STRUCT_DIR *p = SMB_VFS_NEXT_FDOPENDIR(handle,fsp,mask,attr); + + if (!p) { + DEBUG(10,("shadow_copy_opendir: SMB_VFS_NEXT_FDOPENDIR() failed for [%s]\n", + smb_fname_str_dbg(fsp->fsp_name))); + return NULL; + } + + dirp = SMB_MALLOC_P(shadow_copy_Dir); + if (!dirp) { + DEBUG(0,("shadow_copy_fdopendir: Out of memory\n")); + SMB_VFS_NEXT_CLOSEDIR(handle,p); + /* We have now closed the fd in fsp. */ + fsp->fh->fd = -1; + return NULL; + } + + ZERO_STRUCTP(dirp); + + while (True) { + SMB_STRUCT_DIRENT *d; + + d = SMB_VFS_NEXT_READDIR(handle, p, NULL); + if (d == NULL) { + break; + } + + if (shadow_copy_match_name(d->d_name)) { + DEBUG(8,("shadow_copy_fdopendir: hide [%s]\n",d->d_name)); + continue; + } + + DEBUG(10,("shadow_copy_fdopendir: not hide [%s]\n",d->d_name)); + + dirp->dirs = SMB_REALLOC_ARRAY(dirp->dirs,SMB_STRUCT_DIRENT, dirp->num+1); + if (!dirp->dirs) { + DEBUG(0,("shadow_copy_fdopendir: Out of memory\n")); + break; + } + + dirp->dirs[dirp->num++] = *d; + } + + SMB_VFS_NEXT_CLOSEDIR(handle,p); + /* We have now closed the fd in fsp. */ + fsp->fh->fd = -1; + return((SMB_STRUCT_DIR *)dirp); +} + static SMB_STRUCT_DIRENT *shadow_copy_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *_dirp, SMB_STRUCT_STAT *sbuf) @@ -216,6 +268,7 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_str static struct vfs_fn_pointers vfs_shadow_copy_fns = { .opendir = shadow_copy_opendir, + .fdopendir = shadow_copy_fdopendir, .readdir = shadow_copy_readdir, .seekdir = shadow_copy_seekdir, .telldir = shadow_copy_telldir, |