Lines Matching +full:len +full:- +full:or +full:- +full:limit
1 // SPDX-License-Identifier: GPL-2.0-or-later
18 #define ROMFS_MTD_READ(sb, ...) mtd_read((sb)->s_mtd, ##__VA_ARGS__)
30 return (ret < 0 || rlen != buflen) ? -EIO : 0; in romfs_mtd_read()
42 size_t len; in romfs_mtd_strnlen() local
48 ret = ROMFS_MTD_READ(sb, pos, segment, &len, buf); in romfs_mtd_strnlen()
51 p = memchr(buf, 0, len); in romfs_mtd_strnlen()
53 return n + (p - buf); in romfs_mtd_strnlen()
54 maxlen -= len; in romfs_mtd_strnlen()
55 pos += len; in romfs_mtd_strnlen()
56 n += len; in romfs_mtd_strnlen()
64 * - return 1 if matched, 0 if differ, -ve if error
70 size_t len, segment; in romfs_mtd_strcmp() local
79 ret = ROMFS_MTD_READ(sb, pos, segment, &len, buf); in romfs_mtd_strcmp()
82 len--; in romfs_mtd_strcmp()
83 if (memcmp(buf, str, len) != 0) in romfs_mtd_strcmp()
85 buf[0] = buf[len]; in romfs_mtd_strcmp()
86 size -= len; in romfs_mtd_strcmp()
87 pos += len; in romfs_mtd_strcmp()
88 str += len; in romfs_mtd_strcmp()
112 offset = pos & (ROMBSIZE - 1); in romfs_blk_read()
113 segment = min_t(size_t, buflen, ROMBSIZE - offset); in romfs_blk_read()
116 return -EIO; in romfs_blk_read()
117 memcpy(buf, bh->b_data + offset, segment); in romfs_blk_read()
120 buflen -= segment; in romfs_blk_read()
131 unsigned long pos, size_t limit) in romfs_blk_strnlen() argument
140 while (limit > 0) { in romfs_blk_strnlen()
141 offset = pos & (ROMBSIZE - 1); in romfs_blk_strnlen()
142 segment = min_t(size_t, limit, ROMBSIZE - offset); in romfs_blk_strnlen()
145 return -EIO; in romfs_blk_strnlen()
146 buf = bh->b_data + offset; in romfs_blk_strnlen()
150 return n + (p - buf); in romfs_blk_strnlen()
151 limit -= segment; in romfs_blk_strnlen()
161 * - return 1 if matched, 0 if differ, -ve if error
173 offset = pos & (ROMBSIZE - 1); in romfs_blk_strcmp()
174 segment = min_t(size_t, size, ROMBSIZE - offset); in romfs_blk_strcmp()
177 return -EIO; in romfs_blk_strcmp()
178 matched = (memcmp(bh->b_data + offset, str, segment) == 0); in romfs_blk_strcmp()
180 size -= segment; in romfs_blk_strcmp()
184 if (!bh->b_data[offset + segment]) in romfs_blk_strcmp()
197 BUG_ON((pos & (ROMBSIZE - 1)) != 0); in romfs_blk_strcmp()
200 return -EIO; in romfs_blk_strcmp()
201 matched = !bh->b_data[0]; in romfs_blk_strcmp()
217 size_t limit; in romfs_dev_read() local
219 limit = romfs_maxsize(sb); in romfs_dev_read()
220 if (pos >= limit || buflen > limit - pos) in romfs_dev_read()
221 return -EIO; in romfs_dev_read()
224 if (sb->s_mtd) in romfs_dev_read()
228 if (sb->s_bdev) in romfs_dev_read()
231 return -EIO; in romfs_dev_read()
240 size_t limit; in romfs_dev_strnlen() local
242 limit = romfs_maxsize(sb); in romfs_dev_strnlen()
243 if (pos >= limit) in romfs_dev_strnlen()
244 return -EIO; in romfs_dev_strnlen()
245 if (maxlen > limit - pos) in romfs_dev_strnlen()
246 maxlen = limit - pos; in romfs_dev_strnlen()
249 if (sb->s_mtd) in romfs_dev_strnlen()
253 if (sb->s_bdev) in romfs_dev_strnlen()
256 return -EIO; in romfs_dev_strnlen()
261 * - the string to be compared to, str, may not be NUL-terminated; instead the
263 * - return 1 if matched, 0 if differ, -ve if error
268 size_t limit; in romfs_dev_strcmp() local
270 limit = romfs_maxsize(sb); in romfs_dev_strcmp()
271 if (pos >= limit) in romfs_dev_strcmp()
272 return -EIO; in romfs_dev_strcmp()
274 return -ENAMETOOLONG; in romfs_dev_strcmp()
275 if (size + 1 > limit - pos) in romfs_dev_strcmp()
276 return -EIO; in romfs_dev_strcmp()
279 if (sb->s_mtd) in romfs_dev_strcmp()
283 if (sb->s_bdev) in romfs_dev_strcmp()
286 return -EIO; in romfs_dev_strcmp()