From: Jeff Liu <jeff.liu@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, Gene Czarcinski <gene@czarc.net>
Subject: [PATCH v2 1/2] btrfs-progs: refactor check_label()
Date: Wed, 30 Jan 2013 16:32:43 +0800 [thread overview]
Message-ID: <5108DAAB.10401@oracle.com> (raw)
Refactor check_label().
- Make it be static at first, this is a preparation step since we'll remove
btrfslabel.[c|h] and move those functions from there to utils.[c|h], we can
do pre-checking against the input label string with it.
- Fix the label length check up from BTRFS_LABEL_SIZE to BTRFS_LABEL_SIZE - 1.
- Kill the check of label contains an invalid character, see below commits for detail:
79e0e445fc2365e47fc7f060d5a4445d37e184b8
btrfs-progs: kill check for /'s in labels.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
CC: David Sterba <dsterba@suse.cz>
CC: Gene Czarcinski <gene@czarc.net>
---
utils.c | 14 ++++----------
utils.h | 1 -
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/utils.c b/utils.c
index d59bca3..9dc688a 100644
--- a/utils.c
+++ b/utils.c
@@ -1120,23 +1120,17 @@ char *pretty_sizes(u64 size)
* Returns:
0 if everything is safe and usable
-1 if the label is too long
- -2 if the label contains an invalid character
*/
-int check_label(char *input)
+static int check_label(const char *input)
{
- int i;
int len = strlen(input);
- if (len > BTRFS_LABEL_SIZE) {
+ if (len > BTRFS_LABEL_SIZE - 1) {
+ fprintf(stderr, "ERROR: Label %s is too long (max %d)\n",
+ input, BTRFS_LABEL_SIZE - 1);
return -1;
}
- for (i = 0; i < len; i++) {
- if (input[i] == '/' || input[i] == '\\') {
- return -2;
- }
- }
-
return 0;
}
diff --git a/utils.h b/utils.h
index 8750f28..a0b782b 100644
--- a/utils.h
+++ b/utils.h
@@ -42,7 +42,6 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
int super_offset);
char *pretty_sizes(u64 size);
-int check_label(char *input);
int get_mountpt(char *dev, char *mntpt, size_t size);
int btrfs_scan_block_devices(int run_ioctl);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-
reply other threads:[~2013-01-30 8:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=5108DAAB.10401@oracle.com \
--to=jeff.liu@oracle.com \
--cc=dsterba@suse.cz \
--cc=gene@czarc.net \
--cc=linux-btrfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.