svn commit: linux-cifs-client r19 - in branches/linux-2.6bk/fs/cifs: .

2004-12-12 Thread sfrench
Author: sfrench
Date: 2004-12-13 04:17:27 + (Mon, 13 Dec 2004)
New Revision: 19

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=linux-cifs-client&rev=19

Log:
Add support for changing cifs buffer size on insmod

Modified:
   branches/linux-2.6bk/fs/cifs/CHANGES
   branches/linux-2.6bk/fs/cifs/cifsfs.c
   branches/linux-2.6bk/fs/cifs/cifsfs.h
   branches/linux-2.6bk/fs/cifs/cifssmb.c
   branches/linux-2.6bk/fs/cifs/connect.c
   branches/linux-2.6bk/fs/cifs/file.c
   branches/linux-2.6bk/fs/cifs/misc.c
   branches/linux-2.6bk/fs/cifs/transport.c


Changeset:
Modified: branches/linux-2.6bk/fs/cifs/CHANGES
===
--- branches/linux-2.6bk/fs/cifs/CHANGES2004-12-12 21:36:55 UTC (rev 18)
+++ branches/linux-2.6bk/fs/cifs/CHANGES2004-12-13 04:17:27 UTC (rev 19)
@@ -1,3 +1,9 @@
+Version 1.28
+
+Add module init parm for large SMB buffer size (to allow it to be changed
+from its default of 16K) which is especially useful for large file copy
+when mounting with the directio mount option.
+
 Version 1.27
 
 Turn off DNOTIFY (directory change notification support) by default

