[PATCH] smbd: Move make_dir_struct() to reply.c
Volker Lendecke
Volker.Lendecke at SerNet.DE
Mon Sep 8 04:43:28 MDT 2014
Hi!
Attached find a small cleanup patch.
Review&push would be appreciated.
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From d0e3093ad1c2a1cf0ddb675e7e78072478b0c605 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 8 Sep 2014 12:41:19 +0200
Subject: [PATCH] smbd: Move make_dir_struct() to reply.c
This routine has nothing to do with dptr handling, it is SMB1 marshalling
called only from reply_search().
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/dir.c | 46 ----------------------------------------------
source3/smbd/proto.h | 8 --------
source3/smbd/reply.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 54 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 55d7742..6c811fe 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -87,52 +87,6 @@ static void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset);
#define INVALID_DPTR_KEY (-3)
/****************************************************************************
- Make a dir struct.
-****************************************************************************/
-
-bool make_dir_struct(TALLOC_CTX *ctx,
- char *buf,
- const char *mask,
- const char *fname,
- off_t size,
- uint32 mode,
- time_t date,
- bool uc)
-{
- char *p;
- char *mask2 = talloc_strdup(ctx, mask);
-
- if (!mask2) {
- return False;
- }
-
- if ((mode & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- size = 0;
- }
-
- memset(buf+1,' ',11);
- if ((p = strchr_m(mask2,'.')) != NULL) {
- *p = 0;
- push_ascii(buf+1,mask2,8, 0);
- push_ascii(buf+9,p+1,3, 0);
- *p = '.';
- } else {
- push_ascii(buf+1,mask2,11, 0);
- }
-
- memset(buf+21,'\0',DIR_STRUCT_SIZE-21);
- SCVAL(buf,21,mode);
- srv_put_dos_date(buf,22,date);
- SSVAL(buf,26,size & 0xFFFF);
- SSVAL(buf,28,(size >> 16)&0xFFFF);
- /* We only uppercase if FLAGS2_LONG_PATH_COMPONENTS is zero in the input buf.
- Strange, but verified on W2K3. Needed for OS/2. JRA. */
- push_ascii(buf+30,fname,12, uc ? STR_UPPER : 0);
- DEBUG(8,("put name [%s] from [%s] into dir struct\n",buf+30, fname));
- return True;
-}
-
-/****************************************************************************
Initialise the dir bitmap.
****************************************************************************/
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index acf6811..cb05565 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -179,14 +179,6 @@ uint64_t get_dfree_info(connection_struct *conn,
/* The following definitions come from smbd/dir.c */
-bool make_dir_struct(TALLOC_CTX *ctx,
- char *buf,
- const char *mask,
- const char *fname,
- off_t size,
- uint32 mode,
- time_t date,
- bool uc);
bool init_dptrs(struct smbd_server_connection *sconn);
const char *dptr_path(struct smbd_server_connection *sconn, int key);
const char *dptr_wcard(struct smbd_server_connection *sconn, int key);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 4cb446f..0a8c996 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1524,6 +1524,52 @@ static NTSTATUS split_fname_dir_mask(TALLOC_CTX *ctx, const char *fname_in,
}
/****************************************************************************
+ Make a dir struct.
+****************************************************************************/
+
+static bool make_dir_struct(TALLOC_CTX *ctx,
+ char *buf,
+ const char *mask,
+ const char *fname,
+ off_t size,
+ uint32 mode,
+ time_t date,
+ bool uc)
+{
+ char *p;
+ char *mask2 = talloc_strdup(ctx, mask);
+
+ if (!mask2) {
+ return False;
+ }
+
+ if ((mode & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ size = 0;
+ }
+
+ memset(buf+1,' ',11);
+ if ((p = strchr_m(mask2,'.')) != NULL) {
+ *p = 0;
+ push_ascii(buf+1,mask2,8, 0);
+ push_ascii(buf+9,p+1,3, 0);
+ *p = '.';
+ } else {
+ push_ascii(buf+1,mask2,11, 0);
+ }
+
+ memset(buf+21,'\0',DIR_STRUCT_SIZE-21);
+ SCVAL(buf,21,mode);
+ srv_put_dos_date(buf,22,date);
+ SSVAL(buf,26,size & 0xFFFF);
+ SSVAL(buf,28,(size >> 16)&0xFFFF);
+ /* We only uppercase if FLAGS2_LONG_PATH_COMPONENTS is zero in the input buf.
+ Strange, but verified on W2K3. Needed for OS/2. JRA. */
+ push_ascii(buf+30,fname,12, uc ? STR_UPPER : 0);
+ DEBUG(8,("put name [%s] from [%s] into dir struct\n",buf+30, fname));
+ return True;
+}
+
+/****************************************************************************
Reply to a search.
Can be called from SMBsearch, SMBffirst or SMBfunique.
****************************************************************************/
--
1.7.9.5
More information about the samba-technical
mailing list