From patchwork Tue Feb 1 13:54:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Schmidt X-Patchwork-Id: 523061 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p11ESL8X003364 for ; Tue, 1 Feb 2011 14:28:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756903Ab1BAO2R (ORCPT ); Tue, 1 Feb 2011 09:28:17 -0500 Received: from vroomfondel.rzone.de ([81.169.147.145]:41694 "EHLO vroomfondel.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753438Ab1BAO2Q (ORCPT ); Tue, 1 Feb 2011 09:28:16 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 01 Feb 2011 14:28:22 +0000 (UTC) X-Greylist: delayed 1948 seconds by postgrey-1.27 at vger.kernel.org; Tue, 01 Feb 2011 09:28:16 EST Received: from sensei.trapni.de (oglaroon.iata [192.168.96.10]) by vroomfondel.rzone.de (Postfix) with ESMTP id 374374AFD; Tue, 1 Feb 2011 14:55:42 +0100 (MET) Received: by sensei.trapni.de (Postfix, from userid 0) id 38EB09C08FF; Tue, 1 Feb 2011 14:54:50 +0100 (CET) From: Jan Schmidt 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 Message-Id: <1296568490-13264-2-git-send-email-list.btrfs@jan-o-sch.net> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1296568490-13264-1-git-send-email-list.btrfs@jan-o-sch.net> References: <1296568490-13264-1-git-send-email-list.btrfs@jan-o-sch.net> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 #include #include +#include #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