Modified: branches/linux-2.6bk/fs/cifs/cifsfs.c
===
--- branches/linux-2.6bk/fs/cifs/cifsfs.c   2004-12-12 21:36:55 UTC (rev 18)
+++ branches/linux-2.6bk/fs/cifs/cifsfs.c   2004-12-13 04:17:27 UTC (rev 19)
@@ -634,13 +634,14 @@
 {
if(CIFSMaxBufSize < 4096) {
CIFSMaxBufSize = 4096;
-   cFYI(1,("Buffer size set to minimum of 1 page (4096)"));
} else if (CIFSMaxBufSize > 1024*127) {
CIFSMaxBufSize = 1024 * 127;
-   cFYI(1,("Buffer size set to maximum"));
+   } else {
+   CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
}
+/* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
cifs_req_cachep = kmem_cache_create("cifs_request",
-   CIFS_MAX_MSGSIZE +
+   CIFSMaxBufSize +
MAX_CIFS_HDR_SIZE, 0,
SLAB_HWCACHE_ALIGN, NULL, NULL);
if (cifs_req_cachep == NULL)

Modified: branches/linux-2.6bk/fs/cifs/cifsfs.h
===
--- branches/linux-2.6bk/fs/cifs/cifsfs.h   2004-12-12 21:36:55 UTC (rev 18)
+++ branches/linux-2.6bk/fs/cifs/cifsfs.h   2004-12-13 04:17:27 UTC (rev 19)
@@ -90,5 +90,5 @@
 size_t, int);
 extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
-#define CIFS_VERSION   "1.27"
+#define CIFS_VERSION   "1.28"
 #endif /* _CIFSFS_H */

Modified: branches/linux-2.6bk/fs/cifs/cifssmb.c
===
--- branches/linux-2.6bk/fs/cifs/cifssmb.c  2004-12-12 21:36:55 UTC (rev 18)
+++ branches/linux-2.6bk/fs/cifs/cifssmb.c  2004-12-13 04:17:27 UTC (rev 19)
@@ -288,7 +288,7 @@
(char *)pSMB;
if((total_size <= (*(u16 *)pBCC)) && 
   (total_size < 
-   CIFS_MAX_MSGSIZE+MAX_CIFS_HDR_SIZE)) {
+   CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {
return 0;
}

@@ -341,7 +341,7 @@
/* probably no need to store and check maxvcs */
server->maxBuf =
min(le32_to_cpu(pSMBr->MaxBufferSize),
-   (__u32) CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE);
+   (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
cFYI(0, ("Max buf = %d ", ses->server->maxBuf));
GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
@@ -823,7 +823,7 @@
__u16 data_length = le16_to_cpu(pSMBr->DataLength);
*nbytes = data_length;
/*check that DataLength would not go beyond end of SMB */
-   if ((data_length > CIFS_MAX_MSGSIZE) 
+   if ((data_length > CIFSMaxBufSize) 
|| (data_length > count)) {
cFYI(1,("bad length %d for count 
%d",data_length,count));
rc = -EIO;
@@ -2359,7 +2359,7 @@
pSMB->SearchAttributes =
cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
ATTR_DIRECTORY);
-   pSMB->SearchCount = cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof 
(FILE_DIRECTORY_INFO));   /* should this be shrunk even more 

svn commit: samba r4168 - in branches/SAMBA_4_0/source: librpc/idl rpc_server/winreg torture/rpc

2004-12-12 Thread jelmer
Author: jelmer
Date: 2004-12-13 02:04:34 + (Mon, 13 Dec 2004)
New Revision: 4168

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4168

Log:
Implement QueryValue in the server
IDL for NotifyChangeKeyValue

Modified:
   branches/SAMBA_4_0/source/librpc/idl/winreg.idl
   branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c
   branches/SAMBA_4_0/source/torture/rpc/winreg.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/winreg.idl
===
--- branches/SAMBA_4_0/source/librpc/idl/winreg.idl 2004-12-13 01:37:18 UTC 
(rev 4167)
+++ branches/SAMBA_4_0/source/librpc/idl/winreg.idl 2004-12-13 02:04:34 UTC 
(rev 4168)
@@ -181,6 +181,13 @@
/**/
/* Function: 0x0e */
WERROR winreg_NotifyChangeKeyValue(
+   [in,ref] policy_handle *handle,
+   [in] uint8 watch_subtree,
+   [in] uint32 notify_filter,
+   [in] uint32 unknown,
+   [in] winreg_String string1,
+   [in] winreg_String string2, 
+   [in] uint32 unknown2
);
 
/**/

Modified: branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c
===
--- branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c2004-12-13 
01:37:18 UTC (rev 4167)
+++ branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c2004-12-13 
02:04:34 UTC (rev 4168)
@@ -240,6 +240,11 @@
 static WERROR winreg_GetKeySecurity(struct dcesrv_call_state *dce_call, 
TALLOC_CTX *mem_ctx,
   struct winreg_GetKeySecurity *r)
 {
+   struct dcesrv_handle *h;
+
+   h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
+   DCESRV_CHECK_HANDLE(h);
+
return WERR_NOT_SUPPORTED;
 }
 
@@ -341,7 +346,28 @@
 static WERROR winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX 
*mem_ctx,
   struct winreg_QueryValue *r)
 {
-   return WERR_NOT_SUPPORTED;
+   struct dcesrv_handle *h;
+   struct registry_key *key;
+   struct registry_value *val;
+   WERROR result;
+
+   h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
+   DCESRV_CHECK_HANDLE(h);
+
+   key = h->data;
+   
+   result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name, 
&val);
+
+   if (!W_ERROR_IS_OK(result)) { 
+   return result;
+   }
+
+   r->out.type = &val->data_type;
+   r->out.size = r->in.size;
+   r->out.length = &val->data_len;
+   r->out.data = val->data_blk;
+
+   return WERR_OK;
 }
 
 

Modified: branches/SAMBA_4_0/source/torture/rpc/winreg.c
===
--- branches/SAMBA_4_0/source/torture/rpc/winreg.c  2004-12-13 01:37:18 UTC 
(rev 4167)
+++ branches/SAMBA_4_0/source/torture/rpc/winreg.c  2004-12-13 02:04:34 UTC 
(rev 4168)
@@ -60,6 +60,36 @@
return True;
 }
 
+static BOOL test_NotifyChangeKeyValue(struct dcerpc_pipe *p, TALLOC_CTX 
*mem_ctx, 
+ 
struct policy_handle *handle)
+{
+   struct winreg_NotifyChangeKeyValue r;
+   NTSTATUS status;
+
+   printf("\ntesting NotifyChangeKeyValue\n");
+
+   r.in.handle = handle;
+   r.in.watch_subtree = 1;
+   r.in.notify_filter = 0;
+   r.in.unknown = r.in.unknown2 = 0;
+   init_winreg_String(&r.in.string1, NULL);
+   init_winreg_String(&r.in.string2, NULL);
+
+   status = dcerpc_winreg_NotifyChangeKeyValue(p, mem_ctx, &r);
+   
+   if (!NT_STATUS_IS_OK(status)) {
+   printf("NotifyChangeKeyValue failed - %s\n", nt_errstr(status));
+   return False;
+   }
+
+   if (!W_ERROR_IS_OK(r.out.result)) {
+   printf("NotifyChangeKeyValue failed - %s\n", 
win_errstr(r.out.result));
+   return False;
+   }
+
+   return True;
+}
+
 static BOOL test_CreateKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
  struct policy_handle *handle, const char *name, 
   const char *class)
@@ -609,6 +639,9 @@
}
 
 
+   if (!test_NotifyChangeKeyValue(p, mem_ctx, handle)) {
+   }
+   
if (!test_GetKeySecurity(p, mem_ctx, handle)) {
}
 



