svn commit: samba r16855 - in trunk/source: . lib modules
jpeach at samba.org
jpeach at samba.org
Fri Jul 7 04:56:34 GMT 2006
Author: jpeach
Date: 2006-07-07 04:56:33 +0000 (Fri, 07 Jul 2006)
New Revision: 16855
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16855
Log:
Move conv_str_size() to common code.
Modified:
trunk/source/configure.in
trunk/source/lib/util_str.c
trunk/source/modules/vfs_cacheprime.c
trunk/source/modules/vfs_commit.c
trunk/source/modules/vfs_prealloc.c
Changeset:
Modified: trunk/source/configure.in
===================================================================
--- trunk/source/configure.in 2006-07-07 04:55:18 UTC (rev 16854)
+++ trunk/source/configure.in 2006-07-07 04:56:33 UTC (rev 16855)
@@ -1266,7 +1266,8 @@
EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
fi
-AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(strtol strtoll strtoul strtoull)
AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
Modified: trunk/source/lib/util_str.c
===================================================================
--- trunk/source/lib/util_str.c 2006-07-07 04:55:18 UTC (rev 16854)
+++ trunk/source/lib/util_str.c 2006-07-07 04:56:33 UTC (rev 16855)
@@ -5,6 +5,7 @@
Copyright (C) Andrew Tridgell 1992-2001
Copyright (C) Simo Sorce 2001-2002
Copyright (C) Martin Pool 2003
+ Copyright (C) James Peach 2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2303,6 +2304,59 @@
return val;
}
+/* Convert a size specification to a count of bytes. We accept the following
+ * suffixes:
+ * bytes if there is no suffix
+ * kK kibibytes
+ * mM mebibytes
+ * gG gibibytes
+ * tT tibibytes
+ * pP whatever the ISO name for petabytes is
+ *
+ * Returns 0 if the string can't be converted.
+ */
+SMB_OFF_T conv_str_size(const char * str)
+{
+ SMB_OFF_T lval;
+ char * end;
+
+ if (str == NULL || *str == '\0') {
+ return 0;
+ }
+
+#ifdef HAVE_STRTOULL
+ if (sizeof(SMB_OFF_T) == 8) {
+ lval = strtoull(str, &end, 10 /* base */);
+ } else {
+ lval = strtoul(str, &end, 10 /* base */);
+ }
+#else
+ lval = strtoul(str, &end, 10 /* base */);
+#endif
+
+ if (end == NULL || end == str) {
+ return 0;
+ }
+
+ if (*end) {
+ if (strwicmp(end, "K") == 0) {
+ lval *= 1024ULL;
+ } else if (strwicmp(end, "M") == 0) {
+ lval *= (1024ULL * 1024ULL);
+ } else if (strwicmp(end, "G") == 0) {
+ lval *= (1024ULL * 1024ULL * 1024ULL);
+ } else if (strwicmp(end, "T") == 0) {
+ lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
+ } else if (strwicmp(end, "P") == 0) {
+ lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
+ } else {
+ return 0;
+ }
+ }
+
+ return lval;
+}
+
void string_append(char **left, const char *right)
{
int new_len = strlen(right) + 1;
Modified: trunk/source/modules/vfs_cacheprime.c
===================================================================
--- trunk/source/modules/vfs_cacheprime.c 2006-07-07 04:55:18 UTC (rev 16854)
+++ trunk/source/modules/vfs_cacheprime.c 2006-07-07 04:56:33 UTC (rev 16855)
@@ -42,44 +42,6 @@
static ssize_t g_readsz = 0;
static void * g_readbuf = NULL;
-static SMB_OFF_T conv_str_size(const char * str)
-{
- SMB_OFF_T lval;
- char * end;
-
- if (str == NULL || *str == '\0') {
- return 0;
- }
-
- if (sizeof(SMB_OFF_T) == 8) {
- lval = strtoull(str, &end, 10 /* base */);
- } else {
- lval = strtoul(str, &end, 10 /* base */);
- }
-
- if (end == NULL || end == str) {
- return 0;
- }
-
- if (*end) {
- if (strwicmp(end, "K") == 0) {
- lval *= 1024ULL;
- } else if (strwicmp(end, "M") == 0) {
- lval *= (1024ULL * 1024ULL);
- } else if (strwicmp(end, "G") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "T") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "P") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else {
- return 0;
- }
- }
-
- return lval;
-}
-
/* Prime the kernel buffer cache with data from the specified file. We use
* per-fsp data to make sure we only ever do this once. If pread is being
* emulated by seek/read/seek, when this will suck quite a lot.
Modified: trunk/source/modules/vfs_commit.c
===================================================================
--- trunk/source/modules/vfs_commit.c 2006-07-07 04:55:18 UTC (rev 16854)
+++ trunk/source/modules/vfs_commit.c 2006-07-07 04:56:33 UTC (rev 16855)
@@ -46,44 +46,6 @@
SMB_OFF_T dthresh; /* Dirty data threshold */
};
-static SMB_OFF_T conv_str_size(const char * str)
-{
- SMB_OFF_T lval;
- char * end;
-
- if (str == NULL || *str == '\0') {
- return 0;
- }
-
- if (sizeof(SMB_OFF_T) == 8) {
- lval = strtoull(str, &end, 10 /* base */);
- } else {
- lval = strtoul(str, &end, 10 /* base */);
- }
-
- if (end == NULL || end == str) {
- return 0;
- }
-
- if (*end) {
- if (strwicmp(end, "K") == 0) {
- lval *= 1024ULL;
- } else if (strwicmp(end, "M") == 0) {
- lval *= (1024ULL * 1024ULL);
- } else if (strwicmp(end, "G") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "T") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "P") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else {
- return 0;
- }
- }
-
- return lval;
-}
-
static void commit_all(
struct vfs_handle_struct * handle,
files_struct * fsp)
Modified: trunk/source/modules/vfs_prealloc.c
===================================================================
--- trunk/source/modules/vfs_prealloc.c 2006-07-07 04:55:18 UTC (rev 16854)
+++ trunk/source/modules/vfs_prealloc.c 2006-07-07 04:56:33 UTC (rev 16855)
@@ -51,44 +51,6 @@
#define MODULE "prealloc"
static int module_debug;
-static SMB_OFF_T conv_str_size(const char * str)
-{
- SMB_OFF_T lval;
- char * end;
-
- if (str == NULL || *str == '\0') {
- return 0;
- }
-
- if (sizeof(SMB_OFF_T) == 8) {
- lval = strtoull(str, &end, 10 /* base */);
- } else {
- lval = strtoul(str, &end, 10 /* base */);
- }
-
- if (end == NULL || end == str) {
- return 0;
- }
-
- if (*end) {
- if (strwicmp(end, "K") == 0) {
- lval *= 1024ULL;
- } else if (strwicmp(end, "M") == 0) {
- lval *= (1024ULL * 1024ULL);
- } else if (strwicmp(end, "G") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "T") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else if (strwicmp(end, "P") == 0) {
- lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
- } else {
- return 0;
- }
- }
-
- return lval;
-}
-
static int preallocate_space(int fd, SMB_OFF_T size)
{
lock_type fl = {0};
More information about the samba-cvs
mailing list