Lines Matching +full:offset +full:- +full:x

2  * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright © 2001-2007 Red Hat, Inc.
36 return -ENOMEM; in jffs2_read_dnode()
38 ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri); in jffs2_read_dnode()
41 pr_warn("Error reading node from 0x%08x: %d\n", in jffs2_read_dnode()
42 ref_offset(fd->raw), ret); in jffs2_read_dnode()
47 pr_warn("Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", in jffs2_read_dnode()
48 ref_offset(fd->raw), sizeof(*ri), readlen); in jffs2_read_dnode()
49 return -EIO; in jffs2_read_dnode()
51 crc = crc32(0, ri, sizeof(*ri)-8); in jffs2_read_dnode()
53 …jffs2_dbg(1, "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset in jffs2_read_dnode()
54 ref_offset(fd->raw), je32_to_cpu(ri->node_crc), in jffs2_read_dnode()
55 crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), in jffs2_read_dnode()
56 je32_to_cpu(ri->offset), buf); in jffs2_read_dnode()
57 if (crc != je32_to_cpu(ri->node_crc)) { in jffs2_read_dnode()
58 pr_warn("Node CRC %08x != calculated CRC %08x for node at %08x\n", in jffs2_read_dnode()
59 je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); in jffs2_read_dnode()
60 ret = -EIO; in jffs2_read_dnode()
65 if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && in jffs2_read_dnode()
66 je32_to_cpu(ri->csize)) { in jffs2_read_dnode()
67 ri->dsize = ri->csize; in jffs2_read_dnode()
68 ri->csize = cpu_to_je32(0); in jffs2_read_dnode()
71 D1(if(ofs + len > je32_to_cpu(ri->dsize)) { in jffs2_read_dnode()
72 pr_warn("jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n", in jffs2_read_dnode()
73 len, ofs, je32_to_cpu(ri->dsize)); in jffs2_read_dnode()
74 ret = -EINVAL; in jffs2_read_dnode()
79 if (ri->compr == JFFS2_COMPR_ZERO) { in jffs2_read_dnode()
85 Reading whole node and it's uncompressed - read directly to buffer provided, check CRC. in jffs2_read_dnode()
86 …Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer pr… in jffs2_read_dnode()
87 Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy in jffs2_read_dnode()
88 …Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomp… in jffs2_read_dnode()
90 if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) { in jffs2_read_dnode()
93 readbuf = kmalloc(je32_to_cpu(ri->csize), GFP_KERNEL); in jffs2_read_dnode()
95 ret = -ENOMEM; in jffs2_read_dnode()
99 if (ri->compr != JFFS2_COMPR_NONE) { in jffs2_read_dnode()
100 if (len < je32_to_cpu(ri->dsize)) { in jffs2_read_dnode()
101 decomprbuf = kmalloc(je32_to_cpu(ri->dsize), GFP_KERNEL); in jffs2_read_dnode()
103 ret = -ENOMEM; in jffs2_read_dnode()
113 jffs2_dbg(2, "Read %d bytes to %p\n", je32_to_cpu(ri->csize), in jffs2_read_dnode()
115 ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), in jffs2_read_dnode()
116 je32_to_cpu(ri->csize), &readlen, readbuf); in jffs2_read_dnode()
118 if (!ret && readlen != je32_to_cpu(ri->csize)) in jffs2_read_dnode()
119 ret = -EIO; in jffs2_read_dnode()
123 crc = crc32(0, readbuf, je32_to_cpu(ri->csize)); in jffs2_read_dnode()
124 if (crc != je32_to_cpu(ri->data_crc)) { in jffs2_read_dnode()
125 pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n", in jffs2_read_dnode()
126 je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw)); in jffs2_read_dnode()
127 ret = -EIO; in jffs2_read_dnode()
130 jffs2_dbg(2, "Data CRC matches calculated CRC %08x\n", crc); in jffs2_read_dnode()
131 if (ri->compr != JFFS2_COMPR_NONE) { in jffs2_read_dnode()
133 je32_to_cpu(ri->csize), readbuf, in jffs2_read_dnode()
134 je32_to_cpu(ri->dsize), decomprbuf); in jffs2_read_dnode()
135 …et = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri- in jffs2_read_dnode()
142 if (len < je32_to_cpu(ri->dsize)) { in jffs2_read_dnode()
158 unsigned char *buf, uint32_t offset, uint32_t len) in jffs2_read_inode_range() argument
160 uint32_t end = offset + len; in jffs2_read_inode_range()
164 jffs2_dbg(1, "%s(): ino #%u, range 0x%08x-0x%08x\n", in jffs2_read_inode_range()
165 __func__, f->inocache->ino, offset, offset + len); in jffs2_read_inode_range()
167 frag = jffs2_lookup_node_frag(&f->fragtree, offset); in jffs2_read_inode_range()
174 while(offset < end) { in jffs2_read_inode_range()
175 jffs2_dbg(2, "%s(): offset %d, end %d\n", in jffs2_read_inode_range()
176 __func__, offset, end); in jffs2_read_inode_range()
177 if (unlikely(!frag || frag->ofs > offset || in jffs2_read_inode_range()
178 frag->ofs + frag->size <= offset)) { in jffs2_read_inode_range()
179 uint32_t holesize = end - offset; in jffs2_read_inode_range()
180 if (frag && frag->ofs > offset) { in jffs2_read_inode_range()
181 jffs2_dbg(1, "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", in jffs2_read_inode_range()
182 f->inocache->ino, frag->ofs, offset); in jffs2_read_inode_range()
183 holesize = min(holesize, frag->ofs - offset); in jffs2_read_inode_range()
185 jffs2_dbg(1, "Filling non-frag hole from %d-%d\n", in jffs2_read_inode_range()
186 offset, offset + holesize); in jffs2_read_inode_range()
189 offset += holesize; in jffs2_read_inode_range()
191 } else if (unlikely(!frag->node)) { in jffs2_read_inode_range()
192 uint32_t holeend = min(end, frag->ofs + frag->size); in jffs2_read_inode_range()
193 jffs2_dbg(1, "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", in jffs2_read_inode_range()
194 offset, holeend, frag->ofs, in jffs2_read_inode_range()
195 frag->ofs + frag->size); in jffs2_read_inode_range()
196 memset(buf, 0, holeend - offset); in jffs2_read_inode_range()
197 buf += holeend - offset; in jffs2_read_inode_range()
198 offset = holeend; in jffs2_read_inode_range()
203 uint32_t fragofs; /* offset within the frag to start reading */ in jffs2_read_inode_range()
205 fragofs = offset - frag->ofs; in jffs2_read_inode_range()
206 readlen = min(frag->size - fragofs, end - offset); in jffs2_read_inode_range()
207 jffs2_dbg(1, "Reading %d-%d from node at 0x%08x (%d)\n", in jffs2_read_inode_range()
208 frag->ofs+fragofs, in jffs2_read_inode_range()
209 frag->ofs + fragofs+readlen, in jffs2_read_inode_range()
210 ref_offset(frag->node->raw), in jffs2_read_inode_range()
211 ref_flags(frag->node->raw)); in jffs2_read_inode_range()
212 ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); in jffs2_read_inode_range()
221 offset += readlen; in jffs2_read_inode_range()