svn commit: samba r4167 - in branches/SAMBA_4_0/source: lib/registry librpc/idl torture/rpc

2004-12-12 Thread jelmer
Author: jelmer
Date: 2004-12-13 01:37:18 + (Mon, 13 Dec 2004)
New Revision: 4167

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4167

Log:
Fix CreateKey
Support CreateKey in the RPC registry backend

Modified:
   branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c
   branches/SAMBA_4_0/source/librpc/idl/winreg.idl
   branches/SAMBA_4_0/source/torture/rpc/winreg.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c
===
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c2004-12-13 
00:45:29 UTC (rev 4166)
+++ branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c2004-12-13 
01:37:18 UTC (rev 4167)
@@ -259,7 +259,32 @@
 
 static WERROR rpc_add_key(TALLOC_CTX *mem_ctx, struct registry_key *parent, 
const char *name, uint32_t access_mask, SEC_DESC *sec, struct registry_key 
**key)
 {
-   return WERR_NOT_SUPPORTED;
+   NTSTATUS status;
+   struct winreg_CreateKey r;
+
+   init_winreg_String(&r.in.key, name);
+   init_winreg_String(&r.in.class, NULL);
+
+   r.in.handle = parent->backend_data;
+   r.out.handle = talloc_p(mem_ctx, struct policy_handle); 
+   r.in.options = 0;
+   r.in.access_mask = access_mask;
+   r.in.sec_desc = NULL;
+
+   status = dcerpc_winreg_CreateKey((struct dcerpc_pipe 
*)(parent->hive->backend_data), mem_ctx, &r);
+
+if (!NT_STATUS_IS_OK(status)) {
+DEBUG(1, ("CreateKey failed - %s\n", nt_errstr(status)));
+return ntstatus_to_werror(status);
+}
+
+   if (W_ERROR_IS_OK(r.out.result)) {
+   *key = talloc_p(mem_ctx, struct registry_key);
+   (*key)->name = talloc_strdup(*key, name);
+   (*key)->backend_data = r.out.handle;
+   }
+
+   return r.out.result;
 }
 
 static WERROR rpc_query_key(struct registry_key *k)

Modified: branches/SAMBA_4_0/source/librpc/idl/winreg.idl
===
--- branches/SAMBA_4_0/source/librpc/idl/winreg.idl 2004-12-13 00:45:29 UTC 
(rev 4166)
+++ branches/SAMBA_4_0/source/librpc/idl/winreg.idl 2004-12-13 01:37:18 UTC 
(rev 4167)
@@ -75,10 +75,9 @@
[in,out,ref] policy_handle *handle,
[in] winreg_String key,
[in] winreg_String class,
-   [in] uint32 reserved,
-   [out] uint32 *unknown,
+   [in] uint32 options,
[in] uint32 access_mask,
-   [in,ref] uint32 *sec_info,
+   [in,out,ref] uint32 *action_taken,
[in] sec_desc_buf *sec_desc
);
 

Modified: branches/SAMBA_4_0/source/torture/rpc/winreg.c
===
--- branches/SAMBA_4_0/source/torture/rpc/winreg.c  2004-12-13 00:45:29 UTC 
(rev 4166)
+++ branches/SAMBA_4_0/source/torture/rpc/winreg.c  2004-12-13 01:37:18 UTC 
(rev 4167)
@@ -67,7 +67,7 @@
struct winreg_CreateKey r;
struct policy_handle newhandle;
NTSTATUS status;
-   uint32_t sec_info = 0;
+   uint32_t action_taken = 0;
 
