#include "protos.h"
#include "err_protos.h"
-int
+static int
verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)
{
xfs_drfsbno_t agblocks;
return(retval);
}
-int
+static int
verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)
{
xfs_drfsbno_t agblocks;
* filesystem mount-point superblock
*
* the verified fields include id and geometry.
-
+ *
* the inprogress fields, version numbers, and counters
* are allowed to differ as well as all fields after the
* counters to cope with the pre-6.5 mkfs non-zeroed
* secondary superblock sectors.
*/
-
-int
+static int
compare_sb(xfs_mount_t *mp, xfs_sb_t *sb)
{
fs_geometry_t fs_geo, sb_geo;
* Note: contrary to the name, this routine is called for all
* superblocks, not just the secondary superblocks.
*/
-int
+static int
secondary_sb_wack(xfs_mount_t *mp, xfs_buf_t *sbuf, xfs_sb_t *sb,
xfs_agnumber_t i)
{
* in user attribute land without a conflict.
* If value is non-zero, then a remote attribute is being passed in
*/
-
-int
+static int
valuecheck(char *namevalue, char *value, int namelen, int valuelen)
{
/* for proper alignment issues, get the structs and memmove the values */
* if you cannot modify the structures. repair is set to 1, if anything
* was fixed.
*/
-int
+static int
process_shortform_attr(
xfs_ino_t ino,
xfs_dinode_t *dip,
return -1;
}
-int
+static int
process_leaf_attr_block(
xfs_mount_t *mp,
xfs_attr_leafblock_t *leaf,
/*
* returns 0 if the attribute fork is ok, 1 if it has to be junked.
*/
-int
+static int
process_leaf_attr_level(xfs_mount_t *mp,
da_bt_cursor_t *da_cursor)
{
* returns 0 if things are ok, 1 if bad
* Note this code has been based off process_node_dir.
*/
-int
+static int
process_node_attr(
xfs_mount_t *mp,
xfs_ino_t ino,
* returns 0 if things are ok, 1 if bad (attributes needs to be junked)
* repair is set, if anything was changed, but attributes can live thru it
*/
-
-int
+static int
process_longform_attr(
xfs_mount_t *mp,
xfs_ino_t ino,
* the dinodes are verified using verify_uncertain_dinode() which
* means only the basic inode info is checked, no fork checks.
*/
-
-int
+static int
check_aginode_block(xfs_mount_t *mp,
xfs_agnumber_t agno,
xfs_agblock_t agbno)
* routines called by check_uncertain_aginodes() and
* process_uncertain_aginodes().
*/
-int
+static int
verify_inode_chunk(xfs_mount_t *mp,
xfs_ino_t ino,
xfs_ino_t *start_ino)
/*
* same as above only for ag inode chunks
*/
-int
+static int
verify_aginode_chunk(xfs_mount_t *mp,
xfs_agnumber_t agno,
xfs_agino_t agino,
* this does the same as the two above only it returns a pointer
* to the inode record in the good inode tree
*/
-ino_tree_node_t *
+static ino_tree_node_t *
verify_aginode_chunk_irec(xfs_mount_t *mp,
xfs_agnumber_t agno,
xfs_agino_t agino)
* inode clearing routines
*/
-/*
- * return the offset into the inode where the attribute fork starts
- */
-/* ARGSUSED */
-int
-calc_attr_offset(xfs_mount_t *mp, xfs_dinode_t *dino)
-{
- int offset = (__psint_t)XFS_DFORK_DPTR(dino) - (__psint_t)dino;
- xfs_bmdr_block_t *dfp;
-
- /*
- * don't worry about alignment when calculating offset
- * because the data fork is already 8-byte aligned
- */
- switch (dino->di_format) {
- case XFS_DINODE_FMT_DEV:
- offset += sizeof(xfs_dev_t);
- break;
- case XFS_DINODE_FMT_LOCAL:
- offset += be64_to_cpu(dino->di_size);
- break;
- case XFS_DINODE_FMT_EXTENTS:
- offset += be32_to_cpu(dino->di_nextents) *
- sizeof(xfs_bmbt_rec_t);
- break;
- case XFS_DINODE_FMT_BTREE:
- dfp = (xfs_bmdr_block_t *)XFS_DFORK_DPTR(dino);
- offset += be16_to_cpu(dfp->bb_numrecs) *
- sizeof(xfs_bmbt_rec_t);
- break;
- default:
- do_error(_("Unknown inode format.\n"));
- abort();
- break;
- }
-
- return(offset);
-}
-
-/* ARGSUSED */
-int
+static int
clear_dinode_attr(xfs_mount_t *mp, xfs_dinode_t *dino, xfs_ino_t ino_num)
{
ASSERT(dino->di_forkoff != 0);
return(1);
}
-/* ARGSUSED */
-int
+static int
clear_dinode_core(xfs_dinode_t *dinoc, xfs_ino_t ino_num)
{
int dirty = 0;
return(dirty);
}
-/* ARGSUSED */
-int
+static int
clear_dinode_unlinked(xfs_mount_t *mp, xfs_dinode_t *dino)
{
* until after the agi unlinked lists are walked in phase 3.
* returns > zero if the inode has been altered while being cleared
*/
-int
+static int
clear_dinode(xfs_mount_t *mp, xfs_dinode_t *dino, xfs_ino_t ino_num)
{
int dirty;
return verify_ag_bno(sbp, agno, agbno) == 0;
}
-/*
- * return address of block fblock if it's within the range described
- * by the extent list. Otherwise, returns a null address.
- */
-/* ARGSUSED */
-xfs_dfsbno_t
-get_bmbt_reclist(
- xfs_mount_t *mp,
- xfs_bmbt_rec_t *rp,
- int numrecs,
- xfs_dfiloff_t fblock)
-{
- int i;
- xfs_bmbt_irec_t irec;
-
- for (i = 0; i < numrecs; i++) {
- libxfs_bmbt_disk_get_all(rp + i, &irec);
- if (irec.br_startoff >= fblock &&
- irec.br_startoff + irec.br_blockcount < fblock)
- return (irec.br_startblock + fblock - irec.br_startoff);
- }
- return(NULLDFSBNO);
-}
-
-
static int
process_rt_rec(
xfs_mount_t *mp,
* file overlaps with any duplicate extents (in the
* duplicate extent list).
*/
-/* ARGSUSED */
-int
+static int
process_bmbt_reclist_int(
xfs_mount_t *mp,
xfs_bmbt_rec_t *rp,
*
* NOTE: getfunc_extlist only used by dirv1 checking code
*/
-xfs_dfsbno_t
+static xfs_dfsbno_t
getfunc_extlist(xfs_mount_t *mp,
xfs_ino_t ino,
xfs_dinode_t *dip,
/*
* NOTE: getfunc_btree only used by dirv1 checking code...
*/
-xfs_dfsbno_t
+static xfs_dfsbno_t
getfunc_btree(xfs_mount_t *mp,
xfs_ino_t ino,
xfs_dinode_t *dip,
/*
* return 1 if inode should be cleared, 0 otherwise
*/
-/* ARGSUSED */
-int
+static int
process_btinode(
xfs_mount_t *mp,
xfs_agnumber_t agno,
/*
* return 1 if inode should be cleared, 0 otherwise
*/
-/* ARGSUSED */
-int
+static int
process_exinode(
xfs_mount_t *mp,
xfs_agnumber_t agno,
return(0);
}
-int
+static int
process_symlink_extlist(xfs_mount_t *mp, xfs_ino_t lino, xfs_dinode_t *dino)
{
xfs_dfiloff_t expected_offset;
* takes a name and length and returns 1 if the name contains
* a \0, returns 0 otherwise
*/
-int
+static int
null_check(char *name, int length)
{
int i;
* like usual, returns 0 if everything's ok and 1 if something's
* bogus
*/
-int
+static int
process_symlink(
xfs_mount_t *mp,
xfs_ino_t lino,
*
* for detailed, info, look at process_dinode() comments.
*/
-/* ARGSUSED */
-int
+static int
process_dinode_int(xfs_mount_t *mp,
xfs_dinode_t *dino,
xfs_agnumber_t agno,
xfs_drfsbno_t *tot,
int whichfork);
-int
-verify_inode_chunk(xfs_mount_t *mp,
- xfs_ino_t ino,
- xfs_ino_t *start_ino);
-
-int verify_aginode_chunk(xfs_mount_t *mp,
- xfs_agnumber_t agno,
- xfs_agino_t agino,
- xfs_agino_t *agino_start);
-
-int
-clear_dinode(xfs_mount_t *mp, xfs_dinode_t *dino, xfs_ino_t ino_num);
-
void
update_rootino(xfs_mount_t *mp);
* entries. a non-zero return value means the directory is bogus
* and should be blasted.
*/
-/* ARGSUSED */
-int
+static int
process_shortform_dir(
xfs_mount_t *mp,
xfs_ino_t ino,
* returns 0 if holemap is consistent with reality (as expressed by
* the da_freemap_t). returns 1 if there's a conflict.
*/
-int
+static int
verify_da_freemap(xfs_mount_t *mp, da_freemap_t *map, da_hole_map_t *holes,
xfs_ino_t ino, xfs_dablk_t da_bno)
{
return(0);
}
-void
+static void
process_da_freemap(xfs_mount_t *mp, da_freemap_t *map, da_hole_map_t *holes)
{
int i, j, in_hole, start, length, smallest, num_holes;
/*
* returns 1 if the hole info doesn't match, 0 if it does
*/
-/* ARGSUSED */
-int
+static int
compare_da_freemaps(xfs_mount_t *mp, da_hole_map_t *holemap,
da_hole_map_t *block_hmap, int entries,
xfs_ino_t ino, xfs_dablk_t da_bno)
* buffers (e.g. if we do, it's a mistake). if error == 1, we're
* in an error-handling case so unreleased buffers may exist.
*/
-void
+static void
release_da_cursor_int(xfs_mount_t *mp,
da_bt_cursor_t *cursor,
int prev_level,
release_da_cursor_int(mp, cursor, prev_level, 1);
}
-/*
- * like traverse_int_dablock only it does far less checking
- * and doesn't maintain the cursor. Just gets you to the
- * leftmost block in the directory. returns the fsbno
- * of that block if successful, NULLDFSBNO if not.
- */
-xfs_dfsbno_t
-get_first_dblock_fsbno(xfs_mount_t *mp,
- xfs_ino_t ino,
- xfs_dinode_t *dino)
-{
- xfs_dablk_t bno;
- int i;
- xfs_da_intnode_t *node;
- xfs_dfsbno_t fsbno;
- xfs_buf_t *bp;
-
- /*
- * traverse down left-side of tree until we hit the
- * left-most leaf block setting up the btree cursor along
- * the way.
- */
- bno = 0;
- i = -1;
- node = NULL;
-
- fsbno = get_bmapi(mp, dino, ino, bno, XFS_DATA_FORK);
-
- if (fsbno == NULLDFSBNO) {
- do_warn(_("bmap of block #%u of inode %" PRIu64 " failed\n"),
- bno, ino);
- return(fsbno);
- }
-
- if (be64_to_cpu(dino->di_size) <= XFS_LBSIZE(mp))
- return(fsbno);
-
- do {
- /*
- * walk down left side of btree, release buffers as you
- * go. if the root block is a leaf (single-level btree),
- * just return it.
- *
- */
-
- bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, fsbno),
- XFS_FSB_TO_BB(mp, 1), 0);
- if (!bp) {
- do_warn(
- _("can't read block %u (fsbno %" PRIu64 ") for directory inode %" PRIu64 "\n"),
- bno, fsbno, ino);
- return(NULLDFSBNO);
- }
-
- node = (xfs_da_intnode_t *)XFS_BUF_PTR(bp);
-
- if (XFS_DA_NODE_MAGIC !=
- be16_to_cpu(node->hdr.info.magic)) {
- do_warn(
- _("bad dir/attr magic number in inode %" PRIu64 ", file bno = %u, fsbno = %" PRIu64 "\n"),
- ino, bno, fsbno);
- libxfs_putbuf(bp);
- return(NULLDFSBNO);
- }
-
- if (i == -1)
- i = be16_to_cpu(node->hdr.level);
- bno = be32_to_cpu(node->btree[0].before);
-
- libxfs_putbuf(bp);
-
- fsbno = get_bmapi(mp, dino, ino, bno, XFS_DATA_FORK);
-
- if (fsbno == NULLDFSBNO) {
- do_warn(_("bmap of block #%u of inode %" PRIu64 " failed\n"),
- bno, ino);
- return(NULLDFSBNO);
- }
-
- i--;
- } while(i > 0);
-
- return(fsbno);
-}
-
/*
* make sure that all entries in all blocks along the right side of
* of the tree are used and hashval's are consistent. level is the
* bad entry name index pointers), we lose the directory. We could
* try harder to fix this but it'll do for now.
*/
-/* ARGSUSED */
-int
+static int
process_leaf_dir_block(
xfs_mount_t *mp,
xfs_dir_leafblock_t *leaf,
/*
* returns 0 if the directory is ok, 1 if it has to be junked.
*/
-int
+static int
process_leaf_dir_level(xfs_mount_t *mp,
da_bt_cursor_t *da_cursor,
int ino_discovery,
*
* returns 0 if things are ok, 1 if bad (directory needs to be junked)
*/
-/* ARGSUSED */
-int
+static int
process_node_dir(
xfs_mount_t *mp,
xfs_ino_t ino,
*
* returns 0 if things are ok, 1 if bad (directory needs to be junked)
*/
-/* ARGSUSED */
-int
+static int
process_leaf_dir(
xfs_mount_t *mp,
xfs_ino_t ino,
da_bt_cursor_t *cursor,
int prev_level);
-xfs_dfsbno_t
-get_first_dblock_fsbno(
- xfs_mount_t *mp,
- xfs_ino_t ino,
- xfs_dinode_t *dino);
-
void
init_da_freemap(
da_freemap_t *dir_freemap);
char *name,
int length);
-int
-process_shortform_dir(
- xfs_mount_t *mp,
- xfs_ino_t ino,
- xfs_dinode_t *dip,
- int ino_discovery,
- int *dino_dirty, /* is dinode buffer dirty? */
- xfs_ino_t *parent, /* out - NULLFSINO if entry doesn't exist */
- char *dirname, /* directory pathname */
- int *repair); /* out - 1 if dir was fixed up */
-
int
process_dir(
xfs_mount_t *mp,
xfs_ino_t ino;
struct dir2_bad *next;
} dir2_bad_t;
-dir2_bad_t *dir2_bad_list;
-void
+static dir2_bad_t *dir2_bad_list;
+
+static void
dir2_add_badlist(
xfs_ino_t ino)
{
* Multibuffer handling.
* V2 directory blocks can be noncontiguous, needing multiple buffers.
*/
-xfs_dabuf_t *
+static xfs_dabuf_t *
da_read_buf(
xfs_mount_t *mp,
int nex,
free(dabuf);
}
-int
+static int
da_bwrite(
xfs_mount_t *mp,
xfs_dabuf_t *dabuf)
return error;
}
-void
+static void
da_brelse(
xfs_dabuf_t *dabuf)
{
* left-most leaf block if successful (bno). returns 1 if successful,
* 0 if unsuccessful.
*/
-int
+static int
traverse_int_dir2block(xfs_mount_t *mp,
dir2_bt_cursor_t *da_cursor,
xfs_dablk_t *rbno)
* buffers (e.g. if we do, it's a mistake). if error == 1, we're
* in an error-handling case so unreleased buffers may exist.
*/
-void
+static void
release_dir2_cursor_int(xfs_mount_t *mp,
dir2_bt_cursor_t *cursor,
int prev_level,
return;
}
-void
+static void
release_dir2_cursor(xfs_mount_t *mp,
dir2_bt_cursor_t *cursor,
int prev_level)
release_dir2_cursor_int(mp, cursor, prev_level, 0);
}
-void
+static void
err_release_dir2_cursor(xfs_mount_t *mp,
dir2_bt_cursor_t *cursor,
int prev_level)
* technically a block boundary. This routine should be used then
* instead of verify_dir2_path().
*/
-int
+static int
verify_final_dir2_path(xfs_mount_t *mp,
dir2_bt_cursor_t *cursor,
const int p_level)
* since they have to be set so we can get a buffer for the
* block.
*/
-int
+static int
verify_dir2_path(xfs_mount_t *mp,
dir2_bt_cursor_t *cursor,
const int p_level)
struct blkmap *blkmap;
} dir2_bt_cursor_t;
-
-/* ROUTINES */
-
-void
-err_release_dir2_cursor(
- xfs_mount_t *mp,
- dir2_bt_cursor_t *cursor,
- int prev_level);
-
-xfs_dabuf_t *
-da_read_buf(
- xfs_mount_t *mp,
- int nex,
- struct bmap_ext *bmp);
-
-int
-da_bwrite(
- xfs_mount_t *mp,
- xfs_dabuf_t *bp);
-
-void
-da_brelse(
- xfs_dabuf_t *bp);
-
int
process_dir2(
xfs_mount_t *mp,
xfs_dir2_sf_t *sfp,
xfs_dir2_sf_entry_t **next_sfep);
-void
-dir2_add_badlist(
- xfs_ino_t ino);
-
int
dir2_is_badino(
xfs_ino_t ino);
#include "protos.h"
#include "err_protos.h"
-void
+static void
no_sb(void)
{
do_warn(_("Sorry, could not find valid secondary superblock\n"));
* free in which case they'd never be cleared so the fields wouldn't
* be cleared by process_dinode().
*/
-void
+static void
quotino_check(xfs_mount_t *mp)
{
ino_tree_node_t *irec;
}
}
-void
+static void
quota_sb_check(xfs_mount_t *mp)
{
/*
static __uint64_t *sb_ifree_ag; /* free inodes per ag */
static __uint64_t *sb_fdblocks_ag; /* free data blocks per ag */
-int
+static int
mk_incore_fstree(xfs_mount_t *mp, xfs_agnumber_t agno)
{
int in_extent;
return(num_extents);
}
-/* ARGSUSED */
-xfs_agblock_t
+static xfs_agblock_t
get_next_blockaddr(xfs_agnumber_t agno, int level, bt_status_t *curs)
{
ASSERT(curs->free_btree_blocks < curs->btree_blocks +
* cursor pointer to the btree root. called by init_freespace_cursor()
* and init_ino_cursor()
*/
-/* ARGSUSED */
-void
+static void
setup_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *curs)
{
int j;
#endif
}
-void
+static void
write_cursor(bt_status_t *curs)
{
int i;
}
}
-void
+static void
finish_cursor(bt_status_t *curs)
{
ASSERT(curs->num_free_blocks == 0);
* btree_curs is an in/out. returns the number of
* blocks that will show up in the AGFL.
*/
-
-int
+static int
calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
xfs_agblock_t *extents, bt_status_t *btree_curs)
{
return(extra_blocks);
}
-void
+static void
prop_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_status_t *btree_curs, xfs_agblock_t startblock,
xfs_extlen_t blockcount, int level, __uint32_t magic)
* of tree to build (bno or bcnt). returns the number of free blocks
* represented by the tree.
*/
-xfs_extlen_t
+static xfs_extlen_t
build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_status_t *btree_curs, __uint32_t magic)
{
* may perturb things because inode tree building happens before
* freespace tree building.
*/
-void
+static void
init_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs,
__uint64_t *num_inos, __uint64_t *num_free_inos)
{
return;
}
-void
+static void
prop_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs,
xfs_agino_t startino, int level)
{
*bt_ptr = cpu_to_be32(btree_curs->level[level-1].agbno);
}
-void
+static void
build_agi(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_status_t *btree_curs, xfs_agino_t first_agino,
xfs_agino_t count, xfs_agino_t freecount)
* rebuilds an inode tree given a cursor. We're lazy here and call
* the routine that builds the agi
*/
-void
+static void
build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_status_t *btree_curs)
{
* build both the agf and the agfl for an agno given both
* btree cursors
*/
-void
+static void
build_agf_agfl(xfs_mount_t *mp,
xfs_agnumber_t agno,
bt_status_t *bno_bt,
* feature bits to the filesystem, and sync up the on-disk superblock
* to match the incore superblock.
*/
-void
+static void
sync_sb(xfs_mount_t *mp)
{
xfs_buf_t *bp;
* make sure the root and realtime inodes show up allocated
* even if they've been freed. they get reinitialized in phase6.
*/
-void
+static void
keep_fsinos(xfs_mount_t *mp)
{
ino_tree_node_t *irec;
libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC);
}
-int
+static int
fill_rbmino(xfs_mount_t *mp)
{
xfs_buf_t *bp;
return(0);
}
-int
+static int
fill_rsumino(xfs_mount_t *mp)
{
xfs_buf_t *bp;
return(0);
}
-void
+static void
mk_rsumino(xfs_mount_t *mp)
{
xfs_trans_t *tp;
/*
* makes a new root directory.
*/
-void
+static void
mk_root_dir(xfs_mount_t *mp)
{
xfs_trans_t *tp;
/*
* orphanage name == lost+found
*/
-xfs_ino_t
+static xfs_ino_t
mk_orphanage(xfs_mount_t *mp)
{
xfs_ino_t ino;
}
/*
- * like get_first_dblock_fsbno only it uses the simulation code instead
- * of raw I/O.
- *
* Returns the fsbno of the first (leftmost) block in the directory leaf.
* sets *bno to the directory block # corresponding to the returned fsbno.
*/
* mark realtime bitmap and summary inodes as reached.
* quota inode will be marked here as well
*/
-void
+static void
mark_standalone_inodes(xfs_mount_t *mp)
{
ino_tree_node_t *irec;
return(sum);
}
-void
+static void
timediff(int phase)
{
phase_times[phase].duration =
* copy the fields of a superblock that are present in primary and
* secondaries -- preserve fields that are different in the primary.
*/
-void
+static void
copy_sb(xfs_sb_t *source, xfs_sb_t *dest)
{
xfs_ino_t rootino;
* calculate what inode alignment field ought to be
* based on internal superblock info
*/
-int
+static int
calc_ino_align(xfs_sb_t *sb)
{
xfs_extlen_t align;
}
/* returns element on list with highest reference count */
-
-fs_geo_list_t *
+static fs_geo_list_t *
get_best_geo(fs_geo_list_t *list)
{
int cnt = 0;
}
/* adds geometry info to linked list. returns (sometimes new) head of list */
-
-fs_geo_list_t *
+static fs_geo_list_t *
add_geo(fs_geo_list_t *list, fs_geometry_t *geo_p, int index)
{
fs_geo_list_t *current = list;
return(current);
}
-void
+static void
free_geo(fs_geo_list_t *list)
{
fs_geo_list_t *next;
mp = mpp;
}
-void
+static void
scan_sbtree(
xfs_agblock_t root,
int nlevels,
/*
* -o: user-supplied override options
*/
-
-char *o_opts[] = {
+static char *o_opts[] = {
#define ASSUME_XFS 0
"assume_xfs",
#define PRE_65_BETA 1
/*
* -c: conversion options
*/
-
-char *c_opts[] = {
+static char *c_opts[] = {
#define CONVERT_LAZY_COUNT 0
"lazycount",
NULL
/*
* sets only the global argument flags and variables
*/
-void
+static void
process_args(int argc, char **argv)
{
char *p;
va_end(args);
}
-void
+static void
calc_mkfs(xfs_mount_t *mp)
{
xfs_agblock_t fino_bno;