writev.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * JFFS2 -- Journalling Flash File System, Version 2.
  3. *
  4. * Copyright © 2001-2007 Red Hat, Inc.
  5. *
  6. * Created by David Woodhouse <dwmw2@infradead.org>
  7. *
  8. * For licensing information, see the file 'LICENCE' in this directory.
  9. *
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/mtd/mtd.h>
  13. #include "nodelist.h"
  14. int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
  15. unsigned long count, loff_t to, size_t *retlen)
  16. {
  17. if (!jffs2_is_writebuffered(c)) {
  18. if (jffs2_sum_active()) {
  19. int res;
  20. res = jffs2_sum_add_kvec(c, vecs, count, (uint32_t) to);
  21. if (res) {
  22. return res;
  23. }
  24. }
  25. }
  26. return mtd_writev(c->mtd, vecs, count, to, retlen);
  27. }
  28. int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
  29. size_t *retlen, const u_char *buf)
  30. {
  31. int ret;
  32. ret = mtd_write(c->mtd, ofs, len, retlen, buf);
  33. if (jffs2_sum_active()) {
  34. struct kvec vecs[1];
  35. int res;
  36. vecs[0].iov_base = (unsigned char *) buf;
  37. vecs[0].iov_len = len;
  38. res = jffs2_sum_add_kvec(c, vecs, 1, (uint32_t) ofs);
  39. if (res) {
  40. return res;
  41. }
  42. }
  43. return ret;
  44. }