diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-07 08:36:26 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2018-10-23 07:48:17 -0400 |
commit | 0e26b6e2551e21df72c140e46819523e1b686009 (patch) | |
tree | 10704f3951b94efcd5cad1cba250afd8d0920564 /fs/ubifs/lpt.c | |
parent | 22ceaa8c688d0c8a6fc6eb7ebf32c01914220d0a (diff) |
ubifs: Export pnode_lookup as ubifs_pnode_lookup
ubifs_lpt_lookup could be implemented using pnode_lookup. To make that
possible move pnode_lookup from lpt.c to lpt_commit.c. Rename it to
ubifs_pnode_lookup since it's now exported.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r-- | fs/ubifs/lpt.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 31393370e334..ed0c67fe7500 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -1439,6 +1439,38 @@ struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c, | |||
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | /** | 1441 | /** |
1442 | * ubifs_pnode_lookup - lookup a pnode in the LPT. | ||
1443 | * @c: UBIFS file-system description object | ||
1444 | * @i: pnode number (0 to (main_lebs - 1) / UBIFS_LPT_FANOUT) | ||
1445 | * | ||
1446 | * This function returns a pointer to the pnode on success or a negative | ||
1447 | * error code on failure. | ||
1448 | */ | ||
1449 | struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i) | ||
1450 | { | ||
1451 | int err, h, iip, shft; | ||
1452 | struct ubifs_nnode *nnode; | ||
1453 | |||
1454 | if (!c->nroot) { | ||
1455 | err = ubifs_read_nnode(c, NULL, 0); | ||
1456 | if (err) | ||
1457 | return ERR_PTR(err); | ||
1458 | } | ||
1459 | i <<= UBIFS_LPT_FANOUT_SHIFT; | ||
1460 | nnode = c->nroot; | ||
1461 | shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; | ||
1462 | for (h = 1; h < c->lpt_hght; h++) { | ||
1463 | iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1)); | ||
1464 | shft -= UBIFS_LPT_FANOUT_SHIFT; | ||
1465 | nnode = ubifs_get_nnode(c, nnode, iip); | ||
1466 | if (IS_ERR(nnode)) | ||
1467 | return ERR_CAST(nnode); | ||
1468 | } | ||
1469 | iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1)); | ||
1470 | return ubifs_get_pnode(c, nnode, iip); | ||
1471 | } | ||
1472 | |||
1473 | /** | ||
1442 | * ubifs_lpt_lookup - lookup LEB properties in the LPT. | 1474 | * ubifs_lpt_lookup - lookup LEB properties in the LPT. |
1443 | * @c: UBIFS file-system description object | 1475 | * @c: UBIFS file-system description object |
1444 | * @lnum: LEB number to lookup | 1476 | * @lnum: LEB number to lookup |