Skip to content

Commit a99b706

Browse files
geertutorvalds
authored andcommitted
hfsplus: Fix undefined __divdi3 in hfsplus_init_header_node()
ERROR: "__divdi3" [fs/hfsplus/hfsplus.ko] undefined! Introduced by commit 099e924 ("hfsplus: implement attributes file's header node initialization code"). i_size_read() returns loff_t, which is long long, i.e. 64-bit. node_size is size_t, which is either 32-bit or 64-bit. Hence "i_size_read(attr_file) / node_size" is a 64-by-32 or 64-by-64 division, causing (some versions of) gcc to emit a call to __divdi3(). Fortunately node_size is actually 16-bit, as the sole caller of hfsplus_init_header_node() passes a u16. Hence change its type from size_t to u16, and use do_div() to perform a 64-by-32 division. Not seen in m68k/allmodconfig in -next, so it really depends on the verion of gcc. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Vyacheslav Dubeyko <slava@dubeyko.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 498d319 commit a99b706

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎fs/hfsplus/xattr.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int can_set_xattr(struct inode *inode, const char *name,
129129

130130
static void hfsplus_init_header_node(struct inode *attr_file,
131131
u32 clump_size,
132-
char *buf, size_t node_size)
132+
char *buf, u16 node_size)
133133
{
134134
struct hfs_bnode_desc *desc;
135135
struct hfs_btree_header_rec *head;
@@ -139,8 +139,9 @@ static void hfsplus_init_header_node(struct inode *attr_file,
139139
char *bmp;
140140
u32 used_nodes;
141141
u32 used_bmp_bytes;
142+
loff_t tmp;
142143

143-
hfs_dbg(ATTR_MOD, "init_hdr_attr_file: clump %u, node_size %zu\n",
144+
hfs_dbg(ATTR_MOD, "init_hdr_attr_file: clump %u, node_size %u\n",
144145
clump_size, node_size);
145146

146147
/* The end of the node contains list of record offsets */
@@ -154,7 +155,9 @@ static void hfsplus_init_header_node(struct inode *attr_file,
154155

155156
head = (struct hfs_btree_header_rec *)(buf + offset);
156157
head->node_size = cpu_to_be16(node_size);
157-
head->node_count = cpu_to_be32(i_size_read(attr_file) / node_size);
158+
tmp = i_size_read(attr_file);
159+
do_div(tmp, node_size);
160+
head->node_count = cpu_to_be32(tmp);
158161
head->free_nodes = cpu_to_be32(be32_to_cpu(head->node_count) - 1);
159162
head->clump_size = cpu_to_be32(clump_size);
160163
head->attributes |= cpu_to_be32(HFS_TREE_BIGKEYS | HFS_TREE_VARIDXKEYS);

0 commit comments

Comments
 (0)