diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2011-10-31 20:08:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-31 20:30:47 -0400 |
commit | 798248206b59acc6e1238c778281419c041891a7 (patch) | |
tree | ff8564431367b442b18bca4a0a9732e5799e2391 /fs | |
parent | 77311139f364d7f71fc9ba88f59fd90e60205007 (diff) |
lib/string.c: introduce memchr_inv()
memchr_inv() is mainly used to check whether the whole buffer is filled
with just a specified byte.
The function name and prototype are stolen from logfs and the
implementation is from SLUB.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Matt Mackall <mpm@selenic.com>
Acked-by: Joern Engel <joern@logfs.org>
Cc: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/logfs/logfs.h | 1 | ||||
-rw-r--r-- | fs/logfs/super.c | 22 |
2 files changed, 0 insertions, 23 deletions
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h index f22d108bfa5d..398ecff6e548 100644 --- a/fs/logfs/logfs.h +++ b/fs/logfs/logfs.h | |||
@@ -618,7 +618,6 @@ static inline int logfs_buf_recover(struct logfs_area *area, u64 ofs, | |||
618 | struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index); | 618 | struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index); |
619 | void emergency_read_end(struct page *page); | 619 | void emergency_read_end(struct page *page); |
620 | void logfs_crash_dump(struct super_block *sb); | 620 | void logfs_crash_dump(struct super_block *sb); |
621 | void *memchr_inv(const void *s, int c, size_t n); | ||
622 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); | 621 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); |
623 | int logfs_check_ds(struct logfs_disk_super *ds); | 622 | int logfs_check_ds(struct logfs_disk_super *ds); |
624 | int logfs_write_sb(struct super_block *sb); | 623 | int logfs_write_sb(struct super_block *sb); |
diff --git a/fs/logfs/super.c b/fs/logfs/super.c index ce03a182c771..f2697e4df109 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c | |||
@@ -91,28 +91,6 @@ void logfs_crash_dump(struct super_block *sb) | |||
91 | } | 91 | } |
92 | 92 | ||
93 | /* | 93 | /* |
94 | * TODO: move to lib/string.c | ||
95 | */ | ||
96 | /** | ||
97 | * memchr_inv - Find a character in an area of memory. | ||
98 | * @s: The memory area | ||
99 | * @c: The byte to search for | ||
100 | * @n: The size of the area. | ||
101 | * | ||
102 | * returns the address of the first character other than @c, or %NULL | ||
103 | * if the whole buffer contains just @c. | ||
104 | */ | ||
105 | void *memchr_inv(const void *s, int c, size_t n) | ||
106 | { | ||
107 | const unsigned char *p = s; | ||
108 | while (n-- != 0) | ||
109 | if ((unsigned char)c != *p++) | ||
110 | return (void *)(p - 1); | ||
111 | |||
112 | return NULL; | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * FIXME: There should be a reserve for root, similar to ext2. | 94 | * FIXME: There should be a reserve for root, similar to ext2. |
117 | */ | 95 | */ |
118 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats) | 96 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats) |