printf("\ntesting CreateKey\n");
 
@@ -75,9 +75,9 @@
r.out.handle = &newhandle;
init_winreg_String(&r.in.key, name);
init_winreg_String(&r.in.class, class);
-   r.in.reserved = 0x0;
+   r.in.options = 0x0;
r.in.access_mask = 0x0200;
-   r.in.sec_info = &sec_info;
+   r.in.action_taken = r.out.action_taken = &action_taken;
r.in.sec_desc = NULL;
 
status = dcerpc_winreg_CreateKey(p, mem_ctx, &r);
@@ -710,7 +710,7 @@
 
 if (lp_parm_int(-1, "torture", "dangerous") != 1) {
printf("winreg_InitiateShutdown disabled - enable dangerous 
tests to use\n");
-   
+   } else {
ret &= test_InitiateSystemShutdown(p, mem_ctx, "spottyfood", 
30);
ret &= test_AbortSystemShutdown(p, mem_ctx);
}



svn commit: samba r4166 - in branches/SAMBA_4_0/source: include lib/registry lib/registry/common lib/registry/tools rpc_server/winreg

2004-12-12 Thread jelmer
Author: jelmer
Date: 2004-12-13 00:45:29 + (Mon, 13 Dec 2004)
New Revision: 4166

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4166

Log:
More small API fixes, keep registry structs as small as possible.
Implement DelValue in the RPC server

Modified:
   branches/SAMBA_4_0/source/include/registry.h
   branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c
   branches/SAMBA_4_0/source/lib/registry/reg_backend_dir.c
   branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
   branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c
   branches/SAMBA_4_0/source/lib/registry/reg_backend_w95.c
   branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c
   branches/SAMBA_4_0/source/lib/registry/tools/regshell.c
   branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c


Changeset:
Modified: branches/SAMBA_4_0/source/include/registry.h
===
--- branches/SAMBA_4_0/source/include/registry.h2004-12-12 11:30:30 UTC 
(rev 4165)
+++ branches/SAMBA_4_0/source/include/registry.h2004-12-13 00:45:29 UTC 
(rev 4166)
@@ -75,10 +75,8 @@
   const char *path;  /* Full path to the key */
   char *class_name; /* Name of key class */
   NTTIME last_mod; /* Time last modified */
-  SEC_DESC *security;
   struct registry_hive *hive;
   void *backend_data;
-  int ref;
 };
 
 struct registry_value {
@@ -86,10 +84,6 @@
   unsigned int data_type;
   int data_len;
   void *data_blk;/* Might want a separate block */
-  struct registry_hive *hive;
-  struct registry_key *parent;
-  void *backend_data;
-  int ref;
 };
 
 /* FIXME */
@@ -142,7 +136,7 @@
 
/* Value management */
WERROR (*set_value)(struct registry_key *, const char *name, int type, 
void *data, int len); 
-   WERROR (*del_value)(struct registry_value *);
+   WERROR (*del_value)(struct registry_key *, const char *valname);
 };
 
 struct registry_hive {

Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c
===
--- branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c   
2004-12-12 11:30:30 UTC (rev 4165)
+++ branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c   
2004-12-13 00:45:29 UTC (rev 4166)
@@ -281,8 +281,6 @@
return WERR_NOT_SUPPORTED;
}

-   (*val)->parent = key;
-   (*val)->hive = key->hive;
return WERR_OK;
 }
 
@@ -408,9 +406,6 @@
if(!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
return error;

-   (*val)->parent = key;
-   (*val)->hive = key->hive;
-   
return WERR_OK;
 }
 
@@ -447,7 +442,7 @@
}
 
