aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/xattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/xattr.c')
-rw-r--r--fs/jffs2/xattr.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 008f91b1c171..2255f1367bd5 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -304,8 +304,8 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
304static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 304static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
305{ 305{
306 /* must be called under down_write(xattr_sem) */ 306 /* must be called under down_write(xattr_sem) */
307 struct jffs2_raw_xattr rx;
308 struct jffs2_raw_node_ref *raw; 307 struct jffs2_raw_node_ref *raw;
308 struct jffs2_raw_xattr rx;
309 struct kvec vecs[2]; 309 struct kvec vecs[2];
310 uint32_t length; 310 uint32_t length;
311 int rc, totlen; 311 int rc, totlen;
@@ -319,11 +319,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
319 vecs[1].iov_len = xd->name_len + 1 + xd->value_len; 319 vecs[1].iov_len = xd->name_len + 1 + xd->value_len;
320 totlen = vecs[0].iov_len + vecs[1].iov_len; 320 totlen = vecs[0].iov_len + vecs[1].iov_len;
321 321
322 raw = jffs2_alloc_raw_node_ref();
323 if (!raw)
324 return -ENOMEM;
325 raw->flash_offset = phys_ofs;
326
327 /* Setup raw-xattr */ 322 /* Setup raw-xattr */
328 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 323 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
329 rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR); 324 rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR);
@@ -343,19 +338,14 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
343 JFFS2_WARNING("jffs2_flash_writev()=%d, req=%u, wrote=%u, at %#08x\n", 338 JFFS2_WARNING("jffs2_flash_writev()=%d, req=%u, wrote=%u, at %#08x\n",
344 rc, totlen, length, phys_ofs); 339 rc, totlen, length, phys_ofs);
345 rc = rc ? rc : -EIO; 340 rc = rc ? rc : -EIO;
346 if (length) { 341 if (length)
347 raw->flash_offset |= REF_OBSOLETE; 342 jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, PAD(totlen), NULL);
348 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL); 343
349 jffs2_mark_node_obsolete(c, raw);
350 } else {
351 jffs2_free_raw_node_ref(raw);
352 }
353 return rc; 344 return rc;
354 } 345 }
355 346
356 /* success */ 347 /* success */
357 raw->flash_offset |= REF_PRISTINE; 348 raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(totlen), NULL);
358 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
359 /* FIXME */ raw->next_in_ino = (void *)xd; 349 /* FIXME */ raw->next_in_ino = (void *)xd;
360 350
361 if (xd->node) 351 if (xd->node)
@@ -563,11 +553,6 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
563 uint32_t phys_ofs = write_ofs(c); 553 uint32_t phys_ofs = write_ofs(c);
564 int ret; 554 int ret;
565 555
566 raw = jffs2_alloc_raw_node_ref();
567 if (!raw)
568 return -ENOMEM;
569 raw->flash_offset = phys_ofs;
570
571 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 556 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
572 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); 557 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
573 rr.totlen = cpu_to_je32(PAD(sizeof(rr))); 558 rr.totlen = cpu_to_je32(PAD(sizeof(rr)));
@@ -582,18 +567,13 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
582 JFFS2_WARNING("jffs2_flash_write() returned %d, request=%u, retlen=%u, at %#08x\n", 567 JFFS2_WARNING("jffs2_flash_write() returned %d, request=%u, retlen=%u, at %#08x\n",
583 ret, sizeof(rr), length, phys_ofs); 568 ret, sizeof(rr), length, phys_ofs);
584 ret = ret ? ret : -EIO; 569 ret = ret ? ret : -EIO;
585 if (length) { 570 if (length)
586 raw->flash_offset |= REF_OBSOLETE; 571 jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, PAD(sizeof(rr)), NULL);
587 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL); 572
588 jffs2_mark_node_obsolete(c, raw);
589 } else {
590 jffs2_free_raw_node_ref(raw);
591 }
592 return ret; 573 return ret;
593 } 574 }
594 raw->flash_offset |= REF_PRISTINE;
595 575
596 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL); 576 raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), NULL);
597 /* FIXME */ raw->next_in_ino = (void *)ref; 577 /* FIXME */ raw->next_in_ino = (void *)ref;
598 if (ref->node) 578 if (ref->node)
599 delete_xattr_ref_node(c, ref); 579 delete_xattr_ref_node(c, ref);