Lines Matching refs:buf
48 * @buf: buffer to clean
54 static int is_empty(void *buf, int len)
56 uint8_t *p = buf;
69 * @buf: buffer to search in
72 * This function returns offset of the first non-0xff byte in @buf or %-1 if
75 static int first_non_ff(void *buf, int len)
77 uint8_t *p = buf;
109 void *sbuf, *buf;
123 buf = sbuf;
126 struct ubifs_ch *ch = buf;
132 buf += sz;
140 buf -= sz;
142 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
146 buf -= sz;
148 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
159 struct ubifs_ch *ch = buf;
165 *mst = buf;
167 buf += sz;
173 if (!is_empty(buf, min_t(int, len, sz))) {
174 *cor = buf;
178 buf += sz;
183 if (!is_empty(buf, len)) {
418 * @buf: buffer to check
422 * is in @buf, otherwise %0 is returned. The determination is made by checking
426 static int is_last_write(const struct ubifs_info *c, void *buf, int offs)
437 p = buf + empty_offs - offs;
444 * @buf: buffer to clean
450 * sets empty space to all 0xff. @buf, @offs and @len are updated to the next
453 static void clean_buf(const struct ubifs_info *c, void **buf, int lnum, int *offs, int *len)
462 ubifs_pad(c, *buf, pad_len);
464 *buf += pad_len;
466 memset(*buf, 0xff, c->leb_size - empty_offs);
472 * @buf: buffer to check
474 * @lnum: LEB number of the LEB from which @buf was read
475 * @offs: offset from which @buf was read
481 static int no_more_nodes(const struct ubifs_info *c, void *buf, int len, int lnum, int offs)
483 struct ubifs_ch *ch = buf;
488 if (is_empty(buf + skip, len - skip)) {
495 if (ubifs_check_node(c, buf, len, lnum, offs, 1, 0) != -EUCLEAN) {
502 if (is_empty(buf + skip, len - skip)) {
553 err = ubifs_leb_read(c, lnum, sleb->buf, 0, start, 1);
562 void *buf = sleb->buf + len - pad_len;
564 ubifs_pad(c, buf, pad_len);
567 err = ubifs_leb_change(c, lnum, sleb->buf, len);
646 void *buf = sbuf + offs;
665 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
668 struct ubifs_ch *ch = buf;
671 err = ubifs_add_snod(c, sleb, buf, offs);
677 buf += node_len;
682 buf += ret;
686 if (ubifs_check_node(c, buf, len, lnum, offs, 1, 1) == -EUCLEAN &&
687 !no_more_nodes(c, buf, len, lnum, offs)) {
689 struct ubifs_ch *ch = buf;
699 memset(buf + skip, 0xff, len - skip);
705 if (!is_empty(buf, len) && !is_last_write(c, buf, offs)) {
713 memset(buf, 0xff, len);
728 if (!is_last_write(c, buf, offs)) {
732 if (!no_more_nodes(c, buf, len, lnum, offs)) {
735 } else if (!is_empty(buf, len)) {
736 if (!is_last_write(c, buf, offs)) {
737 int corruption = first_non_ff(buf, len);
746 buf += corruption;
816 buf = sbuf + offs;
819 clean_buf(c, &buf, lnum, &offs, &len);
832 ubifs_scan_a_node(c, buf, len, lnum, offs, 0);
834 ubifs_scanned_corruption(c, lnum, offs, buf);
1041 void *buf = sbuf;
1050 err = ubifs_leb_read(c, lnum, buf, offs, len, 0);
1061 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, quiet);
1064 struct ubifs_ch *ch = buf;
1069 buf += node_len;
1077 buf += ret;
1093 ubifs_scanned_corruption(c, lnum, offs, buf);
1102 buf = c->sbuf + len - pad_len;
1103 ubifs_pad(c, buf, pad_len);