summaryrefslogtreecommitdiffstats
path: root/source3/smbd/dir.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-06-25 03:03:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:02 -0500
commitff7e5c26733c933d0ed71616c39e2d931ad1e597 (patch)
tree535f0ecc77553329d2ad0fa11e01b09184ed1d62 /source3/smbd/dir.c
parentb8e787bcac79b01d3f44d497517138b0c013be00 (diff)
downloadsamba-ff7e5c26733c933d0ed71616c39e2d931ad1e597.tar.gz
samba-ff7e5c26733c933d0ed71616c39e2d931ad1e597.tar.xz
samba-ff7e5c26733c933d0ed71616c39e2d931ad1e597.zip
r7893: Add in the extra parameters to opendir() to fix the large directory/insane app
problem. Rev vfs version. Doesn't change the normal codepath. Jeremy. (This used to be commit 0f03a6bdcdbdf60da81e0aeffa84ac6e48fc6a04)
Diffstat (limited to 'source3/smbd/dir.c')
-rw-r--r--source3/smbd/dir.c69
1 files changed, 30 insertions, 39 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index ae21e16e311..fd0a3035044 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -53,7 +53,7 @@ struct dptr_struct {
struct smb_Dir *dir_hnd;
BOOL expect_close;
char *wcard;
- uint16 attr;
+ uint32 attr;
char *path;
BOOL has_wild; /* Set to true if the wcard entry has MS wildcard characters in it. */
};
@@ -68,7 +68,7 @@ static int dirhandles_open = 0;
Make a dir struct.
****************************************************************************/
-void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T size,int mode,time_t date, BOOL uc)
+void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T size,uint32 mode,time_t date, BOOL uc)
{
char *p;
pstring mask2;
@@ -175,7 +175,7 @@ static struct dptr_struct *dptr_get(int key, BOOL forclose)
if (dirhandles_open >= MAX_OPEN_DIRECTORIES)
dptr_idleoldest();
DEBUG(4,("dptr_get: Reopening dptr key %d\n",key));
- if (!(dptr->dir_hnd = OpenDir(dptr->conn, dptr->path))) {
+ if (!(dptr->dir_hnd = OpenDir(dptr->conn, dptr->path, dptr->wcard, dptr->attr))) {
DEBUG(4,("dptr_get: Failed to open %s (%s)\n",dptr->path,
strerror(errno)));
return False;
@@ -225,30 +225,6 @@ uint16 dptr_attr(int key)
}
/****************************************************************************
- Set the dir wcard for a dir index.
- Returns 0 on ok, 1 on fail.
-****************************************************************************/
-
-BOOL dptr_set_wcard_and_attributes(int key, const char *wcard, uint16 attr)
-{
- struct dptr_struct *dptr = dptr_get(key, False);
-
- if (dptr) {
- dptr->attr = attr;
- dptr->wcard = SMB_STRDUP(wcard);
- if (!dptr->wcard)
- return False;
- if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
- dptr->has_wild = True;
- } else {
- dptr->has_wild = ms_has_wild(wcard);
- }
- return True;
- }
- return False;
-}
-
-/****************************************************************************
Close a dptr (internal func).
****************************************************************************/
@@ -399,7 +375,8 @@ static void dptr_close_oldest(BOOL old)
a directory handle is never zero.
****************************************************************************/
-int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL expect_close,uint16 spid)
+int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL expect_close,uint16 spid,
+ const char *wcard, uint32 attr)
{
struct dptr_struct *dptr = NULL;
struct smb_Dir *dir_hnd;
@@ -415,7 +392,7 @@ int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL exp
if (!*dir2)
dir2 = ".";
- dir_hnd = OpenDir(conn, dir2);
+ dir_hnd = OpenDir(conn, dir2, wcard, attr);
if (!dir_hnd) {
return (-2);
}
@@ -503,9 +480,23 @@ int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL exp
dptr->dir_hnd = dir_hnd;
dptr->spid = spid;
dptr->expect_close = expect_close;
- dptr->wcard = NULL; /* Only used in lanman2 searches */
- dptr->attr = 0; /* Only used in lanman2 searches */
- dptr->has_wild = True; /* Only used in lanman2 searches */
+ if (wcard) {
+ dptr->wcard = SMB_STRDUP(wcard);
+ if (!dptr->wcard) {
+ bitmap_clear(dptr_bmap, dptr->dnum - 1);
+ SAFE_FREE(dptr);
+ CloseDir(dir_hnd);
+ return -1;
+ }
+ } else {
+ dptr->wcard = NULL;
+ }
+ dptr->attr = attr;
+ if (lp_posix_pathnames() || (wcard && (wcard[0] == '.' && wcard[1] == 0))) {
+ dptr->has_wild = True;
+ } else {
+ dptr->has_wild = ms_has_wild(wcard);
+ }
DLIST_ADD(dirptrs, dptr);
@@ -715,9 +706,9 @@ struct dptr_struct *dptr_fetch_lanman2(int dptr_num)
Check a filetype for being valid.
****************************************************************************/
-BOOL dir_check_ftype(connection_struct *conn,int mode,int dirtype)
+BOOL dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype)
{
- int mask;
+ uint32 mask;
/* Check the "may have" search bits. */
if (((mode & ~dirtype) & (aHIDDEN | aSYSTEM | aDIR)) != 0)
@@ -747,8 +738,8 @@ static BOOL mangle_mask_match(connection_struct *conn, fstring filename, char *m
Get an 8.3 directory entry.
****************************************************************************/
-BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname,
- SMB_OFF_T *size,int *mode,time_t *date,BOOL check_descend)
+BOOL get_dir_entry(connection_struct *conn,char *mask,uint32 dirtype, pstring fname,
+ SMB_OFF_T *size,uint32 *mode,time_t *date,BOOL check_descend)
{
const char *dname;
BOOL found = False;
@@ -804,7 +795,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname
*mode = dos_mode(conn,pathreal,&sbuf);
if (!dir_check_ftype(conn,*mode,dirtype)) {
- DEBUG(5,("[%s] attribs didn't match %x\n",filename,dirtype));
+ DEBUG(5,("[%s] attribs didn't match %x\n",filename,(unsigned int)dirtype));
continue;
}
@@ -1000,7 +991,7 @@ BOOL is_visible_file(connection_struct *conn, const char *dir_path, const char *
Open a directory.
********************************************************************/
-struct smb_Dir *OpenDir(connection_struct *conn, const char *name)
+struct smb_Dir *OpenDir(connection_struct *conn, const char *name, const char *mask, uint32 attr)
{
struct smb_Dir *dirp = SMB_MALLOC_P(struct smb_Dir);
if (!dirp) {
@@ -1014,7 +1005,7 @@ struct smb_Dir *OpenDir(connection_struct *conn, const char *name)
if (!dirp->dir_path) {
goto fail;
}
- dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path);
+ dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
if (!dirp->dir) {
DEBUG(5,("OpenDir: Can't open %s. %s\n", dirp->dir_path, strerror(errno) ));
goto fail;