File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 15
15
16
16
#include "btree.h"
17
17
18
- void hfs_bnode_read (struct hfs_bnode * node , void * buf ,
19
- int off , int len )
18
+ void hfs_bnode_read (struct hfs_bnode * node , void * buf , int off , int len )
20
19
{
21
20
struct page * page ;
21
+ int pagenum ;
22
+ int bytes_read ;
23
+ int bytes_to_read ;
24
+ void * vaddr ;
22
25
23
26
off += node -> page_offset ;
24
- page = node -> page [0 ];
27
+ pagenum = off >> PAGE_SHIFT ;
28
+ off &= ~PAGE_MASK ; /* compute page offset for the first page */
25
29
26
- memcpy (buf , kmap (page ) + off , len );
27
- kunmap (page );
30
+ for (bytes_read = 0 ; bytes_read < len ; bytes_read += bytes_to_read ) {
31
+ if (pagenum >= node -> tree -> pages_per_bnode )
32
+ break ;
33
+ page = node -> page [pagenum ];
34
+ bytes_to_read = min_t (int , len - bytes_read , PAGE_SIZE - off );
35
+
36
+ vaddr = kmap_atomic (page );
37
+ memcpy (buf + bytes_read , vaddr + off , bytes_to_read );
38
+ kunmap_atomic (vaddr );
39
+
40
+ pagenum ++ ;
41
+ off = 0 ; /* page offset only applies to the first page */
42
+ }
28
43
}
29
44
30
45
u16 hfs_bnode_read_u16 (struct hfs_bnode * node , int off )
You can’t perform that action at this time.
0 commit comments