/* * read data from an romfs image on an MTD device
*/ staticint romfs_mtd_read(struct super_block *sb, unsignedlong pos, void *buf, size_t buflen)
{
size_t rlen; int ret;
/* * determine the length of a string in a romfs image on an MTD device
*/ static ssize_t romfs_mtd_strnlen(struct super_block *sb, unsignedlong pos, size_t maxlen)
{
ssize_t n = 0;
size_t segment;
u_char buf[16], *p;
size_t len; int ret;
/* scan the string up to 16 bytes at a time */ while (maxlen > 0) {
segment = min_t(size_t, maxlen, 16);
ret = ROMFS_MTD_READ(sb, pos, segment, &len, buf); if (ret < 0) return ret;
p = memchr(buf, 0, len); if (p) return n + (p - buf);
maxlen -= len;
pos += len;
n += len;
}
return n;
}
/* * compare a string to one in a romfs image on MTD * - return 1 if matched, 0 if differ, -ve if error
*/ staticint romfs_mtd_strcmp(struct super_block *sb, unsignedlong pos, constchar *str, size_t size)
{
u_char buf[17];
size_t len, segment; int ret;
/* scan the string up to 16 bytes at a time, and attempt to grab the
* trailing NUL whilst we're at it */
buf[0] = 0xff;
if (!terminated) { /* the terminating NUL must be on the first byte of the next
* block */
BUG_ON((pos & (ROMBSIZE - 1)) != 0);
bh = sb_bread(sb, pos >> ROMBSBITS); if (!bh) return -EIO;
matched = !bh->b_data[0];
brelse(bh); if (!matched) return 0;
}
return 1;
} #endif/* CONFIG_ROMFS_ON_BLOCK */
/* * read data from the romfs image
*/ int romfs_dev_read(struct super_block *sb, unsignedlong pos, void *buf, size_t buflen)
{
size_t limit;
/* * compare a string to one in romfs * - the string to be compared to, str, may not be NUL-terminated; instead the * string is of the specified size * - return 1 if matched, 0 if differ, -ve if error
*/ int romfs_dev_strcmp(struct super_block *sb, unsignedlong pos, constchar *str, size_t size)
{
size_t limit;
limit = romfs_maxsize(sb); if (pos >= limit) return -EIO; if (size > ROMFS_MAXFN) return -ENAMETOOLONG; if (size + 1 > limit - pos) return -EIO;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.