if(W_ERROR_IS_OK(error)) {
-   error = reg_del_value(val);
+   error = reg_del_value(key, val->name);
if(!W_ERROR_IS_OK(error)) {
talloc_destroy(mem_ctx);
return error;
@@ -564,13 +559,13 @@
 
 
 
-WERROR reg_del_value(struct registry_value *val)
+WERROR reg_del_value(struct registry_key *key, const char *valname)
 {
WERROR ret = WERR_OK;
-   if(!val->hive->functions->del_value)
+   if(!key->hive->functions->del_value)
return WERR_NOT_SUPPORTED;
 
-   ret = val->hive->functions->del_value(val);
+   ret = key->hive->functions->del_value(key, valname);
 
if(!W_ERROR_IS_OK(ret)) return ret;
 

Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_dir.c
===
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_dir.c2004-12-12 
11:30:30 UTC (rev 4165)
+++ branches/SAMBA_4_0/source/lib/registry/reg_backend_dir.c2004-12-13 
00:45:29 UTC (rev 4166)
@@ -120,27 +120,13 @@
return WERR_OK;
 }
 
-static WERROR reg_dir_set_value(struct registry_key *p, const char *name, int 
type, void *data, int len)
-{
-   /* FIXME */
-   return WERR_NOT_SUPPORTED;
-}
-
-static WERROR reg_dir_del_value(struct registry_value *v)
-{
-   /* FIXME*/
-   return WERR_NOT_SUPPORTED;
-}
-
 static struct hive_operations reg_backend_dir = {
.name = "dir",
.open_hive = reg_dir_open,
.open_key = reg_dir_open_key,
.add_key = reg_dir_add_key,
.del_key = reg_dir_del_key,
-   .get_subkey_by_index = reg_dir_key_by_index,
-   .set_value = reg_dir_set_value,
-   .del_value = reg_dir_del_value,
+   .get_subkey_by_index = reg_dir_key_by_index
 };
 
 NTSTATUS registry_dir_init(void)

Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
===
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c2004-12-12 
11:30:30 UTC (rev 4165)
+++ branches/SAMBA_4_0/source/lib/registry/reg_

svn commit: linux-cifs-client r18 - in branches/linux-2.6bk/fs/cifs: .

2004-12-12 Thread sfrench
Author: sfrench
Date: 2004-12-12 21:36:55 + (Sun, 12 Dec 2004)
New Revision: 18

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=linux-cifs-client&rev=18

Log:
Merge with current cifs bk code

Modified:
   branches/linux-2.6bk/fs/cifs/CHANGES
   branches/linux-2.6bk/fs/cifs/cifsfs.c
   branches/linux-2.6bk/fs/cifs/cifsfs.h
   branches/linux-2.6bk/fs/cifs/cifsglob.h
   branches/linux-2.6bk/fs/cifs/cifsproto.h
   branches/linux-2.6bk/fs/cifs/cifssmb.c
   branches/linux-2.6bk/fs/cifs/connect.c
   branches/linux-2.6bk/fs/cifs/file.c
   branches/linux-2.6bk/fs/cifs/transport.c


Changeset:
Sorry, the patch is too large (508 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=linux-cifs-client&rev=18


svn commit: samba r4165 - in branches/SAMBA_4_0/source/ntvfs/posix: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 11:30:30 + (Sun, 12 Dec 2004)
New Revision: 4165

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4165

Log:
added a 100 element name cache to cope with some amount of seeking
back to filenames that have been deleted. This fixes the new os/2
delete test.


Modified:
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_search.c


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c
===
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
11:29:35 UTC (rev 4164)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
11:30:30 UTC (rev 4165)
@@ -25,15 +25,24 @@
 #include "vfs_posix.h"
 #include "system/dir.h"
 
+#define NAME_CACHE_SIZE 100
+
+struct name_cache_entry {
+   char *name;
+   off_t offset;
+};
+
 struct pvfs_dir {
struct pvfs_state *pvfs;
BOOL no_wildcard;
-   char *last_name;
+   char *single_name;
const char *pattern;
off_t offset;
DIR *dir;
const char *unix_path;
BOOL end_of_search;
+   struct name_cache_entry *name_cache;
+   uint32_t name_cache_index;
 };
 
 /*
@@ -55,8 +64,8 @@
return NT_STATUS_NO_MEMORY;
}
 
-   dir->last_name = talloc_strdup(dir, pattern);
-   if (!dir->last_name) {
+   dir->single_name = talloc_strdup(dir, pattern);
+   if (!dir->single_name) {
return NT_STATUS_NO_MEMORY;
}
 
@@ -88,7 +97,7 @@
char *pattern;
struct pvfs_dir *dir;
 
-   (*dirp) = talloc_p(mem_ctx, struct pvfs_dir);
+   (*dirp) = talloc_zero_p(mem_ctx, struct pvfs_dir);
if (*dirp == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -126,9 +135,15 @@
 
dir->pvfs = pvfs;
dir->no_wildcard = False;
-   dir->last_name = NULL;
dir->end_of_search = False;
dir->offset = 0;
+   dir->name_cache = talloc_zero_array_p(dir, 
+ struct name_cache_entry, 
+ NAME_CACHE_SIZE);
+   if (dir->name_cache == NULL) {
+   talloc_free(dir);
+   return NT_STATUS_NO_MEMORY;
+   }
 
talloc_set_destructor(dir, pvfs_dirlist_destructor);
 
@@ -147,7 +162,7 @@
dir->end_of_search = True;
if (*ofs != 0) return NULL;
(*ofs)++;
-   return dir->last_name;
+   return dir->single_name;
}
 
if (*ofs != dir->offset) {
@@ -157,6 +172,7 @@

while ((de = readdir(dir->dir))) {
const char *dname = de->d_name;
+   struct name_cache_entry *e;
 
if (ms_fnmatch(dir->pattern, dname, 
   dir->pvfs->tcon->smb_conn->negotiate.protocol) 
!= 0) {
@@ -173,10 +189,15 @@
dir->offset = telldir(dir->dir);
(*ofs) = dir->offset;
 
-   if (dir->last_name) talloc_free(dir->last_name);
-   dir->last_name = talloc_strdup(dir, de->d_name);
+   dir->name_cache_index = (dir->name_cache_index+1) % 
NAME_CACHE_SIZE;
+   e = &dir->name_cache[dir->name_cache_index];
 
-   return dir->last_name;
+   if (e->name) talloc_free(e->name);
+
+   e->name = talloc_strdup(dir, de->d_name);
+   e->offset = dir->offset;
+
+   return e->name;
}
 
dir->end_of_search = True;
@@ -248,17 +269,27 @@
 {
struct dirent *de;
NTSTATUS status;
+   int i;
 
status = pvfs_list_wakeup(dir, ofs);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
 
-   if (dir->last_name &&
-   StrCaseCmp(name, dir->last_name) == 0) {
-   *ofs = dir->offset;
-   return NT_STATUS_OK;
+   for (i=dir->name_cache_index;i>=0;i--) {
+   struct name_cache_entry *e = &dir->name_cache[i];
+   if (e->name && StrCaseCmp(name, e->name) == 0) {
+   *ofs = e->offset;
+   return NT_STATUS_OK;
+   }
}
+   for (i=NAME_CACHE_SIZE-1;i>dir->name_cache_index;i--) {
+   struct name_cache_entry *e = &dir->name_cache[i];
+   if (e->name && StrCaseCmp(name, e->name) == 0) {
+   *ofs = e->offset;
+   return NT_STATUS_OK;
+   }
+   }
 
rewinddir(dir->dir);
 
@@ -266,8 +297,6 @@
if (StrCaseCmp(name, de->d_name) == 0) {
dir->offset = telldir(dir->dir);
*ofs = dir->offset;
-   if (dir->last_name) talloc_free(dir->last_name);
-   dir->last_name = talloc_strdup(dir, de->d

svn commit: samba r4164 - in branches/SAMBA_4_0/source/torture/raw: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 11:29:35 + (Sun, 12 Dec 2004)
New Revision: 4164

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4164

Log:
added a test that simulates a OS/2 file delete. This includes seek by
name back into a directory for files that no longer exist.


Modified:
   branches/SAMBA_4_0/source/torture/raw/search.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/search.c
===
--- branches/SAMBA_4_0/source/torture/raw/search.c  2004-12-12 09:11:39 UTC 
(rev 4163)
+++ branches/SAMBA_4_0/source/torture/raw/search.c  2004-12-12 11:29:35 UTC 
(rev 4164)
@@ -1068,7 +1068,111 @@
return ret;
 }
 
+
 /* 
+   testing of OS/2 style delete
+*/
+static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+   const int num_files = 700;
+   const int delete_count = 4;
+   int total_deleted = 0;
+   int i, fnum;
+   char *fname;
+   BOOL ret = True;
+   NTSTATUS status;
+   union smb_search_first io;
+   union smb_search_next io2;
+   struct multiple_result result;
+
+   if (!torture_setup_dir(cli, BASEDIR)) {
+   return False;
+   }
+
+   printf("Testing OS/2 style delete on %d files\n", num_files);
+
+   for (i=0;itree, fname, O_CREAT|O_RDWR, DENY_NONE);
+   if (fnum == -1) {
+   printf("Failed to create %s - %s\n", fname, 
smbcli_errstr(cli->tree));
+   ret = False;
+   goto done;
+   }
+   free(fname);
+   smbcli_close(cli->tree, fnum);
+   }
+
+
+   ZERO_STRUCT(result);
+   result.mem_ctx = mem_ctx;
+
+   io.t2ffirst.level = RAW_SEARCH_EA_SIZE;
+   io.t2ffirst.in.search_attrib = 0;
+   io.t2ffirst.in.max_count = 100;
+   io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
+   io.t2ffirst.in.storage_type = 0;
+   io.t2ffirst.in.pattern = BASEDIR "\\*";
+
+   status = smb_raw_search_first(cli->tree, mem_ctx,
+ &io, &result, multiple_search_callback);
+   CHECK_STATUS(status, NT_STATUS_OK);
+
+   for (i=0;itree, fname);
+   CHECK_STATUS(status, NT_STATUS_OK);
+   total_deleted++;
+   }
+
+   io2.t2fnext.level = RAW_SEARCH_EA_SIZE;
+   io2.t2fnext.in.handle = io.t2ffirst.out.handle;
+   io2.t2fnext.in.max_count = 100;
+   io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
+   io2.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
+   io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
+
+   do {
+   ZERO_STRUCT(result);
+   result.mem_ctx = mem_ctx;
+
+   status = smb_raw_search_next(cli->tree, mem_ctx,
+&io2, &result, 
multiple_search_callback);
+   if (!NT_STATUS_IS_OK(status)) {
+   break;
+   }
+
+   for (i=0;itree, fname);
+   CHECK_STATUS(status, NT_STATUS_OK);
+   total_deleted++;
+   }
+
+   if (i>0) {
+   io2.t2fnext.in.resume_key = 0;
+   io2.t2fnext.in.last_name = 
result.list[i-1].ea_size.name.s;
+   }
+   } while (NT_STATUS_IS_OK(status) && result.count != 0);
+
+   CHECK_STATUS(status, NT_STATUS_OK);
+
+   if (total_deleted != num_files) {
+   printf("error: deleted %d - expected to delete %d\n", 
+  total_deleted, num_files);
+   ret = False;
+   }
+
+done:
+   smb_raw_exit(cli->session);
+   smbcli_deltree(cli->tree, BASEDIR);
+
+   return ret;
+}
+
+
+
+/* 
basic testing of all RAW_SEARCH_* calls using a single file
 */
 BOOL torture_raw_search(void)
