7
7
#include "adfs.h"
8
8
#include "dir_fplus.h"
9
9
10
+ /* Return the byte offset to directory entry pos */
11
+ static unsigned int adfs_fplus_offset (const struct adfs_bigdirheader * h ,
12
+ unsigned int pos )
13
+ {
14
+ return offsetof(struct adfs_bigdirheader , bigdirname ) +
15
+ ALIGN (le32_to_cpu (h -> bigdirnamelen ), 4 ) +
16
+ pos * sizeof (struct adfs_bigdirentry );
17
+ }
18
+
10
19
static int adfs_fplus_read (struct super_block * sb , u32 indaddr ,
11
20
unsigned int size , struct adfs_dir * dir )
12
21
{
@@ -83,9 +92,7 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
83
92
if (dir -> pos >= le32_to_cpu (h -> bigdirentries ))
84
93
return - ENOENT ;
85
94
86
- offset = offsetof(struct adfs_bigdirheader , bigdirname );
87
- offset += ((le32_to_cpu (h -> bigdirnamelen ) + 4 ) & ~3 );
88
- offset += dir -> pos * sizeof (struct adfs_bigdirentry );
95
+ offset = adfs_fplus_offset (h , dir -> pos );
89
96
90
97
ret = adfs_dir_copyfrom (& bde , dir , offset ,
91
98
sizeof (struct adfs_bigdirentry ));
@@ -99,9 +106,7 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
99
106
obj -> attr = le32_to_cpu (bde .bigdirattr );
100
107
obj -> name_len = le32_to_cpu (bde .bigdirobnamelen );
101
108
102
- offset = offsetof(struct adfs_bigdirheader , bigdirname );
103
- offset += ((le32_to_cpu (h -> bigdirnamelen ) + 4 ) & ~3 );
104
- offset += le32_to_cpu (h -> bigdirentries ) * sizeof (struct adfs_bigdirentry );
109
+ offset = adfs_fplus_offset (h , le32_to_cpu (h -> bigdirentries ));
105
110
offset += le32_to_cpu (bde .bigdirobnameptr );
106
111
107
112
ret = adfs_dir_copyfrom (obj -> name , dir , offset , obj -> name_len );
0 commit comments