[PATCH] A few cleanup patches

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Sep 16 12:12:37 MDT 2014


Hi!

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 9ce629d993b9a238361fedfffac61ee3543fba96 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 14 Sep 2014 18:44:36 +0200
Subject: [PATCH 1/4] lib: Move "large_file_support()" to the source4 smb
 server

That's the only place where it's used, make it static there.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/lib/util/util.h             |    1 -
 lib/util/samba_util.h            |    1 -
 lib/util/util_file.c             |   21 ---------------------
 source4/smb_server/smb/negprot.c |   21 +++++++++++++++++++++
 4 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/ctdb/lib/util/util.h b/ctdb/lib/util/util.h
index abf5c464..8702f2a 100644
--- a/ctdb/lib/util/util.h
+++ b/ctdb/lib/util/util.h
@@ -344,7 +344,6 @@ _PUBLIC_ void file_lines_slashcont(char **lines);
 _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
 _PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
 _PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-_PUBLIC_ bool large_file_support(const char *path);
 
 /* The following definitions come from lib/util/util.c  */
 
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 528d373..958df88 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -600,7 +600,6 @@ _PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
 _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
 _PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
 _PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-_PUBLIC_ bool large_file_support(const char *path);
 
 /*
   compare two files, return true if the two files have the same content
diff --git a/lib/util/util_file.c b/lib/util/util_file.c
index 815cc2b..8fd3277 100644
--- a/lib/util/util_file.c
+++ b/lib/util/util_file.c
@@ -420,27 +420,6 @@ _PUBLIC_ int fdprintf(int fd, const char *format, ...)
 
 
 /*
-  try to determine if the filesystem supports large files
-*/
-_PUBLIC_ bool large_file_support(const char *path)
-{
-	int fd;
-	ssize_t ret;
-	char c;
-
-	fd = open(path, O_RDWR|O_CREAT, 0600);
-	unlink(path);
-	if (fd == -1) {
-		/* have to assume large files are OK */
-		return true;
-	}
-	ret = pread(fd, &c, 1, ((uint64_t)1)<<32);
-	close(fd);
-	return ret == 0;
-}
-
-
-/*
   compare two files, return true if the two files have the same content
  */
 bool file_compare(const char *path1, const char *path2)
diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c
index 339fa7a..cdfa2b4 100644
--- a/source4/smb_server/smb/negprot.c
+++ b/source4/smb_server/smb/negprot.c
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
 #include "auth/auth.h"
@@ -251,6 +252,26 @@ static void reply_nt1_orig(struct smbsrv_request *req)
 	DEBUG(3,("not using extended security (SPNEGO or NTLMSSP)\n"));
 }
 
+/*
+  try to determine if the filesystem supports large files
+*/
+static bool large_file_support(const char *path)
+{
+	int fd;
+	ssize_t ret;
+	char c;
+
+	fd = open(path, O_RDWR|O_CREAT, 0600);
+	unlink(path);
+	if (fd == -1) {
+		/* have to assume large files are OK */
+		return true;
+	}
+	ret = pread(fd, &c, 1, ((uint64_t)1)<<32);
+	close(fd);
+	return ret == 0;
+}
+
 /****************************************************************************
  Reply for the nt protocol.
 ****************************************************************************/
-- 
1.7.9.5


From 9e4a76ef675da5df4bc0b6dc653942f076477a5e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 14 Sep 2014 18:49:46 +0200
Subject: [PATCH 2/4] lib: Remove unused file_lines_slashcont

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/lib/util/util.h  |    6 ------
 lib/util/samba_util.h |    6 ------
 lib/util/util_file.c  |   24 ------------------------
 3 files changed, 36 deletions(-)

diff --git a/ctdb/lib/util/util.h b/ctdb/lib/util/util.h
index 8702f2a..33f46bd 100644
--- a/ctdb/lib/util/util.h
+++ b/ctdb/lib/util/util.h
@@ -333,12 +333,6 @@ the list.
 _PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
 
 /**
-take a list of lines and modify them to produce a list where \ continues
-a line
-**/
-_PUBLIC_ void file_lines_slashcont(char **lines);
-
-/**
   save a lump of data into a file. Mostly used for debugging 
 */
 _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 958df88..a8d3cd6 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -586,12 +586,6 @@ the list.
 **/
 _PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
 