@@ -1088,6 +1192,7 @@
ret &= test_sorted(cli, mem_ctx);
ret &= test_modify_search(cli, mem_ctx);
ret &= test_many_dirs(cli, mem_ctx);
+   ret &= test_os2_delete(cli, mem_ctx);
 
torture_close_connection(cli);
talloc_destroy(mem_ctx);



svn commit: samba r4163 - in branches/SAMBA_4_0/source/ntvfs/posix: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 09:11:39 + (Sun, 12 Dec 2004)
New Revision: 4163

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4163

Log:
2nd attempt at fixing the OS/2 "del *" problem



Modified:
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c
===
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
09:02:18 UTC (rev 4162)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
09:11:39 UTC (rev 4163)
@@ -179,8 +179,6 @@
return dir->last_name;
}
 
-   if (dir->last_name) talloc_free(dir->last_name);
-   dir->last_name = NULL;
dir->end_of_search = True;
pvfs_list_hibernate(dir);
return NULL;
@@ -196,10 +194,6 @@
closedir(dir->dir);
dir->dir = NULL;
}
-   if (!dir->no_wildcard && dir->last_name) {
-   talloc_free(dir->last_name);
-   dir->last_name = NULL;
-   }
 }
 
 



svn commit: samba r4162 - in branches/SAMBA_4_0/source/ntvfs/posix: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 09:02:18 + (Sun, 12 Dec 2004)
New Revision: 4162

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4162

