Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * JFFS2 -- Journalling Flash File System, Version 2.
0003  *
0004  * Copyright © 2001-2007 Red Hat, Inc.
0005  *
0006  * Created by David Woodhouse <dwmw2@infradead.org>
0007  *
0008  * For licensing information, see the file 'LICENCE' in this directory.
0009  *
0010  */
0011 
0012 #include <linux/kernel.h>
0013 #include <linux/mtd/mtd.h>
0014 #include "nodelist.h"
0015 
0016 int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
0017                   unsigned long count, loff_t to, size_t *retlen)
0018 {
0019     if (!jffs2_is_writebuffered(c)) {
0020         if (jffs2_sum_active()) {
0021             int res;
0022             res = jffs2_sum_add_kvec(c, vecs, count, (uint32_t) to);
0023             if (res) {
0024                 return res;
0025             }
0026         }
0027     }
0028 
0029     return mtd_writev(c->mtd, vecs, count, to, retlen);
0030 }
0031 
0032 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
0033             size_t *retlen, const u_char *buf)
0034 {
0035     int ret;
0036     ret = mtd_write(c->mtd, ofs, len, retlen, buf);
0037 
0038     if (jffs2_sum_active()) {
0039         struct kvec vecs[1];
0040         int res;
0041 
0042         vecs[0].iov_base = (unsigned char *) buf;
0043         vecs[0].iov_len = len;
0044 
0045         res = jffs2_sum_add_kvec(c, vecs, 1, (uint32_t) ofs);
0046         if (res) {
0047             return res;
0048         }
0049     }
0050     return ret;
0051 }