-/**
-take a list of lines and modify them to produce a list where \ continues
-a line
-**/
-_PUBLIC_ void file_lines_slashcont(char **lines);
-
 _PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
 			     size_t length, mode_t mode);
 /**
diff --git a/lib/util/util_file.c b/lib/util/util_file.c
index 8fd3277..886bcae 100644
--- a/lib/util/util_file.c
+++ b/lib/util/util_file.c
@@ -344,30 +344,6 @@ _PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX
 	return file_lines_parse(p, size, numlines, mem_ctx);
 }
 
-
-/**
-take a list of lines and modify them to produce a list where \ continues
-a line
-**/
-_PUBLIC_ void file_lines_slashcont(char **lines)
-{
-	int i, j;
-
-	for (i=0; lines[i];) {
-		int len = strlen(lines[i]);
-		if (lines[i][len-1] == '\\') {
-			lines[i][len-1] = ' ';
-			if (lines[i+1]) {
-				char *p = &lines[i][len];
-				while (p < lines[i+1]) *p++ = ' ';
-				for (j = i+1; lines[j]; j++) lines[j] = lines[j+1];
-			}
-		} else {
-			i++;
-		}
-	}
-}
-
 _PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
 			     size_t length, mode_t mode)
 {
-- 
1.7.9.5


From 237cfff5e3201effacbd04cbd489a38b09f5d85d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 16 Sep 2014 19:19:06 +0200
Subject: [PATCH 3/4] lib: Avoid a talloc in write_data_iov

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/util_sock.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 522f600..d865ffb 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -255,7 +255,8 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
 	ssize_t to_send;
 	ssize_t thistime;
 	size_t sent;
-	struct iovec *iov_copy, *iov;
+	struct iovec iov_copy[iovcnt];
+	struct iovec *iov;
 
 	to_send = iov_buflen(orig_iov, iovcnt);
 	if (to_send == -1) {
@@ -276,13 +277,7 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
 	 * discarding elements.
 	 */
 
-	iov_copy = (struct iovec *)talloc_memdup(
-		talloc_tos(), orig_iov, sizeof(struct iovec) * iovcnt);
-
-	if (iov_copy == NULL) {
-		errno = ENOMEM;
-		return -1;
-	}
+	memcpy(iov_copy, orig_iov, sizeof(struct iovec) * iovcnt);
 	iov = iov_copy;
 
 	while (sent < to_send) {
@@ -311,7 +306,6 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
 		sent += thistime;
 	}
 
-	TALLOC_FREE(iov_copy);
 	return sent;
 }
 
-- 
1.7.9.5


From ff53c4a8ffed22e9e8d255dd9efca35feac68949 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 16 Sep 2014 19:44:57 +0200
Subject: [PATCH 4/4] replace: Make EWOULDBLOCK always available

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/replace/replace.h |    4 ++++
 lib/replace/wscript   |    1 +
 2 files changed, 5 insertions(+)

diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index bc40bf0..3ff4e36 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -41,6 +41,10 @@
 #include <stdarg.h>
 #include <errno.h>
 
+#ifndef HAVE_DECL_EWOULDBLOCK
+#define EWOULDBLOCK EAGAIN
+#endif
+
 #if defined(_MSC_VER) || defined(__MINGW32__)
 #include "win32_replace.h"
 #endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 6f2fb66..16fd50b 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -518,6 +518,7 @@ removeea setea
     conf.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')
 
     conf.CHECK_DECLS('errno', headers='errno.h', reverse=True)
+    conf.CHECK_DECLS('EWOULDBLOCK', headers='errno.h')
     conf.CHECK_DECLS('environ getgrent_r getpwent_r', reverse=True, headers='pwd.h grp.h')
     conf.CHECK_DECLS('pread pwrite setenv setresgid setresuid', reverse=True)
 
-- 
1.7.9.5



More information about the samba-technical mailing list