Log:
this should fix the delete/findnext problem from OS/2 clients. Thanks
again to kukks for the excellent and detailed bug report


Modified:
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_search.c


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c
===
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
08:35:11 UTC (rev 4161)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_dirlist.c2004-12-12 
09:02:18 UTC (rev 4162)
@@ -282,5 +282,7 @@
 
pvfs_list_hibernate(dir);
 
-   return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+   /* it is not an error to give a bad name (it may have been deleted). 
Instead
+  just continue from end of directory */
+   return NT_STATUS_OK;
 }

Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_search.c
===
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_search.c 2004-12-12 08:35:11 UTC 
(rev 4161)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_search.c 2004-12-12 09:02:18 UTC 
(rev 4162)
@@ -562,6 +562,10 @@
talloc_free(search);
}
 
+   if (reply_count == 0) {
+   return NT_STATUS_NO_SUCH_FILE;
+   }
+
return NT_STATUS_OK;
 }
 


svn commit: samba r4161 - in branches/SAMBA_4_0/source/rpc_server: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 08:35:11 + (Sun, 12 Dec 2004)
New Revision: 4161

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4161

Log:
two more fixes for NT4 clients. Bugs found by kukks.

 - nt4 doesn't setup the pfc flags correctly for rpc packet types
   other than normal requests, so don't check for fragmented packets
   unless they are of type request

 - ensure we give STATUS_BUFFER_OVERFLOW when we return a partial
   fragment in SMBtrans requests on ncacn_np




