Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-6.18/hpfs-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull hpfs updates from Mikulas Patocka:

- Avoid -Wflex-array-member-not-at-end warnings

- Replace simple_strtoul with kstrtoint

- Fix error code for new_inode() failure

* tag 'for-6.18/hpfs-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
fs/hpfs: Fix error code for new_inode() failure in mkdir/create/mknod/symlink
hpfs: Replace simple_strtoul with kstrtoint in hpfs_parse_param
fs: hpfs: Avoid multiple -Wflex-array-member-not-at-end warnings

+75 -52
+22 -21
fs/hpfs/anode.c
··· 27 27 a = le32_to_cpu(btree->u.internal[i].down); 28 28 brelse(bh); 29 29 if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; 30 - btree = &anode->btree; 30 + btree = GET_BTREE_PTR(&anode->btree); 31 31 goto go_down; 32 32 } 33 33 hpfs_error(s, "sector %08x not found in internal anode %08x", sec, a); ··· 69 69 int n; 70 70 unsigned fs; 71 71 int c1, c2 = 0; 72 + 72 73 if (fnod) { 73 74 if (!(fnode = hpfs_map_fnode(s, node, &bh))) return -1; 74 - btree = &fnode->btree; 75 + btree = GET_BTREE_PTR(&fnode->btree); 75 76 } else { 76 77 if (!(anode = hpfs_map_anode(s, node, &bh))) return -1; 77 - btree = &anode->btree; 78 + btree = GET_BTREE_PTR(&anode->btree); 78 79 } 79 80 a = node; 80 81 go_down: ··· 92 91 if (hpfs_sb(s)->sb_chk) 93 92 if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_add_sector_to_btree #1")) return -1; 94 93 if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; 95 - btree = &anode->btree; 94 + btree = GET_BTREE_PTR(&anode->btree); 96 95 goto go_down; 97 96 } 98 97 if (n >= 0) { ··· 152 151 } 153 152 brelse(bh); 154 153 bh = bh1; 155 - btree = &anode->btree; 154 + btree = GET_BTREE_PTR(&anode->btree); 156 155 } 157 156 btree->n_free_nodes--; n = btree->n_used_nodes++; 158 157 le16_add_cpu(&btree->first_free, 12); ··· 169 168 if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1; 170 169 if (up != node || !fnod) { 171 170 if (!(anode = hpfs_map_anode(s, up, &bh))) return -1; 172 - btree = &anode->btree; 171 + btree = GET_BTREE_PTR(&anode->btree); 173 172 } else { 174 173 if (!(fnode = hpfs_map_fnode(s, up, &bh))) return -1; 175 - btree = &fnode->btree; 174 + btree = GET_BTREE_PTR(&fnode->btree); 176 175 } 177 176 if (btree->n_free_nodes) { 178 177 btree->n_free_nodes--; n = btree->n_used_nodes++; ··· 207 206 anode->btree.n_used_nodes = 1; 208 207 anode->btree.n_free_nodes = 59; 209 208 anode->btree.first_free = cpu_to_le16(16); 210 - anode->btree.u.internal[0].down = cpu_to_le32(a); 211 - anode->btree.u.internal[0].file_secno = cpu_to_le32(-1); 209 + GET_BTREE_PTR(&anode->btree)->u.internal[0].down = cpu_to_le32(a); 210 + GET_BTREE_PTR(&anode->btree)->u.internal[0].file_secno = cpu_to_le32(-1); 212 211 mark_buffer_dirty(bh); 213 212 brelse(bh); 214 213 if ((anode = hpfs_map_anode(s, a, &bh))) { ··· 230 229 brelse(bh2); 231 230 return -1; 232 231 } 233 - btree = &anode->btree; 232 + btree = GET_BTREE_PTR(&anode->btree); 234 233 } else { 235 234 if (!(fnode = hpfs_map_fnode(s, node, &bh))) { 236 235 brelse(bh2); 237 236 return -1; 238 237 } 239 - btree = &fnode->btree; 238 + btree = GET_BTREE_PTR(&fnode->btree); 240 239 } 241 240 ranode->up = cpu_to_le32(node); 242 241 memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free)); 243 242 if (fnod) 244 243 ranode->btree.flags |= BP_fnode_parent; 245 - ranode->btree.n_free_nodes = (bp_internal(&ranode->btree) ? 60 : 40) - ranode->btree.n_used_nodes; 246 - if (bp_internal(&ranode->btree)) for (n = 0; n < ranode->btree.n_used_nodes; n++) { 244 + GET_BTREE_PTR(&ranode->btree)->n_free_nodes = (bp_internal(GET_BTREE_PTR(&ranode->btree)) ? 60 : 40) - GET_BTREE_PTR(&ranode->btree)->n_used_nodes; 245 + if (bp_internal(GET_BTREE_PTR(&ranode->btree))) for (n = 0; n < GET_BTREE_PTR(&ranode->btree)->n_used_nodes; n++) { 247 246 struct anode *unode; 248 247 if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) { 249 248 unode->up = cpu_to_le32(ra); ··· 292 291 if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1")) 293 292 return; 294 293 if (!(anode = hpfs_map_anode(s, ano, &bh))) return; 295 - btree1 = &anode->btree; 294 + btree1 = GET_BTREE_PTR(&anode->btree); 296 295 level++; 297 296 pos = 0; 298 297 } ··· 308 307 ano = le32_to_cpu(anode->up); 309 308 if (--level) { 310 309 if (!(anode = hpfs_map_anode(s, ano, &bh))) return; 311 - btree1 = &anode->btree; 310 + btree1 = GET_BTREE_PTR(&anode->btree); 312 311 } else btree1 = btree; 313 312 for (i = 0; i < btree1->n_used_nodes; i++) { 314 313 if (le32_to_cpu(btree1->u.internal[i].down) == oano) { ··· 333 332 struct anode *anode; 334 333 struct buffer_head *bh; 335 334 if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; 336 - return hpfs_bplus_lookup(s, NULL, &anode->btree, sec, bh); 335 + return hpfs_bplus_lookup(s, NULL, GET_BTREE_PTR(&anode->btree), sec, bh); 337 336 } 338 337 339 338 int hpfs_ea_read(struct super_block *s, secno a, int ano, unsigned pos, ··· 389 388 struct buffer_head *bh; 390 389 if (ano) { 391 390 if (!(anode = hpfs_map_anode(s, a, &bh))) return; 392 - hpfs_remove_btree(s, &anode->btree); 391 + hpfs_remove_btree(s, GET_BTREE_PTR(&anode->btree)); 393 392 brelse(bh); 394 393 hpfs_free_sectors(s, a, 1); 395 394 } else hpfs_free_sectors(s, a, (len + 511) >> 9); ··· 408 407 int c1, c2 = 0; 409 408 if (fno) { 410 409 if (!(fnode = hpfs_map_fnode(s, f, &bh))) return; 411 - btree = &fnode->btree; 410 + btree = GET_BTREE_PTR(&fnode->btree); 412 411 } else { 413 412 if (!(anode = hpfs_map_anode(s, f, &bh))) return; 414 - btree = &anode->btree; 413 + btree = GET_BTREE_PTR(&anode->btree); 415 414 } 416 415 if (!secs) { 417 416 hpfs_remove_btree(s, btree); ··· 449 448 if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree")) 450 449 return; 451 450 if (!(anode = hpfs_map_anode(s, node, &bh))) return; 452 - btree = &anode->btree; 451 + btree = GET_BTREE_PTR(&anode->btree); 453 452 } 454 453 nodes = btree->n_used_nodes + btree->n_free_nodes; 455 454 for (i = 0; i < btree->n_used_nodes; i++) ··· 486 485 struct extended_attribute *ea; 487 486 struct extended_attribute *ea_end; 488 487 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; 489 - if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, &fnode->btree); 488 + if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, GET_BTREE_PTR(&fnode->btree)); 490 489 else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); 491 490 ea_end = fnode_end_ea(fnode); 492 491 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea))
+1 -1
fs/hpfs/ea.c
··· 41 41 struct buffer_head *bh; 42 42 struct anode *anode; 43 43 if ((anode = hpfs_map_anode(s, a, &bh))) { 44 - hpfs_remove_btree(s, &anode->btree); 44 + hpfs_remove_btree(s, GET_BTREE_PTR(&anode->btree)); 45 45 brelse(bh); 46 46 hpfs_free_sectors(s, a, 1); 47 47 }
+3 -1
fs/hpfs/file.c
··· 51 51 return hpfs_inode->i_disk_sec + n; 52 52 } 53 53 if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0; 54 - disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh); 54 + disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, 55 + GET_BTREE_PTR(&fnode->btree), 56 + file_secno, bh); 55 57 if (disk_secno == -1) return 0; 56 58 if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0; 57 59 n = file_secno - hpfs_inode->i_file_sec;
+31 -13
fs/hpfs/hpfs.h
··· 394 394 BP_binary_search = 0x40, 395 395 BP_internal = 0x80 396 396 }; 397 + 398 + /** 399 + * GET_BTREE_PTR() - Get a pointer to struct bplus_header 400 + * 401 + * Wrapper around container_of() to retrieve a pointer to struct 402 + * bplus_header from a pointer to struct bplus_header_fixed. 403 + * 404 + * @ptr: Pointer to struct bplus_header_fixed. 405 + * 406 + */ 407 + #define GET_BTREE_PTR(ptr) \ 408 + container_of(ptr, struct bplus_header, __hdr) 409 + 397 410 struct bplus_header 398 411 { 399 - u8 flags; /* bit 0 - high bit of first free entry offset 412 + /* New members MUST be added within the struct_group() macro below. */ 413 + struct_group_tagged(bplus_header_fixed, __hdr, 414 + u8 flags; /* bit 0 - high bit of first free entry offset 400 415 bit 5 - we're pointed to by an fnode, 401 416 the data btree or some ea or the 402 417 main ea bootage pointer ea_secno 403 418 bit 6 - suggest binary search (unused) 404 419 bit 7 - 1 -> (internal) tree of anodes 405 420 0 -> (leaf) list of extents */ 406 - u8 fill[3]; 407 - u8 n_free_nodes; /* free nodes in following array */ 408 - u8 n_used_nodes; /* used nodes in following array */ 409 - __le16 first_free; /* offset from start of header to 421 + u8 fill[3]; 422 + u8 n_free_nodes; /* free nodes in following array */ 423 + u8 n_used_nodes; /* used nodes in following array */ 424 + __le16 first_free; /* offset from start of header to 410 425 first free node in array */ 411 - union { 412 - /* (internal) 2-word entries giving subtree pointers */ 413 - DECLARE_FLEX_ARRAY(struct bplus_internal_node, internal); 414 - /* (external) 3-word entries giving sector runs */ 415 - DECLARE_FLEX_ARRAY(struct bplus_leaf_node, external); 416 - } u; 426 + ); 427 + union { 428 + /* (internal) 2-word entries giving subtree pointers */ 429 + DECLARE_FLEX_ARRAY(struct bplus_internal_node, internal); 430 + /* (external) 3-word entries giving sector runs */ 431 + DECLARE_FLEX_ARRAY(struct bplus_leaf_node, external); 432 + } u; 417 433 }; 434 + static_assert(offsetof(struct bplus_header, u.internal) == sizeof(struct bplus_header_fixed), 435 + "struct member likely outside of struct_group_tagged()"); 418 436 419 437 static inline bool bp_internal(struct bplus_header *bp) 420 438 { ··· 471 453 __le16 flags; /* bit 1 set -> ea_secno is an anode */ 472 454 /* bit 8 set -> directory. first & only extent 473 455 points to dnode. */ 474 - struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ 456 + struct bplus_header_fixed btree; /* b+ tree, 8 extents or 12 subtrees */ 475 457 union { 476 458 struct bplus_leaf_node external[8]; 477 459 struct bplus_internal_node internal[12]; ··· 513 495 __le32 self; /* pointer to this anode */ 514 496 __le32 up; /* parent anode or fnode */ 515 497 516 - struct bplus_header btree; /* b+tree, 40 extents or 60 subtrees */ 498 + struct bplus_header_fixed btree; /* b+tree, 40 extents or 60 subtrees */ 517 499 union { 518 500 struct bplus_leaf_node external[40]; 519 501 struct bplus_internal_node internal[60];
+4 -4
fs/hpfs/map.c
··· 178 178 } 179 179 if (!fnode_is_dir(fnode)) { 180 180 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != 181 - (bp_internal(&fnode->btree) ? 12 : 8)) { 181 + (bp_internal(GET_BTREE_PTR(&fnode->btree)) ? 12 : 8)) { 182 182 hpfs_error(s, 183 183 "bad number of nodes in fnode %08lx", 184 184 (unsigned long)ino); 185 185 goto bail; 186 186 } 187 187 if (le16_to_cpu(fnode->btree.first_free) != 188 - 8 + fnode->btree.n_used_nodes * (bp_internal(&fnode->btree) ? 8 : 12)) { 188 + 8 + fnode->btree.n_used_nodes * (bp_internal(GET_BTREE_PTR(&fnode->btree)) ? 8 : 12)) { 189 189 hpfs_error(s, 190 190 "bad first_free pointer in fnode %08lx", 191 191 (unsigned long)ino); ··· 233 233 goto bail; 234 234 } 235 235 if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != 236 - (bp_internal(&anode->btree) ? 60 : 40)) { 236 + (bp_internal(GET_BTREE_PTR(&anode->btree)) ? 60 : 40)) { 237 237 hpfs_error(s, "bad number of nodes in anode %08x", ano); 238 238 goto bail; 239 239 } 240 240 if (le16_to_cpu(anode->btree.first_free) != 241 - 8 + anode->btree.n_used_nodes * (bp_internal(&anode->btree) ? 8 : 12)) { 241 + 8 + anode->btree.n_used_nodes * (bp_internal(GET_BTREE_PTR(&anode->btree)) ? 8 : 12)) { 242 242 hpfs_error(s, "bad first_free pointer in anode %08x", ano); 243 243 goto bail; 244 244 }
+12 -6
fs/hpfs/namei.c
··· 52 52 dee.fnode = cpu_to_le32(fno); 53 53 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(local_get_seconds(dir->i_sb)); 54 54 result = new_inode(dir->i_sb); 55 - if (!result) 55 + if (!result) { 56 + err = -ENOMEM; 56 57 goto bail2; 58 + } 57 59 hpfs_init_inode(result); 58 60 result->i_ino = fno; 59 61 hpfs_i(result)->i_parent_dir = dir->i_ino; ··· 155 153 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(local_get_seconds(dir->i_sb)); 156 154 157 155 result = new_inode(dir->i_sb); 158 - if (!result) 156 + if (!result) { 157 + err = -ENOMEM; 159 158 goto bail1; 160 - 159 + } 161 160 hpfs_init_inode(result); 162 161 result->i_ino = fno; 163 162 result->i_mode |= S_IFREG; ··· 242 239 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(local_get_seconds(dir->i_sb)); 243 240 244 241 result = new_inode(dir->i_sb); 245 - if (!result) 242 + if (!result) { 243 + err = -ENOMEM; 246 244 goto bail1; 247 - 245 + } 248 246 hpfs_init_inode(result); 249 247 result->i_ino = fno; 250 248 hpfs_i(result)->i_parent_dir = dir->i_ino; ··· 318 314 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(local_get_seconds(dir->i_sb)); 319 315 320 316 result = new_inode(dir->i_sb); 321 - if (!result) 317 + if (!result) { 318 + err = -ENOMEM; 322 319 goto bail1; 320 + } 323 321 result->i_ino = fno; 324 322 hpfs_init_inode(result); 325 323 hpfs_i(result)->i_parent_dir = dir->i_ino;
+2 -6
fs/hpfs/super.c
··· 404 404 break; 405 405 case Opt_timeshift: 406 406 { 407 - int m = 1; 408 407 char *rhs = param->string; 409 408 int timeshift; 410 409 411 - if (*rhs == '-') m = -1; 412 - if (*rhs == '+' || *rhs == '-') rhs++; 413 - timeshift = simple_strtoul(rhs, &rhs, 0) * m; 414 - if (*rhs) 415 - return -EINVAL; 410 + if (kstrtoint(rhs, 0, &timeshift)) 411 + return -EINVAL; 416 412 ctx->timeshift = timeshift; 417 413 break; 418 414 }