aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/if_fddi.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-24 11:37:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-24 11:37:29 -0400
commite270b51df657011983241ec61a1fc7de186e16cd (patch)
tree3397be4cbf31676ca6ebb187903e8cfc2218f223 /include/linux/if_fddi.h
parent8fa82790fb9dfe57aeafc8de6b6a5c1df63efa06 (diff)
parent227739bf4c110bbd02d0c0f13b272c32de406e4c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6: (23 commits) sparc: sunzilog uart order [SPARC64]: Detect trap frames in stack backtraces. [SPARC64]: %l6 trap return handling no longer necessary. [SPARC64]: Use trap type stored in pt_regs to handle syscall restart. [SPARC64]: Store magic cookie and trap type in pt_regs. [SPARC64]: PROM debug console can be CON_ANYTIME. sparc64: cleanup after SunOS/Solaris binary emulation removal sparc: cleanup after SunOS binary emulation removal [SPARC64]: Add NUMA support. [SPARC64]: Allocate TSB node-local. [SPARC64]: NUMA device infrastructure. [SPARC64]: Kill pci_iommu_table_init() declaration. [SPARC64]: Once we have the boot cmdline, call parse_early_param() [SPARC64]: Remove unused asm-sparc64/numnodes.h [SPARC64]: Decrease SECTION_SIZE_BITS to 30. [SPARC64]: Initialize MDESC earlier and use lmb_alloc() [SPARC64]: Use lmb_alloc() for PROM device tree. [SPARC64]: Call real_setup_per_cpu_areas() earlier and use lmb_alloc(). [SPARC64]: Fully use LMB information in bootmem_init(). [SPARC64]: Start using LMB information in bootmem_init(). ...
Diffstat (limited to 'include/linux/if_fddi.h')
0 files changed, 0 insertions, 0 deletions
gi/litmus-rt-ext-res.git/commit/fs/jffs2/read.c?id=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2'>1da177e4c3f4
9c261b33a9c4
1da177e4c3f4
da320f055a88

1da177e4c3f4




182ec4eee397
1da177e4c3f4





da320f055a88

1da177e4c3f4



182ec4eee397
1da177e4c3f4






182ec4eee397

1da177e4c3f4
























9c261b33a9c4

1da177e4c3f4









da320f055a88

1da177e4c3f4


9c261b33a9c4
1da177e4c3f4
9c261b33a9c4


1da177e4c3f4

da320f055a88
1da177e4c3f4

























9c261b33a9c4

1da177e4c3f4




199bc9ff5ca5


1da177e4c3f4
9c261b33a9c4

199bc9ff5ca5

1da177e4c3f4
199bc9ff5ca5
9c261b33a9c4

1da177e4c3f4
1da177e4c3f4
9c261b33a9c4

1da177e4c3f4





9c261b33a9c4


1da177e4c3f4







182ec4eee397
1da177e4c3f4

9c261b33a9c4




1da177e4c3f4
9c261b33a9c4
1da177e4c3f4
9c261b33a9c4

1da177e4c3f4





