Lines Matching refs:offs

38  * have to make sure that the write-buffer offset (@wbuf->offs) becomes aligned
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);
99 len, lnum, offs, err);
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);
119 len, lnum, offs, err);
203 * @offs: offset within the logical eraseblock
227 int lnum, int offs, int quiet, int must_chk_crc)
233 ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0);
234 ubifs_assert(c, !(offs & 7) && offs < c->leb_size);
253 if (node_len + offs > c->leb_size)
284 ubifs_err(c, "bad node at LEB %d:%d", lnum, offs);
548 wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead));
550 ubifs_assert(c, wbuf->offs + wbuf->size <= c->leb_size);
555 if (c->leb_size - wbuf->offs >= c->max_write_size)
556 ubifs_assert(c, !((wbuf->offs + wbuf->size) % c->max_write_size));
569 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, sync_len);
574 wbuf->offs += sync_len;
576 * Now @wbuf->offs is not necessarily aligned to @c->max_write_size.
579 * Thus, if @wbuf->offs is not aligned to @c->max_write_size now, make
580 * sure that @wbuf->offs + @wbuf->size is aligned to
585 if (c->leb_size - wbuf->offs < c->max_write_size)
586 wbuf->size = c->leb_size - wbuf->offs;
587 else if (wbuf->offs & (c->max_write_size - 1))
588 wbuf->size = ALIGN(wbuf->offs, c->max_write_size) - wbuf->offs;
598 c->leb_size - wbuf->offs, dirt);
606 * @offs: logical eraseblock offset to seek to
608 * This function targets the write-buffer to logical eraseblock @lnum:@offs.
612 int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs)
616 dbg_io("LEB %d:%d, jhead %s", lnum, offs, dbg_jhead(wbuf->jhead));
618 ubifs_assert(c, offs >= 0 && offs <= c->leb_size);
619 ubifs_assert(c, offs % c->min_io_size == 0 && !(offs & 7));
625 wbuf->offs = offs;
626 if (c->leb_size - wbuf->offs < c->max_write_size)
627 wbuf->size = c->leb_size - wbuf->offs;
628 else if (wbuf->offs & (c->max_write_size - 1))
629 wbuf->size = ALIGN(wbuf->offs, c->max_write_size) - wbuf->offs;
726 dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs + wbuf->used);
728 ubifs_assert(c, wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0);
729 ubifs_assert(c, !(wbuf->offs & 7) && wbuf->offs <= c->leb_size);
737 if (c->leb_size - wbuf->offs >= c->max_write_size)
738 ubifs_assert(c, !((wbuf->offs + wbuf->size) % c->max_write_size));
740 if (c->leb_size - wbuf->offs - wbuf->used < aligned_len) {
763 dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
765 wbuf->offs, wbuf->size);
770 wbuf->offs += wbuf->size;
771 if (c->leb_size - wbuf->offs >= c->max_write_size)
774 wbuf->size = c->leb_size - wbuf->offs;
796 dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
798 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs,
803 wbuf->offs += wbuf->size;
807 } else if (wbuf->offs & (c->max_write_size - 1)) {
816 wbuf->size, wbuf->lnum, wbuf->offs);
817 err = ubifs_leb_write(c, wbuf->lnum, buf, wbuf->offs,
822 wbuf->offs += wbuf->size;
839 wbuf->offs);
845 wbuf->offs, m);
848 wbuf->offs += m;
866 err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, n);
869 wbuf->offs += n;
889 if (c->leb_size - wbuf->offs >= c->max_write_size)
892 wbuf->size = c->leb_size - wbuf->offs;
900 int free = c->leb_size - wbuf->offs - wbuf->used;
914 len, wbuf->lnum, wbuf->offs, err);
927 * @offs: offset within the logical eraseblock
937 int offs, int hmac_offs)
942 lnum, offs, dbg_ntype(((struct ubifs_ch *)buf)->node_type), len,
944 ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0);
945 ubifs_assert(c, offs % c->min_io_size == 0 && offs < c->leb_size);
956 err = ubifs_leb_write(c, lnum, buf, offs, buf_len);
969 * @offs: offset within the logical eraseblock
978 int offs)
980 return ubifs_write_node_hmac(c, buf, len, lnum, offs, -1);
990 * @offs: offset within the logical eraseblock
999 int lnum, int offs)
1005 dbg_io("LEB %d:%d, %s, length %d, jhead %s", lnum, offs,
1007 ubifs_assert(c, wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0);
1008 ubifs_assert(c, !(offs & 7) && offs < c->leb_size);
1012 overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs);
1016 return ubifs_read_node(c, buf, type, len, lnum, offs);
1020 rlen = wbuf->offs - 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);
1056 ubifs_err(c, "bad node at LEB %d:%d", lnum, offs);
1069 * @offs: offset within the logical eraseblock
1076 int lnum, int offs)
1081 dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len);
1082 ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0);
1083 ubifs_assert(c, len >= UBIFS_CH_SZ && offs + len <= c->leb_size);
1084 ubifs_assert(c, !(offs & 7) && offs < c->leb_size);
1087 err = ubifs_leb_read(c, lnum, buf, offs, len, 0);
1097 err = ubifs_check_node(c, buf, len, lnum, offs, 0, 0);
1113 offs, ubi_is_mapped(c->ubi, lnum));
1146 wbuf->lnum = wbuf->offs = -1;