|
@@ -115,7 +115,7 @@ int ubifs_leb_read(const struct ubifs_info *c, int lnum, void *buf, int offs,
|
|
}
|
|
}
|
|
|
|
|
|
int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
|
|
int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
|
|
- int len, int dtype)
|
|
|
|
|
|
+ int len)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
|
|
|
|
@@ -123,9 +123,9 @@ int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
|
|
if (c->ro_error)
|
|
if (c->ro_error)
|
|
return -EROFS;
|
|
return -EROFS;
|
|
if (!dbg_is_tst_rcvry(c))
|
|
if (!dbg_is_tst_rcvry(c))
|
|
- err = ubi_leb_write(c->ubi, lnum, buf, offs, len, dtype);
|
|
|
|
|
|
+ err = ubi_leb_write(c->ubi, lnum, buf, offs, len);
|
|
else
|
|
else
|
|
- err = dbg_leb_write(c, lnum, buf, offs, len, dtype);
|
|
|
|
|
|
+ err = dbg_leb_write(c, lnum, buf, offs, len);
|
|
if (err) {
|
|
if (err) {
|
|
ubifs_err("writing %d bytes to LEB %d:%d failed, error %d",
|
|
ubifs_err("writing %d bytes to LEB %d:%d failed, error %d",
|
|
len, lnum, offs, err);
|
|
len, lnum, offs, err);
|
|
@@ -135,8 +135,7 @@ int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
-int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len,
|
|
|
|
- int dtype)
|
|
|
|
|
|
+int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
|
|
|
|
@@ -144,9 +143,9 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len,
|
|
if (c->ro_error)
|
|
if (c->ro_error)
|
|
return -EROFS;
|
|
return -EROFS;
|
|
if (!dbg_is_tst_rcvry(c))
|
|
if (!dbg_is_tst_rcvry(c))
|
|
- err = ubi_leb_change(c->ubi, lnum, buf, len, dtype);
|
|
|
|
|
|
+ err = ubi_leb_change(c->ubi, lnum, buf, len);
|
|
else
|
|
else
|
|
- err = dbg_leb_change(c, lnum, buf, len, dtype);
|
|
|
|
|
|
+ err = dbg_leb_change(c, lnum, buf, len);
|
|
if (err) {
|
|
if (err) {
|
|
ubifs_err("changing %d bytes in LEB %d failed, error %d",
|
|
ubifs_err("changing %d bytes in LEB %d failed, error %d",
|
|
len, lnum, err);
|
|
len, lnum, err);
|
|
@@ -175,7 +174,7 @@ int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
-int ubifs_leb_map(struct ubifs_info *c, int lnum, int dtype)
|
|
|
|
|
|
+int ubifs_leb_map(struct ubifs_info *c, int lnum)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
|
|
|
|
@@ -183,9 +182,9 @@ int ubifs_leb_map(struct ubifs_info *c, int lnum, int dtype)
|
|
if (c->ro_error)
|
|
if (c->ro_error)
|
|
return -EROFS;
|
|
return -EROFS;
|
|
if (!dbg_is_tst_rcvry(c))
|
|
if (!dbg_is_tst_rcvry(c))
|
|
- err = ubi_leb_map(c->ubi, lnum, dtype);
|
|
|
|
|
|
+ err = ubi_leb_map(c->ubi, lnum);
|
|
else
|
|
else
|
|
- err = dbg_leb_map(c, lnum, dtype);
|
|
|
|
|
|
+ err = dbg_leb_map(c, lnum);
|
|
if (err) {
|
|
if (err) {
|
|
ubifs_err("mapping LEB %d failed, error %d", lnum, err);
|
|
ubifs_err("mapping LEB %d failed, error %d", lnum, err);
|
|
ubifs_ro_mode(c, err);
|
|
ubifs_ro_mode(c, err);
|
|
@@ -523,8 +522,7 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf)
|
|
dirt = sync_len - wbuf->used;
|
|
dirt = sync_len - wbuf->used;
|
|
if (dirt)
|
|
if (dirt)
|
|
ubifs_pad(c, wbuf->buf + wbuf->used, dirt);
|
|
ubifs_pad(c, wbuf->buf + wbuf->used, dirt);
|
|
- err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, sync_len,
|
|
|
|
- wbuf->dtype);
|
|
|
|
|
|
+ err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs, sync_len);
|
|
if (err)
|
|
if (err)
|
|
return err;
|
|
return err;
|
|
|
|
|
|
@@ -562,14 +560,12 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf)
|
|
* @wbuf: write-buffer
|
|
* @wbuf: write-buffer
|
|
* @lnum: logical eraseblock number to seek to
|
|
* @lnum: logical eraseblock number to seek to
|
|
* @offs: logical eraseblock offset to seek to
|
|
* @offs: logical eraseblock offset to seek to
|
|
- * @dtype: data type
|
|
|
|
*
|
|
*
|
|
* This function targets the write-buffer to logical eraseblock @lnum:@offs.
|
|
* This function targets the write-buffer to logical eraseblock @lnum:@offs.
|
|
* The write-buffer has to be empty. Returns zero in case of success and a
|
|
* The write-buffer has to be empty. Returns zero in case of success and a
|
|
* negative error code in case of failure.
|
|
* negative error code in case of failure.
|
|
*/
|
|
*/
|
|
-int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs,
|
|
|
|
- int dtype)
|
|
|
|
|
|
+int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs)
|
|
{
|
|
{
|
|
const struct ubifs_info *c = wbuf->c;
|
|
const struct ubifs_info *c = wbuf->c;
|
|
|
|
|
|
@@ -592,7 +588,6 @@ int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs,
|
|
wbuf->avail = wbuf->size;
|
|
wbuf->avail = wbuf->size;
|
|
wbuf->used = 0;
|
|
wbuf->used = 0;
|
|
spin_unlock(&wbuf->lock);
|
|
spin_unlock(&wbuf->lock);
|
|
- wbuf->dtype = dtype;
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -719,8 +714,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
|
|
dbg_io("flush jhead %s wbuf to LEB %d:%d",
|
|
dbg_io("flush jhead %s wbuf to LEB %d:%d",
|
|
dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
|
|
dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
|
|
err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf,
|
|
err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf,
|
|
- wbuf->offs, wbuf->size,
|
|
|
|
- wbuf->dtype);
|
|
|
|
|
|
+ wbuf->offs, wbuf->size);
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
@@ -756,7 +750,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
|
|
dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
|
|
dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs);
|
|
memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail);
|
|
memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail);
|
|
err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs,
|
|
err = ubifs_leb_write(c, wbuf->lnum, wbuf->buf, wbuf->offs,
|
|
- wbuf->size, wbuf->dtype);
|
|
|
|
|
|
+ wbuf->size);
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
@@ -775,7 +769,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
|
|
dbg_io("write %d bytes to LEB %d:%d",
|
|
dbg_io("write %d bytes to LEB %d:%d",
|
|
wbuf->size, wbuf->lnum, wbuf->offs);
|
|
wbuf->size, wbuf->lnum, wbuf->offs);
|
|
err = ubifs_leb_write(c, wbuf->lnum, buf, wbuf->offs,
|
|
err = ubifs_leb_write(c, wbuf->lnum, buf, wbuf->offs,
|
|
- wbuf->size, wbuf->dtype);
|
|
|
|
|
|
+ wbuf->size);
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
@@ -797,7 +791,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
|
|
dbg_io("write %d bytes to LEB %d:%d", n, wbuf->lnum,
|
|
dbg_io("write %d bytes to LEB %d:%d", n, wbuf->lnum,
|
|
wbuf->offs);
|
|
wbuf->offs);
|
|
err = ubifs_leb_write(c, wbuf->lnum, buf + written,
|
|
err = ubifs_leb_write(c, wbuf->lnum, buf + written,
|
|
- wbuf->offs, n, wbuf->dtype);
|
|
|
|
|
|
+ wbuf->offs, n);
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
wbuf->offs += n;
|
|
wbuf->offs += n;
|
|
@@ -854,7 +848,6 @@ out:
|
|
* @len: node length
|
|
* @len: node length
|
|
* @lnum: logical eraseblock number
|
|
* @lnum: logical eraseblock number
|
|
* @offs: offset within the logical eraseblock
|
|
* @offs: offset within the logical eraseblock
|
|
- * @dtype: node life-time hint (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
|
|
|
|
*
|
|
*
|
|
* This function automatically fills node magic number, assigns sequence
|
|
* This function automatically fills node magic number, assigns sequence
|
|
* number, and calculates node CRC checksum. The length of the @buf buffer has
|
|
* number, and calculates node CRC checksum. The length of the @buf buffer has
|
|
@@ -863,7 +856,7 @@ out:
|
|
* success and a negative error code in case of failure.
|
|
* success and a negative error code in case of failure.
|
|
*/
|
|
*/
|
|
int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
|
|
int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
|
|
- int offs, int dtype)
|
|
|
|
|
|
+ int offs)
|
|
{
|
|
{
|
|
int err, buf_len = ALIGN(len, c->min_io_size);
|
|
int err, buf_len = ALIGN(len, c->min_io_size);
|
|
|
|
|
|
@@ -879,7 +872,7 @@ int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
|
|
return -EROFS;
|
|
return -EROFS;
|
|
|
|
|
|
ubifs_prepare_node(c, buf, len, 1);
|
|
ubifs_prepare_node(c, buf, len, 1);
|
|
- err = ubifs_leb_write(c, lnum, buf, offs, buf_len, dtype);
|
|
|
|
|
|
+ err = ubifs_leb_write(c, lnum, buf, offs, buf_len);
|
|
if (err)
|
|
if (err)
|
|
ubifs_dump_node(c, buf);
|
|
ubifs_dump_node(c, buf);
|
|
|
|
|
|
@@ -1056,7 +1049,6 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
|
|
*/
|
|
*/
|
|
size = c->max_write_size - (c->leb_start % c->max_write_size);
|
|
size = c->max_write_size - (c->leb_start % c->max_write_size);
|
|
wbuf->avail = wbuf->size = size;
|
|
wbuf->avail = wbuf->size = size;
|
|
- wbuf->dtype = UBI_UNKNOWN;
|
|
|
|
wbuf->sync_callback = NULL;
|
|
wbuf->sync_callback = NULL;
|
|
mutex_init(&wbuf->io_mutex);
|
|
mutex_init(&wbuf->io_mutex);
|
|
spin_lock_init(&wbuf->lock);
|
|
spin_lock_init(&wbuf->lock);
|