Modified:
   branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c
===
--- branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c2004-12-12 
08:33:08 UTC (rev 4160)
+++ branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c2004-12-12 
08:35:11 UTC (rev 4161)
@@ -849,7 +849,8 @@
dce_partial_advance(dce_conn, blob.length);
 
/* see if this is a continued packet */
-   if (!(call->pkt.pfc_flags & DCERPC_PFC_FLAG_FIRST)) {
+   if (call->pkt.ptype == DCERPC_PKT_REQUEST &&
+   !(call->pkt.pfc_flags & DCERPC_PFC_FLAG_FIRST)) {
struct dcesrv_call_state *call2 = call;
uint32_t alloc_size;
 
@@ -895,7 +896,8 @@
 
/* this may not be the last pdu in the chain - if its isn't then
   just put it on the call_list and wait for the rest */
-   if (!(call->pkt.pfc_flags & DCERPC_PFC_FLAG_LAST)) {
+   if (call->pkt.ptype == DCERPC_PKT_REQUEST &&
+   !(call->pkt.pfc_flags & DCERPC_PFC_FLAG_LAST)) {
DLIST_ADD_END(dce_conn->call_list, call, struct 
dcesrv_call_state *);
return NT_STATUS_OK;
}
@@ -998,6 +1000,8 @@
if (rep->data.length == 0) {
/* we're done with this section of the call */
DLIST_REMOVE(call->replies, rep);
+   } else {
+   return STATUS_BUFFER_OVERFLOW;
}
 
if (call->replies == NULL) {



svn commit: samba r4160 - in branches/SAMBA_4_0/source/ntvfs/ipc: .

2004-12-12 Thread tridge
Author: tridge
Date: 2004-12-12 08:33:08 + (Sun, 12 Dec 2004)
New Revision: 4160

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4160

Log:
fixed the file_type in ntcreatex reply on a named pipe. NT4 requires this to be 
right.



Modified:
   branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c
===
--- branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c   2004-12-12 07:22:59 UTC 
(rev 4159)
+++ branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c   2004-12-12 08:33:08 UTC 
(rev 4160)
@@ -267,6 +267,7 @@
ZERO_STRUCT(oi->ntcreatex.out);
oi->ntcreatex.out.fnum = p->fnum;
oi->ntcreatex.out.ipc_state = p->ipc_state;
+   oi->ntcreatex.out.file_type = FILE_TYPE_MESSAGE_MODE_PIPE;
 
return status;
 }