linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
To: linux-btrfs@vger.kernel.org
Cc: chris.mason@oracle.com, sensille@gmx.net
Subject: [PATCH 1/7] moved parse_size() to utils.c
Date: Tue,  1 Feb 2011 14:54:44 +0100	[thread overview]
Message-ID: <1296568490-13264-2-git-send-email-list.btrfs@jan-o-sch.net> (raw)
In-Reply-To: <1296568490-13264-1-git-send-email-list.btrfs@jan-o-sch.net>

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
---
 btrfs_cmds.c |   26 --------------------------
 mkfs.c       |   26 --------------------------
 utils.c      |   26 ++++++++++++++++++++++++++
 utils.h      |    1 +
 4 files changed, 27 insertions(+), 52 deletions(-)

diff --git a/btrfs_cmds.c b/btrfs_cmds.c
index 8031c58..d707a7d 100644
--- a/btrfs_cmds.c
+++ b/btrfs_cmds.c
@@ -116,32 +116,6 @@ static int open_file_or_dir(const char *fname)
 	return fd;
 }
 
-static u64 parse_size(char *s)
-{
-	int len = strlen(s);
-	char c;
-	u64 mult = 1;
-
-	if (!isdigit(s[len - 1])) {
-		c = tolower(s[len - 1]);
-		switch (c) {
-		case 'g':
-			mult *= 1024;
-		case 'm':
-			mult *= 1024;
-		case 'k':
-			mult *= 1024;
-		case 'b':
-			break;
-		default:
-			fprintf(stderr, "Unknown size descriptor %c\n", c);
-			exit(1);
-		}
-		s[len - 1] = '\0';
-	}
-	return atoll(s) * mult;
-}
-
 int do_defrag(int ac, char **av)
 {
 	int fd;
diff --git a/mkfs.c b/mkfs.c
index 2e99b95..d1dd4a3 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -43,32 +43,6 @@
 #include "utils.h"
 #include "version.h"
 
-static u64 parse_size(char *s)
-{
-	int len = strlen(s);
-	char c;
-	u64 mult = 1;
-
-	if (!isdigit(s[len - 1])) {
-		c = tolower(s[len - 1]);
-		switch (c) {
-		case 'g':
-			mult *= 1024;
-		case 'm':
-			mult *= 1024;
-		case 'k':
-			mult *= 1024;
-		case 'b':
-			break;
-		default:
-			fprintf(stderr, "Unknown size descriptor %c\n", c);
-			exit(1);
-		}
-		s[len - 1] = '\0';
-	}
-	return atol(s) * mult;
-}
-
 static int make_root_dir(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
diff --git a/utils.c b/utils.c
index 815b967..5fb82dc 100644
--- a/utils.c
+++ b/utils.c
@@ -35,6 +35,7 @@
 #include <linux/major.h>
 #include <linux/kdev_t.h>
 #include <limits.h>
+#include <ctype.h>
 #include "kerncompat.h"
 #include "radix-tree.h"
 #include "ctree.h"
@@ -1003,3 +1004,28 @@ char *pretty_sizes(u64 size)
 	return pretty;
 }
 
+u64 parse_size(char *s)
+{
+	int len = strlen(s);
+	char c;
+	u64 mult = 1;
+
+	if (!isdigit(s[len - 1])) {
+		c = tolower(s[len - 1]);
+		switch (c) {
+		case 'g':
+			mult *= 1024;
+		case 'm':
+			mult *= 1024;
+		case 'k':
+			mult *= 1024;
+		case 'b':
+			break;
+		default:
+			fprintf(stderr, "Unknown size descriptor %c\n", c);
+			exit(1);
+		}
+		s[len - 1] = '\0';
+	}
+	return atoll(s) * mult;
+}
diff --git a/utils.h b/utils.h
index 9dce5b0..dc1b41d 100644
--- a/utils.h
+++ b/utils.h
@@ -40,4 +40,5 @@ int check_mounted(const char *devicename);
 int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
 				 int super_offset);
 char *pretty_sizes(u64 size);
+u64 parse_size(char *s);
 #endif
-- 
1.7.2.2


  reply	other threads:[~2011-02-01 13:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 13:54 [PATCH 0/7] Btrfs: Progs modifications to introduce speed profiles and dedicated log devices Jan Schmidt
2011-02-01 13:54 ` Jan Schmidt [this message]
2011-02-01 13:54 ` [PATCH 2/7] pulled current kernel version of ioctl.h Jan Schmidt
2011-02-01 13:54 ` [PATCH 3/7] check open_ctree() right after it returned Jan Schmidt
2011-02-01 13:54 ` [PATCH 4/7] speed classes (needed for profiles) for device add. subsequent patch needed to fix mkfs Jan Schmidt
2011-02-01 13:54 ` [PATCH 5/7] speed classes (needed for profiles) for mkfs Jan Schmidt
2011-02-01 13:54 ` [PATCH 6/7] debug-tree output: device speed added; type output switched to hex Jan Schmidt
2011-02-01 13:54 ` [PATCH 7/7] made btrfs-vol compile. looks unused, so no speed class support here for now Jan Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296568490-13264-2-git-send-email-list.btrfs@jan-o-sch.net \
    --to=list.btrfs@jan-o-sch.net \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sensille@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).