9c261b33a9c4
1da177e4c3f4




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228


                                                     
                                       




                                                                       

   

                                           


























                                                                                          

                                                               



                                         

                                                                                  



                                          
                                                                                                                        

                                                                      
                                                
                                               

                                                                                  




                                                                         
                                                                       





                                                   

                                                                                                  



                              
 






                                                                                                  

                                                                                                                   
























                                                                                                                          

                                                                     









                                                                          

                                                                                  


                                    
                                                                    
                                            


                                                                               

                                                                                                                                                    
                                                                              

























                                                                               

                                                                    




                                                                           


                                                                        
                             

                                                         

                                                                 
                                                         
                                                         

                                                                                                                    
                                                                             
                         

                                                                          





                                                                            


                                                                                       







                                                                                       
 

                                                                          




                                                                                
                                                                                                                      
                                                         
                                  

                                                                





                                                        
                                                                    




                 
/*
 * JFFS2 -- Journalling Flash File System, Version 2.
 *
 * Copyright © 2001-2007 Red Hat, Inc.
 *
 * Created by David Woodhouse <dwmw2@infradead.org>
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/crc32.h>
#include <linux/pagemap.h>
#include <linux/mtd/mtd.h>
#include <linux/compiler.h>
#include "nodelist.h"
#include "compr.h"

int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
		     struct jffs2_full_dnode *fd, unsigned char *buf,
		     int ofs, int len)
{
	struct jffs2_raw_inode *ri;
	size_t readlen;
	uint32_t crc;
	unsigned char *decomprbuf = NULL;
	unsigned char *readbuf = NULL;
	int ret = 0;

	ri = jffs2_alloc_raw_inode();
	if (!ri)
		return -ENOMEM;

	ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri);
	if (ret) {
		jffs2_free_raw_inode(ri);
		pr_warn("Error reading node from 0x%08x: %d\n",
			ref_offset(fd->raw), ret);
		return ret;
	}
	if (readlen != sizeof(*ri)) {
		jffs2_free_raw_inode(ri);
		pr_warn("Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n",
			ref_offset(fd->raw), sizeof(*ri), readlen);
		return -EIO;
	}
	crc = crc32(0, ri, sizeof(*ri)-8);

	jffs2_dbg(1, "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n",
		  ref_offset(fd->raw), je32_to_cpu(ri->node_crc),
		  crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize),
		  je32_to_cpu(ri->offset), buf);
	if (crc != je32_to_cpu(ri->node_crc)) {
		pr_warn("Node CRC %08x != calculated CRC %08x for node at %08x\n",
			je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw));
		ret = -EIO;
		goto out_ri;
	}
	/* There was a bug where we wrote hole nodes out with csize/dsize
	   swapped. Deal with it */
	if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) &&
	    je32_to_cpu(ri->csize)) {
		ri->dsize = ri->csize;
		ri->csize = cpu_to_je32(0);
	}

	D1(if(ofs + len > je32_to_cpu(ri->dsize)) {
			pr_warn("jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n",
				len, ofs, je32_to_cpu(ri->dsize));
		ret = -EINVAL;
		goto out_ri;
	});


	if (ri->compr == JFFS2_COMPR_ZERO) {
		memset(buf, 0, len);
		goto out_ri;
	}

	/* Cases:
	   Reading whole node and it's uncompressed - read directly to buffer provided, check CRC.
	   Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided
	   Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy
	   Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomprbuf and copy
	*/
	if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) {
		readbuf = buf;
	} else {
		readbuf = kmalloc(je32_to_cpu(ri->csize), GFP_KERNEL);
		if (!readbuf) {
			ret = -ENOMEM;
			goto out_ri;
		}
	}
	if (ri->compr != JFFS2_COMPR_NONE) {
		if (len < je32_to_cpu(ri->dsize)) {
			decomprbuf = kmalloc(je32_to_cpu(ri->dsize), GFP_KERNEL);
			if (!decomprbuf) {
				ret = -ENOMEM;
				goto out_readbuf;
			}
		} else {
			decomprbuf = buf;
		}
	} else {
		decomprbuf = readbuf;
	}

	jffs2_dbg(2, "Read %d bytes to %p\n", je32_to_cpu(ri->csize),
		  readbuf);
	ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri),
			       je32_to_cpu(ri->csize), &readlen, readbuf);

	if (!ret && readlen != je32_to_cpu(ri->csize))
		ret = -EIO;
	if (ret)
		goto out_decomprbuf;

	crc = crc32(0, readbuf, je32_to_cpu(ri->csize));
	if (crc != je32_to_cpu(ri->data_crc)) {
		pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n",
			je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw));
		ret = -EIO;
		goto out_decomprbuf;
	}
	jffs2_dbg(2, "Data CRC matches calculated CRC %08x\n", crc);
	if (ri->compr != JFFS2_COMPR_NONE) {
		jffs2_dbg(2, "Decompress %d bytes from %p to %d bytes at %p\n",
			  je32_to_cpu(ri->csize), readbuf,
			  je32_to_cpu(ri->dsize), decomprbuf);
		ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize));
		if (ret) {
			pr_warn("Error: jffs2_decompress returned %d\n", ret);
			goto out_decomprbuf;
		}
	}

	if (len < je32_to_cpu(ri->dsize)) {