Lines Matching defs:buf
87 int ubifs_leb_read(const struct ubifs_info *c, int lnum, void *buf, int offs,
92 err = ubi_read(c->ubi, lnum, buf, offs, len);
105 int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
114 err = ubi_leb_write(c->ubi, lnum, buf, offs, len);
116 err = dbg_leb_write(c, lnum, buf, offs, len);
126 int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
134 err = ubi_leb_change(c->ubi, lnum, buf, len);
136 err = dbg_leb_change(c, lnum, buf, len);
200 * @buf: node to check
226 int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
231 const struct ubifs_ch *ch = buf;
267 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8);
285 ubifs_dump_node(c, buf, len);
294 * @buf: buffer to put padding to
307 void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
314 struct ubifs_ch *ch = buf;
315 struct ubifs_pad_node *pad_node = buf;
325 crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8);
327 memset(buf + UBIFS_PAD_NODE_SZ, 0, pad);
330 memset(buf, UBIFS_PADDING_BYTE, pad);
528 * This function synchronizes write-buffer @buf and returns zero in case of
568 ubifs_pad(c, wbuf->buf + wbuf->used, dirt);
569 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, sync_len);
706 * @buf: node to write
719 int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
725 dbg_ntype(((struct ubifs_ch *)buf)->node_type),
755 memcpy(wbuf->buf + wbuf->used, buf, len);
758 ubifs_pad(c, wbuf->buf + wbuf->used + len, aligned_len - len);
764 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf,
797 memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail);
798 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs,
817 err = ubifs_leb_write(c, wbuf->lnum, buf, wbuf->offs,
844 err = ubifs_leb_write(c, wbuf->lnum, buf + written,
855 * The non-written len of buf may be less than 'n' because
857 * min(len, n) bytes from buf.
860 memcpy(wbuf->buf, buf + written, min(len, n));
863 ubifs_pad(c, wbuf->buf + len, n - len);
866 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, n);
882 memcpy(wbuf->buf, buf + written, len);
885 ubifs_pad(c, wbuf->buf + len, aligned_len - len);
915 ubifs_dump_node(c, buf, written + len);
924 * @buf: the node to write
931 * number, and calculates node CRC checksum. The length of the @buf buffer has
936 int ubifs_write_node_hmac(struct ubifs_info *c, void *buf, int len, int lnum,
942 lnum, offs, dbg_ntype(((struct ubifs_ch *)buf)->node_type), len,
952 err = ubifs_prepare_node_hmac(c, buf, len, hmac_offs, 1);
956 err = ubifs_leb_write(c, lnum, buf, offs, buf_len);
958 ubifs_dump_node(c, buf, len);
966 * @buf: the node to write
972 * number, and calculates node CRC checksum. The length of the @buf buffer has
977 int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
980 return ubifs_write_node_hmac(c, buf, len, lnum, offs, -1);
986 * @buf: buffer to read to
993 * in @buf. If the node partially or fully sits in the write-buffer, this
998 int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
1003 struct ubifs_ch *ch = buf;
1016 return ubifs_read_node(c, buf, type, len, lnum, offs);
1025 memcpy(buf + rlen, wbuf->buf + offs + rlen - wbuf->offs, len - rlen);
1030 err = ubifs_leb_read(c, lnum, buf, offs, rlen, 0);
1041 err = ubifs_check_node(c, buf, len, lnum, offs, 0, 0);
1057 ubifs_dump_node(c, buf, len);
1065 * @buf: buffer to read to
1072 * stores in @buf. Returns zero in case of success, %-EUCLEAN if CRC mismatched
1075 int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
1079 struct ubifs_ch *ch = buf;
1087 err = ubifs_leb_read(c, lnum, buf, offs, len, 0);
1097 err = ubifs_check_node(c, buf, len, lnum, offs, 0, 0);
1115 ubifs_dump_node(c, buf, len);
1133 wbuf->buf = kmalloc(c->max_write_size, GFP_KERNEL);
1134 if (!wbuf->buf)
1140 kfree(wbuf->buf);
1141 wbuf->buf = NULL;
1175 if (!wbuf->buf)